Mercurial > dwindows
changeset 891:3774af45eb0c
Fix for dw_draw_text() not using the background color on the Mac.
Also default the background color to transparent instead of black.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 17 Apr 2011 02:45:20 +0000 |
parents | 5a96cc2695b9 |
children | 82f68adde8a0 |
files | mac/dw.m |
diffstat | 1 files changed, 27 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Thu Apr 07 19:31:32 2011 +0000 +++ b/mac/dw.m Sun Apr 17 02:45:20 2011 +0000 @@ -85,10 +85,9 @@ void _init_colors(void) { NSColor *fgcolor = [[NSColor grayColor] retain]; - NSColor *bgcolor = [[NSColor blackColor] retain]; pthread_setspecific(_dw_fg_color_key, fgcolor); - pthread_setspecific(_dw_bg_color_key, bgcolor); + pthread_setspecific(_dw_bg_color_key, NULL); } typedef struct _sighandler @@ -4269,12 +4268,19 @@ NSColor *oldcolor = pthread_getspecific(_dw_bg_color_key); NSColor *newcolor; - _background = _get_color(value); + if(value == DW_CLR_DEFAULT) + { + pthread_setspecific(_dw_bg_color_key, NULL); + } + else + { + _background = _get_color(value); - newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green: - DW_GREEN_VALUE(_background)/255.0 blue: - DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; - pthread_setspecific(_dw_bg_color_key, newcolor); + newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green: + DW_GREEN_VALUE(_background)/255.0 blue: + DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; + pthread_setspecific(_dw_bg_color_key, newcolor); + } [oldcolor release]; } @@ -4427,8 +4433,13 @@ DW_MUTEX_UNLOCK; return; } - NSColor *color = pthread_getspecific(_dw_fg_color_key); - NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; + NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); + NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); + NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; + if(bgcolor) + { + [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName]; + } if(font) { [dict setValue:font forKey:NSFontAttributeName]; @@ -4449,8 +4460,13 @@ } image = (id)pixmap->image; [image lockFocus]; - NSColor *color = pthread_getspecific(_dw_fg_color_key); - NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; + NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); + NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); + NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; + if(bgcolor) + { + [dict setValue:bgcolor forKey:NSBackgroundColorAttributeName]; + } if(font) { [dict setValue:font forKey:NSFontAttributeName];