Mercurial > dwindows
comparison mac/dw.m @ 1230:75a773cdb626
Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font().
Also added multi-page printing code to the test program to make sure that works properly on all platforms.
It will print the selected file on page 2, or a centered error message if none is selected.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 16 Oct 2011 19:12:53 +0000 |
parents | f5b79d8b0694 |
children | bee6fc8119ec |
comparison
equal
deleted
inserted
replaced
1229:437b045a3b07 | 1230:75a773cdb626 |
---|---|
5029 */ | 5029 */ |
5030 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) | 5030 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
5031 { | 5031 { |
5032 id object = handle; | 5032 id object = handle; |
5033 NSString *nstr = [NSString stringWithUTF8String:text]; | 5033 NSString *nstr = [NSString stringWithUTF8String:text]; |
5034 NSFont *font = nil; | |
5035 /* Check the pixmap for associated object or font */ | |
5034 if(pixmap) | 5036 if(pixmap) |
5035 { | 5037 { |
5036 object = pixmap->handle; | 5038 object = pixmap->handle; |
5039 font = pixmap->font; | |
5037 } | 5040 } |
5038 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; | 5041 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; |
5039 if([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]]) | 5042 /* If we didn't get a font from the pixmap... try the associated object */ |
5040 { | 5043 if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]])) |
5041 NSFont *font = [object font]; | 5044 { |
5042 | 5045 font = [object font]; |
5043 if(font) | 5046 } |
5044 { | 5047 /* If we got a font... add it to the dictionary */ |
5045 [dict setValue:font forKey:NSFontAttributeName]; | 5048 if(font) |
5046 } | 5049 { |
5047 } | 5050 [dict setValue:font forKey:NSFontAttributeName]; |
5051 } | |
5052 /* Calculate the size of the string */ | |
5048 NSSize size = [nstr sizeWithAttributes:dict]; | 5053 NSSize size = [nstr sizeWithAttributes:dict]; |
5049 [dict release]; | 5054 [dict release]; |
5055 /* Return whatever information we can */ | |
5050 if(width) | 5056 if(width) |
5051 { | 5057 { |
5052 *width = size.width; | 5058 *width = size.width; |
5053 } | 5059 } |
5054 if(height) | 5060 if(height) |