Mercurial > dwindows
comparison mac/dw.m @ 2621:e63c1373c010
Mac: Switch to using internal event message constants.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 26 Jul 2021 00:24:59 +0000 |
parents | 156ad91481eb |
children | 401a3b9f21ba |
comparison
equal
deleted
inserted
replaced
2620:dcd71b04cc46 | 2621:e63c1373c010 |
---|---|
526 typedef struct | 526 typedef struct |
527 { | 527 { |
528 ULONG message; | 528 ULONG message; |
529 char name[30]; | 529 char name[30]; |
530 | 530 |
531 } SignalList; | 531 } DWSignalList; |
532 | 532 |
533 /* List of signals */ | 533 /* List of signals */ |
534 #define SIGNALMAX 19 | 534 #define SIGNALMAX 19 |
535 | 535 |
536 static SignalList DWSignalTranslate[SIGNALMAX] = { | 536 static DWSignalList DWSignalTranslate[SIGNALMAX] = { |
537 { 1, DW_SIGNAL_CONFIGURE }, | 537 { _DW_EVENT_CONFIGURE, DW_SIGNAL_CONFIGURE }, |
538 { 2, DW_SIGNAL_KEY_PRESS }, | 538 { _DW_EVENT_KEY_PRESS, DW_SIGNAL_KEY_PRESS }, |
539 { 3, DW_SIGNAL_BUTTON_PRESS }, | 539 { _DW_EVENT_BUTTON_PRESS, DW_SIGNAL_BUTTON_PRESS }, |
540 { 4, DW_SIGNAL_BUTTON_RELEASE }, | 540 { _DW_EVENT_BUTTON_RELEASE, DW_SIGNAL_BUTTON_RELEASE }, |
541 { 5, DW_SIGNAL_MOTION_NOTIFY }, | 541 { _DW_EVENT_MOTION_NOTIFY, DW_SIGNAL_MOTION_NOTIFY }, |
542 { 6, DW_SIGNAL_DELETE }, | 542 { _DW_EVENT_DELETE, DW_SIGNAL_DELETE }, |
543 { 7, DW_SIGNAL_EXPOSE }, | 543 { _DW_EVENT_EXPOSE, DW_SIGNAL_EXPOSE }, |
544 { 8, DW_SIGNAL_CLICKED }, | 544 { _DW_EVENT_CLICKED, DW_SIGNAL_CLICKED }, |
545 { 9, DW_SIGNAL_ITEM_ENTER }, | 545 { _DW_EVENT_ITEM_ENTER, DW_SIGNAL_ITEM_ENTER }, |
546 { 10, DW_SIGNAL_ITEM_CONTEXT }, | 546 { _DW_EVENT_ITEM_CONTEXT, DW_SIGNAL_ITEM_CONTEXT }, |
547 { 11, DW_SIGNAL_LIST_SELECT }, | 547 { _DW_EVENT_LIST_SELECT, DW_SIGNAL_LIST_SELECT }, |
548 { 12, DW_SIGNAL_ITEM_SELECT }, | 548 { _DW_EVENT_ITEM_SELECT, DW_SIGNAL_ITEM_SELECT }, |
549 { 13, DW_SIGNAL_SET_FOCUS }, | 549 { _DW_EVENT_SET_FOCUS, DW_SIGNAL_SET_FOCUS }, |
550 { 14, DW_SIGNAL_VALUE_CHANGED }, | 550 { _DW_EVENT_VALUE_CHANGED, DW_SIGNAL_VALUE_CHANGED }, |
551 { 15, DW_SIGNAL_SWITCH_PAGE }, | 551 { _DW_EVENT_SWITCH_PAGE, DW_SIGNAL_SWITCH_PAGE }, |
552 { 16, DW_SIGNAL_TREE_EXPAND }, | 552 { _DW_EVENT_TREE_EXPAND, DW_SIGNAL_TREE_EXPAND }, |
553 { 17, DW_SIGNAL_COLUMN_CLICK }, | 553 { _DW_EVENT_COLUMN_CLICK, DW_SIGNAL_COLUMN_CLICK }, |
554 { 18, DW_SIGNAL_HTML_RESULT }, | 554 { _DW_EVENT_HTML_RESULT, DW_SIGNAL_HTML_RESULT }, |
555 { 19, DW_SIGNAL_HTML_CHANGED } | 555 { _DW_EVENT_HTML_CHANGED, DW_SIGNAL_HTML_CHANGED } |
556 }; | 556 }; |
557 | 557 |
558 int _dw_event_handler1(id object, NSEvent *event, int message) | 558 int _dw_event_handler1(id object, NSEvent *event, int message) |
559 { | 559 { |
560 SignalHandler *handler = _dw_get_handler(object, message); | 560 SignalHandler *handler = _dw_get_handler(object, message); |
563 if(handler) | 563 if(handler) |
564 { | 564 { |
565 switch(message) | 565 switch(message) |
566 { | 566 { |
567 /* Timer event */ | 567 /* Timer event */ |
568 case 0: | 568 case _DW_EVENT_TIMER: |
569 { | 569 { |
570 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; | 570 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
571 | 571 |
572 if(!timerfunc(handler->data)) | 572 if(!timerfunc(handler->data)) |
573 dw_timer_disconnect(handler->id); | 573 dw_timer_disconnect(handler->id); |
574 return 0; | 574 return 0; |
575 } | 575 } |
576 /* Configure/Resize event */ | 576 /* Configure/Resize event */ |
577 case 1: | 577 case _DW_EVENT_CONFIGURE: |
578 { | 578 { |
579 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; | 579 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
580 NSSize size; | 580 NSSize size; |
581 | 581 |
582 if([object isKindOfClass:[NSWindow class]]) | 582 if([object isKindOfClass:[NSWindow class]]) |
594 { | 594 { |
595 return sizefunc(object, size.width, size.height, handler->data); | 595 return sizefunc(object, size.width, size.height, handler->data); |
596 } | 596 } |
597 return 0; | 597 return 0; |
598 } | 598 } |
599 case 2: | 599 case _DW_EVENT_KEY_PRESS: |
600 { | 600 { |
601 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction; | 601 int (*keypressfunc)(HWND, char, int, int, void *, char *) = handler->signalfunction; |
602 NSString *nchar = [event charactersIgnoringModifiers]; | 602 NSString *nchar = [event charactersIgnoringModifiers]; |
603 int special = (int)[event modifierFlags]; | 603 int special = (int)[event modifierFlags]; |
604 unichar vk = [nchar characterAtIndex:0]; | 604 unichar vk = [nchar characterAtIndex:0]; |
616 } | 616 } |
617 | 617 |
618 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); | 618 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); |
619 } | 619 } |
620 /* Button press and release event */ | 620 /* Button press and release event */ |
621 case 3: | 621 case _DW_EVENT_BUTTON_PRESS: |
622 case 4: | 622 case _DW_EVENT_BUTTON_RELEASE: |
623 { | 623 { |
624 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | 624 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
625 NSPoint p = [NSEvent mouseLocation]; | 625 NSPoint p = [NSEvent mouseLocation]; |
626 int button = DW_BUTTON1_MASK; | 626 int button = DW_BUTTON1_MASK; |
627 | 627 |
647 } | 647 } |
648 | 648 |
649 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); | 649 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); |
650 } | 650 } |
651 /* Motion notify event */ | 651 /* Motion notify event */ |
652 case 5: | 652 case _DW_EVENT_MOTION_NOTIFY: |
653 { | 653 { |
654 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | 654 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
655 id view = [[[event window] contentView] superview]; | 655 id view = [[[event window] contentView] superview]; |
656 NSPoint p = [view convertPoint:[event locationInWindow] toView:object]; | 656 NSPoint p = [view convertPoint:[event locationInWindow] toView:object]; |
657 SEL spmb = NSSelectorFromString(@"pressedMouseButtons"); | 657 SEL spmb = NSSelectorFromString(@"pressedMouseButtons"); |
659 NSUInteger buttonmask = ipmb ? (NSUInteger)ipmb([NSEvent class], spmb) : (1 << [event buttonNumber]); | 659 NSUInteger buttonmask = ipmb ? (NSUInteger)ipmb([NSEvent class], spmb) : (1 << [event buttonNumber]); |
660 | 660 |
661 return motionfunc(object, (int)p.x, (int)p.y, (int)buttonmask, handler->data); | 661 return motionfunc(object, (int)p.x, (int)p.y, (int)buttonmask, handler->data); |
662 } | 662 } |
663 /* Window close event */ | 663 /* Window close event */ |
664 case 6: | 664 case _DW_EVENT_DELETE: |
665 { | 665 { |
666 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 666 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
667 return closefunc(object, handler->data); | 667 return closefunc(object, handler->data); |
668 } | 668 } |
669 /* Window expose/draw event */ | 669 /* Window expose/draw event */ |
670 case 7: | 670 case _DW_EVENT_EXPOSE: |
671 { | 671 { |
672 DWExpose exp; | 672 DWExpose exp; |
673 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; | 673 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
674 NSRect rect = [object frame]; | 674 NSRect rect = [object frame]; |
675 | 675 |
682 [[object window] flushWindow]; | 682 [[object window] flushWindow]; |
683 #endif | 683 #endif |
684 return result; | 684 return result; |
685 } | 685 } |
686 /* Clicked event for buttons and menu items */ | 686 /* Clicked event for buttons and menu items */ |
687 case 8: | 687 case _DW_EVENT_CLICKED: |
688 { | 688 { |
689 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 689 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
690 | 690 |
691 return clickfunc(object, handler->data); | 691 return clickfunc(object, handler->data); |
692 } | 692 } |
693 /* Container class selection event */ | 693 /* Container class selection event */ |
694 case 9: | 694 case _DW_EVENT_ITEM_ENTER: |
695 { | 695 { |
696 int (*containerselectfunc)(HWND, char *, void *, void *) = handler->signalfunction; | 696 int (*containerselectfunc)(HWND, char *, void *, void *) = handler->signalfunction; |
697 void **params = (void **)event; | 697 void **params = (void **)event; |
698 | 698 |
699 return containerselectfunc(handler->window, params[0], handler->data, params[1]); | 699 return containerselectfunc(handler->window, params[0], handler->data, params[1]); |
700 } | 700 } |
701 /* Container context menu event */ | 701 /* Container context menu event */ |
702 case 10: | 702 case _DW_EVENT_ITEM_CONTEXT: |
703 { | 703 { |
704 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; | 704 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
705 char *text = NULL; | 705 char *text = NULL; |
706 void *user = NULL; | 706 void *user = NULL; |
707 LONG x,y; | 707 LONG x,y; |
729 dw_pointer_query_pos(&x, &y); | 729 dw_pointer_query_pos(&x, &y); |
730 | 730 |
731 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); | 731 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
732 } | 732 } |
733 /* Generic selection changed event for several classes */ | 733 /* Generic selection changed event for several classes */ |
734 case 11: | 734 case _DW_EVENT_LIST_SELECT: |
735 case 14: | 735 case _DW_EVENT_VALUE_CHANGED: |
736 { | 736 { |
737 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; | 737 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction; |
738 int selected = DW_POINTER_TO_INT(event); | 738 int selected = DW_POINTER_TO_INT(event); |
739 | 739 |
740 return valuechangedfunc(handler->window, selected, handler->data);; | 740 return valuechangedfunc(handler->window, selected, handler->data);; |
741 } | 741 } |
742 /* Tree class selection event */ | 742 /* Tree class selection event */ |
743 case 12: | 743 case _DW_EVENT_ITEM_SELECT: |
744 { | 744 { |
745 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; | 745 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; |
746 char *text = NULL; | 746 char *text = NULL; |
747 void *user = NULL; | 747 void *user = NULL; |
748 id item = nil; | 748 id item = nil; |
778 } | 778 } |
779 | 779 |
780 return treeselectfunc(handler->window, item, text, handler->data, user); | 780 return treeselectfunc(handler->window, item, text, handler->data, user); |
781 } | 781 } |
782 /* Set Focus event */ | 782 /* Set Focus event */ |
783 case 13: | 783 case _DW_EVENT_SET_FOCUS: |
784 { | 784 { |
785 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 785 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
786 | 786 |
787 return setfocusfunc(handler->window, handler->data); | 787 return setfocusfunc(handler->window, handler->data); |
788 } | 788 } |
789 /* Notebook page change event */ | 789 /* Notebook page change event */ |
790 case 15: | 790 case _DW_EVENT_SWITCH_PAGE: |
791 { | 791 { |
792 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; | 792 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction; |
793 int pageid = DW_POINTER_TO_INT(event); | 793 int pageid = DW_POINTER_TO_INT(event); |
794 | 794 |
795 return switchpagefunc(handler->window, pageid, handler->data); | 795 return switchpagefunc(handler->window, pageid, handler->data); |
796 } | 796 } |
797 /* Tree expand event */ | 797 /* Tree expand event */ |
798 case 16: | 798 case _DW_EVENT_TREE_EXPAND: |
799 { | 799 { |
800 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; | 800 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction; |
801 | 801 |
802 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); | 802 return treeexpandfunc(handler->window, (HTREEITEM)event, handler->data); |
803 } | 803 } |
804 /* Column click event */ | 804 /* Column click event */ |
805 case 17: | 805 case _DW_EVENT_COLUMN_CLICK: |
806 { | 806 { |
807 int (* API clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; | 807 int (* API clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; |
808 int column_num = DW_POINTER_TO_INT(event); | 808 int column_num = DW_POINTER_TO_INT(event); |
809 | 809 |
810 return clickcolumnfunc(handler->window, column_num, handler->data); | 810 return clickcolumnfunc(handler->window, column_num, handler->data); |
811 } | 811 } |
812 /* HTML result event */ | 812 /* HTML result event */ |
813 case 18: | 813 case _DW_EVENT_HTML_RESULT: |
814 { | 814 { |
815 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction; | 815 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction; |
816 void **params = (void **)event; | 816 void **params = (void **)event; |
817 NSString *result = params[0]; | 817 NSString *result = params[0]; |
818 | 818 |
819 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data); | 819 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data); |
820 } | 820 } |
821 /* HTML changed event */ | 821 /* HTML changed event */ |
822 case 19: | 822 case _DW_EVENT_HTML_CHANGED: |
823 { | 823 { |
824 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction; | 824 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction; |
825 void **params = (void **)event; | 825 void **params = (void **)event; |
826 NSString *uri = params[1]; | 826 NSString *uri = params[1]; |
827 | 827 |
845 @interface DWTimerHandler : NSObject { } | 845 @interface DWTimerHandler : NSObject { } |
846 -(void)runTimer:(id)sender; | 846 -(void)runTimer:(id)sender; |
847 @end | 847 @end |
848 | 848 |
849 @implementation DWTimerHandler | 849 @implementation DWTimerHandler |
850 -(void)runTimer:(id)sender { _dw_event_handler(sender, nil, 0); } | 850 -(void)runTimer:(id)sender { _dw_event_handler(sender, nil, _DW_EVENT_TIMER); } |
851 @end | 851 @end |
852 | 852 |
853 static NSApplication *DWApp = nil; | 853 static NSApplication *DWApp = nil; |
854 static NSFontManager *DWFontManager = nil; | 854 static NSFontManager *DWFontManager = nil; |
855 static NSMenu *DWMainMenu; | 855 static NSMenu *DWMainMenu; |
980 [bgcolor set]; | 980 [bgcolor set]; |
981 NSRectFill([self bounds]); | 981 NSRectFill([self bounds]); |
982 } | 982 } |
983 } | 983 } |
984 -(BOOL)isFlipped { return YES; } | 984 -(BOOL)isFlipped { return YES; } |
985 -(void)mouseDown:(NSEvent *)theEvent { _dw_event_handler(self, (void *)1, 3); } | 985 -(void)mouseDown:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON1_MASK), _DW_EVENT_BUTTON_PRESS); } |
986 -(void)mouseUp:(NSEvent *)theEvent { _dw_event_handler(self, (void *)1, 4); } | 986 -(void)mouseUp:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON1_MASK), _DW_EVENT_BUTTON_RELEASE); } |
987 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _dw_event_handler(self, (void *)2, 3); return nil; } | 987 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON2_MASK), _DW_EVENT_BUTTON_PRESS); return nil; } |
988 -(void)rightMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, (void *)2, 4); } | 988 -(void)rightMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON2_MASK), _DW_EVENT_BUTTON_RELEASE); } |
989 -(void)otherMouseDown:(NSEvent *)theEvent { _dw_event_handler(self, (void *)3, 3); } | 989 -(void)otherMouseDown:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON3_MASK), _DW_EVENT_BUTTON_PRESS); } |
990 -(void)otherMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, (void *)3, 4); } | 990 -(void)otherMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, DW_INT_TO_POINTER(DW_BUTTON3_MASK), _DW_EVENT_BUTTON_RELEASE); } |
991 -(void)keyDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 2); } | 991 -(void)keyDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_KEY_PRESS); } |
992 -(void)setColor:(unsigned long)input | 992 -(void)setColor:(unsigned long)input |
993 { | 993 { |
994 id orig = bgcolor; | 994 id orig = bgcolor; |
995 | 995 |
996 if(input == _dw_colors[DW_CLR_DEFAULT]) | 996 if(input == _dw_colors[DW_CLR_DEFAULT]) |
1068 -(void)sendEvent:(NSEvent *)theEvent | 1068 -(void)sendEvent:(NSEvent *)theEvent |
1069 { | 1069 { |
1070 int rcode = -1; | 1070 int rcode = -1; |
1071 if([theEvent type] == DWEventTypeKeyDown) | 1071 if([theEvent type] == DWEventTypeKeyDown) |
1072 { | 1072 { |
1073 rcode = _dw_event_handler(self, theEvent, 2); | 1073 rcode = _dw_event_handler(self, theEvent, _DW_EVENT_KEY_PRESS); |
1074 } | 1074 } |
1075 if ( rcode != TRUE ) | 1075 if ( rcode != TRUE ) |
1076 [super sendEvent:theEvent]; | 1076 [super sendEvent:theEvent]; |
1077 } | 1077 } |
1078 -(void)keyDown:(NSEvent *)theEvent { } | 1078 -(void)keyDown:(NSEvent *)theEvent { } |
1079 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 5); } | 1079 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_MOTION_NOTIFY); } |
1080 -(int)redraw { return redraw; } | 1080 -(int)redraw { return redraw; } |
1081 -(void)setRedraw:(int)val { redraw = val; } | 1081 -(void)setRedraw:(int)val { redraw = val; } |
1082 -(int)shown { return shown; } | 1082 -(int)shown { return shown; } |
1083 -(void)setShown:(int)val { shown = val; } | 1083 -(void)setShown:(int)val { shown = val; } |
1084 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; } | 1084 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; } |
1146 } | 1146 } |
1147 #endif | 1147 #endif |
1148 -(void)mouseDown:(NSEvent *)theEvent | 1148 -(void)mouseDown:(NSEvent *)theEvent |
1149 { | 1149 { |
1150 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & DWEventModifierFlagControl)) | 1150 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & DWEventModifierFlagControl)) |
1151 _dw_event_handler(self, theEvent, 3); | 1151 _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_PRESS); |
1152 } | 1152 } |
1153 -(void)mouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 4); } | 1153 -(void)mouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_RELEASE); } |
1154 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 3); return nil; } | 1154 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_PRESS); return nil; } |
1155 -(void)rightMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 4); } | 1155 -(void)rightMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_RELEASE); } |
1156 -(void)otherMouseDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 3); } | 1156 -(void)otherMouseDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_PRESS); } |
1157 -(void)otherMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 4); } | 1157 -(void)otherMouseUp:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_BUTTON_RELEASE); } |
1158 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 5); } | 1158 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_MOTION_NOTIFY); } |
1159 -(void)delayedNeedsDisplay { [self setNeedsDisplay:YES]; } | 1159 -(void)delayedNeedsDisplay { [self setNeedsDisplay:YES]; } |
1160 -(void)drawRect:(NSRect)rect { | 1160 -(void)drawRect:(NSRect)rect { |
1161 _dw_event_handler(self, nil, 7); | 1161 _dw_event_handler(self, nil, _DW_EVENT_EXPOSE); |
1162 #ifdef BUILDING_FOR_MOJAVE | 1162 #ifdef BUILDING_FOR_MOJAVE |
1163 if (cachedDrawingRep) | 1163 if (cachedDrawingRep) |
1164 { | 1164 { |
1165 [cachedDrawingRep drawInRect:self.bounds]; | 1165 [cachedDrawingRep drawInRect:self.bounds]; |
1166 [_DWDirtyDrawables removeObject:self]; | 1166 [_DWDirtyDrawables removeObject:self]; |
1170 else | 1170 else |
1171 [self performSelector:@selector(delayedNeedsDisplay) withObject:nil afterDelay:0]; | 1171 [self performSelector:@selector(delayedNeedsDisplay) withObject:nil afterDelay:0]; |
1172 } | 1172 } |
1173 #endif | 1173 #endif |
1174 } | 1174 } |
1175 -(void)keyDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 2); } | 1175 -(void)keyDown:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_KEY_PRESS); } |
1176 -(BOOL)isFlipped { return YES; } | 1176 -(BOOL)isFlipped { return YES; } |
1177 -(void)dealloc { | 1177 -(void)dealloc { |
1178 UserData *root = userdata; | 1178 UserData *root = userdata; |
1179 _dw_remove_userdata(&root, NULL, TRUE); | 1179 _dw_remove_userdata(&root, NULL, TRUE); |
1180 [font release]; | 1180 [font release]; |
1207 if([item state] == DWControlStateValueOn) | 1207 if([item state] == DWControlStateValueOn) |
1208 [item setState:DWControlStateValueOff]; | 1208 [item setState:DWControlStateValueOff]; |
1209 else | 1209 else |
1210 [item setState:DWControlStateValueOn]; | 1210 [item setState:DWControlStateValueOn]; |
1211 } | 1211 } |
1212 _dw_event_handler(param, nil, 8); | 1212 _dw_event_handler(param, nil, _DW_EVENT_CLICKED); |
1213 } | 1213 } |
1214 #ifdef BUILDING_FOR_MOJAVE | 1214 #ifdef BUILDING_FOR_MOJAVE |
1215 -(void)callBack:(NSPointerArray *)params | 1215 -(void)callBack:(NSPointerArray *)params |
1216 { | 1216 { |
1217 void (*mycallback)(NSPointerArray *) = [params pointerAtIndex:0]; | 1217 void (*mycallback)(NSPointerArray *) = [params pointerAtIndex:0]; |
1399 -(void *)userdata { return userdata; } | 1399 -(void *)userdata { return userdata; } |
1400 -(void)setUserdata:(void *)input { userdata = input; } | 1400 -(void)setUserdata:(void *)input { userdata = input; } |
1401 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation | 1401 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation |
1402 { | 1402 { |
1403 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [[self URL] absoluteString] }; | 1403 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [[self URL] absoluteString] }; |
1404 _dw_event_handler(self, (NSEvent *)params, 19); | 1404 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1405 } | 1405 } |
1406 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation | 1406 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation |
1407 { | 1407 { |
1408 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [[self URL] absoluteString] }; | 1408 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [[self URL] absoluteString] }; |
1409 _dw_event_handler(self, (NSEvent *)params, 19); | 1409 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1410 } | 1410 } |
1411 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation | 1411 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation |
1412 { | 1412 { |
1413 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [[self URL] absoluteString] }; | 1413 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [[self URL] absoluteString] }; |
1414 _dw_event_handler(self, (NSEvent *)params, 19); | 1414 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1415 } | 1415 } |
1416 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation | 1416 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation |
1417 { | 1417 { |
1418 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), [[self URL] absoluteString] }; | 1418 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), [[self URL] absoluteString] }; |
1419 _dw_event_handler(self, (NSEvent *)params, 19); | 1419 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1420 } | 1420 } |
1421 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 1421 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
1422 @end | 1422 @end |
1423 #else | 1423 #else |
1424 @interface DWWebView : WebView | 1424 @interface DWWebView : WebView |
1436 -(void *)userdata { return userdata; } | 1436 -(void *)userdata { return userdata; } |
1437 -(void)setUserdata:(void *)input { userdata = input; } | 1437 -(void)setUserdata:(void *)input { userdata = input; } |
1438 -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame | 1438 -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame |
1439 { | 1439 { |
1440 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [self mainFrameURL] }; | 1440 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [self mainFrameURL] }; |
1441 _dw_event_handler(self, (NSEvent *)params, 19); | 1441 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1442 } | 1442 } |
1443 -(void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame | 1443 -(void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame |
1444 { | 1444 { |
1445 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [self mainFrameURL] }; | 1445 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [self mainFrameURL] }; |
1446 _dw_event_handler(self, (NSEvent *)params, 19); | 1446 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1447 } | 1447 } |
1448 -(void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame | 1448 -(void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame |
1449 { | 1449 { |
1450 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [self mainFrameURL] }; | 1450 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [self mainFrameURL] }; |
1451 _dw_event_handler(self, (NSEvent *)params, 19); | 1451 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_HTML_CHANGED); |
1452 } | 1452 } |
1453 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 1453 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
1454 @end | 1454 @end |
1455 #endif | 1455 #endif |
1456 | 1456 |
1457 | 1457 |
1458 @implementation DWAppDel | 1458 @implementation DWAppDel |
1459 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender | 1459 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender |
1460 { | 1460 { |
1461 if(_dw_event_handler(sender, nil, 6) > 0) | 1461 if(_dw_event_handler(sender, nil, _DW_EVENT_DELETE) > 0) |
1462 return NSTerminateCancel; | 1462 return NSTerminateCancel; |
1463 return NSTerminateNow; | 1463 return NSTerminateNow; |
1464 } | 1464 } |
1465 #if defined(BUILDING_FOR_MOUNTAIN_LION) && !defined(BUILDING_FOR_BIG_SUR) | 1465 #if defined(BUILDING_FOR_MOUNTAIN_LION) && !defined(BUILDING_FOR_BIG_SUR) |
1466 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification | 1466 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification |
1490 notification = DW_UINT_TO_POINTER(handle); | 1490 notification = DW_UINT_TO_POINTER(handle); |
1491 | 1491 |
1492 switch(usernotification.activationType) | 1492 switch(usernotification.activationType) |
1493 { | 1493 { |
1494 case NSUserNotificationActivationTypeContentsClicked: | 1494 case NSUserNotificationActivationTypeContentsClicked: |
1495 _dw_event_handler(notification, nil, 8); | 1495 _dw_event_handler(notification, nil, _DW_EVENT_CLICKED); |
1496 break; | 1496 break; |
1497 default: | 1497 default: |
1498 break; | 1498 break; |
1499 } | 1499 } |
1500 dw_signal_disconnect_by_window(notification); | 1500 dw_signal_disconnect_by_window(notification); |
1519 @end | 1519 @end |
1520 | 1520 |
1521 @implementation DWView | 1521 @implementation DWView |
1522 -(BOOL)windowShouldClose:(id)sender | 1522 -(BOOL)windowShouldClose:(id)sender |
1523 { | 1523 { |
1524 if(_dw_event_handler(sender, nil, 6) > 0) | 1524 if(_dw_event_handler(sender, nil, _DW_EVENT_DELETE) > 0) |
1525 return NO; | 1525 return NO; |
1526 return YES; | 1526 return YES; |
1527 } | 1527 } |
1528 -(void)viewDidMoveToWindow | 1528 -(void)viewDidMoveToWindow |
1529 { | 1529 { |
1545 NSSize size = [self frame].size; | 1545 NSSize size = [self frame].size; |
1546 | 1546 |
1547 if(oldsize.width != size.width || oldsize.height != size.height) | 1547 if(oldsize.width != size.width || oldsize.height != size.height) |
1548 { | 1548 { |
1549 _dw_do_resize(box, size.width, size.height); | 1549 _dw_do_resize(box, size.width, size.height); |
1550 _dw_event_handler([self window], nil, 1); | 1550 _dw_event_handler([self window], nil, _DW_EVENT_CONFIGURE); |
1551 oldsize.width = size.width; | 1551 oldsize.width = size.width; |
1552 oldsize.height = size.height; | 1552 oldsize.height = size.height; |
1553 _dw_handle_resize_events(box); | 1553 _dw_handle_resize_events(box); |
1554 } | 1554 } |
1555 } | 1555 } |
1572 } | 1572 } |
1573 else | 1573 else |
1574 { | 1574 { |
1575 [DWApp setMainMenu:DWMainMenu]; | 1575 [DWApp setMainMenu:DWMainMenu]; |
1576 } | 1576 } |
1577 _dw_event_handler([self window], nil, 13); | 1577 _dw_event_handler([self window], nil, _DW_EVENT_SET_FOCUS); |
1578 } | 1578 } |
1579 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; } | 1579 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; } |
1580 -(void)menuHandler:(id)sender | 1580 -(void)menuHandler:(id)sender |
1581 { | 1581 { |
1582 id menu = [sender menu]; | 1582 id menu = [sender menu]; |
1592 [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0]; | 1592 [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0]; |
1593 else | 1593 else |
1594 [DWObj menuHandler:sender]; | 1594 [DWObj menuHandler:sender]; |
1595 _dw_wakeup_app(); | 1595 _dw_wakeup_app(); |
1596 } | 1596 } |
1597 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, 5); } | 1597 -(void)mouseDragged:(NSEvent *)theEvent { _dw_event_handler(self, theEvent, _DW_EVENT_MOTION_NOTIFY); } |
1598 -(void)mouseMoved:(NSEvent *)theEvent | 1598 -(void)mouseMoved:(NSEvent *)theEvent |
1599 { | 1599 { |
1600 id hit = [self hitTest:[theEvent locationInWindow]]; | 1600 id hit = [self hitTest:[theEvent locationInWindow]]; |
1601 | 1601 |
1602 if([hit isMemberOfClass:[DWRender class]]) | 1602 if([hit isMemberOfClass:[DWRender class]]) |
1603 { | 1603 { |
1604 _dw_event_handler(hit, theEvent, 5); | 1604 _dw_event_handler(hit, theEvent, _DW_EVENT_MOTION_NOTIFY); |
1605 } | 1605 } |
1606 } | 1606 } |
1607 @end | 1607 @end |
1608 | 1608 |
1609 /* Subclass for a button type */ | 1609 /* Subclass for a button type */ |
1627 @implementation DWButton | 1627 @implementation DWButton |
1628 -(void *)userdata { return userdata; } | 1628 -(void *)userdata { return userdata; } |
1629 -(void)setUserdata:(void *)input { userdata = input; } | 1629 -(void)setUserdata:(void *)input { userdata = input; } |
1630 -(void)buttonClicked:(id)sender | 1630 -(void)buttonClicked:(id)sender |
1631 { | 1631 { |
1632 _dw_event_handler(self, nil, 8); | 1632 _dw_event_handler(self, nil, _DW_EVENT_CLICKED); |
1633 if([self buttonType] == DWButtonTypeRadio) | 1633 if([self buttonType] == DWButtonTypeRadio) |
1634 { | 1634 { |
1635 DWBox *viewbox = [self parent]; | 1635 DWBox *viewbox = [self parent]; |
1636 Box *thisbox = [viewbox box]; | 1636 Box *thisbox = [viewbox box]; |
1637 int z; | 1637 int z; |
1975 Box *box = [view box]; | 1975 Box *box = [view box]; |
1976 NSSize size = [view frame].size; | 1976 NSSize size = [view frame].size; |
1977 _dw_do_resize(box, size.width, size.height); | 1977 _dw_do_resize(box, size.width, size.height); |
1978 _dw_handle_resize_events(box); | 1978 _dw_handle_resize_events(box); |
1979 } | 1979 } |
1980 _dw_event_handler(self, DW_INT_TO_POINTER([page pageid]), 15); | 1980 _dw_event_handler(self, DW_INT_TO_POINTER([page pageid]), _DW_EVENT_SWITCH_PAGE); |
1981 } | 1981 } |
1982 -(void)keyDown:(NSEvent *)theEvent | 1982 -(void)keyDown:(NSEvent *)theEvent |
1983 { | 1983 { |
1984 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; | 1984 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |
1985 | 1985 |
2142 @end | 2142 @end |
2143 | 2143 |
2144 @implementation DWSlider | 2144 @implementation DWSlider |
2145 -(void *)userdata { return userdata; } | 2145 -(void *)userdata { return userdata; } |
2146 -(void)setUserdata:(void *)input { userdata = input; } | 2146 -(void)setUserdata:(void *)input { userdata = input; } |
2147 -(void)sliderChanged:(id)sender { _dw_event_handler(self, (void *)[self integerValue], 14); } | 2147 -(void)sliderChanged:(id)sender { _dw_event_handler(self, (void *)[self integerValue], _DW_EVENT_VALUE_CHANGED); } |
2148 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 2148 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
2149 @end | 2149 @end |
2150 | 2150 |
2151 /* Subclass for a slider type */ | 2151 /* Subclass for a slider type */ |
2152 @interface DWScrollbar : NSScroller | 2152 @interface DWScrollbar : NSScroller |
2220 newpos = (newpos - (double)newposi) > 0.5 ? (double)(newposi + 1) : (double)newposi; | 2220 newpos = (newpos - (double)newposi) > 0.5 ? (double)(newposi + 1) : (double)newposi; |
2221 if(newpos != result) | 2221 if(newpos != result) |
2222 { | 2222 { |
2223 [self setDoubleValue:(newpos/max)]; | 2223 [self setDoubleValue:(newpos/max)]; |
2224 } | 2224 } |
2225 _dw_event_handler(self, DW_INT_TO_POINTER((int)newpos), 14); | 2225 _dw_event_handler(self, DW_INT_TO_POINTER((int)newpos), _DW_EVENT_VALUE_CHANGED); |
2226 } | 2226 } |
2227 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 2227 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
2228 @end | 2228 @end |
2229 | 2229 |
2230 /* Subclass for a MLE type */ | 2230 /* Subclass for a MLE type */ |
3012 | 3012 |
3013 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; | 3013 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; |
3014 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; | 3014 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; |
3015 | 3015 |
3016 /* Handler for container class */ | 3016 /* Handler for container class */ |
3017 _dw_event_handler(self, (NSEvent *)params, 9); | 3017 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_ITEM_ENTER); |
3018 } | 3018 } |
3019 -(void)keyUp:(NSEvent *)theEvent | 3019 -(void)keyUp:(NSEvent *)theEvent |
3020 { | 3020 { |
3021 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) | 3021 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
3022 { | 3022 { |
3023 void *params[2]; | 3023 void *params[2]; |
3024 | 3024 |
3025 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; | 3025 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; |
3026 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; | 3026 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; |
3027 | 3027 |
3028 _dw_event_handler(self, (NSEvent *)params, 9); | 3028 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_ITEM_ENTER); |
3029 } | 3029 } |
3030 [super keyUp:theEvent]; | 3030 [super keyUp:theEvent]; |
3031 } | 3031 } |
3032 | 3032 |
3033 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn | 3033 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn |
3034 { | 3034 { |
3035 NSUInteger index = [tvcols indexOfObject:tableColumn]; | 3035 NSUInteger index = [tvcols indexOfObject:tableColumn]; |
3036 | 3036 |
3037 /* Handler for column click class */ | 3037 /* Handler for column click class */ |
3038 _dw_event_handler(self, (NSEvent *)index, 17); | 3038 _dw_event_handler(self, (NSEvent *)index, _DW_EVENT_COLUMN_CLICK); |
3039 } | 3039 } |
3040 -(void)selectionChanged:(id)sender | 3040 -(void)selectionChanged:(id)sender |
3041 { | 3041 { |
3042 void *params[2]; | 3042 void *params[2]; |
3043 | 3043 |
3044 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; | 3044 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; |
3045 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; | 3045 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; |
3046 | 3046 |
3047 /* Handler for container class */ | 3047 /* Handler for container class */ |
3048 _dw_event_handler(self, (NSEvent *)params, 12); | 3048 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_ITEM_SELECT); |
3049 /* Handler for listbox class */ | 3049 /* Handler for listbox class */ |
3050 _dw_event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11); | 3050 _dw_event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), _DW_EVENT_LIST_SELECT); |
3051 } | 3051 } |
3052 -(NSMenu *)menuForEvent:(NSEvent *)event | 3052 -(NSMenu *)menuForEvent:(NSEvent *)event |
3053 { | 3053 { |
3054 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; | 3054 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
3055 int row = (int)[self rowAtPoint:where]; | 3055 int row = (int)[self rowAtPoint:where]; |
3056 void *params[2]; | 3056 void *params[2]; |
3057 | 3057 |
3058 params[0] = [self getRowTitle:row]; | 3058 params[0] = [self getRowTitle:row]; |
3059 params[1] = [self getRowData:row]; | 3059 params[1] = [self getRowData:row]; |
3060 | 3060 |
3061 _dw_event_handler(self, (NSEvent *)params, 10); | 3061 _dw_event_handler(self, (NSEvent *)params, _DW_EVENT_ITEM_CONTEXT); |
3062 return nil; | 3062 return nil; |
3063 } | 3063 } |
3064 -(void)keyDown:(NSEvent *)theEvent | 3064 -(void)keyDown:(NSEvent *)theEvent |
3065 { | 3065 { |
3066 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; | 3066 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |
3312 /* Handler for tree class */ | 3312 /* Handler for tree class */ |
3313 id item = [self itemAtRow:[self selectedRow]]; | 3313 id item = [self itemAtRow:[self selectedRow]]; |
3314 | 3314 |
3315 if(item) | 3315 if(item) |
3316 { | 3316 { |
3317 _dw_event_handler(self, (void *)item, 12); | 3317 _dw_event_handler(self, (void *)item, _DW_EVENT_ITEM_SELECT); |
3318 } | 3318 } |
3319 } | 3319 } |
3320 -(void)treeItemExpanded:(NSNotification *)notification | 3320 -(void)treeItemExpanded:(NSNotification *)notification |
3321 { | 3321 { |
3322 id item = [[notification userInfo ] objectForKey: @"NSObject"]; | 3322 id item = [[notification userInfo ] objectForKey: @"NSObject"]; |
3323 | 3323 |
3324 if(item) | 3324 if(item) |
3325 { | 3325 { |
3326 _dw_event_handler(self, (void *)item, 16); | 3326 _dw_event_handler(self, (void *)item, _DW_EVENT_TREE_EXPAND); |
3327 } | 3327 } |
3328 } | 3328 } |
3329 -(NSMenu *)menuForEvent:(NSEvent *)event | 3329 -(NSMenu *)menuForEvent:(NSEvent *)event |
3330 { | 3330 { |
3331 int row; | 3331 int row; |
3332 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; | 3332 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
3333 row = (int)[self rowAtPoint:where]; | 3333 row = (int)[self rowAtPoint:where]; |
3334 id item = [self itemAtRow:row]; | 3334 id item = [self itemAtRow:row]; |
3335 _dw_event_handler(self, (NSEvent *)item, 10); | 3335 _dw_event_handler(self, (NSEvent *)item, _DW_EVENT_ITEM_CONTEXT); |
3336 return nil; | 3336 return nil; |
3337 } | 3337 } |
3338 -(NSScrollView *)scrollview { return scrollview; } | 3338 -(NSScrollView *)scrollview { return scrollview; } |
3339 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } | 3339 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
3340 -(void)deleteNode:(NSMutableArray *)item { _dw_free_tree_recurse(data, item); } | 3340 -(void)deleteNode:(NSMutableArray *)item { _dw_free_tree_recurse(data, item); } |
3398 @end | 3398 @end |
3399 | 3399 |
3400 @implementation DWComboBox | 3400 @implementation DWComboBox |
3401 -(void *)userdata { return userdata; } | 3401 -(void *)userdata { return userdata; } |
3402 -(void)setUserdata:(void *)input { userdata = input; } | 3402 -(void)setUserdata:(void *)input { userdata = input; } |
3403 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _dw_event_handler(self, (void *)[self indexOfSelectedItem], 11); } | 3403 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _dw_event_handler(self, (void *)[self indexOfSelectedItem], _DW_EVENT_LIST_SELECT); } |
3404 -(void)setClickDefault:(id)input { clickDefault = input; } | 3404 -(void)setClickDefault:(id)input { clickDefault = input; } |
3405 -(void)keyUp:(NSEvent *)theEvent | 3405 -(void)keyUp:(NSEvent *)theEvent |
3406 { | 3406 { |
3407 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) | 3407 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
3408 { | 3408 { |
3442 [self mouseUp:event]; | 3442 [self mouseUp:event]; |
3443 } | 3443 } |
3444 -(void)mouseUp:(NSEvent *)event | 3444 -(void)mouseUp:(NSEvent *)event |
3445 { | 3445 { |
3446 [textfield takeIntValueFrom:self]; | 3446 [textfield takeIntValueFrom:self]; |
3447 _dw_event_handler(parent, (void *)[self integerValue], 14); | 3447 _dw_event_handler(parent, (void *)[self integerValue], _DW_EVENT_VALUE_CHANGED); |
3448 } | 3448 } |
3449 -(void)keyDown:(NSEvent *)theEvent | 3449 -(void)keyDown:(NSEvent *)theEvent |
3450 { | 3450 { |
3451 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; | 3451 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |
3452 if(vk == VK_UP || vk == VK_DOWN) | 3452 if(vk == VK_UP || vk == VK_DOWN) |
3514 -(NSStepper *)stepper { return stepper; } | 3514 -(NSStepper *)stepper { return stepper; } |
3515 -(void)controlTextDidChange:(NSNotification *)aNotification | 3515 -(void)controlTextDidChange:(NSNotification *)aNotification |
3516 { | 3516 { |
3517 [stepper takeIntValueFrom:textfield]; | 3517 [stepper takeIntValueFrom:textfield]; |
3518 [textfield takeIntValueFrom:stepper]; | 3518 [textfield takeIntValueFrom:stepper]; |
3519 _dw_event_handler(self, (void *)[stepper integerValue], 14); | 3519 _dw_event_handler(self, (void *)[stepper integerValue], _DW_EVENT_VALUE_CHANGED); |
3520 } | 3520 } |
3521 -(void)setClickDefault:(id)input { clickDefault = input; } | 3521 -(void)setClickDefault:(id)input { clickDefault = input; } |
3522 -(void)keyUp:(NSEvent *)theEvent | 3522 -(void)keyUp:(NSEvent *)theEvent |
3523 { | 3523 { |
3524 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) | 3524 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) |
3563 dw_signal_disconnect_by_window(notification); | 3563 dw_signal_disconnect_by_window(notification); |
3564 } | 3564 } |
3565 else if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) | 3565 else if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) |
3566 { | 3566 { |
3567 /* The user launched the app. */ | 3567 /* The user launched the app. */ |
3568 _dw_event_handler(notification, nil, 8); | 3568 _dw_event_handler(notification, nil, _DW_EVENT_CLICKED); |
3569 dw_signal_disconnect_by_window(notification); | 3569 dw_signal_disconnect_by_window(notification); |
3570 } | 3570 } |
3571 completionHandler(); | 3571 completionHandler(); |
3572 } | 3572 } |
3573 @end | 3573 @end |
3679 if(oldsize.width != newsize.width || oldsize.height != newsize.height) | 3679 if(oldsize.width != newsize.width || oldsize.height != newsize.height) |
3680 { | 3680 { |
3681 if(newsize.width > 0 && newsize.height > 0) | 3681 if(newsize.width > 0 && newsize.height > 0) |
3682 { | 3682 { |
3683 [render setSize:newsize]; | 3683 [render setSize:newsize]; |
3684 _dw_event_handler(handle, nil, 1); | 3684 _dw_event_handler(handle, nil, _DW_EVENT_CONFIGURE); |
3685 } | 3685 } |
3686 } | 3686 } |
3687 } | 3687 } |
3688 /* Special handling for notebook controls */ | 3688 /* Special handling for notebook controls */ |
3689 else if([handle isMemberOfClass:[DWNotebook class]]) | 3689 else if([handle isMemberOfClass:[DWNotebook class]]) |
9285 | 9285 |
9286 #if WK_API_ENABLED | 9286 #if WK_API_ENABLED |
9287 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error) | 9287 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error) |
9288 { | 9288 { |
9289 void *params[2] = { result, scriptdata }; | 9289 void *params[2] = { result, scriptdata }; |
9290 _dw_event_handler(html, (NSEvent *)params, 18); | 9290 _dw_event_handler(html, (NSEvent *)params, _DW_EVENT_HTML_RESULT); |
9291 }]; | 9291 }]; |
9292 #else | 9292 #else |
9293 NSString *result = [html stringByEvaluatingJavaScriptFromString:[NSString stringWithUTF8String:script]]; | 9293 NSString *result = [html stringByEvaluatingJavaScriptFromString:[NSString stringWithUTF8String:script]]; |
9294 void *params[2] = { result, scriptdata }; | 9294 void *params[2] = { result, scriptdata }; |
9295 _dw_event_handler(html, (NSEvent *)params, 18); | 9295 _dw_event_handler(html, (NSEvent *)params, _DW_EVENT_HTML_RESULT); |
9296 #endif | 9296 #endif |
9297 DW_LOCAL_POOL_OUT; | 9297 DW_LOCAL_POOL_OUT; |
9298 return DW_ERROR_NONE; | 9298 return DW_ERROR_NONE; |
9299 } | 9299 } |
9300 | 9300 |