Mercurial > dwindows
changeset 674:78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 28 Feb 2011 03:09:50 +0000 |
parents | 6d0f0dc7ff7c |
children | 48f8efba898f |
files | dwtest.c mac/dw.m mac/file.png mac/folder.png |
diffstat | 4 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtest.c Sun Feb 27 21:00:02 2011 +0000 +++ b/dwtest.c Mon Feb 28 03:09:50 2011 +0000 @@ -12,6 +12,10 @@ #define FIXEDFONT "10.Terminal" #define FOLDER_ICON_NAME "win\\folder" #define FILE_ICON_NAME "win\\file" +#elif defined(__MAC__) +#define FIXEDFONT "8.Monaco" +#define FOLDER_ICON_NAME "mac/folder" +#define FILE_ICON_NAME "mac/file" #elif GTK_MAJOR_VERSION > 1 #define FIXEDFONT "monospace 10" #define FOLDER_ICON_NAME "gtk/folder"
--- a/mac/dw.m Sun Feb 27 21:00:02 2011 +0000 +++ b/mac/dw.m Mon Feb 28 03:09:50 2011 +0000 @@ -200,7 +200,7 @@ @end @implementation DWTimerHandler --(void)runTimer:(id)sender { _event_handler(self, nil, 0); } +-(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } @end NSApplication *DWApp; @@ -1912,7 +1912,14 @@ */ HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) { - NSImage *image = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; + NSString *nstr = [ NSString stringWithUTF8String:filename ]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; + if(!image) + { + nstr = [nstr stringByAppendingString:@".png"]; + image = [[NSImage alloc] initWithContentsOfFile:nstr]; + } + [nstr release]; DWButton *button = _button_new("", id); [button setImage:image]; return button; @@ -3636,7 +3643,15 @@ */ HICN API dw_icon_load_from_file(char *filename) { - return [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; + NSString *nstr = [ NSString stringWithUTF8String:filename ]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; + if(!image) + { + nstr = [nstr stringByAppendingString:@".png"]; + image = [[NSImage alloc] initWithContentsOfFile:nstr]; + } + [nstr release]; + return image; } /* @@ -3781,7 +3796,14 @@ if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) return NULL; - NSImage *image = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; + NSString *nstr = [ NSString stringWithUTF8String:filename ]; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; + if(!image) + { + nstr = [nstr stringByAppendingString:@".png"]; + image = [[NSImage alloc] initWithContentsOfFile:nstr]; + } + [nstr release]; NSSize size = [image size]; pixmap->width = size.width; pixmap->height = size.height; @@ -4665,7 +4687,10 @@ [font set]; [object unlockFocus]; } - [object setFont:font]; + if([object isMemberOfClass:[NSControl class]]) + { + [object setFont:font]; + } } } free(fontcopy);