comparison android/dw.cpp @ 2620:dcd71b04cc46

Android: Add internal event constants for more clarity about what code does. Several platforms which do not use integer messages for events have our own internal system implemented, adding enum constants for each internal message.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 25 Jul 2021 23:35:02 +0000
parents a11522c30345
children 401a3b9f21ba
comparison
equal deleted inserted replaced
2619:4d5467e57115 2620:dcd71b04cc46
239 239
240 /* List of signals */ 240 /* List of signals */
241 #define SIGNALMAX 19 241 #define SIGNALMAX 19
242 242
243 static DWSignalList DWSignalTranslate[SIGNALMAX] = { 243 static DWSignalList DWSignalTranslate[SIGNALMAX] = {
244 { 1, DW_SIGNAL_CONFIGURE }, 244 { _DW_EVENT_CONFIGURE, DW_SIGNAL_CONFIGURE },
245 { 2, DW_SIGNAL_KEY_PRESS }, 245 { _DW_EVENT_KEY_PRESS, DW_SIGNAL_KEY_PRESS },
246 { 3, DW_SIGNAL_BUTTON_PRESS }, 246 { _DW_EVENT_BUTTON_PRESS, DW_SIGNAL_BUTTON_PRESS },
247 { 4, DW_SIGNAL_BUTTON_RELEASE }, 247 { _DW_EVENT_BUTTON_RELEASE, DW_SIGNAL_BUTTON_RELEASE },
248 { 5, DW_SIGNAL_MOTION_NOTIFY }, 248 { _DW_EVENT_MOTION_NOTIFY, DW_SIGNAL_MOTION_NOTIFY },
249 { 6, DW_SIGNAL_DELETE }, 249 { _DW_EVENT_DELETE, DW_SIGNAL_DELETE },
250 { 7, DW_SIGNAL_EXPOSE }, 250 { _DW_EVENT_EXPOSE, DW_SIGNAL_EXPOSE },
251 { 8, DW_SIGNAL_CLICKED }, 251 { _DW_EVENT_CLICKED, DW_SIGNAL_CLICKED },
252 { 9, DW_SIGNAL_ITEM_ENTER }, 252 { _DW_EVENT_ITEM_ENTER, DW_SIGNAL_ITEM_ENTER },
253 { 10, DW_SIGNAL_ITEM_CONTEXT }, 253 { _DW_EVENT_ITEM_CONTEXT, DW_SIGNAL_ITEM_CONTEXT },
254 { 11, DW_SIGNAL_LIST_SELECT }, 254 { _DW_EVENT_LIST_SELECT, DW_SIGNAL_LIST_SELECT },
255 { 12, DW_SIGNAL_ITEM_SELECT }, 255 { _DW_EVENT_ITEM_SELECT, DW_SIGNAL_ITEM_SELECT },
256 { 13, DW_SIGNAL_SET_FOCUS }, 256 { _DW_EVENT_SET_FOCUS, DW_SIGNAL_SET_FOCUS },
257 { 14, DW_SIGNAL_VALUE_CHANGED }, 257 { _DW_EVENT_VALUE_CHANGED, DW_SIGNAL_VALUE_CHANGED },
258 { 15, DW_SIGNAL_SWITCH_PAGE }, 258 { _DW_EVENT_SWITCH_PAGE, DW_SIGNAL_SWITCH_PAGE },
259 { 16, DW_SIGNAL_TREE_EXPAND }, 259 { _DW_EVENT_TREE_EXPAND, DW_SIGNAL_TREE_EXPAND },
260 { 17, DW_SIGNAL_COLUMN_CLICK }, 260 { _DW_EVENT_COLUMN_CLICK, DW_SIGNAL_COLUMN_CLICK },
261 { 18, DW_SIGNAL_HTML_RESULT }, 261 { _DW_EVENT_HTML_RESULT, DW_SIGNAL_HTML_RESULT },
262 { 19, DW_SIGNAL_HTML_CHANGED } 262 { _DW_EVENT_HTML_CHANGED, DW_SIGNAL_HTML_CHANGED }
263 }; 263 };
264 264
265 #define _DW_EVENT_PARAM_SIZE 10 265 #define _DW_EVENT_PARAM_SIZE 10
266 266
267 int _dw_event_handler2(void **params) 267 int _dw_event_handler2(void **params)
273 if(handler) 273 if(handler)
274 { 274 {
275 switch(message) 275 switch(message)
276 { 276 {
277 /* Timer event */ 277 /* Timer event */
278 case 0: 278 case _DW_EVENT_TIMER:
279 { 279 {
280 int (*timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; 280 int (*timerfunc)(void *) = (int (* API)(void *))handler->signalfunction;
281 281
282 if(!timerfunc(handler->data)) 282 if(!timerfunc(handler->data))
283 dw_timer_disconnect(handler->window); 283 dw_timer_disconnect(handler->window);
284 retval = 0; 284 retval = 0;
285 break; 285 break;
286 } 286 }
287 /* Configure/Resize event */ 287 /* Configure/Resize event */
288 case 1: 288 case _DW_EVENT_CONFIGURE:
289 { 289 {
290 int (*sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))handler->signalfunction; 290 int (*sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))handler->signalfunction;
291 int width = DW_POINTER_TO_INT(params[3]); 291 int width = DW_POINTER_TO_INT(params[3]);
292 int height = DW_POINTER_TO_INT(params[4]); 292 int height = DW_POINTER_TO_INT(params[4]);
293 293
295 retval = sizefunc(handler->window, width, height, handler->data); 295 retval = sizefunc(handler->window, width, height, handler->data);
296 else 296 else
297 retval = 0; 297 retval = 0;
298 break; 298 break;
299 } 299 }
300 case 2: 300 case _DW_EVENT_KEY_PRESS:
301 { 301 {
302 int (*keypressfunc)(HWND, char, int, int, void *, char *) = (int (* API)(HWND, char, int, int, void *, char *))handler->signalfunction; 302 int (*keypressfunc)(HWND, char, int, int, void *, char *) = (int (* API)(HWND, char, int, int, void *, char *))handler->signalfunction;
303 char *utf8 = (char *)params[1], ch = (char)DW_POINTER_TO_INT(params[3]); 303 char *utf8 = (char *)params[1], ch = (char)DW_POINTER_TO_INT(params[3]);
304 int vk = DW_POINTER_TO_INT(params[4]), special = DW_POINTER_TO_INT(params[5]); 304 int vk = DW_POINTER_TO_INT(params[4]), special = DW_POINTER_TO_INT(params[5]);
305 305
306 retval = keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); 306 retval = keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8);
307 break; 307 break;
308 } 308 }
309 /* Button press and release event */ 309 /* Button press and release event */
310 case 3: 310 case _DW_EVENT_BUTTON_PRESS:
311 case 4: 311 case _DW_EVENT_BUTTON_RELEASE:
312 { 312 {
313 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 313 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
314 int button = params[5] ? DW_POINTER_TO_INT(params[5]) : 1; 314 int button = params[5] ? DW_POINTER_TO_INT(params[5]) : 1;
315 315
316 retval = buttonfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), button, handler->data); 316 retval = buttonfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), button, handler->data);
317 break; 317 break;
318 } 318 }
319 /* Motion notify event */ 319 /* Motion notify event */
320 case 5: 320 case _DW_EVENT_MOTION_NOTIFY:
321 { 321 {
322 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 322 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
323 323
324 retval = motionfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), DW_POINTER_TO_INT(params[5]), handler->data); 324 retval = motionfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), DW_POINTER_TO_INT(params[5]), handler->data);
325 break; 325 break;
326 } 326 }
327 /* Window close event */ 327 /* Window close event */
328 case 6: 328 case _DW_EVENT_DELETE:
329 { 329 {
330 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; 330 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
331 retval = closefunc(handler->window, handler->data); 331 retval = closefunc(handler->window, handler->data);
332 break; 332 break;
333 } 333 }
334 /* Window expose/draw event */ 334 /* Window expose/draw event */
335 case 7: 335 case _DW_EVENT_EXPOSE:
336 { 336 {
337 DWExpose exp; 337 DWExpose exp;
338 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; 338 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction;
339 339
340 exp.x = DW_POINTER_TO_INT(params[3]); 340 exp.x = DW_POINTER_TO_INT(params[3]);
346 * are always handling expose/draw on the UI thread. 346 * are always handling expose/draw on the UI thread.
347 */ 347 */
348 return retval; 348 return retval;
349 } 349 }
350 /* Clicked event for buttons and menu items */ 350 /* Clicked event for buttons and menu items */
351 case 8: 351 case _DW_EVENT_CLICKED:
352 { 352 {
353 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; 353 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
354 354
355 retval = clickfunc(handler->window, handler->data); 355 retval = clickfunc(handler->window, handler->data);
356 break; 356 break;
357 } 357 }
358 /* Container class selection event */ 358 /* Container class selection event */
359 case 9: 359 case _DW_EVENT_ITEM_ENTER:
360 { 360 {
361 int (*containerselectfunc)(HWND, char *, void *, void *) =(int (* API)(HWND, char *, void *, void *)) handler->signalfunction; 361 int (*containerselectfunc)(HWND, char *, void *, void *) =(int (* API)(HWND, char *, void *, void *)) handler->signalfunction;
362 362
363 retval = containerselectfunc(handler->window, (char *)params[1], handler->data, params[7]); 363 retval = containerselectfunc(handler->window, (char *)params[1], handler->data, params[7]);
364 break; 364 break;
365 } 365 }
366 /* Container context menu event */ 366 /* Container context menu event */
367 case 10: 367 case _DW_EVENT_ITEM_CONTEXT:
368 { 368 {
369 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; 369 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction;
370 char *text = (char *)params[1]; 370 char *text = (char *)params[1];
371 void *user = params[7]; 371 void *user = params[7];
372 int x = DW_POINTER_TO_INT(params[3]); 372 int x = DW_POINTER_TO_INT(params[3]);
374 374
375 retval = containercontextfunc(handler->window, text, x, y, handler->data, user); 375 retval = containercontextfunc(handler->window, text, x, y, handler->data, user);
376 break; 376 break;
377 } 377 }
378 /* Generic selection changed event for several classes */ 378 /* Generic selection changed event for several classes */
379 case 11: 379 case _DW_EVENT_LIST_SELECT:
380 case 14: 380 case _DW_EVENT_VALUE_CHANGED:
381 { 381 {
382 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; 382 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
383 int selected = DW_POINTER_TO_INT(params[3]); 383 int selected = DW_POINTER_TO_INT(params[3]);
384 384
385 retval = valuechangedfunc(handler->window, selected, handler->data); 385 retval = valuechangedfunc(handler->window, selected, handler->data);
386 break; 386 break;
387 } 387 }
388 /* Tree class selection event */ 388 /* Tree class selection event */
389 case 12: 389 case _DW_EVENT_ITEM_SELECT:
390 { 390 {
391 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; 391 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction;
392 char *text = (char *)params[1]; 392 char *text = (char *)params[1];
393 void *user = params[7]; 393 void *user = params[7];
394 394
395 retval = treeselectfunc(handler->window, params[0], text, handler->data, user); 395 retval = treeselectfunc(handler->window, params[0], text, handler->data, user);
396 break; 396 break;
397 } 397 }
398 /* Set Focus event */ 398 /* Set Focus event */
399 case 13: 399 case _DW_EVENT_SET_FOCUS:
400 { 400 {
401 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; 401 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
402 402
403 retval = setfocusfunc(handler->window, handler->data); 403 retval = setfocusfunc(handler->window, handler->data);
404 break; 404 break;
405 } 405 }
406 /* Notebook page change event */ 406 /* Notebook page change event */
407 case 15: 407 case _DW_EVENT_SWITCH_PAGE:
408 { 408 {
409 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; 409 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction;
410 unsigned long pageID = DW_POINTER_TO_INT(params[3]); 410 unsigned long pageID = DW_POINTER_TO_INT(params[3]);
411 411
412 retval = switchpagefunc(handler->window, pageID, handler->data); 412 retval = switchpagefunc(handler->window, pageID, handler->data);
413 break; 413 break;
414 } 414 }
415 /* Tree expand event */ 415 /* Tree expand event */
416 case 16: 416 case _DW_EVENT_TREE_EXPAND:
417 { 417 {
418 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; 418 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction;
419 419
420 retval = treeexpandfunc(handler->window, (HTREEITEM)params[0], handler->data); 420 retval = treeexpandfunc(handler->window, (HTREEITEM)params[0], handler->data);
421 break; 421 break;
422 } 422 }
423 /* Column click event */ 423 /* Column click event */
424 case 17: 424 case _DW_EVENT_COLUMN_CLICK:
425 { 425 {
426 int (* API clickcolumnfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; 426 int (* API clickcolumnfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
427 int column_num = DW_POINTER_TO_INT(params[3]); 427 int column_num = DW_POINTER_TO_INT(params[3]);
428 428
429 retval = clickcolumnfunc(handler->window, column_num, handler->data); 429 retval = clickcolumnfunc(handler->window, column_num, handler->data);
430 break; 430 break;
431 } 431 }
432 /* HTML result event */ 432 /* HTML result event */
433 case 18: 433 case _DW_EVENT_HTML_RESULT:
434 { 434 {
435 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = (int (* API)(HWND, int, char *, void *, void *))handler->signalfunction; 435 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = (int (* API)(HWND, int, char *, void *, void *))handler->signalfunction;
436 char *result = (char *)params[1]; 436 char *result = (char *)params[1];
437 437
438 retval = htmlresultfunc(handler->window, result ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, result, params[7], handler->data); 438 retval = htmlresultfunc(handler->window, result ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, result, params[7], handler->data);
439 break; 439 break;
440 } 440 }
441 /* HTML changed event */ 441 /* HTML changed event */
442 case 19: 442 case _DW_EVENT_HTML_CHANGED:
443 { 443 {
444 int (* API htmlchangedfunc)(HWND, int, char *, void *) = (int (* API)(HWND, int, char *, void *))handler->signalfunction; 444 int (* API htmlchangedfunc)(HWND, int, char *, void *) = (int (* API)(HWND, int, char *, void *))handler->signalfunction;
445 char *uri = (char *)params[1]; 445 char *uri = (char *)params[1];
446 446
447 retval = htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[3]), uri, handler->data); 447 retval = htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[3]), uri, handler->data);