comparison mac/dw.m @ 745:d29fb0d5b291

Fixes for font handling on pixmaps... it needs to use the associated render control to get the fonts.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 16 Mar 2011 07:39:28 +0000
parents 9882b0dfa304
children a4f99795ff26
comparison
equal deleted inserted replaced
744:9882b0dfa304 745:d29fb0d5b291
182 { 182 {
183 int (*keypressfunc)(HWND, char, int, int, void *) = handler->signalfunction; 183 int (*keypressfunc)(HWND, char, int, int, void *) = handler->signalfunction;
184 NSString *nchar = [event charactersIgnoringModifiers]; 184 NSString *nchar = [event charactersIgnoringModifiers];
185 int special = (int)[event modifierFlags]; 185 int special = (int)[event modifierFlags];
186 unichar vk = [nchar characterAtIndex:0]; 186 unichar vk = [nchar characterAtIndex:0];
187 char ch; 187 char ch = '\0';
188 188
189 /* Handle a valid key */ 189 /* Handle a valid key */
190 if([nchar length] == 1) 190 if([nchar length] == 1)
191 { 191 {
192 const char *tmp = [nchar UTF8String]; 192 const char *tmp = [nchar UTF8String];
509 { 509 {
510 bgcolor = nil; 510 bgcolor = nil;
511 } 511 }
512 else 512 else
513 { 513 {
514 NSLog(@"R: %d G: %d B: %d", (int)DW_RED_VALUE(input), (int)DW_GREEN_VALUE(input), (int)DW_BLUE_VALUE(input));
515 bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1]; 514 bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1];
516 } 515 }
517 } 516 }
518 @end 517 @end
519 518
829 newpos = max; 828 newpos = max;
830 } 829 }
831 break; 830 break;
832 831
833 default: 832 default:
834 ; // do nothing 833 ; /* do nothing */
835 } 834 }
836 if(newpos != result) 835 if(newpos != result)
837 { 836 {
838 double newposd = (double)newpos/max; 837 double newposd = (double)newpos/max;
839 [self setDoubleValue:newposd]; 838 [self setDoubleValue:newposd];
845 844
846 /* Subclass for a render area type */ 845 /* Subclass for a render area type */
847 @interface DWRender : NSView 846 @interface DWRender : NSView
848 { 847 {
849 void *userdata; 848 void *userdata;
849 NSFont *font;
850 } 850 }
851 -(void *)userdata; 851 -(void *)userdata;
852 -(void)setUserdata:(void *)input; 852 -(void)setUserdata:(void *)input;
853 -(void)setFont:(NSFont *)input;
854 -(NSFont *)font;
853 -(void)mouseDown:(NSEvent *)theEvent; 855 -(void)mouseDown:(NSEvent *)theEvent;
854 -(void)mouseUp:(NSEvent *)theEvent; 856 -(void)mouseUp:(NSEvent *)theEvent;
855 -(NSMenu *)menuForEvent:(NSEvent *)theEvent; 857 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
856 -(void)rightMouseUp:(NSEvent *)theEvent; 858 -(void)rightMouseUp:(NSEvent *)theEvent;
857 -(void)otherMouseDown:(NSEvent *)theEvent; 859 -(void)otherMouseDown:(NSEvent *)theEvent;
862 @end 864 @end
863 865
864 @implementation DWRender 866 @implementation DWRender
865 -(void *)userdata { return userdata; } 867 -(void *)userdata { return userdata; }
866 -(void)setUserdata:(void *)input { userdata = input; } 868 -(void)setUserdata:(void *)input { userdata = input; }
869 -(void)setFont:(NSFont *)input { [font release]; font = input; [font retain]; }
870 -(NSFont *)font { return font; }
867 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } 871 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); }
868 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } 872 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); }
869 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; } 873 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; }
870 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); } 874 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); }
871 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } 875 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); }
872 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } 876 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); }
873 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } 877 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); }
874 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); } 878 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); _event_handler([self window], theEvent, 2); }
875 -(BOOL)isFlipped { return NO; } 879 -(BOOL)isFlipped { return NO; }
876 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 880 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; }
877 @end 881 @end
878 882
879 /* Subclass for a MLE type */ 883 /* Subclass for a MLE type */
880 @interface DWMLE : NSTextView 884 @interface DWMLE : NSTextView
881 { 885 {
2637 NSString *respath = [bundle resourcePath]; 2641 NSString *respath = [bundle resourcePath];
2638 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; 2642 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
2639 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; 2643 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
2640 DWButton *button = _button_new("", resid); 2644 DWButton *button = _button_new("", resid);
2641 [button setImage:image]; 2645 [button setImage:image];
2642 //[button setBezelStyle:0];
2643 [button setButtonType:NSMomentaryLight]; 2646 [button setButtonType:NSMomentaryLight];
2644 [button setBordered:NO]; 2647 [button setBordered:NO];
2645 [image release]; 2648 [image release];
2646 return button; 2649 return button;
2647 } 2650 }
3410 HWND API dw_mle_new(ULONG cid) 3413 HWND API dw_mle_new(ULONG cid)
3411 { 3414 {
3412 DWMLE *mle = [[DWMLE alloc] init]; 3415 DWMLE *mle = [[DWMLE alloc] init];
3413 NSScrollView *scrollview = [[NSScrollView alloc] init]; 3416 NSScrollView *scrollview = [[NSScrollView alloc] init];
3414 3417
3415 //[mle setScrollview:scrollview];
3416 [scrollview setBorderType:NSBezelBorder]; 3418 [scrollview setBorderType:NSBezelBorder];
3417 [scrollview setHasVerticalScroller:YES]; 3419 [scrollview setHasVerticalScroller:YES];
3418 [scrollview setAutohidesScrollers:YES]; 3420 [scrollview setAutohidesScrollers:YES];
3419 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 3421 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
3420 [scrollview setDocumentView:mle]; 3422 [scrollview setDocumentView:mle];
3744 int _locked_by_me = FALSE; 3746 int _locked_by_me = FALSE;
3745 DW_MUTEX_LOCK; 3747 DW_MUTEX_LOCK;
3746 id image = handle; 3748 id image = handle;
3747 if(pixmap) 3749 if(pixmap)
3748 { 3750 {
3749 image = (id)pixmap->handle; 3751 image = (id)pixmap->image;
3750 [image lockFocus]; 3752 [image lockFocus];
3751 } 3753 }
3752 else 3754 else
3753 { 3755 {
3754 [image lockFocusIfCanDraw]; 3756 [image lockFocusIfCanDraw];
3779 int _locked_by_me = FALSE; 3781 int _locked_by_me = FALSE;
3780 DW_MUTEX_LOCK; 3782 DW_MUTEX_LOCK;
3781 id image = handle; 3783 id image = handle;
3782 if(pixmap) 3784 if(pixmap)
3783 { 3785 {
3784 image = (id)pixmap->handle; 3786 image = (id)pixmap->image;
3785 [image lockFocus]; 3787 [image lockFocus];
3786 } 3788 }
3787 else 3789 else
3788 { 3790 {
3789 [image lockFocusIfCanDraw]; 3791 [image lockFocusIfCanDraw];
3812 */ 3814 */
3813 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 3815 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
3814 { 3816 {
3815 int _locked_by_me = FALSE; 3817 int _locked_by_me = FALSE;
3816 DW_MUTEX_LOCK; 3818 DW_MUTEX_LOCK;
3817 id image = handle; 3819 id image = handle;
3818 NSString *nstr = [ NSString stringWithUTF8String:text ]; 3820 NSString *nstr = [ NSString stringWithUTF8String:text ];
3819 if(image) 3821 if(image)
3820 { 3822 {
3821 if([image isMemberOfClass:[NSView class]]) 3823 if([image isMemberOfClass:[DWRender class]])
3822 { 3824 {
3823 [image lockFocusIfCanDraw]; 3825 DWRender *render = handle;
3826 NSFont *font = [render font];
3827 [image lockFocusIfCanDraw];
3824 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]; 3828 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];
3825 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: 3829 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil];
3826 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ 3830 if(font)
3827 color, NSForegroundColorAttributeName, nil]; 3831 {
3828 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; 3832 [dict setValue:font forKey:NSFontAttributeName];
3829 [dict release]; 3833 }
3830 [image unlockFocus]; 3834 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict];
3831 } 3835 [image unlockFocus];
3832 _DWLastDrawable = handle; 3836 }
3833 } 3837 _DWLastDrawable = handle;
3834 if(pixmap) 3838 }
3835 { 3839 if(pixmap)
3836 image = (id)pixmap->handle; 3840 {
3837 [image lockFocus]; 3841 NSFont *font = nil;
3838 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]; 3842 DWRender *render = pixmap->handle;
3839 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: 3843 if([render isMemberOfClass:[DWRender class]])
3840 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ 3844 {
3841 color, NSForegroundColorAttributeName, nil]; 3845 font = [render font];
3842 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; 3846 }
3843 [dict release]; 3847 image = (id)pixmap->image;
3844 [image unlockFocus]; 3848 [image lockFocus];
3845 } 3849 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];
3850 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil];
3851 if(font)
3852 {
3853 [dict setValue:font forKey:NSFontAttributeName];
3854 }
3855 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict];
3856 [image unlockFocus];
3857 }
3846 DW_MUTEX_UNLOCK; 3858 DW_MUTEX_UNLOCK;
3847 } 3859 }
3848 3860
3849 /* Query the width and height of a text string. 3861 /* Query the width and height of a text string.
3850 * Parameters: 3862 * Parameters:
3854 * width: Pointer to a variable to be filled in with the width. 3866 * width: Pointer to a variable to be filled in with the width.
3855 * height Pointer to a variable to be filled in with the height. 3867 * height Pointer to a variable to be filled in with the height.
3856 */ 3868 */
3857 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) 3869 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
3858 { 3870 {
3859 int _locked_by_me = FALSE; 3871 id image = handle;
3860 DW_MUTEX_LOCK; 3872 id object = handle;
3861 id image = handle; 3873 NSString *nstr = [NSString stringWithUTF8String:text];
3862 NSString *nstr = [NSString stringWithUTF8String:text]; 3874 if(pixmap)
3863 if(pixmap) 3875 {
3864 { 3876 image = (id)pixmap->image;
3865 image = (id)pixmap->handle; 3877 object = pixmap->handle;
3866 [image lockFocus]; 3878 }
3867 } 3879 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
3868 else 3880 if([object isMemberOfClass:[DWRender class]])
3869 { 3881 {
3870 [image lockFocusIfCanDraw]; 3882 NSFont *font = [object font];
3871 } 3883
3872 NSDictionary *dict = [[NSDictionary alloc] init]; 3884 if(font)
3873 NSSize size = [nstr sizeWithAttributes:dict]; 3885 {
3886 [dict setValue:font forKey:NSFontAttributeName];
3887 }
3888 }
3889 NSSize size = [nstr sizeWithAttributes:dict];
3874 [dict release]; 3890 [dict release];
3875 if(width) 3891 if(width)
3876 { 3892 {
3877 *width = size.width; 3893 *width = size.width;
3878 } 3894 }
3879 if(height) 3895 if(height)
3880 { 3896 {
3881 *height = size.height; 3897 *height = size.height;
3882 } 3898 }
3883 [image unlockFocus];
3884 DW_MUTEX_UNLOCK;
3885 } 3899 }
3886 3900
3887 /* Draw a polygon on a window (preferably a render window). 3901 /* Draw a polygon on a window (preferably a render window).
3888 * Parameters: 3902 * Parameters:
3889 * handle: Handle to the window. 3903 * handle: Handle to the window.
3900 DW_MUTEX_LOCK; 3914 DW_MUTEX_LOCK;
3901 id image = handle; 3915 id image = handle;
3902 int z; 3916 int z;
3903 if(pixmap) 3917 if(pixmap)
3904 { 3918 {
3905 image = (id)pixmap->handle; 3919 image = (id)pixmap->image;
3906 [image lockFocus]; 3920 [image lockFocus];
3907 } 3921 }
3908 else 3922 else
3909 { 3923 {
3910 [image lockFocusIfCanDraw]; 3924 [image lockFocusIfCanDraw];
3945 int _locked_by_me = FALSE; 3959 int _locked_by_me = FALSE;
3946 DW_MUTEX_LOCK; 3960 DW_MUTEX_LOCK;
3947 id image = handle; 3961 id image = handle;
3948 if(pixmap) 3962 if(pixmap)
3949 { 3963 {
3950 image = (id)pixmap->handle; 3964 image = (id)pixmap->image;
3951 [image lockFocus]; 3965 [image lockFocus];
3952 } 3966 }
3953 else 3967 else
3954 { 3968 {
3955 [image lockFocusIfCanDraw]; 3969 [image lockFocusIfCanDraw];
4957 * Returns: 4971 * Returns:
4958 * A handle to a pixmap or NULL on failure. 4972 * A handle to a pixmap or NULL on failure.
4959 */ 4973 */
4960 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 4974 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
4961 { 4975 {
4962 NSSize size = { (float)width, (float)height }; 4976 NSSize size = { (float)width, (float)height };
4963 HPIXMAP pixmap; 4977 HPIXMAP pixmap;
4964 4978
4965 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 4979 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4966 return NULL; 4980 return NULL;
4967 pixmap->width = width; 4981 pixmap->width = width;
4968 pixmap->height = height; 4982 pixmap->height = height;
4969 NSImage *image = pixmap->handle = [[NSImage alloc] initWithSize:size]; 4983 pixmap->handle = handle;
4984 NSImage *image = pixmap->image = [[NSImage alloc] initWithSize:size];
4970 [image setFlipped:YES]; 4985 [image setFlipped:YES];
4971 return pixmap; 4986 return pixmap;
4972 } 4987 }
4973 4988
4974 /* 4989 /*
4975 * Creates a pixmap from a file. 4990 * Creates a pixmap from a file.
4976 * Parameters: 4991 * Parameters:
4981 * Returns: 4996 * Returns:
4982 * A handle to a pixmap or NULL on failure. 4997 * A handle to a pixmap or NULL on failure.
4983 */ 4998 */
4984 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) 4999 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
4985 { 5000 {
4986 HPIXMAP pixmap; 5001 HPIXMAP pixmap;
4987 5002
4988 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 5003 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4989 return NULL; 5004 return NULL;
4990 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 5005 NSString *nstr = [ NSString stringWithUTF8String:filename ];
4991 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; 5006 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr];
4992 if(!image) 5007 if(!image)
4993 { 5008 {
4994 nstr = [nstr stringByAppendingString:@".png"]; 5009 nstr = [nstr stringByAppendingString:@".png"];
4995 image = [[NSImage alloc] initWithContentsOfFile:nstr]; 5010 image = [[NSImage alloc] initWithContentsOfFile:nstr];
4996 } 5011 }
4997 NSSize size = [image size]; 5012 NSSize size = [image size];
4998 pixmap->width = size.width; 5013 pixmap->width = size.width;
4999 pixmap->height = size.height; 5014 pixmap->height = size.height;
5000 pixmap->handle = image; 5015 pixmap->image = image;
5001 return pixmap; 5016 pixmap->handle = handle;
5017 [image setFlipped:YES];
5018 return pixmap;
5002 } 5019 }
5003 5020
5004 /* 5021 /*
5005 * Creates a pixmap from memory. 5022 * Creates a pixmap from memory.
5006 * Parameters: 5023 * Parameters:
5011 * Returns: 5028 * Returns:
5012 * A handle to a pixmap or NULL on failure. 5029 * A handle to a pixmap or NULL on failure.
5013 */ 5030 */
5014 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) 5031 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len)
5015 { 5032 {
5016 HPIXMAP pixmap; 5033 HPIXMAP pixmap;
5017 5034
5018 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 5035 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
5019 return NULL; 5036 return NULL;
5020 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; 5037 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len];
5021 NSImage *image = [[NSImage alloc] initWithData:thisdata]; 5038 NSImage *image = [[NSImage alloc] initWithData:thisdata];
5022 NSSize size = [image size]; 5039 NSSize size = [image size];
5023 pixmap->width = size.width; 5040 pixmap->width = size.width;
5024 pixmap->height = size.height; 5041 pixmap->height = size.height;
5025 pixmap->handle = image; 5042 pixmap->image = image;
5026 return pixmap; 5043 pixmap->handle = handle;
5044 [image setFlipped:YES];
5045 return pixmap;
5027 } 5046 }
5028 5047
5029 /* 5048 /*
5030 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds 5049 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds
5031 */ 5050 */
5042 * Returns: 5061 * Returns:
5043 * A handle to a pixmap or NULL on failure. 5062 * A handle to a pixmap or NULL on failure.
5044 */ 5063 */
5045 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid) 5064 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid)
5046 { 5065 {
5047 HPIXMAP pixmap; 5066 HPIXMAP pixmap;
5048 5067
5049 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 5068 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
5050 return NULL; 5069 return NULL;
5051 5070
5052 NSBundle *bundle = [NSBundle mainBundle]; 5071 NSBundle *bundle = [NSBundle mainBundle];
5053 NSString *respath = [bundle resourcePath]; 5072 NSString *respath = [bundle resourcePath];
5054 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; 5073 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
5055 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; 5074 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
5056 NSSize size = [image size]; 5075 NSSize size = [image size];
5057 pixmap->width = size.width; 5076 pixmap->width = size.width;
5058 pixmap->height = size.height; 5077 pixmap->height = size.height;
5059 pixmap->handle = image; 5078 pixmap->image = image;
5060 [image release]; 5079 pixmap->handle = handle;
5061 return pixmap; 5080 [image setFlipped:YES];
5081 return pixmap;
5062 } 5082 }
5063 5083
5064 /* 5084 /*
5065 * Destroys an allocated pixmap. 5085 * Destroys an allocated pixmap.
5066 * Parameters: 5086 * Parameters:
5067 * pixmap: Handle to a pixmap returned by 5087 * pixmap: Handle to a pixmap returned by
5068 * dw_pixmap_new.. 5088 * dw_pixmap_new..
5069 */ 5089 */
5070 void API dw_pixmap_destroy(HPIXMAP pixmap) 5090 void API dw_pixmap_destroy(HPIXMAP pixmap)
5071 { 5091 {
5072 NSImage *image = (NSImage *)pixmap->handle; 5092 NSImage *image = (NSImage *)pixmap->image;
5073 [image dealloc]; 5093 [image dealloc];
5074 free(pixmap); 5094 free(pixmap);
5075 } 5095 }
5076 5096
5077 /* 5097 /*
5103 bltinfo->xsrc = xsrc; 5123 bltinfo->xsrc = xsrc;
5104 bltinfo->ysrc = ysrc; 5124 bltinfo->ysrc = ysrc;
5105 5125
5106 if(destp) 5126 if(destp)
5107 { 5127 {
5108 bltinfo->dest = (id)destp->handle; 5128 bltinfo->dest = (id)destp->image;
5109 } 5129 }
5110 if(srcp) 5130 if(srcp)
5111 { 5131 {
5112 id object = bltinfo->src = (id)srcp->handle; 5132 id object = bltinfo->src = (id)srcp->image;
5113 [object retain]; 5133 [object retain];
5114 } 5134 }
5115 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES]; 5135 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES];
5116 } 5136 }
5117 5137
6011 if([object isKindOfClass:[NSControl class]]) 6031 if([object isKindOfClass:[NSControl class]])
6012 { 6032 {
6013 [object setFont:font]; 6033 [object setFont:font];
6014 [[object cell] setFont:font]; 6034 [[object cell] setFont:font];
6015 } 6035 }
6036 else if([object isMemberOfClass:[DWRender class]])
6037 {
6038 DWRender *render = object;
6039
6040 [render setFont:font];
6041 }
6016 } 6042 }
6017 return 0; 6043 return 0;
6018 } 6044 }
6019 6045
6020 /* 6046 /*
6024 */ 6050 */
6025 char * API dw_window_get_font(HWND handle) 6051 char * API dw_window_get_font(HWND handle)
6026 { 6052 {
6027 id object = handle; 6053 id object = handle;
6028 6054
6029 if([object isKindOfClass:[NSControl class]]) 6055 if([object isKindOfClass:[NSControl class]] || [object isMemberOfClass:[DWRender class]])
6030 { 6056 {
6031 NSControl *control = object; 6057 NSFont *font = [object font];
6032 NSFont *font = [control font];
6033 NSString *fontname = [font fontName]; 6058 NSString *fontname = [font fontName];
6034 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]]; 6059 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]];
6035 return strdup([output UTF8String]); 6060 return strdup([output UTF8String]);
6036 } 6061 }
6037 return NULL; 6062 return NULL;
6181 { 6206 {
6182 NSObject *object = handle; 6207 NSObject *object = handle;
6183 if([ object isKindOfClass:[ NSImageView class ] ]) 6208 if([ object isKindOfClass:[ NSImageView class ] ])
6184 { 6209 {
6185 NSImageView *iv = handle; 6210 NSImageView *iv = handle;
6186 NSImage *bitmap = NULL; 6211 NSImage *bitmap = nil;
6187 6212
6188 if(filename) 6213 if(filename)
6189 { 6214 {
6190 bitmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; 6215 bitmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]];
6191 } 6216 }
7485 7510
7486 threadfunc(tmp[1]); 7511 threadfunc(tmp[1]);
7487 /* Release the pool when we are done so we don't leak */ 7512 /* Release the pool when we are done so we don't leak */
7488 #if !defined(GARBAGE_COLLECT) 7513 #if !defined(GARBAGE_COLLECT)
7489 pool = pthread_getspecific(_dw_pool_key); 7514 pool = pthread_getspecific(_dw_pool_key);
7490 [pool release]; 7515 [pool drain];
7491 #endif 7516 #endif
7492 free(tmp); 7517 free(tmp);
7493 } 7518 }
7494 7519
7495 void _dw_default_font(char *fontname) 7520 void _dw_default_font(char *fontname)