comparison mac/dw.m @ 1713:c836c6c33d8e

Create an internal _dw_icon_load() which does not resize the image on Mac. Found that I was using dw_icon_load() internally in dw_window_set_bitmap() which had the effect of resizing images that shouldn't have been.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 07 May 2012 13:56:14 +0000
parents daa59fc8d6e5
children 032c3388dda6
comparison
equal deleted inserted replaced
1712:daa59fc8d6e5 1713:c836c6c33d8e
6836 [image setSize:size]; 6836 [image setSize:size];
6837 } 6837 }
6838 } 6838 }
6839 } 6839 }
6840 6840
6841 /* Internal version that does not resize the image */
6842 HICN _dw_icon_load(unsigned long resid)
6843 {
6844 NSBundle *bundle = [NSBundle mainBundle];
6845 NSString *respath = [bundle resourcePath];
6846 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
6847 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
6848 return image;
6849 }
6850
6841 /* 6851 /*
6842 * Obtains an icon from a module (or header in GTK). 6852 * Obtains an icon from a module (or header in GTK).
6843 * Parameters: 6853 * Parameters:
6844 * module: Handle to module (DLL) in OS/2 and Windows. 6854 * module: Handle to module (DLL) in OS/2 and Windows.
6845 * id: A unsigned long id int the resources on OS/2 and 6855 * id: A unsigned long id int the resources on OS/2 and
6846 * Windows, on GTK this is converted to a pointer 6856 * Windows, on GTK this is converted to a pointer
6847 * to an embedded XPM. 6857 * to an embedded XPM.
6848 */ 6858 */
6849 HICN API dw_icon_load(unsigned long module, unsigned long resid) 6859 HICN API dw_icon_load(unsigned long module, unsigned long resid)
6850 { 6860 {
6851 NSBundle *bundle = [NSBundle mainBundle]; 6861 NSImage *image = _dw_icon_load(resid);
6852 NSString *respath = [bundle resourcePath];
6853 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid];
6854 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath];
6855 _icon_resize(image); 6862 _icon_resize(image);
6856 return image; 6863 return image;
6857 } 6864 }
6858 6865
6859 /* 6866 /*
8899 { 8906 {
8900 bitmap = [[[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]] autorelease]; 8907 bitmap = [[[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]] autorelease];
8901 } 8908 }
8902 else if(resid > 0 && resid < 65536) 8909 else if(resid > 0 && resid < 65536)
8903 { 8910 {
8904 bitmap = dw_icon_load(0, resid); 8911 bitmap = _dw_icon_load(resid);
8905 } 8912 }
8906 8913
8907 if(bitmap) 8914 if(bitmap)
8908 { 8915 {
8909 [iv setImage:bitmap]; 8916 [iv setImage:bitmap];