comparison ios/dw.m @ 2373:8d6ab1f46a29

iOS: Converting more types and classes to the iOS equivalents.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 17 Mar 2021 03:17:58 +0000
parents df0a66945296
children 6393d8c10569
comparison
equal deleted inserted replaced
2372:df0a66945296 2373:8d6ab1f46a29
322 { 17, DW_SIGNAL_COLUMN_CLICK }, 322 { 17, DW_SIGNAL_COLUMN_CLICK },
323 { 18, DW_SIGNAL_HTML_RESULT }, 323 { 18, DW_SIGNAL_HTML_RESULT },
324 { 19, DW_SIGNAL_HTML_CHANGED } 324 { 19, DW_SIGNAL_HTML_CHANGED }
325 }; 325 };
326 326
327 int _event_handler1(id object, NSEvent *event, int message) 327 int _event_handler1(id object, UIEvent *event, int message)
328 { 328 {
329 SignalHandler *handler = _get_handler(object, message); 329 SignalHandler *handler = _get_handler(object, message);
330 /* NSLog(@"Event handler - type %d\n", message); */ 330 /* NSLog(@"Event handler - type %d\n", message); */
331 331
332 if(handler) 332 if(handler)
344 } 344 }
345 /* Configure/Resize event */ 345 /* Configure/Resize event */
346 case 1: 346 case 1:
347 { 347 {
348 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; 348 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction;
349 NSSize size; 349 CGSize size;
350 350
351 if([object isKindOfClass:[UIWindow class]]) 351 if([object isKindOfClass:[UIWindow class]])
352 { 352 {
353 UIWindow *window = object; 353 UIWindow *window = object;
354 size = [[window contentView] frame].size; 354 size = [[window contentView] frame].size;
389 /* Button press and release event */ 389 /* Button press and release event */
390 case 3: 390 case 3:
391 case 4: 391 case 4:
392 { 392 {
393 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 393 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
394 NSPoint p = [NSEvent mouseLocation]; 394 CGPoint p = [UIEvent mouseLocation];
395 int button = 1; 395 int button = 1;
396 396
397 if([event isMemberOfClass:[NSEvent class]]) 397 if([event isMemberOfClass:[UIEvent class]])
398 { 398 {
399 id view = [[[event window] contentView] superview]; 399 id view = [[[event window] contentView] superview];
400 NSEventType type = [event type]; 400 UIEventType type = [event type];
401 401
402 p = [view convertPoint:[event locationInWindow] toView:object]; 402 p = [view convertPoint:[event locationInWindow] toView:object];
403 403
404 if(type == DWEventTypeRightMouseDown || type == DWEventTypeRightMouseUp) 404 if(type == DWEventTypeRightMouseDown || type == DWEventTypeRightMouseUp)
405 { 405 {
420 /* Motion notify event */ 420 /* Motion notify event */
421 case 5: 421 case 5:
422 { 422 {
423 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 423 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
424 id view = [[[event window] contentView] superview]; 424 id view = [[[event window] contentView] superview];
425 NSPoint p = [view convertPoint:[event locationInWindow] toView:object]; 425 CGPoint p = [view convertPoint:[event locationInWindow] toView:object];
426 SEL spmb = NSSelectorFromString(@"pressedMouseButtons"); 426 SEL spmb = NSSelectorFromString(@"pressedMouseButtons");
427 DWIMP ipmb = [[NSEvent class] respondsToSelector:spmb] ? (DWIMP)[[NSEvent class] methodForSelector:spmb] : 0; 427 DWIMP ipmb = [[UIEvent class] respondsToSelector:spmb] ? (DWIMP)[[UIEvent class] methodForSelector:spmb] : 0;
428 NSUInteger buttonmask = ipmb ? (NSUInteger)ipmb([NSEvent class], spmb) : (1 << [event buttonNumber]); 428 NSUInteger buttonmask = ipmb ? (NSUInteger)ipmb([UIEvent class], spmb) : (1 << [event buttonNumber]);
429 429
430 return motionfunc(object, (int)p.x, (int)p.y, (int)buttonmask, handler->data); 430 return motionfunc(object, (int)p.x, (int)p.y, (int)buttonmask, handler->data);
431 } 431 }
432 /* Window close event */ 432 /* Window close event */
433 case 6: 433 case 6:
438 /* Window expose/draw event */ 438 /* Window expose/draw event */
439 case 7: 439 case 7:
440 { 440 {
441 DWExpose exp; 441 DWExpose exp;
442 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; 442 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction;
443 NSRect rect = [object frame]; 443 CGRect rect = [object frame];
444 444
445 exp.x = rect.origin.x; 445 exp.x = rect.origin.x;
446 exp.y = rect.origin.y; 446 exp.y = rect.origin.y;
447 exp.width = rect.size.width; 447 exp.width = rect.size.width;
448 exp.height = rect.size.height; 448 exp.height = rect.size.height;
590 } 590 }
591 return -1; 591 return -1;
592 } 592 }
593 593
594 /* Sub function to handle redraws */ 594 /* Sub function to handle redraws */
595 int _event_handler(id object, NSEvent *event, int message) 595 int _event_handler(id object, UIEvent *event, int message)
596 { 596 {
597 int ret = _event_handler1(object, event, message); 597 int ret = _event_handler1(object, event, message);
598 if(ret != -1) 598 if(ret != -1)
599 _dw_redraw(nil, FALSE); 599 _dw_redraw(nil, FALSE);
600 return ret; 600 return ret;
607 607
608 @implementation DWTimerHandler 608 @implementation DWTimerHandler
609 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } 609 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); }
610 @end 610 @end
611 611
612 NSApplication *DWApp = nil; 612 UIApplication *DWApp = nil;
613 UIFontManager *DWFontManager = nil; 613 UIFontManager *DWFontManager = nil;
614 UIFont *DWDefaultFont; 614 UIFont *DWDefaultFont;
615 DWTimerHandler *DWHandler; 615 DWTimerHandler *DWHandler;
616 NSAutoreleasePool *pool; 616 NSAutoreleasePool *pool;
617 NSMutableArray *_DWDirtyDrawables; 617 NSMutableArray *_DWDirtyDrawables;
618 DWTID DWThread = (DWTID)-1; 618 DWTID DWThread = (DWTID)-1;
619 619
620 /* Send fake event to make sure the loop isn't stuck */ 620 /* Send fake event to make sure the loop isn't stuck */
621 void _dw_wakeup_app() 621 void _dw_wakeup_app()
622 { 622 {
623 [DWApp postEvent:[NSEvent otherEventWithType:DWEventTypeApplicationDefined 623 [DWApp postEvent:[UIEvent otherEventWithType:DWEventTypeApplicationDefined
624 location:NSMakePoint(0, 0) 624 location:NSMakePoint(0, 0)
625 modifierFlags:0 625 modifierFlags:0
626 timestamp:0 626 timestamp:0
627 windowNumber:0 627 windowNumber:0
628 context:NULL 628 context:NULL
653 -(void)menuHandler:(id)param; 653 -(void)menuHandler:(id)param;
654 -(void)doBitBlt:(id)param; 654 -(void)doBitBlt:(id)param;
655 -(void)doFlush:(id)param; 655 -(void)doFlush:(id)param;
656 @end 656 @end
657 657
658 @interface DWMenuItem : NSMenuItem 658 API_AVAILABLE(ios(13.0))
659 @interface DWMenuItem : UIMenuItem
659 { 660 {
660 int check; 661 int check;
661 } 662 }
662 -(void)setCheck:(int)input; 663 -(void)setCheck:(int)input;
663 -(int)check; 664 -(int)check;
683 -(void)dealloc; 684 -(void)dealloc;
684 -(Box *)box; 685 -(Box *)box;
685 -(id)contentView; 686 -(id)contentView;
686 -(void *)userdata; 687 -(void *)userdata;
687 -(void)setUserdata:(void *)input; 688 -(void)setUserdata:(void *)input;
688 -(void)drawRect:(NSRect)rect; 689 -(void)drawRect:(CGRect)rect;
689 -(BOOL)isFlipped; 690 -(BOOL)isFlipped;
690 -(void)mouseDown:(NSEvent *)theEvent; 691 -(void)mouseDown:(UIEvent *)theEvent;
691 -(void)mouseUp:(NSEvent *)theEvent; 692 -(void)mouseUp:(UIEvent *)theEvent;
692 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; 693 -(UIMenu *)menuForEvent:(UIEvent *)theEvent;
693 -(void)rightMouseUp:(NSEvent *)theEvent; 694 -(void)rightMouseUp:(UIEvent *)theEvent;
694 -(void)otherMouseDown:(NSEvent *)theEvent; 695 -(void)otherMouseDown:(UIEvent *)theEvent;
695 -(void)otherMouseUp:(NSEvent *)theEvent; 696 -(void)otherMouseUp:(UIEvent *)theEvent;
696 -(void)keyDown:(NSEvent *)theEvent; 697 -(void)keyDown:(UIEvent *)theEvent;
697 -(void)setColor:(unsigned long)input; 698 -(void)setColor:(unsigned long)input;
698 @end 699 @end
699 700
700 @implementation DWBox 701 @implementation DWBox
701 -(id)init 702 -(id)init
723 } 724 }
724 -(Box *)box { return box; } 725 -(Box *)box { return box; }
725 -(id)contentView { return self; } 726 -(id)contentView { return self; }
726 -(void *)userdata { return userdata; } 727 -(void *)userdata { return userdata; }
727 -(void)setUserdata:(void *)input { userdata = input; } 728 -(void)setUserdata:(void *)input { userdata = input; }
728 -(void)drawRect:(NSRect)rect 729 -(void)drawRect:(CGRect)rect
729 { 730 {
730 if(bgcolor) 731 if(bgcolor)
731 { 732 {
732 [bgcolor set]; 733 [bgcolor set];
733 NSRectFill([self bounds]); 734 CGRectFill([self bounds]);
734 } 735 }
735 } 736 }
736 -(BOOL)isFlipped { return YES; } 737 -(BOOL)isFlipped { return YES; }
737 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } 738 -(void)mouseDown:(UIEvent *)theEvent { _event_handler(self, (void *)1, 3); }
738 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } 739 -(void)mouseUp:(UIEvent *)theEvent { _event_handler(self, (void *)1, 4); }
739 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; } 740 -(UIMenu *)menuForEvent:(UIEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; }
740 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); } 741 -(void)rightMouseUp:(UIEvent *)theEvent { _event_handler(self, (void *)2, 4); }
741 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } 742 -(void)otherMouseDown:(UIEvent *)theEvent { _event_handler(self, (void *)3, 3); }
742 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } 743 -(void)otherMouseUp:(UIEvent *)theEvent { _event_handler(self, (void *)3, 4); }
743 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } 744 -(void)keyDown:(UIEvent *)theEvent { _event_handler(self, theEvent, 2); }
744 -(void)setColor:(unsigned long)input 745 -(void)setColor:(unsigned long)input
745 { 746 {
746 id orig = bgcolor; 747 id orig = bgcolor;
747 748
748 if(input == _colors[DW_CLR_DEFAULT]) 749 if(input == _colors[DW_CLR_DEFAULT])
753 { 754 {
754 bgcolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain]; 755 bgcolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain];
755 if(UIGraphicsGetCurrentContext()) 756 if(UIGraphicsGetCurrentContext())
756 { 757 {
757 [bgcolor set]; 758 [bgcolor set];
758 NSRectFill([self bounds]); 759 CGRectFill([self bounds]);
759 } 760 }
760 } 761 }
761 [self setNeedsDisplay:YES]; 762 [self setNeedsDisplay:YES];
762 [orig release]; 763 [orig release];
763 } 764 }
766 /* Subclass for a group box type */ 767 /* Subclass for a group box type */
767 @interface DWGroupBox : UIView 768 @interface DWGroupBox : UIView
768 { 769 {
769 void *userdata; 770 void *userdata;
770 UIColor *bgcolor; 771 UIColor *bgcolor;
771 NSSize borderSize; 772 CGSize borderSize;
772 NSString *title; 773 NSString *title;
773 } 774 }
774 -(Box *)box; 775 -(Box *)box;
775 -(void *)userdata; 776 -(void *)userdata;
776 -(void)setUserdata:(void *)input; 777 -(void)setUserdata:(void *)input;
778 @end 779 @end
779 780
780 @implementation DWGroupBox 781 @implementation DWGroupBox
781 -(Box *)box { return [[self contentView] box]; } 782 -(Box *)box { return [[self contentView] box]; }
782 -(void *)userdata { return userdata; } 783 -(void *)userdata { return userdata; }
783 -(NSSize)borderSize { return borderSize; } 784 -(CGSize)borderSize { return borderSize; }
784 -(NSSize)initBorder 785 -(CGSize)initBorder
785 { 786 {
786 NSSize frameSize = [self frame].size; 787 CGSize frameSize = [self frame].size;
787 788
788 if(frameSize.height < 20 || frameSize.width < 20) 789 if(frameSize.height < 20 || frameSize.width < 20)
789 { 790 {
790 frameSize.width = frameSize.height = 100; 791 frameSize.width = frameSize.height = 100;
791 [self setFrameSize:frameSize]; 792 [self setFrameSize:frameSize];
792 } 793 }
793 NSSize contentSize = [[self contentView] frame].size; 794 CGSize contentSize = [[self contentView] frame].size;
794 NSSize titleSize = [self titleRect].size; 795 CGSize titleSize = [self titleRect].size;
795 796
796 borderSize.width = 100-contentSize.width; 797 borderSize.width = 100-contentSize.width;
797 borderSize.height = (100-contentSize.height)-titleSize.height; 798 borderSize.height = (100-contentSize.height)-titleSize.height;
798 return borderSize; 799 return borderSize;
799 } 800 }
804 @interface DWWindow : UIWindow 805 @interface DWWindow : UIWindow
805 { 806 {
806 int redraw; 807 int redraw;
807 int shown; 808 int shown;
808 } 809 }
809 -(void)sendEvent:(NSEvent *)theEvent; 810 -(void)sendEvent:(UIEvent *)theEvent;
810 -(void)keyDown:(NSEvent *)theEvent; 811 -(void)keyDown:(UIEvent *)theEvent;
811 -(void)mouseDragged:(NSEvent *)theEvent; 812 -(void)mouseDragged:(UIEvent *)theEvent;
812 -(int)redraw; 813 -(int)redraw;
813 -(void)setRedraw:(int)val; 814 -(void)setRedraw:(int)val;
814 -(int)shown; 815 -(int)shown;
815 -(void)setShown:(int)val; 816 -(void)setShown:(int)val;
816 @end 817 @end
817 818
818 @implementation DWWindow 819 @implementation DWWindow
819 -(void)sendEvent:(NSEvent *)theEvent 820 -(void)sendEvent:(UIEvent *)theEvent
820 { 821 {
821 int rcode = -1; 822 int rcode = -1;
822 if([theEvent type] == DWEventTypeKeyDown) 823 if([theEvent type] == DWEventTypeKeyDown)
823 { 824 {
824 rcode = _event_handler(self, theEvent, 2); 825 rcode = _event_handler(self, theEvent, 2);
825 } 826 }
826 if ( rcode != TRUE ) 827 if ( rcode != TRUE )
827 [super sendEvent:theEvent]; 828 [super sendEvent:theEvent];
828 } 829 }
829 -(void)keyDown:(NSEvent *)theEvent { } 830 -(void)keyDown:(UIEvent *)theEvent { }
830 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); } 831 -(void)mouseDragged:(UIEvent *)theEvent { _event_handler(self, theEvent, 5); }
831 -(int)redraw { return redraw; } 832 -(int)redraw { return redraw; }
832 -(void)setRedraw:(int)val { redraw = val; } 833 -(void)setRedraw:(int)val { redraw = val; }
833 -(int)shown { return shown; } 834 -(int)shown { return shown; }
834 -(void)setShown:(int)val { shown = val; } 835 -(void)setShown:(int)val { shown = val; }
835 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; } 836 -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; }
838 /* Subclass for a render area type */ 839 /* Subclass for a render area type */
839 @interface DWRender : UIControl 840 @interface DWRender : UIControl
840 { 841 {
841 void *userdata; 842 void *userdata;
842 UIFont *font; 843 UIFont *font;
843 NSSize size; 844 CGSize size;
844 NSBitmapImageRep *cachedDrawingRep; 845 NSBitmapImageRep *cachedDrawingRep;
845 } 846 }
846 -(void *)userdata; 847 -(void *)userdata;
847 -(void)setUserdata:(void *)input; 848 -(void)setUserdata:(void *)input;
848 -(void)setFont:(UIFont *)input; 849 -(void)setFont:(UIFont *)input;
849 -(UIFont *)font; 850 -(UIFont *)font;
850 -(void)setSize:(NSSize)input; 851 -(void)setSize:(CGSize)input;
851 -(NSSize)size; 852 -(CGSize)size;
852 -(NSBitmapImageRep *)cachedDrawingRep; 853 -(NSBitmapImageRep *)cachedDrawingRep;
853 -(void)mouseDown:(NSEvent *)theEvent; 854 -(void)mouseDown:(UIEvent *)theEvent;
854 -(void)mouseUp:(NSEvent *)theEvent; 855 -(void)mouseUp:(UIEvent *)theEvent;
855 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; 856 -(UIMenu *)menuForEvent:(UIEvent *)theEvent;
856 -(void)rightMouseUp:(NSEvent *)theEvent; 857 -(void)rightMouseUp:(UIEvent *)theEvent;
857 -(void)otherMouseDown:(NSEvent *)theEvent; 858 -(void)otherMouseDown:(UIEvent *)theEvent;
858 -(void)otherMouseUp:(NSEvent *)theEvent; 859 -(void)otherMouseUp:(UIEvent *)theEvent;
859 -(void)drawRect:(NSRect)rect; 860 -(void)drawRect:(CGRect)rect;
860 -(void)keyDown:(NSEvent *)theEvent; 861 -(void)keyDown:(UIEvent *)theEvent;
861 -(BOOL)isFlipped; 862 -(BOOL)isFlipped;
862 @end 863 @end
863 864
864 @implementation DWRender 865 @implementation DWRender
865 -(void *)userdata { return userdata; } 866 -(void *)userdata { return userdata; }
866 -(void)setUserdata:(void *)input { userdata = input; } 867 -(void)setUserdata:(void *)input { userdata = input; }
867 -(void)setFont:(UIFont *)input { [font release]; font = input; [font retain]; } 868 -(void)setFont:(UIFont *)input { [font release]; font = input; [font retain]; }
868 -(UIFont *)font { return font; } 869 -(UIFont *)font { return font; }
869 -(void)setSize:(NSSize)input { 870 -(void)setSize:(CGSize)input {
870 size = input; 871 size = input;
871 if(cachedDrawingRep) 872 if(cachedDrawingRep)
872 { 873 {
873 NSBitmapImageRep *oldrep = cachedDrawingRep; 874 NSBitmapImageRep *oldrep = cachedDrawingRep;
874 cachedDrawingRep = [self bitmapImageRepForCachingDisplayInRect:self.bounds]; 875 cachedDrawingRep = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
875 [cachedDrawingRep retain]; 876 [cachedDrawingRep retain];
876 [oldrep release]; 877 [oldrep release];
877 } 878 }
878 } 879 }
879 -(NSSize)size { return size; } 880 -(CGSize)size { return size; }
880 -(NSBitmapImageRep *)cachedDrawingRep { 881 -(NSBitmapImageRep *)cachedDrawingRep {
881 if(!cachedDrawingRep) 882 if(!cachedDrawingRep)
882 { 883 {
883 cachedDrawingRep = [self bitmapImageRepForCachingDisplayInRect:self.bounds]; 884 cachedDrawingRep = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
884 [cachedDrawingRep retain]; 885 [cachedDrawingRep retain];
886 /* Mark this render dirty if something is requesting it to draw */ 887 /* Mark this render dirty if something is requesting it to draw */
887 if(![_DWDirtyDrawables containsObject:self]) 888 if(![_DWDirtyDrawables containsObject:self])
888 [_DWDirtyDrawables addObject:self]; 889 [_DWDirtyDrawables addObject:self];
889 return cachedDrawingRep; 890 return cachedDrawingRep;
890 } 891 }
891 -(void)mouseDown:(NSEvent *)theEvent 892 -(void)mouseDown:(UIEvent *)theEvent
892 { 893 {
893 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & DWEventModifierFlagControl)) 894 if(![theEvent isMemberOfClass:[UIEvent class]] || !([theEvent modifierFlags] & DWEventModifierFlagControl))
894 _event_handler(self, theEvent, 3); 895 _event_handler(self, theEvent, 3);
895 } 896 }
896 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } 897 -(void)mouseUp:(UIEvent *)theEvent { _event_handler(self, theEvent, 4); }
897 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; } 898 -(UIMenu *)menuForEvent:(UIEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; }
898 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } 899 -(void)rightMouseUp:(UIEvent *)theEvent { _event_handler(self, theEvent, 4); }
899 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } 900 -(void)otherMouseDown:(UIEvent *)theEvent { _event_handler(self, theEvent, 3); }
900 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } 901 -(void)otherMouseUp:(UIEvent *)theEvent { _event_handler(self, theEvent, 4); }
901 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); } 902 -(void)mouseDragged:(UIEvent *)theEvent { _event_handler(self, theEvent, 5); }
902 -(void)delayedNeedsDisplay { [self setNeedsDisplay:YES]; } 903 -(void)delayedNeedsDisplay { [self setNeedsDisplay:YES]; }
903 -(void)drawRect:(NSRect)rect { 904 -(void)drawRect:(CGRect)rect {
904 _event_handler(self, nil, 7); 905 _event_handler(self, nil, 7);
905 if (cachedDrawingRep) 906 if (cachedDrawingRep)
906 { 907 {
907 [cachedDrawingRep drawInRect:self.bounds]; 908 [cachedDrawingRep drawInRect:self.bounds];
908 [_DWDirtyDrawables removeObject:self]; 909 [_DWDirtyDrawables removeObject:self];
911 [self setNeedsDisplay:YES]; 912 [self setNeedsDisplay:YES];
912 else 913 else
913 [self performSelector:@selector(delayedNeedsDisplay) withObject:nil afterDelay:0]; 914 [self performSelector:@selector(delayedNeedsDisplay) withObject:nil afterDelay:0];
914 } 915 }
915 } 916 }
916 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } 917 -(void)keyDown:(UIEvent *)theEvent { _event_handler(self, theEvent, 2); }
917 -(BOOL)isFlipped { return YES; } 918 -(BOOL)isFlipped { return YES; }
918 -(void)dealloc { 919 -(void)dealloc {
919 UserData *root = userdata; 920 UserData *root = userdata;
920 _remove_userdata(&root, NULL, TRUE); 921 _remove_userdata(&root, NULL, TRUE);
921 [font release]; 922 [font release];
1063 @end 1064 @end
1064 1065
1065 DWObject *DWObj; 1066 DWObject *DWObj;
1066 1067
1067 /* Subclass for the application class */ 1068 /* Subclass for the application class */
1068 @interface DWAppDel : NSObject <NSApplicationDelegate> 1069 @interface DWAppDel : NSObject <UIApplicationDelegate>
1069 { 1070 {
1070 } 1071 }
1071 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; 1072 -(UIApplicationTerminateReply)applicationShouldTerminate:(UIApplication *)sender;
1072 @end 1073 @end
1073 1074
1074 @interface DWWebView : WKWebView <WKNavigationDelegate> 1075 @interface DWWebView : WKWebView <WKNavigationDelegate>
1075 { 1076 {
1076 void *userdata; 1077 void *userdata;
1087 -(void *)userdata { return userdata; } 1088 -(void *)userdata { return userdata; }
1088 -(void)setUserdata:(void *)input { userdata = input; } 1089 -(void)setUserdata:(void *)input { userdata = input; }
1089 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation 1090 -(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
1090 { 1091 {
1091 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [[self URL] absoluteString] }; 1092 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), [[self URL] absoluteString] };
1092 _event_handler(self, (NSEvent *)params, 19); 1093 _event_handler(self, (UIEvent *)params, 19);
1093 } 1094 }
1094 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 1095 -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
1095 { 1096 {
1096 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [[self URL] absoluteString] }; 1097 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), [[self URL] absoluteString] };
1097 _event_handler(self, (NSEvent *)params, 19); 1098 _event_handler(self, (UIEvent *)params, 19);
1098 } 1099 }
1099 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation 1100 -(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
1100 { 1101 {
1101 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [[self URL] absoluteString] }; 1102 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), [[self URL] absoluteString] };
1102 _event_handler(self, (NSEvent *)params, 19); 1103 _event_handler(self, (UIEvent *)params, 19);
1103 } 1104 }
1104 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation 1105 -(void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
1105 { 1106 {
1106 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), [[self URL] absoluteString] }; 1107 void *params[2] = { DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), [[self URL] absoluteString] };
1107 _event_handler(self, (NSEvent *)params, 19); 1108 _event_handler(self, (UIEvent *)params, 19);
1108 } 1109 }
1109 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } 1110 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
1110 @end 1111 @end
1111 1112
1112 @implementation DWAppDel 1113 @implementation DWAppDel
1113 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender 1114 -(UIApplicationTerminateReply)applicationShouldTerminate:(UIApplication *)sender
1114 { 1115 {
1115 if(_event_handler(sender, nil, 6) > 0) 1116 if(_event_handler(sender, nil, 6) > 0)
1116 return NSTerminateCancel; 1117 return NSTerminateCancel;
1117 return NSTerminateNow; 1118 return NSTerminateNow;
1118 } 1119 }
1119 @end 1120 @end
1120 1121
1121 /* Subclass for a top-level window */ 1122 /* Subclass for a top-level window */
1122 @interface DWView : DWBox <UIWindowDelegate> 1123 @interface DWView : DWBox <UIWindowDelegate>
1123 { 1124 {
1124 NSMenu *windowmenu; 1125 UIMenu *windowmenu;
1125 NSSize oldsize; 1126 CGSize oldsize;
1126 } 1127 }
1127 -(BOOL)windowShouldClose:(id)sender; 1128 -(BOOL)windowShouldClose:(id)sender;
1128 -(void)setMenu:(NSMenu *)input; 1129 -(void)setMenu:(UIMenu *)input;
1129 -(void)windowDidBecomeMain:(id)sender; 1130 -(void)windowDidBecomeMain:(id)sender;
1130 -(void)menuHandler:(id)sender; 1131 -(void)menuHandler:(id)sender;
1131 -(void)mouseDragged:(NSEvent *)theEvent; 1132 -(void)mouseDragged:(UIEvent *)theEvent;
1132 @end 1133 @end
1133 1134
1134 @implementation DWView 1135 @implementation DWView
1135 -(BOOL)windowShouldClose:(id)sender 1136 -(BOOL)windowShouldClose:(id)sender
1136 { 1137 {
1153 dw_signal_disconnect_by_window(self); 1154 dw_signal_disconnect_by_window(self);
1154 [super dealloc]; 1155 [super dealloc];
1155 } 1156 }
1156 -(void)windowResized:(NSNotification *)notification; 1157 -(void)windowResized:(NSNotification *)notification;
1157 { 1158 {
1158 NSSize size = [self frame].size; 1159 CGSize size = [self frame].size;
1159 1160
1160 if(oldsize.width != size.width || oldsize.height != size.height) 1161 if(oldsize.width != size.width || oldsize.height != size.height)
1161 { 1162 {
1162 _do_resize(box, size.width, size.height); 1163 _do_resize(box, size.width, size.height);
1163 _event_handler([self window], nil, 1); 1164 _event_handler([self window], nil, 1);
1166 _handle_resize_events(box); 1167 _handle_resize_events(box);
1167 } 1168 }
1168 } 1169 }
1169 -(void)showWindow 1170 -(void)showWindow
1170 { 1171 {
1171 NSSize size = [self frame].size; 1172 CGSize size = [self frame].size;
1172 1173
1173 if(oldsize.width == size.width && oldsize.height == size.height) 1174 if(oldsize.width == size.width && oldsize.height == size.height)
1174 { 1175 {
1175 _do_resize(box, size.width, size.height); 1176 _do_resize(box, size.width, size.height);
1176 _handle_resize_events(box); 1177 _handle_resize_events(box);
1187 { 1188 {
1188 [DWApp setMainMenu:DWMainMenu]; 1189 [DWApp setMainMenu:DWMainMenu];
1189 } 1190 }
1190 _event_handler([self window], nil, 13); 1191 _event_handler([self window], nil, 13);
1191 } 1192 }
1192 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; } 1193 -(void)setMenu:(UIMenu *)input { windowmenu = input; [windowmenu retain]; }
1193 -(void)menuHandler:(id)sender 1194 -(void)menuHandler:(id)sender
1194 { 1195 {
1195 id menu = [sender menu]; 1196 id menu = [sender menu];
1196 1197
1197 /* Find the highest menu for this item */ 1198 /* Find the highest menu for this item */
1205 [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0]; 1206 [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0];
1206 else 1207 else
1207 [DWObj menuHandler:sender]; 1208 [DWObj menuHandler:sender];
1208 _dw_wakeup_app(); 1209 _dw_wakeup_app();
1209 } 1210 }
1210 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); } 1211 -(void)mouseDragged:(UIEvent *)theEvent { _event_handler(self, theEvent, 5); }
1211 -(void)mouseMoved:(NSEvent *)theEvent 1212 -(void)mouseMoved:(UIEvent *)theEvent
1212 { 1213 {
1213 id hit = [self hitTest:[theEvent locationInWindow]]; 1214 id hit = [self hitTest:[theEvent locationInWindow]];
1214 1215
1215 if([hit isMemberOfClass:[DWRender class]]) 1216 if([hit isMemberOfClass:[DWRender class]])
1216 { 1217 {
1295 range:range]; 1296 range:range];
1296 [attrTitle fixAttributesInRange:range]; 1297 [attrTitle fixAttributesInRange:range];
1297 [self setAttributedTitle:attrTitle]; 1298 [self setAttributedTitle:attrTitle];
1298 [attrTitle release]; 1299 [attrTitle release];
1299 } 1300 }
1300 -(void)keyDown:(NSEvent *)theEvent 1301 -(void)keyDown:(UIEvent *)theEvent
1301 { 1302 {
1302 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 1303 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
1303 if(vk == VK_RETURN || vk == VK_SPACE) 1304 if(vk == VK_RETURN || vk == VK_SPACE)
1304 { 1305 {
1305 if(buttonType == DWButtonTypeSwitch) 1306 if(buttonType == DWButtonTypeSwitch)
1364 /* Subclass for a textfield that supports vertical centering */ 1365 /* Subclass for a textfield that supports vertical centering */
1365 @interface DWTextFieldCell : UITextFieldCell 1366 @interface DWTextFieldCell : UITextFieldCell
1366 { 1367 {
1367 BOOL vcenter; 1368 BOOL vcenter;
1368 } 1369 }
1369 -(NSRect)drawingRectForBounds:(NSRect)theRect; 1370 -(CGRect)drawingRectForBounds:(CGRect)theRect;
1370 -(void)setVCenter:(BOOL)input; 1371 -(void)setVCenter:(BOOL)input;
1371 @end 1372 @end
1372 1373
1373 @implementation DWTextFieldCell 1374 @implementation DWTextFieldCell
1374 -(NSRect)drawingRectForBounds:(NSRect)theRect 1375 -(CGRect)drawingRectForBounds:(CGRect)theRect
1375 { 1376 {
1376 /* Get the parent's idea of where we should draw */ 1377 /* Get the parent's idea of where we should draw */
1377 NSRect newRect = [super drawingRectForBounds:theRect]; 1378 CGRect newRect = [super drawingRectForBounds:theRect];
1378 1379
1379 /* If we are being vertically centered */ 1380 /* If we are being vertically centered */
1380 if(vcenter) 1381 if(vcenter)
1381 { 1382 {
1382 /* Get our ideal size for current text */ 1383 /* Get our ideal size for current text */
1383 NSSize textSize = [self cellSizeForBounds:theRect]; 1384 CGSize textSize = [self cellSizeForBounds:theRect];
1384 1385
1385 /* Center that in the proposed rect */ 1386 /* Center that in the proposed rect */
1386 float heightDelta = newRect.size.height - textSize.height; 1387 float heightDelta = newRect.size.height - textSize.height;
1387 if (heightDelta > 0) 1388 if (heightDelta > 0)
1388 { 1389 {
1446 1447
1447 @implementation DWEntryField 1448 @implementation DWEntryField
1448 -(void *)userdata { return userdata; } 1449 -(void *)userdata { return userdata; }
1449 -(void)setUserdata:(void *)input { userdata = input; } 1450 -(void)setUserdata:(void *)input { userdata = input; }
1450 -(void)setClickDefault:(id)input { clickDefault = input; } 1451 -(void)setClickDefault:(id)input { clickDefault = input; }
1451 -(void)keyUp:(NSEvent *)theEvent 1452 -(void)keyUp:(UIEvent *)theEvent
1452 { 1453 {
1453 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 1454 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
1454 if(clickDefault && vk == VK_RETURN) 1455 if(clickDefault && vk == VK_RETURN)
1455 { 1456 {
1456 if([clickDefault isKindOfClass:[UIButton class]]) 1457 if([clickDefault isKindOfClass:[UIButton class]])
1460 } else 1461 } else
1461 { 1462 {
1462 [super keyUp:theEvent]; 1463 [super keyUp:theEvent];
1463 } 1464 }
1464 } 1465 }
1465 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent 1466 -(BOOL)performKeyEquivalent:(UIEvent *)theEvent
1466 { 1467 {
1467 if(([theEvent modifierFlags] & DWEventModifierFlagDeviceIndependentFlagsMask) == DWEventModifierFlagCommand) 1468 if(([theEvent modifierFlags] & DWEventModifierFlagDeviceIndependentFlagsMask) == DWEventModifierFlagCommand)
1468 { 1469 {
1469 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) 1470 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"])
1470 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; 1471 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self];
1510 1511
1511 @implementation DWEntryFieldPassword 1512 @implementation DWEntryFieldPassword
1512 -(void *)userdata { return userdata; } 1513 -(void *)userdata { return userdata; }
1513 -(void)setUserdata:(void *)input { userdata = input; } 1514 -(void)setUserdata:(void *)input { userdata = input; }
1514 -(void)setClickDefault:(id)input { clickDefault = input; } 1515 -(void)setClickDefault:(id)input { clickDefault = input; }
1515 -(void)keyUp:(NSEvent *)theEvent 1516 -(void)keyUp:(UIEvent *)theEvent
1516 { 1517 {
1517 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 1518 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
1518 { 1519 {
1519 if([clickDefault isKindOfClass:[UIButton class]]) 1520 if([clickDefault isKindOfClass:[UIButton class]])
1520 [clickDefault buttonClicked:self]; 1521 [clickDefault buttonClicked:self];
1524 else 1525 else
1525 { 1526 {
1526 [super keyUp:theEvent]; 1527 [super keyUp:theEvent];
1527 } 1528 }
1528 } 1529 }
1529 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent 1530 -(BOOL)performKeyEquivalent:(UIEvent *)theEvent
1530 { 1531 {
1531 if(([theEvent modifierFlags] & DWEventModifierFlagDeviceIndependentFlagsMask) == DWEventModifierFlagCommand) 1532 if(([theEvent modifierFlags] & DWEventModifierFlagDeviceIndependentFlagsMask) == DWEventModifierFlagCommand)
1532 { 1533 {
1533 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) 1534 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"])
1534 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; 1535 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self];
1581 1582
1582 if([object isMemberOfClass:[DWBox class]]) 1583 if([object isMemberOfClass:[DWBox class]])
1583 { 1584 {
1584 DWBox *view = object; 1585 DWBox *view = object;
1585 Box *box = [view box]; 1586 Box *box = [view box];
1586 NSSize size = [view frame].size; 1587 CGSize size = [view frame].size;
1587 _do_resize(box, size.width, size.height); 1588 _do_resize(box, size.width, size.height);
1588 _handle_resize_events(box); 1589 _handle_resize_events(box);
1589 } 1590 }
1590 _event_handler(self, DW_INT_TO_POINTER([page pageid]), 15); 1591 _event_handler(self, DW_INT_TO_POINTER([page pageid]), 15);
1591 } 1592 }
1592 -(void)keyDown:(NSEvent *)theEvent 1593 -(void)keyDown:(UIEvent *)theEvent
1593 { 1594 {
1594 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 1595 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
1595 1596
1596 if(vk == NSTabCharacter || vk == NSBackTabCharacter) 1597 if(vk == NSTabCharacter || vk == NSBackTabCharacter)
1597 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; 1598 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
1722 { 1723 {
1723 if([object isMemberOfClass:[DWBox class]]) 1724 if([object isMemberOfClass:[DWBox class]])
1724 { 1725 {
1725 DWBox *view = object; 1726 DWBox *view = object;
1726 Box *box = [view box]; 1727 Box *box = [view box];
1727 NSSize size = [view frame].size; 1728 CGSize size = [view frame].size;
1728 _do_resize(box, size.width, size.height); 1729 _do_resize(box, size.width, size.height);
1729 _handle_resize_events(box); 1730 _handle_resize_events(box);
1730 } 1731 }
1731 } 1732 }
1732 } 1733 }
1873 if([result imageView] && [result textField]) 1874 if([result imageView] && [result textField])
1874 { 1875 {
1875 UIImageView *iv = [result imageView]; 1876 UIImageView *iv = [result imageView];
1876 UIImage *icon = [iv image]; 1877 UIImage *icon = [iv image];
1877 UITextField *tf = [result textField]; 1878 UITextField *tf = [result textField];
1878 NSRect rect = result.frame; 1879 CGRect rect = result.frame;
1879 int width =[icon size].width; 1880 int width =[icon size].width;
1880 1881
1881 [iv setFrame:NSMakeRect(0,0,width,rect.size.height)]; 1882 [iv setFrame:NSMakeRect(0,0,width,rect.size.height)];
1882 1883
1883 /* Adjust the rect to allow space for the image */ 1884 /* Adjust the rect to allow space for the image */
1912 shouldDrawFocusRing = (resp != nil && [resp isKindOfClass:[UIView class]] && [(UIView*)resp isDescendantOf:self]); 1913 shouldDrawFocusRing = (resp != nil && [resp isKindOfClass:[UIView class]] && [(UIView*)resp isDescendantOf:self]);
1913 lastResp = resp; 1914 lastResp = resp;
1914 [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; 1915 [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
1915 return YES; 1916 return YES;
1916 } 1917 }
1917 -(void)drawRect:(NSRect)rect 1918 -(void)drawRect:(CGRect)rect
1918 { 1919 {
1919 [super drawRect:rect]; 1920 [super drawRect:rect];
1920 1921
1921 if(shouldDrawFocusRing) 1922 if(shouldDrawFocusRing)
1922 { 1923 {
1923 NSSetFocusRingStyle(NSFocusRingOnly); 1924 NSSetFocusRingStyle(NSFocusRingOnly);
1924 NSRectFill(rect); 1925 CGRectFill(rect);
1925 } 1926 }
1926 } 1927 }
1927 @end 1928 @end
1928 1929
1929 /* Subclass for a Container/List type */ 1930 /* Subclass for a Container/List type */
1965 -(int)lastQueryPoint; 1966 -(int)lastQueryPoint;
1966 -(void)setLastQueryPoint:(int)input; 1967 -(void)setLastQueryPoint:(int)input;
1967 -(void)clear; 1968 -(void)clear;
1968 -(void)setup; 1969 -(void)setup;
1969 -(void)optimize; 1970 -(void)optimize;
1970 -(NSSize)getsize; 1971 -(CGSize)getsize;
1971 -(void)setForegroundColor:(UIColor *)input; 1972 -(void)setForegroundColor:(UIColor *)input;
1972 -(void)doubleClicked:(id)sender; 1973 -(void)doubleClicked:(id)sender;
1973 -(void)keyUp:(NSEvent *)theEvent; 1974 -(void)keyUp:(UIEvent *)theEvent;
1974 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn; 1975 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
1975 -(void)selectionChanged:(id)sender; 1976 -(void)selectionChanged:(id)sender;
1976 -(NSMenu *)menuForEvent:(NSEvent *)event; 1977 -(UIMenu *)menuForEvent:(UIEvent *)event;
1977 -(void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row; 1978 -(void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row;
1978 -(UIView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; 1979 -(UIView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
1979 @end 1980 @end
1980 1981
1981 @implementation DWContainer 1982 @implementation DWContainer
2261 if(!dw_oddcolor && !dw_evencolor) 2262 if(!dw_oddcolor && !dw_evencolor)
2262 dw_oddcolor = dw_evencolor = DW_CLR_DEFAULT; 2263 dw_oddcolor = dw_evencolor = DW_CLR_DEFAULT;
2263 [self checkDark]; 2264 [self checkDark];
2264 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; 2265 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self];
2265 } 2266 }
2266 -(NSSize)getsize 2267 -(CGSize)getsize
2267 { 2268 {
2268 int cwidth = 0, cheight = 0; 2269 int cwidth = 0, cheight = 0;
2269 2270
2270 if(tvcols) 2271 if(tvcols)
2271 { 2272 {
2397 2398
2398 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2399 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2399 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2400 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2400 2401
2401 /* Handler for container class */ 2402 /* Handler for container class */
2402 _event_handler(self, (NSEvent *)params, 9); 2403 _event_handler(self, (UIEvent *)params, 9);
2403 } 2404 }
2404 -(void)keyUp:(NSEvent *)theEvent 2405 -(void)keyUp:(UIEvent *)theEvent
2405 { 2406 {
2406 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 2407 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
2407 { 2408 {
2408 void *params[2]; 2409 void *params[2];
2409 2410
2410 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2411 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2411 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2412 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2412 2413
2413 _event_handler(self, (NSEvent *)params, 9); 2414 _event_handler(self, (UIEvent *)params, 9);
2414 } 2415 }
2415 [super keyUp:theEvent]; 2416 [super keyUp:theEvent];
2416 } 2417 }
2417 2418
2418 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn 2419 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn
2419 { 2420 {
2420 NSUInteger index = [tvcols indexOfObject:tableColumn]; 2421 NSUInteger index = [tvcols indexOfObject:tableColumn];
2421 2422
2422 /* Handler for column click class */ 2423 /* Handler for column click class */
2423 _event_handler(self, (NSEvent *)index, 17); 2424 _event_handler(self, (UIEvent *)index, 17);
2424 } 2425 }
2425 -(void)selectionChanged:(id)sender 2426 -(void)selectionChanged:(id)sender
2426 { 2427 {
2427 void *params[2]; 2428 void *params[2];
2428 2429
2429 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2430 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2430 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2431 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2431 2432
2432 /* Handler for container class */ 2433 /* Handler for container class */
2433 _event_handler(self, (NSEvent *)params, 12); 2434 _event_handler(self, (UIEvent *)params, 12);
2434 /* Handler for listbox class */ 2435 /* Handler for listbox class */
2435 _event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11); 2436 _event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11);
2436 } 2437 }
2437 -(NSMenu *)menuForEvent:(NSEvent *)event 2438 -(UIMenu *)menuForEvent:(UIEvent *)event
2438 { 2439 {
2439 int row; 2440 int row;
2440 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; 2441 CGPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
2441 row = (int)[self rowAtPoint:where]; 2442 row = (int)[self rowAtPoint:where];
2442 _event_handler(self, (NSEvent *)[self getRowTitle:row], 10); 2443 _event_handler(self, (UIEvent *)[self getRowTitle:row], 10);
2443 return nil; 2444 return nil;
2444 } 2445 }
2445 -(void)keyDown:(NSEvent *)theEvent 2446 -(void)keyDown:(UIEvent *)theEvent
2446 { 2447 {
2447 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 2448 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
2448 2449
2449 if(vk == NSTabCharacter || vk == NSBackTabCharacter) 2450 if(vk == NSTabCharacter || vk == NSBackTabCharacter)
2450 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; 2451 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
2664 if(item) 2665 if(item)
2665 { 2666 {
2666 _event_handler(self, (void *)item, 16); 2667 _event_handler(self, (void *)item, 16);
2667 } 2668 }
2668 } 2669 }
2669 -(NSMenu *)menuForEvent:(NSEvent *)event 2670 -(UIMenu *)menuForEvent:(UIEvent *)event
2670 { 2671 {
2671 int row; 2672 int row;
2672 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; 2673 CGPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
2673 row = (int)[self rowAtPoint:where]; 2674 row = (int)[self rowAtPoint:where];
2674 id item = [self itemAtRow:row]; 2675 id item = [self itemAtRow:row];
2675 _event_handler(self, (NSEvent *)item, 10); 2676 _event_handler(self, (UIEvent *)item, 10);
2676 return nil; 2677 return nil;
2677 } 2678 }
2678 -(UIScrollView *)scrollview { return scrollview; } 2679 -(UIScrollView *)scrollview { return scrollview; }
2679 -(void)setScrollview:(UIScrollView *)input { scrollview = input; } 2680 -(void)setScrollview:(UIScrollView *)input { scrollview = input; }
2680 -(void)deleteNode:(NSMutableArray *)item { _free_tree_recurse(data, item); } 2681 -(void)deleteNode:(NSMutableArray *)item { _free_tree_recurse(data, item); }
2684 fgcolor = input; 2685 fgcolor = input;
2685 [fgcolor retain]; 2686 [fgcolor retain];
2686 [cell setTextColor:fgcolor]; 2687 [cell setTextColor:fgcolor];
2687 } 2688 }
2688 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } 2689 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; }
2689 -(void)keyDown:(NSEvent *)theEvent 2690 -(void)keyDown:(UIEvent *)theEvent
2690 { 2691 {
2691 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 2692 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
2692 2693
2693 if(vk == NSTabCharacter || vk == NSBackTabCharacter) 2694 if(vk == NSTabCharacter || vk == NSBackTabCharacter)
2694 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; 2695 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
2737 @implementation DWComboBox 2738 @implementation DWComboBox
2738 -(void *)userdata { return userdata; } 2739 -(void *)userdata { return userdata; }
2739 -(void)setUserdata:(void *)input { userdata = input; } 2740 -(void)setUserdata:(void *)input { userdata = input; }
2740 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } 2741 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); }
2741 -(void)setClickDefault:(id)input { clickDefault = input; } 2742 -(void)setClickDefault:(id)input { clickDefault = input; }
2742 -(void)keyUp:(NSEvent *)theEvent 2743 -(void)keyUp:(UIEvent *)theEvent
2743 { 2744 {
2744 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 2745 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
2745 { 2746 {
2746 [[self window] makeFirstResponder:clickDefault]; 2747 [[self window] makeFirstResponder:clickDefault];
2747 } else 2748 } else
2761 } 2762 }
2762 -(void)setTextfield:(id)input; 2763 -(void)setTextfield:(id)input;
2763 -(id)textfield; 2764 -(id)textfield;
2764 -(void)setParent:(id)input; 2765 -(void)setParent:(id)input;
2765 -(id)parent; 2766 -(id)parent;
2766 -(void)mouseDown:(NSEvent *)event; 2767 -(void)mouseDown:(UIEvent *)event;
2767 -(void)mouseUp:(NSEvent *)event; 2768 -(void)mouseUp:(UIEvent *)event;
2768 @end 2769 @end
2769 2770
2770 @implementation DWStepper 2771 @implementation DWStepper
2771 -(void)setTextfield:(id)input { textfield = input; } 2772 -(void)setTextfield:(id)input { textfield = input; }
2772 -(id)textfield { return textfield; } 2773 -(id)textfield { return textfield; }
2773 -(void)setParent:(id)input { parent = input; } 2774 -(void)setParent:(id)input { parent = input; }
2774 -(id)parent { return parent; } 2775 -(id)parent { return parent; }
2775 -(void)mouseDown:(NSEvent *)event 2776 -(void)mouseDown:(UIEvent *)event
2776 { 2777 {
2777 [super mouseDown:event]; 2778 [super mouseDown:event];
2778 if([[NSApp currentEvent] type] == DWEventTypeLeftMouseUp) 2779 if([[NSApp currentEvent] type] == DWEventTypeLeftMouseUp)
2779 [self mouseUp:event]; 2780 [self mouseUp:event];
2780 } 2781 }
2781 -(void)mouseUp:(NSEvent *)event 2782 -(void)mouseUp:(UIEvent *)event
2782 { 2783 {
2783 [textfield takeIntValueFrom:self]; 2784 [textfield takeIntValueFrom:self];
2784 _event_handler(parent, (void *)[self integerValue], 14); 2785 _event_handler(parent, (void *)[self integerValue], 14);
2785 } 2786 }
2786 -(void)keyDown:(NSEvent *)theEvent 2787 -(void)keyDown:(UIEvent *)theEvent
2787 { 2788 {
2788 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 2789 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
2789 if(vk == VK_UP || vk == VK_DOWN) 2790 if(vk == VK_UP || vk == VK_DOWN)
2790 { 2791 {
2791 if(vk == VK_UP) 2792 if(vk == VK_UP)
2851 [stepper takeIntValueFrom:textfield]; 2852 [stepper takeIntValueFrom:textfield];
2852 [textfield takeIntValueFrom:stepper]; 2853 [textfield takeIntValueFrom:stepper];
2853 _event_handler(self, (void *)[stepper integerValue], 14); 2854 _event_handler(self, (void *)[stepper integerValue], 14);
2854 } 2855 }
2855 -(void)setClickDefault:(id)input { clickDefault = input; } 2856 -(void)setClickDefault:(id)input { clickDefault = input; }
2856 -(void)keyUp:(NSEvent *)theEvent 2857 -(void)keyUp:(UIEvent *)theEvent
2857 { 2858 {
2858 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 2859 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
2859 { 2860 {
2860 [[self window] makeFirstResponder:clickDefault]; 2861 [[self window] makeFirstResponder:clickDefault];
2861 } 2862 }
2990 else 2991 else
2991 { 2992 {
2992 if([handle isMemberOfClass:[DWRender class]]) 2993 if([handle isMemberOfClass:[DWRender class]])
2993 { 2994 {
2994 DWRender *render = (DWRender *)handle; 2995 DWRender *render = (DWRender *)handle;
2995 NSSize oldsize = [render size]; 2996 CGSize oldsize = [render size];
2996 NSSize newsize = [render frame].size; 2997 CGSize newsize = [render frame].size;
2997 2998
2998 /* Eliminate duplicate configure requests */ 2999 /* Eliminate duplicate configure requests */
2999 if(oldsize.width != newsize.width || oldsize.height != newsize.height) 3000 if(oldsize.width != newsize.width || oldsize.height != newsize.height)
3000 { 3001 {
3001 if(newsize.width > 0 && newsize.height > 0) 3002 if(newsize.width > 0 && newsize.height > 0)
3058 * use the cached values on second. 3059 * use the cached values on second.
3059 */ 3060 */
3060 if(pass == 1) 3061 if(pass == 1)
3061 { 3062 {
3062 DWGroupBox *groupbox = thisbox->grouphwnd; 3063 DWGroupBox *groupbox = thisbox->grouphwnd;
3063 NSSize borderSize = [groupbox borderSize]; 3064 CGSize borderSize = [groupbox borderSize];
3064 NSRect titleRect; 3065 CGRect titleRect;
3065 3066
3066 if(borderSize.width == 0 || borderSize.height == 0) 3067 if(borderSize.width == 0 || borderSize.height == 0)
3067 { 3068 {
3068 borderSize = [groupbox initBorder]; 3069 borderSize = [groupbox initBorder];
3069 } 3070 }
3211 /* If the calculated size is valid... */ 3212 /* If the calculated size is valid... */
3212 if(height > 0 && width > 0) 3213 if(height > 0 && width > 0)
3213 { 3214 {
3214 int pad = thisbox->items[z].pad; 3215 int pad = thisbox->items[z].pad;
3215 UIView *handle = thisbox->items[z].hwnd; 3216 UIView *handle = thisbox->items[z].hwnd;
3216 NSPoint point; 3217 CGPoint point;
3217 NSSize size; 3218 CGSize size;
3218 3219
3219 point.x = currentx + pad; 3220 point.x = currentx + pad;
3220 point.y = currenty + pad; 3221 point.y = currenty + pad;
3221 size.width = width; 3222 size.width = width;
3222 size.height = height; 3223 size.height = height;
3245 id view = [notepage view]; 3246 id view = [notepage view];
3246 3247
3247 if([view isMemberOfClass:[DWBox class]]) 3248 if([view isMemberOfClass:[DWBox class]])
3248 { 3249 {
3249 Box *box = (Box *)[view box]; 3250 Box *box = (Box *)[view box];
3250 NSSize size = [view frame].size; 3251 CGSize size = [view frame].size;
3251 _do_resize(box, size.width, size.height); 3252 _do_resize(box, size.width, size.height);
3252 _handle_resize_events(box); 3253 _handle_resize_events(box);
3253 } 3254 }
3254 } 3255 }
3255 /* Handle laying out scrollviews... if required space is less 3256 /* Handle laying out scrollviews... if required space is less
3259 { 3260 {
3260 int depth = 0; 3261 int depth = 0;
3261 DWScrollBox *scrollbox = (DWScrollBox *)handle; 3262 DWScrollBox *scrollbox = (DWScrollBox *)handle;
3262 DWBox *contentbox = [scrollbox documentView]; 3263 DWBox *contentbox = [scrollbox documentView];
3263 Box *thisbox = [contentbox box]; 3264 Box *thisbox = [contentbox box];
3264 NSSize contentsize = [scrollbox contentSize]; 3265 CGSize contentsize = [scrollbox contentSize];
3265 3266
3266 /* Get the required space for the box */ 3267 /* Get the required space for the box */
3267 _resize_box(thisbox, &depth, x, y, 1); 3268 _resize_box(thisbox, &depth, x, y, 1);
3268 3269
3269 if(contentsize.width < thisbox->minwidth) 3270 if(contentsize.width < thisbox->minwidth)
3333 _resize_box(thisbox, &depth, x, y, 2); 3334 _resize_box(thisbox, &depth, x, y, 2);
3334 } 3335 }
3335 } 3336 }
3336 } 3337 }
3337 3338
3338 NSMenu *_generate_main_menu()
3339 {
3340 NSString *applicationName = nil;
3341
3342 applicationName = [[NSRunningApplication currentApplication] localizedName];
3343 if(applicationName == nil)
3344 {
3345 applicationName = [[NSProcessInfo processInfo] processName];
3346 }
3347
3348 /* Create the main menu */
3349 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease];
3350
3351 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""];
3352 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease];
3353
3354 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu];
3355
3356 /* Setup the Application menu */
3357 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName]
3358 action:@selector(orderFrontStandardAboutPanel:)
3359 keyEquivalent:@""];
3360 [item setTarget:DWApp];
3361
3362 [menu addItem:[NSMenuItem separatorItem]];
3363
3364 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil)
3365 action:NULL
3366 keyEquivalent:@""];
3367 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
3368 [menu setSubmenu:servicesMenu forItem:item];
3369 [DWApp setServicesMenu:servicesMenu];
3370
3371 [menu addItem:[NSMenuItem separatorItem]];
3372
3373 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName]
3374 action:@selector(hide:)
3375 keyEquivalent:@"h"];
3376 [item setTarget:DWApp];
3377
3378 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil)
3379 action:@selector(hideOtherApplications:)
3380 keyEquivalent:@"h"];
3381 [item setKeyEquivalentModifierMask:DWEventModifierFlagCommand | DWEventModifierFlagOption];
3382 [item setTarget:DWApp];
3383
3384 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil)
3385 action:@selector(unhideAllApplications:)
3386 keyEquivalent:@""];
3387 [item setTarget:DWApp];
3388
3389 [menu addItem:[NSMenuItem separatorItem]];
3390
3391 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName]
3392 action:@selector(terminate:)
3393 keyEquivalent:@"q"];
3394 [item setTarget:DWApp];
3395
3396 [mainMenu setSubmenu:menu forItem:mitem];
3397
3398 return mainMenu;
3399 }
3400
3401 /* 3339 /*
3402 * Runs a message loop for Dynamic Windows. 3340 * Runs a message loop for Dynamic Windows.
3403 */ 3341 */
3404 void API dw_main(void) 3342 void API dw_main(void)
3405 { 3343 {
3454 } 3392 }
3455 3393
3456 /* Internal version that doesn't lock the run mutex */ 3394 /* Internal version that doesn't lock the run mutex */
3457 int _dw_main_iteration(NSDate *date) 3395 int _dw_main_iteration(NSDate *date)
3458 { 3396 {
3459 NSEvent *event = [DWApp nextEventMatchingMask:DWEventMaskAny 3397 UIEvent *event = [DWApp nextEventMatchingMask:DWEventMaskAny
3460 untilDate:date 3398 untilDate:date
3461 inMode:NSDefaultRunLoopMode 3399 inMode:NSDefaultRunLoopMode
3462 dequeue:YES]; 3400 dequeue:YES];
3463 if(event) 3401 if(event)
3464 { 3402 {
4003 */ 3941 */
4004 int API dw_scrollbox_get_pos(HWND handle, int orient) 3942 int API dw_scrollbox_get_pos(HWND handle, int orient)
4005 { 3943 {
4006 DWScrollBox *scrollbox = handle; 3944 DWScrollBox *scrollbox = handle;
4007 UIView *view = [scrollbox documentView]; 3945 UIView *view = [scrollbox documentView];
4008 NSSize contentsize = [scrollbox contentSize]; 3946 CGSize contentsize = [scrollbox contentSize];
4009 NSScroller *scrollbar; 3947 NSScroller *scrollbar;
4010 int range = 0; 3948 int range = 0;
4011 int val = 0; 3949 int val = 0;
4012 if(orient == DW_VERT) 3950 if(orient == DW_VERT)
4013 { 3951 {
4102 UIImage *image = [object image]; 4040 UIImage *image = [object image];
4103 4041
4104 if(image) 4042 if(image)
4105 { 4043 {
4106 /* Image button */ 4044 /* Image button */
4107 NSSize size = [image size]; 4045 CGSize size = [image size];
4108 thiswidth = (int)size.width; 4046 thiswidth = (int)size.width;
4109 thisheight = (int)size.height; 4047 thisheight = (int)size.height;
4110 if([object isBordered]) 4048 if([object isBordered])
4111 { 4049 {
4112 extrawidth = 4; 4050 extrawidth = 4;
4184 { 4122 {
4185 UIImage *image = [object image]; 4123 UIImage *image = [object image];
4186 4124
4187 if(image) 4125 if(image)
4188 { 4126 {
4189 NSSize size = [image size]; 4127 CGSize size = [image size];
4190 thiswidth = (int)size.width; 4128 thiswidth = (int)size.width;
4191 thisheight = (int)size.height; 4129 thisheight = (int)size.height;
4192 } 4130 }
4193 } 4131 }
4194 /* Handle calendar */ 4132 /* Handle calendar */
4196 { 4134 {
4197 NSCell *cell = [object cell]; 4135 NSCell *cell = [object cell];
4198 4136
4199 if(cell) 4137 if(cell)
4200 { 4138 {
4201 NSSize size = [cell cellSize]; 4139 CGSize size = [cell cellSize];
4202 4140
4203 thiswidth = size.width; 4141 thiswidth = size.width;
4204 thisheight = size.height; 4142 thisheight = size.height;
4205 } 4143 }
4206 } 4144 }
4207 /* MLE and Container */ 4145 /* MLE and Container */
4208 else if([ object isMemberOfClass:[DWMLE class] ] || 4146 else if([ object isMemberOfClass:[DWMLE class] ] ||
4209 [ object isMemberOfClass:[DWContainer class] ]) 4147 [ object isMemberOfClass:[DWContainer class] ])
4210 { 4148 {
4211 NSSize size; 4149 CGSize size;
4212 4150
4213 if([ object isMemberOfClass:[DWMLE class] ]) 4151 if([ object isMemberOfClass:[DWMLE class] ])
4214 { 4152 {
4215 UIScrollView *sv = [object scrollview]; 4153 UIScrollView *sv = [object scrollview];
4216 NSSize frame = [sv frame].size; 4154 CGSize frame = [sv frame].size;
4217 BOOL hscroll = [sv hasHorizontalScroller]; 4155 BOOL hscroll = [sv hasHorizontalScroller];
4218 4156
4219 /* Make sure word wrap is off for the first part */ 4157 /* Make sure word wrap is off for the first part */
4220 if(!hscroll) 4158 if(!hscroll)
4221 { 4159 {
4236 [sv setHasHorizontalScroller:NO]; 4174 [sv setHasHorizontalScroller:NO];
4237 4175
4238 /* If the un wrapped it is beyond the bounds... */ 4176 /* If the un wrapped it is beyond the bounds... */
4239 if(size.width > _DW_SCROLLED_MAX_WIDTH) 4177 if(size.width > _DW_SCROLLED_MAX_WIDTH)
4240 { 4178 {
4241 NSSize max = [object maxSize]; 4179 CGSize max = [object maxSize];
4242 4180
4243 /* Set the max size to the limit */ 4181 /* Set the max size to the limit */
4244 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)]; 4182 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)];
4245 /* Recalculate the size */ 4183 /* Recalculate the size */
4246 [object sizeToFit]; 4184 [object sizeToFit];
5580 */ 5518 */
5581 HWND API dw_mle_new(ULONG cid) 5519 HWND API dw_mle_new(ULONG cid)
5582 { 5520 {
5583 DWMLE *mle = [[DWMLE alloc] init]; 5521 DWMLE *mle = [[DWMLE alloc] init];
5584 UIScrollView *scrollview = [[UIScrollView alloc] init]; 5522 UIScrollView *scrollview = [[UIScrollView alloc] init];
5585 NSSize size = [mle maxSize]; 5523 CGSize size = [mle maxSize];
5586 5524
5587 size.width = size.height; 5525 size.width = size.height;
5588 [mle setMaxSize:size]; 5526 [mle setMaxSize:size];
5589 [scrollview setBorderType:NSBezelBorder]; 5527 [scrollview setBorderType:NSBezelBorder];
5590 [scrollview setHasVerticalScroller:YES]; 5528 [scrollview setHasVerticalScroller:YES];
5792 DWMLE *mle = handle; 5730 DWMLE *mle = handle;
5793 UIScrollView *sv = [mle scrollview]; 5731 UIScrollView *sv = [mle scrollview];
5794 5732
5795 if(state) 5733 if(state)
5796 { 5734 {
5797 NSSize newsize = NSMakeSize([sv contentSize].width,[mle maxSize].height); 5735 CGSize newsize = NSMakeSize([sv contentSize].width,[mle maxSize].height);
5798 NSRect newrect = NSMakeRect(0, 0, [sv contentSize].width, 0); 5736 CGRect newrect = NSMakeRect(0, 0, [sv contentSize].width, 0);
5799 5737
5800 [[mle textContainer] setWidthTracksTextView:YES]; 5738 [[mle textContainer] setWidthTracksTextView:YES];
5801 [mle setFrame:newrect]; 5739 [mle setFrame:newrect];
5802 [[mle textContainer] setContainerSize:newsize]; 5740 [[mle textContainer] setContainerSize:newsize];
5803 [mle setHorizontallyResizable:NO]; 5741 [mle setHorizontallyResizable:NO];
6281 if(font) 6219 if(font)
6282 { 6220 {
6283 [dict setValue:font forKey:UIFontAttributeName]; 6221 [dict setValue:font forKey:UIFontAttributeName];
6284 } 6222 }
6285 /* Calculate the size of the string */ 6223 /* Calculate the size of the string */
6286 NSSize size = [nstr sizeWithAttributes:dict]; 6224 CGSize size = [nstr sizeWithAttributes:dict];
6287 [dict release]; 6225 [dict release];
6288 /* Return whatever information we can */ 6226 /* Return whatever information we can */
6289 if(width) 6227 if(width)
6290 { 6228 {
6291 *width = size.width; 6229 *width = size.width;
7633 /* Internal function to keep HICNs from getting too big */ 7571 /* Internal function to keep HICNs from getting too big */
7634 void _icon_resize(UIImage *image) 7572 void _icon_resize(UIImage *image)
7635 { 7573 {
7636 if(image) 7574 if(image)
7637 { 7575 {
7638 NSSize size = [image size]; 7576 CGSize size = [image size];
7639 if(size.width > 24 || size.height > 24) 7577 if(size.width > 24 || size.height > 24)
7640 { 7578 {
7641 if(size.width > 24) 7579 if(size.width > 24)
7642 size.width = 24; 7580 size.width = 24;
7643 if(size.height > 24) 7581 if(size.height > 24)
7789 DW_FUNCTION_NO_RETURN(dw_splitbar_set) 7727 DW_FUNCTION_NO_RETURN(dw_splitbar_set)
7790 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float) 7728 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float)
7791 { 7729 {
7792 DW_FUNCTION_INIT; 7730 DW_FUNCTION_INIT;
7793 DWSplitBar *split = handle; 7731 DWSplitBar *split = handle;
7794 NSRect rect = [split frame]; 7732 CGRect rect = [split frame];
7795 float pos; 7733 float pos;
7796 /* Calculate the position based on the size */ 7734 /* Calculate the position based on the size */
7797 if([split isVertical]) 7735 if([split isVertical])
7798 { 7736 {
7799 pos = rect.size.width * (percent / 100.0); 7737 pos = rect.size.width * (percent / 100.0);
7823 * handle: The handle to the splitbar returned by dw_splitbar_new(). 7761 * handle: The handle to the splitbar returned by dw_splitbar_new().
7824 */ 7762 */
7825 float API dw_splitbar_get(HWND handle) 7763 float API dw_splitbar_get(HWND handle)
7826 { 7764 {
7827 DWSplitBar *split = handle; 7765 DWSplitBar *split = handle;
7828 NSRect rect1 = [split frame]; 7766 CGRect rect1 = [split frame];
7829 NSArray *subviews = [split subviews]; 7767 NSArray *subviews = [split subviews];
7830 UIView *view = [subviews objectAtIndex:0]; 7768 UIView *view = [subviews objectAtIndex:0];
7831 NSRect rect2 = [view frame]; 7769 CGRect rect2 = [view frame];
7832 float pos, total, retval = 0.0; 7770 float pos, total, retval = 0.0;
7833 if([split isVertical]) 7771 if([split isVertical])
7834 { 7772 {
7835 total = rect1.size.width; 7773 total = rect1.size.width;
7836 pos = rect2.size.width; 7774 pos = rect2.size.width;
7927 bitsPerPixel:0]; 7865 bitsPerPixel:0];
7928 return pixmap; 7866 return pixmap;
7929 } 7867 }
7930 7868
7931 /* Function takes an UIImage and copies it into a flipped NSBitmapImageRep */ 7869 /* Function takes an UIImage and copies it into a flipped NSBitmapImageRep */
7932 void _flip_image(UIImage *tmpimage, NSBitmapImageRep *image, NSSize size) 7870 void _flip_image(UIImage *tmpimage, NSBitmapImageRep *image, CGSize size)
7933 { 7871 {
7934 NSCompositingOperation op = DWCompositingOperationSourceOver; 7872 NSCompositingOperation op = DWCompositingOperationSourceOver;
7935 [NSGraphicsContext saveGraphicsState]; 7873 [NSGraphicsContext saveGraphicsState];
7936 [NSGraphicsContext setCurrentContext:_dw_draw_context(image)]; 7874 [NSGraphicsContext setCurrentContext:_dw_draw_context(image)];
7937 [[[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil] autorelease]; 7875 [[[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil] autorelease];
7982 if(!tmpimage) 7920 if(!tmpimage)
7983 { 7921 {
7984 DW_LOCAL_POOL_OUT; 7922 DW_LOCAL_POOL_OUT;
7985 return NULL; 7923 return NULL;
7986 } 7924 }
7987 NSSize size = [tmpimage size]; 7925 CGSize size = [tmpimage size];
7988 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] 7926 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
7989 initWithBitmapDataPlanes:NULL 7927 initWithBitmapDataPlanes:NULL
7990 pixelsWide:size.width 7928 pixelsWide:size.width
7991 pixelsHigh:size.height 7929 pixelsHigh:size.height
7992 bitsPerSample:8 7930 bitsPerSample:8
8030 if(!tmpimage) 7968 if(!tmpimage)
8031 { 7969 {
8032 DW_LOCAL_POOL_OUT; 7970 DW_LOCAL_POOL_OUT;
8033 return NULL; 7971 return NULL;
8034 } 7972 }
8035 NSSize size = [tmpimage size]; 7973 CGSize size = [tmpimage size];
8036 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] 7974 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
8037 initWithBitmapDataPlanes:NULL 7975 initWithBitmapDataPlanes:NULL
8038 pixelsWide:size.width 7976 pixelsWide:size.width
8039 pixelsHigh:size.height 7977 pixelsHigh:size.height
8040 bitsPerSample:8 7978 bitsPerSample:8
8091 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid]; 8029 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid];
8092 UIImage *temp = [[UIImage alloc] initWithContentsOfFile:filepath]; 8030 UIImage *temp = [[UIImage alloc] initWithContentsOfFile:filepath];
8093 8031
8094 if(temp) 8032 if(temp)
8095 { 8033 {
8096 NSSize size = [temp size]; 8034 CGSize size = [temp size];
8097 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] 8035 NSBitmapImageRep *image = [[NSBitmapImageRep alloc]
8098 initWithBitmapDataPlanes:NULL 8036 initWithBitmapDataPlanes:NULL
8099 pixelsWide:size.width 8037 pixelsWide:size.width
8100 pixelsHigh:size.height 8038 pixelsHigh:size.height
8101 bitsPerSample:8 8039 bitsPerSample:8
8392 DW_LOCAL_POOL_IN; 8330 DW_LOCAL_POOL_IN;
8393 8331
8394 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error) 8332 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error)
8395 { 8333 {
8396 void *params[2] = { result, scriptdata }; 8334 void *params[2] = { result, scriptdata };
8397 _event_handler(html, (NSEvent *)params, 18); 8335 _event_handler(html, (UIEvent *)params, 18);
8398 }]; 8336 }];
8399 DW_LOCAL_POOL_OUT; 8337 DW_LOCAL_POOL_OUT;
8400 return DW_ERROR_NONE; 8338 return DW_ERROR_NONE;
8401 } 8339 }
8402 8340
8425 * x: Pointer to variable to store X coordinate. 8363 * x: Pointer to variable to store X coordinate.
8426 * y: Pointer to variable to store Y coordinate. 8364 * y: Pointer to variable to store Y coordinate.
8427 */ 8365 */
8428 void API dw_pointer_query_pos(long *x, long *y) 8366 void API dw_pointer_query_pos(long *x, long *y)
8429 { 8367 {
8430 NSPoint mouseLoc; 8368 CGPoint mouseLoc;
8431 mouseLoc = [NSEvent mouseLocation]; 8369 mouseLoc = [UIEvent mouseLocation];
8432 if(x) 8370 if(x)
8433 { 8371 {
8434 *x = mouseLoc.x; 8372 *x = mouseLoc.x;
8435 } 8373 }
8436 if(y) 8374 if(y)
8456 * id: An ID to be used for getting the resource from the 8394 * id: An ID to be used for getting the resource from the
8457 * resource file. 8395 * resource file.
8458 */ 8396 */
8459 HMENUI API dw_menu_new(ULONG cid) 8397 HMENUI API dw_menu_new(ULONG cid)
8460 { 8398 {
8461 NSMenu *menu = [[NSMenu alloc] init]; 8399 UIMenu *menu = [[UIMenu alloc] init];
8462 [menu setAutoenablesItems:NO]; 8400 [menu setAutoenablesItems:NO];
8463 /* [menu setTag:cid]; Why doesn't this work? */ 8401 /* [menu setTag:cid]; Why doesn't this work? */
8464 return menu; 8402 return menu;
8465 } 8403 }
8466 8404
8470 * location: Handle of a window frame to be attached to. 8408 * location: Handle of a window frame to be attached to.
8471 */ 8409 */
8472 HMENUI API dw_menubar_new(HWND location) 8410 HMENUI API dw_menubar_new(HWND location)
8473 { 8411 {
8474 UIWindow *window = location; 8412 UIWindow *window = location;
8475 NSMenu *windowmenu = _generate_main_menu(); 8413 UIMenu *windowmenu = _generate_main_menu();
8476 [[window contentView] setMenu:windowmenu]; 8414 [[window contentView] setMenu:windowmenu];
8477 return (HMENUI)windowmenu; 8415 return (HMENUI)windowmenu;
8478 } 8416 }
8479 8417
8480 /* 8418 /*
8482 * Parameters: 8420 * Parameters:
8483 * menu: Handle of a menu. 8421 * menu: Handle of a menu.
8484 */ 8422 */
8485 void API dw_menu_destroy(HMENUI *menu) 8423 void API dw_menu_destroy(HMENUI *menu)
8486 { 8424 {
8487 NSMenu *thismenu = *menu; 8425 UIMenu *thismenu = *menu;
8488 DW_LOCAL_POOL_IN; 8426 DW_LOCAL_POOL_IN;
8489 [thismenu release]; 8427 [thismenu release];
8490 DW_LOCAL_POOL_OUT; 8428 DW_LOCAL_POOL_OUT;
8491 } 8429 }
8492 8430
8493 /* Handle deprecation of convertScreenToBase in 10.10 yet still supporting 8431 /* Handle deprecation of convertScreenToBase in 10.10 yet still supporting
8494 * 10.6 and earlier since convertRectFromScreen was introduced in 10.7. 8432 * 10.6 and earlier since convertRectFromScreen was introduced in 10.7.
8495 */ 8433 */
8496 NSPoint _windowPointFromScreen(id window, NSPoint p) 8434 CGPoint _windowPointFromScreen(id window, CGPoint p)
8497 { 8435 {
8498 SEL crfs = NSSelectorFromString(@"convertRectFromScreen:"); 8436 SEL crfs = NSSelectorFromString(@"convertRectFromScreen:");
8499 8437
8500 if([window respondsToSelector:crfs]) 8438 if([window respondsToSelector:crfs])
8501 { 8439 {
8502 NSRect (* icrfs)(id, SEL, NSRect) = (NSRect (*)(id, SEL, NSRect))[window methodForSelector:crfs]; 8440 CGRect (* icrfs)(id, SEL, CGRect) = (CGRect (*)(id, SEL, CGRect))[window methodForSelector:crfs];
8503 NSRect rect = icrfs(window, crfs, NSMakeRect(p.x, p.y, 1, 1)); 8441 CGRect rect = icrfs(window, crfs, NSMakeRect(p.x, p.y, 1, 1));
8504 return rect.origin; 8442 return rect.origin;
8505 } 8443 }
8506 else 8444 else
8507 { 8445 {
8508 SEL cstb = NSSelectorFromString(@"convertScreenToBase:"); 8446 SEL cstb = NSSelectorFromString(@"convertScreenToBase:");
8509 8447
8510 if([window respondsToSelector:cstb]) 8448 if([window respondsToSelector:cstb])
8511 { 8449 {
8512 NSPoint (* icstb)(id, SEL, NSPoint) = (NSPoint (*)(id, SEL, NSPoint))[window methodForSelector:cstb]; 8450 CGPoint (* icstb)(id, SEL, CGPoint) = (CGPoint (*)(id, SEL, CGPoint))[window methodForSelector:cstb];
8513 return icstb(window, cstb, p); 8451 return icstb(window, cstb, p);
8514 } 8452 }
8515 } 8453 }
8516 return NSMakePoint(0,0); 8454 return NSMakePoint(0,0);
8517 } 8455 }
8524 * x: X coordinate. 8462 * x: X coordinate.
8525 * y: Y coordinate. 8463 * y: Y coordinate.
8526 */ 8464 */
8527 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) 8465 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
8528 { 8466 {
8529 NSMenu *thismenu = (NSMenu *)*menu; 8467 UIMenu *thismenu = (UIMenu *)*menu;
8530 id object = parent; 8468 id object = parent;
8531 UIView *view = [object isKindOfClass:[UIWindow class]] ? [object contentView] : parent; 8469 UIView *view = [object isKindOfClass:[UIWindow class]] ? [object contentView] : parent;
8532 UIWindow *window = [view window]; 8470 UIWindow *window = [view window];
8533 NSEvent *event = [DWApp currentEvent]; 8471 UIEvent *event = [DWApp currentEvent];
8534 if(!window) 8472 if(!window)
8535 window = [event window]; 8473 window = [event window];
8536 [thismenu autorelease]; 8474 [thismenu autorelease];
8537 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); 8475 CGPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y);
8538 NSEvent* fake = [NSEvent mouseEventWithType:DWEventTypeRightMouseDown 8476 UIEvent* fake = [UIEvent mouseEventWithType:DWEventTypeRightMouseDown
8539 location:_windowPointFromScreen(window, p) 8477 location:_windowPointFromScreen(window, p)
8540 modifierFlags:0 8478 modifierFlags:0
8541 timestamp:[event timestamp] 8479 timestamp:[event timestamp]
8542 windowNumber:[window windowNumber] 8480 windowNumber:[window windowNumber]
8543 context:[NSGraphicsContext currentContext] 8481 context:[NSGraphicsContext currentContext]
8544 eventNumber:1 8482 eventNumber:1
8545 clickCount:1 8483 clickCount:1
8546 pressure:0.0]; 8484 pressure:0.0];
8547 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; 8485 [UIMenu popUpContextMenu:thismenu withEvent:fake forView:view];
8548 } 8486 }
8549 8487
8550 char _removetilde(char *dest, const char *src) 8488 char _removetilde(char *dest, const char *src)
8551 { 8489 {
8552 int z, cur=0; 8490 int z, cur=0;
8580 * flags: Extended attributes to set on the menu. 8518 * flags: Extended attributes to set on the menu.
8581 * submenu: Handle to an existing menu to be a submenu or NULL. 8519 * submenu: Handle to an existing menu to be a submenu or NULL.
8582 */ 8520 */
8583 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux) 8521 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
8584 { 8522 {
8585 NSMenu *menu = menux; 8523 UIMenu *menu = menux;
8586 NSMenu *submenu = submenux; 8524 UIMenu *submenu = submenux;
8587 DWMenuItem *item = NULL; 8525 DWMenuItem *item = NULL;
8588 if(strlen(title) == 0) 8526 if(strlen(title) == 0)
8589 { 8527 {
8590 [menu addItem:[DWMenuItem separatorItem]]; 8528 [menu addItem:[DWMenuItem separatorItem]];
8591 } 8529 }
8639 * check: TRUE for checked FALSE for not checked. 8577 * check: TRUE for checked FALSE for not checked.
8640 */ 8578 */
8641 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check) 8579 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check)
8642 { 8580 {
8643 id menu = menux; 8581 id menu = menux;
8644 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; 8582 UIMenuItem *menuitem = (UIMenuItem *)[menu itemWithTag:itemid];
8645 8583
8646 if(menuitem != nil) 8584 if(menuitem != nil)
8647 { 8585 {
8648 if(check) 8586 if(check)
8649 { 8587 {
8665 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. 8603 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
8666 */ 8604 */
8667 int API dw_menu_delete_item(HMENUI menux, unsigned long itemid) 8605 int API dw_menu_delete_item(HMENUI menux, unsigned long itemid)
8668 { 8606 {
8669 id menu = menux; 8607 id menu = menux;
8670 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; 8608 UIMenuItem *menuitem = (UIMenuItem *)[menu itemWithTag:itemid];
8671 8609
8672 if(menuitem != nil) 8610 if(menuitem != nil)
8673 { 8611 {
8674 [menu removeItem:menuitem]; 8612 [menu removeItem:menuitem];
8675 return DW_ERROR_NONE; 8613 return DW_ERROR_NONE;
8686 * DW_MIS_CHECKED/DW_MIS_UNCHECKED 8624 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
8687 */ 8625 */
8688 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state) 8626 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state)
8689 { 8627 {
8690 id menu = menux; 8628 id menu = menux;
8691 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; 8629 UIMenuItem *menuitem = (UIMenuItem *)[menu itemWithTag:itemid];
8692 8630
8693 if(menuitem != nil) 8631 if(menuitem != nil)
8694 { 8632 {
8695 if(state & DW_MIS_CHECKED) 8633 if(state & DW_MIS_CHECKED)
8696 { 8634 {
8877 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle) 8815 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle)
8878 DW_FUNCTION_RETURN(dw_window_new, HWND) 8816 DW_FUNCTION_RETURN(dw_window_new, HWND)
8879 DW_FUNCTION_RESTORE_PARAM3(hwndOwner, HWND, title, char *, flStyle, ULONG) 8817 DW_FUNCTION_RESTORE_PARAM3(hwndOwner, HWND, title, char *, flStyle, ULONG)
8880 { 8818 {
8881 DW_FUNCTION_INIT; 8819 DW_FUNCTION_INIT;
8882 NSRect frame = NSMakeRect(1,1,1,1); 8820 CGRect frame = NSMakeRect(1,1,1,1);
8883 DWWindow *window = [[DWWindow alloc] 8821 DWWindow *window = [[DWWindow alloc]
8884 initWithContentRect:frame 8822 initWithContentRect:frame
8885 styleMask:(flStyle) 8823 styleMask:(flStyle)
8886 backing:NSBackingStoreBuffered 8824 backing:NSBackingStoreBuffered
8887 defer:false]; 8825 defer:false];
8958 { 8896 {
8959 [view discardCursorRects]; 8897 [view discardCursorRects];
8960 } 8898 }
8961 else if(pointertype == DW_POINTER_ARROW) 8899 else if(pointertype == DW_POINTER_ARROW)
8962 { 8900 {
8963 NSRect rect = [view frame]; 8901 CGRect rect = [view frame];
8964 NSCursor *cursor = [NSCursor arrowCursor]; 8902 NSCursor *cursor = [NSCursor arrowCursor];
8965 8903
8966 [view addCursorRect:rect cursor:cursor]; 8904 [view addCursorRect:rect cursor:cursor];
8967 } 8905 }
8968 /* No cursor for DW_POINTER_CLOCK? */ 8906 /* No cursor for DW_POINTER_CLOCK? */
8979 NSObject *object = handle; 8917 NSObject *object = handle;
8980 8918
8981 if([ object isMemberOfClass:[ DWWindow class ] ]) 8919 if([ object isMemberOfClass:[ DWWindow class ] ])
8982 { 8920 {
8983 DWWindow *window = handle; 8921 DWWindow *window = handle;
8984 NSRect rect = [[window contentView] frame]; 8922 CGRect rect = [[window contentView] frame];
8985 id defaultitem = [window initialFirstResponder]; 8923 id defaultitem = [window initialFirstResponder];
8986 8924
8987 if([window isMiniaturized]) 8925 if([window isMiniaturized])
8988 { 8926 {
8989 [window deminiaturize:nil]; 8927 [window deminiaturize:nil];
9000 if(![window shown]) 8938 if(![window shown])
9001 { 8939 {
9002 static int defaultx = 0, defaulty = 0; 8940 static int defaultx = 0, defaulty = 0;
9003 int cx = dw_screen_width(), cy = dw_screen_height(); 8941 int cx = dw_screen_width(), cy = dw_screen_height();
9004 int maxx = cx / 4, maxy = cy / 4; 8942 int maxx = cx / 4, maxy = cy / 4;
9005 NSPoint point; 8943 CGPoint point;
9006 8944
9007 rect = [window frame]; 8945 rect = [window frame];
9008 8946
9009 defaultx += 20; 8947 defaultx += 20;
9010 defaulty += 20; 8948 defaulty += 20;
9535 { 9473 {
9536 DWWindow *window = handle; 9474 DWWindow *window = handle;
9537 [window close]; 9475 [window close];
9538 } 9476 }
9539 /* Handle removing menu items from menus */ 9477 /* Handle removing menu items from menus */
9540 else if([ object isKindOfClass:[NSMenuItem class]]) 9478 else if([ object isKindOfClass:[UIMenuItem class]])
9541 { 9479 {
9542 NSMenu *menu = [object menu]; 9480 UIMenu *menu = [object menu];
9543 9481
9544 [menu removeItem:object]; 9482 [menu removeItem:object];
9545 } 9483 }
9546 /* Handle destroying a control or box */ 9484 /* Handle destroying a control or box */
9547 else if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]]) 9485 else if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]])
9732 if([object isMemberOfClass:[UIScrollView class]]) 9670 if([object isMemberOfClass:[UIScrollView class]])
9733 { 9671 {
9734 UIScrollView *sv = handle; 9672 UIScrollView *sv = handle;
9735 object = [sv documentView]; 9673 object = [sv documentView];
9736 } 9674 }
9737 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[NSMenuItem class]]) 9675 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[UIMenuItem class]])
9738 { 9676 {
9739 [object setEnabled:NO]; 9677 [object setEnabled:NO];
9740 } 9678 }
9741 if([object isKindOfClass:[UITextView class]]) 9679 if([object isKindOfClass:[UITextView class]])
9742 { 9680 {
9763 if([object isMemberOfClass:[UIScrollView class]]) 9701 if([object isMemberOfClass:[UIScrollView class]])
9764 { 9702 {
9765 UIScrollView *sv = handle; 9703 UIScrollView *sv = handle;
9766 object = [sv documentView]; 9704 object = [sv documentView];
9767 } 9705 }
9768 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[NSMenuItem class]]) 9706 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[UIMenuItem class]])
9769 { 9707 {
9770 [object setEnabled:YES]; 9708 [object setEnabled:YES];
9771 } 9709 }
9772 if([object isKindOfClass:[UITextView class]]) 9710 if([object isKindOfClass:[UITextView class]])
9773 { 9711 {
9971 9909
9972 if([ object isMemberOfClass:[ DWWindow class ] ]) 9910 if([ object isMemberOfClass:[ DWWindow class ] ])
9973 { 9911 {
9974 DWWindow *window = handle; 9912 DWWindow *window = handle;
9975 Box *thisbox; 9913 Box *thisbox;
9976 NSRect content, frame = NSMakeRect(0, 0, width, height); 9914 CGRect content, frame = NSMakeRect(0, 0, width, height);
9977 9915
9978 /* Convert the external frame size to internal content size */ 9916 /* Convert the external frame size to internal content size */
9979 content = [UIWindow contentRectForFrameRect:frame styleMask:[window styleMask]]; 9917 content = [UIWindow contentRectForFrameRect:frame styleMask:[window styleMask]];
9980 9918
9981 /* 9919 /*
10016 Box *thisbox; 9954 Box *thisbox;
10017 9955
10018 if((thisbox = (Box *)[[object contentView] box])) 9956 if((thisbox = (Box *)[[object contentView] box]))
10019 { 9957 {
10020 int depth = 0; 9958 int depth = 0;
10021 NSRect frame; 9959 CGRect frame;
10022 9960
10023 /* Calculate space requirements */ 9961 /* Calculate space requirements */
10024 _resize_box(thisbox, &depth, 0, 0, 1); 9962 _resize_box(thisbox, &depth, 0, 0, 1);
10025 9963
10026 /* Figure out the border size */ 9964 /* Figure out the border size */
10094 *y = newy; 10032 *y = newy;
10095 } 10033 }
10096 /* Adjust the values to avoid Dock/Menubar if requested */ 10034 /* Adjust the values to avoid Dock/Menubar if requested */
10097 if((horz | vert) & DW_GRAV_OBSTACLES) 10035 if((horz | vert) & DW_GRAV_OBSTACLES)
10098 { 10036 {
10099 NSRect visiblerect = [[object screen] visibleFrame]; 10037 CGRect visiblerect = [[object screen] visibleFrame];
10100 NSRect totalrect = [[object screen] frame]; 10038 CGRect totalrect = [[object screen] frame];
10101 10039
10102 if(horz & DW_GRAV_OBSTACLES) 10040 if(horz & DW_GRAV_OBSTACLES)
10103 { 10041 {
10104 if((horz & 0xf) == DW_GRAV_LEFT) 10042 if((horz & 0xf) == DW_GRAV_LEFT)
10105 *x += visiblerect.origin.x; 10043 *x += visiblerect.origin.x;
10132 NSObject *object = handle; 10070 NSObject *object = handle;
10133 10071
10134 if([ object isMemberOfClass:[ DWWindow class ] ]) 10072 if([ object isMemberOfClass:[ DWWindow class ] ])
10135 { 10073 {
10136 DWWindow *window = handle; 10074 DWWindow *window = handle;
10137 NSPoint point; 10075 CGPoint point;
10138 NSSize size = [[window contentView] frame].size; 10076 CGSize size = [[window contentView] frame].size;
10139 10077
10140 /* Can't position an unsized window, so attempt to auto-size */ 10078 /* Can't position an unsized window, so attempt to auto-size */
10141 if(size.width <= 1 || size.height <= 1) 10079 if(size.width <= 1 || size.height <= 1)
10142 { 10080 {
10143 /* Determine the contents size */ 10081 /* Determine the contents size */
10186 NSObject *object = handle; 10124 NSObject *object = handle;
10187 10125
10188 if([ object isKindOfClass:[ UIWindow class ] ]) 10126 if([ object isKindOfClass:[ UIWindow class ] ])
10189 { 10127 {
10190 UIWindow *window = handle; 10128 UIWindow *window = handle;
10191 NSRect rect = [window frame]; 10129 CGRect rect = [window frame];
10192 if(x) 10130 if(x)
10193 *x = rect.origin.x; 10131 *x = rect.origin.x;
10194 if(y) 10132 if(y)
10195 *y = [[window screen] frame].size.height - rect.origin.y - rect.size.height; 10133 *y = [[window screen] frame].size.height - rect.origin.y - rect.size.height;
10196 if(width) 10134 if(width)
10200 return; 10138 return;
10201 } 10139 }
10202 else if([ object isKindOfClass:[ UIControl class ] ]) 10140 else if([ object isKindOfClass:[ UIControl class ] ])
10203 { 10141 {
10204 UIControl *control = handle; 10142 UIControl *control = handle;
10205 NSRect rect = [control frame]; 10143 CGRect rect = [control frame];
10206 if(x) 10144 if(x)
10207 *x = rect.origin.x; 10145 *x = rect.origin.x;
10208 if(y) 10146 if(y)
10209 *y = rect.origin.y; 10147 *y = rect.origin.y;
10210 if(width) 10148 if(width)
10218 /* 10156 /*
10219 * Returns the width of the screen. 10157 * Returns the width of the screen.
10220 */ 10158 */
10221 int API dw_screen_width(void) 10159 int API dw_screen_width(void)
10222 { 10160 {
10223 NSRect screenRect = [[NSScreen mainScreen] frame]; 10161 CGRect screenRect = [[NSScreen mainScreen] frame];
10224 return screenRect.size.width; 10162 return screenRect.size.width;
10225 } 10163 }
10226 10164
10227 /* 10165 /*
10228 * Returns the height of the screen. 10166 * Returns the height of the screen.
10229 */ 10167 */
10230 int API dw_screen_height(void) 10168 int API dw_screen_height(void)
10231 { 10169 {
10232 NSRect screenRect = [[NSScreen mainScreen] frame]; 10170 CGRect screenRect = [[NSScreen mainScreen] frame];
10233 return screenRect.size.height; 10171 return screenRect.size.height;
10234 } 10172 }
10235 10173
10236 /* This should return the current color depth */ 10174 /* This should return the current color depth */
10237 unsigned long API dw_color_depth_get(void) 10175 unsigned long API dw_color_depth_get(void)
11512 /* If DWApp is uninitialized, initialize it */ 11450 /* If DWApp is uninitialized, initialize it */
11513 void _dw_app_init(void) 11451 void _dw_app_init(void)
11514 { 11452 {
11515 if(!DWApp) 11453 if(!DWApp)
11516 { 11454 {
11517 DWApp = [NSApplication sharedApplication]; 11455 DWApp = [UIApplication sharedApplication];
11518 DWAppDel *del = [[DWAppDel alloc] init]; 11456 DWAppDel *del = [[DWAppDel alloc] init];
11519 [DWApp setDelegate:del]; 11457 [DWApp setDelegate:del];
11520 } 11458 }
11521 } 11459 }
11522 11460
11951 NSPrintInfo *pi; 11889 NSPrintInfo *pi;
11952 NSPrintOperation *po; 11890 NSPrintOperation *po;
11953 HPIXMAP pixmap, pixmap2; 11891 HPIXMAP pixmap, pixmap2;
11954 UIImage *image, *flipped; 11892 UIImage *image, *flipped;
11955 UIImageView *iv; 11893 UIImageView *iv;
11956 NSSize size; 11894 CGSize size;
11957 PMPrintSettings settings; 11895 PMPrintSettings settings;
11958 int x, result = DW_ERROR_UNKNOWN; 11896 int x, result = DW_ERROR_UNKNOWN;
11959 UInt32 start, end; 11897 UInt32 start, end;
11960 11898
11961 if(!p) 11899 if(!p)