Mercurial > dwindows
comparison mac/dw.m @ 664:ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 25 Feb 2011 21:12:02 +0000 |
parents | d7badd5606ca |
children | e6bec2290f3f |
comparison
equal
deleted
inserted
replaced
663:86c404056262 | 664:ba3af8eb56f1 |
---|---|
514 -(void *)userdata; | 514 -(void *)userdata; |
515 -(void)setUserdata:(void *)input; | 515 -(void)setUserdata:(void *)input; |
516 -(void)drawRect:(NSRect)rect; | 516 -(void)drawRect:(NSRect)rect; |
517 -(void)mouseDown:(NSEvent *)theEvent; | 517 -(void)mouseDown:(NSEvent *)theEvent; |
518 -(void)mouseUp:(NSEvent *)theEvent; | 518 -(void)mouseUp:(NSEvent *)theEvent; |
519 -(BOOL)isFlipped; | |
519 @end | 520 @end |
520 | 521 |
521 @implementation DWRender | 522 @implementation DWRender |
522 -(void *)userdata { return userdata; } | 523 -(void *)userdata { return userdata; } |
523 -(void)setUserdata:(void *)input { userdata = input; } | 524 -(void)setUserdata:(void *)input { userdata = input; } |
524 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } | 525 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } |
525 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } | 526 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } |
526 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } | 527 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } |
528 -(BOOL)isFlipped { return NO; } | |
527 @end | 529 @end |
528 | 530 |
529 /* Subclass for a MLE type */ | 531 /* Subclass for a MLE type */ |
530 @interface DWMLE : NSTextView | 532 @interface DWMLE : NSTextView |
531 { | 533 { |
2745 else | 2747 else |
2746 { | 2748 { |
2747 [image lockFocusIfCanDraw]; | 2749 [image lockFocusIfCanDraw]; |
2748 _DWLastDrawable = handle; | 2750 _DWLastDrawable = handle; |
2749 } | 2751 } |
2750 NSRect rect = NSMakeRect(x, y, x, y); | 2752 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
2753 [aPath setLineWidth: 0.5]; | |
2751 [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; | 2754 [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; |
2752 NSRectFill(rect); | 2755 |
2756 [aPath moveToPoint:NSMakePoint(x, y)]; | |
2757 [aPath stroke]; | |
2753 [image unlockFocus]; | 2758 [image unlockFocus]; |
2754 } | 2759 } |
2755 | 2760 |
2756 /* Draw a line on a window (preferably a render window). | 2761 /* Draw a line on a window (preferably a render window). |
2757 * Parameters: | 2762 * Parameters: |
2812 } | 2817 } |
2813 if(pixmap) | 2818 if(pixmap) |
2814 { | 2819 { |
2815 image = (id)pixmap->handle; | 2820 image = (id)pixmap->handle; |
2816 [image lockFocus]; | 2821 [image lockFocus]; |
2817 [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; | 2822 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
2818 NSDictionary *dict = [[NSDictionary alloc] init]; | 2823 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: |
2824 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ | |
2825 color, NSForegroundColorAttributeName, nil]; | |
2819 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; | 2826 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
2820 [image unlockFocus]; | 2827 [image unlockFocus]; |
2821 } | 2828 } |
2822 } | 2829 } |
2823 | 2830 |
2918 else | 2925 else |
2919 { | 2926 { |
2920 [image lockFocusIfCanDraw]; | 2927 [image lockFocusIfCanDraw]; |
2921 _DWLastDrawable = handle; | 2928 _DWLastDrawable = handle; |
2922 } | 2929 } |
2923 NSRect rect = NSMakeRect(x, y, x + width, y + height); | 2930 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
2931 [aPath setLineWidth: 0.5]; | |
2924 [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; | 2932 [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] set]; |
2925 NSRectFill(rect); | 2933 |
2934 [aPath moveToPoint:NSMakePoint(x, y)]; | |
2935 [aPath lineToPoint:NSMakePoint(x, y + height)]; | |
2936 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; | |
2937 [aPath lineToPoint:NSMakePoint(x + width, y)]; | |
2938 [aPath closePath]; | |
2939 [aPath fill]; | |
2940 [aPath stroke]; | |
2926 [image unlockFocus]; | 2941 [image unlockFocus]; |
2927 } | 2942 } |
2928 | 2943 |
2929 /* | 2944 /* |
2930 * Create a tree object to be packed. | 2945 * Create a tree object to be packed. |
3621 | 3636 |
3622 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | 3637 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
3623 return NULL; | 3638 return NULL; |
3624 pixmap->width = width; | 3639 pixmap->width = width; |
3625 pixmap->height = height; | 3640 pixmap->height = height; |
3626 pixmap->handle = [[NSImage alloc] initWithSize:size]; | 3641 NSImage *image = pixmap->handle = [[NSImage alloc] initWithSize:size]; |
3642 [image setFlipped:YES]; | |
3627 return pixmap; | 3643 return pixmap; |
3628 } | 3644 } |
3629 | 3645 |
3630 /* | 3646 /* |
3631 * Creates a pixmap from a file. | 3647 * Creates a pixmap from a file. |