Mercurial > dwindows
comparison ios/dw.m @ 2764:4c602db2d2cf
iOS: _dw_event_handler() switch needs to be updated using internal constants.
Missed this somehow when I was converting things earlier, Mac and Android
were converted but not iOS. Doesn't affect anything really besides
readability, but should consistently be using the constants.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 17 Jan 2022 17:37:17 +0000 |
parents | ee1cfa7d645e |
children | f734185664cc |
comparison
equal
deleted
inserted
replaced
2763:17517a7f8c22 | 2764:4c602db2d2cf |
---|---|
384 if(handler) | 384 if(handler) |
385 { | 385 { |
386 switch(message) | 386 switch(message) |
387 { | 387 { |
388 /* Timer event */ | 388 /* Timer event */ |
389 case 0: | 389 case _DW_EVENT_TIMER: |
390 { | 390 { |
391 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; | 391 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
392 | 392 |
393 if(!timerfunc(handler->data)) | 393 if(!timerfunc(handler->data)) |
394 dw_timer_disconnect(handler->window); | 394 dw_timer_disconnect(handler->window); |
395 return 0; | 395 return 0; |
396 } | 396 } |
397 /* Configure/Resize event */ | 397 /* Configure/Resize event */ |
398 case 1: | 398 case _DW_EVENT_CONFIGURE: |
399 { | 399 { |
400 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; | 400 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
401 CGSize size; | 401 CGSize size; |
402 | 402 |
403 if([object isKindOfClass:[UIWindow class]]) | 403 if([object isKindOfClass:[UIWindow class]]) |
415 { | 415 { |
416 return sizefunc(object, size.width, size.height, handler->data); | 416 return sizefunc(object, size.width, size.height, handler->data); |
417 } | 417 } |
418 return 0; | 418 return 0; |
419 } | 419 } |
420 case 2: | 420 case _DW_EVENT_KEY_PRESS: |
421 { | 421 { |
422 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction; | 422 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction; |
423 int special = 0; | 423 int special = 0; |
424 NSString *nchar = @""; | 424 NSString *nchar = @""; |
425 if (@available(iOS 13.4, *)) { | 425 if (@available(iOS 13.4, *)) { |
445 } | 445 } |
446 | 446 |
447 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); | 447 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); |
448 } | 448 } |
449 /* Button press and release event */ | 449 /* Button press and release event */ |
450 case 3: | 450 case _DW_EVENT_BUTTON_PRESS: |
451 case 4: | 451 case _DW_EVENT_BUTTON_RELEASE: |
452 { | 452 { |
453 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | 453 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
454 /* Event will be nil when handling the context menu events... | 454 /* Event will be nil when handling the context menu events... |
455 * So button should default to 2 if event is nil | 455 * So button should default to 2 if event is nil |
456 */ | 456 */ |
478 } | 478 } |
479 | 479 |
480 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); | 480 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); |
481 } | 481 } |
482 /* Motion notify event */ | 482 /* Motion notify event */ |
483 case 5: | 483 case _DW_EVENT_MOTION_NOTIFY: |
484 { | 484 { |
485 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | 485 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
486 int button = 1; | 486 int button = 1; |
487 | 487 |
488 if(event && [event isKindOfClass:[UIEvent class]]) | 488 if(event && [event isKindOfClass:[UIEvent class]]) |
500 } | 500 } |
501 } | 501 } |
502 return -1; | 502 return -1; |
503 } | 503 } |
504 /* Window close event */ | 504 /* Window close event */ |
505 case 6: | 505 case _DW_EVENT_DELETE: |
506 { | 506 { |
507 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 507 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
508 return closefunc(object, handler->data); | 508 return closefunc(object, handler->data); |
509 } | 509 } |
510 /* Window expose/draw event */ | 510 /* Window expose/draw event */ |
511 case 7: | 511 case _DW_EVENT_EXPOSE: |
512 { | 512 { |
513 DWExpose exp; | 513 DWExpose exp; |
514 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; | 514 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
515 CGRect rect = [object frame]; | 515 CGRect rect = [object frame]; |
516 | 516 |
520 exp.height = rect.size.height; | 520 exp.height = rect.size.height; |
521 int result = exposefunc(object, &exp, handler->data); | 521 int result = exposefunc(object, &exp, handler->data); |
522 return result; | 522 return result; |
523 } | 523 } |
524 /* Clicked event for buttons and menu items */ | 524 /* Clicked event for buttons and menu items */ |
525 case 8: | 525 case _DW_EVENT_CLICKED: |
526 { | 526 { |
527 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 527 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
528 | 528 |
529 return clickfunc(object, handler->data); | 529 return clickfunc(object, handler->data); |
530 } | 530 } |
531 /* Container class selection event */ | 531 /* Container class selection event */ |
532 case 9: | 532 case _DW_EVENT_ITEM_ENTER: |
533 { | 533 { |
534 int (*containerselectfunc)(HWND, char *, void *, void *) = handler->signalfunction; | 534 int (*containerselectfunc)(HWND, char *, void *, void *) = handler->signalfunction; |
535 void **params = (void **)event; | 535 void **params = (void **)event; |
536 | 536 |
537 return containerselectfunc(handler->window, params[0], handler->data, params[1]); | 537 return containerselectfunc(handler->window, params[0], handler->data, params[1]); |
538 } | 538 } |
539 /* Container context menu event */ | 539 /* Container context menu event */ |
540 case 10: | 540 case _DW_EVENT_ITEM_CONTEXT: |
541 { | 541 { |
542 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; | 542 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
543 void **params = (void **)event; | 543 void **params = (void **)event; |
544 char *text = (char *)params[0]; | 544 char *text = (char *)params[0]; |
545 void *user = params[1]; | 545 void *user = params[1]; |
547 int y = DW_POINTER_TO_INT(params[3]); | 547 int y = DW_POINTER_TO_INT(params[3]); |
548 | 548 |
549 return containercontextfunc(handler->window, text, x, y, handler->data, user); | 549 return containercontextfunc(handler->window, text, x, y, handler->data, user); |
550 } | 550 } |
551 /* Generic selection changed event for several classes */ | 551 /* Generic selection changed event for several classes */ |
552 case 11: | 552 case _DW_EVENT_LIST_SELECT: |
553 case 14: | 553 case _DW_EVENT_VALUE_CHANGED: |
554 { | 554 { |
555 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; | 555 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; |
556 int selected = DW_POINTER_TO_INT(event); | 556 int selected = DW_POINTER_TO_INT(event); |
557 | 557 |
558 return valuechangedfunc(handler->window, selected, handler->data);; | 558 return valuechangedfunc(handler->window, selected, handler->data);; |
559 } | 559 } |
560 /* Tree class selection event */ | 560 /* Tree class selection event */ |
561 case 12: | 561 case _DW_EVENT_ITEM_SELECT: |
562 { | 562 { |
563 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; | 563 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; |
564 char *text = NULL; | 564 char *text = NULL; |
565 void *user = NULL; | 565 void *user = NULL; |
566 id item = nil; | 566 id item = nil; |
574 } | 574 } |
575 | 575 |
576 return treeselectfunc(handler->window, item, text, handler->data, user); | 576 return treeselectfunc(handler->window, item, text, handler->data, user); |
577 } | 577 } |
578 /* Set Focus event */ | 578 /* Set Focus event */ |
579 case 13: | 579 case _DW_EVENT_SET_FOCUS: |
580 { | 580 { |
581 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 581 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
582 | 582 |
583 return setfocusfunc(handler->window, handler->data); | 583 return setfocusfunc(handler->window, handler->data); |
584 } | 584 } |
585 /* Notebook page change event */ | 585 /* Notebook page change event */ |
586 case 15: | 586 case _DW_EVENT_SWITCH_PAGE: |
587 { | 587 { |
588 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; | 588 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; |
589 int pageid = DW_POINTER_TO_INT(event); | 589 int pageid = DW_POINTER_TO_INT(event); |
590 | 590 |
591 return switchpagefunc(handler->window, pageid, handler->data); | 591 return switchpagefunc(handler->window, pageid, handler->data); |
592 } | 592 } |
593 /* Tree expand event */ | 593 /* Tree expand event */ |
594 case 16: | 594 case _DW_EVENT_TREE_EXPAND: |
595 { | 595 { |
596 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; | 596 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; |
597 | 597 |
598 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); | 598 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); |
599 } | 599 } |
600 /* Column click event */ | 600 /* Column click event */ |
601 case 17: | 601 case _DW_EVENT_COLUMN_CLICK: |
602 { | 602 { |
603 int (* API clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; | 603 int (* API clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; |
604 int column_num = DW_POINTER_TO_INT(event); | 604 int column_num = DW_POINTER_TO_INT(event); |
605 | 605 |
606 return clickcolumnfunc(handler->window, column_num, handler->data); | 606 return clickcolumnfunc(handler->window, column_num, handler->data); |
607 } | 607 } |
608 /* HTML result event */ | 608 /* HTML result event */ |
609 case 18: | 609 case _DW_EVENT_HTML_RESULT: |
610 { | 610 { |
611 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction; | 611 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction; |
612 void **params = (void **)event; | 612 void **params = (void **)event; |
613 NSString *result = params[0]; | 613 NSString *result = params[0]; |
614 | 614 |
615 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data); | 615 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data); |
616 } | 616 } |
617 /* HTML changed event */ | 617 /* HTML changed event */ |
618 case 19: | 618 case _DW_EVENT_HTML_CHANGED: |
619 { | 619 { |
620 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction; | 620 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction; |
621 void **params = (void **)event; | 621 void **params = (void **)event; |
622 NSString *uri = params[1]; | 622 NSString *uri = params[1]; |
623 | 623 |