Mercurial > dwindows
comparison mac/dw.m @ 740:bb3b2d804f0e
Working on fonts some more.... setting a default label font that is smaller.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Mar 2011 02:22:14 +0000 |
parents | a0aec9a56914 |
children | 1d80d728a773 |
comparison
equal
deleted
inserted
replaced
739:a0aec9a56914 | 740:bb3b2d804f0e |
---|---|
333 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } | 333 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } |
334 @end | 334 @end |
335 | 335 |
336 NSApplication *DWApp; | 336 NSApplication *DWApp; |
337 NSMenu *DWMainMenu; | 337 NSMenu *DWMainMenu; |
338 NSFont *DWDefaultFont; | |
338 DWTimerHandler *DWHandler; | 339 DWTimerHandler *DWHandler; |
339 #if !defined(GARBAGE_COLLECT) | 340 #if !defined(GARBAGE_COLLECT) |
340 NSAutoreleasePool *pool; | 341 NSAutoreleasePool *pool; |
341 #endif | 342 #endif |
342 HWND _DWLastDrawable; | 343 HWND _DWLastDrawable; |
3634 [textfield setSelectable:NO]; | 3635 [textfield setSelectable:NO]; |
3635 [textfield setBordered:NO]; | 3636 [textfield setBordered:NO]; |
3636 [textfield setDrawsBackground:NO]; | 3637 [textfield setDrawsBackground:NO]; |
3637 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; | 3638 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; |
3638 [textfield setTag:cid]; | 3639 [textfield setTag:cid]; |
3640 [[textfield cell] setFont:DWDefaultFont]; | |
3639 return textfield; | 3641 return textfield; |
3640 } | 3642 } |
3641 | 3643 |
3642 /* | 3644 /* |
3643 * Creates a rendering context widget (window) to be packed. | 3645 * Creates a rendering context widget (window) to be packed. |
5843 tmp |= style; | 5845 tmp |= style; |
5844 | 5846 |
5845 [window setStyleMask:tmp]; | 5847 [window setStyleMask:tmp]; |
5846 #endif | 5848 #endif |
5847 } | 5849 } |
5850 else if([object isKindOfClass:[NSTextField class]]) | |
5851 { | |
5852 NSTextField *tf = object; | |
5853 | |
5854 /* TODO: See if we need to switch to a bitmask */ | |
5855 [[tf cell] setAlignment:style]; | |
5856 } | |
5848 else if([object isMemberOfClass:[NSTextView class]]) | 5857 else if([object isMemberOfClass:[NSTextView class]]) |
5849 { | 5858 { |
5850 NSTextView *tv = handle; | 5859 NSTextView *tv = handle; |
5851 [tv setAlignment:(style & mask)]; | 5860 [tv setAlignment:(style & mask)]; |
5852 } | 5861 } |
5962 * handle: The window (widget) handle. | 5971 * handle: The window (widget) handle. |
5963 * fontname: Name and size of the font in the form "size.fontname" | 5972 * fontname: Name and size of the font in the form "size.fontname" |
5964 */ | 5973 */ |
5965 int API dw_window_set_font(HWND handle, char *fontname) | 5974 int API dw_window_set_font(HWND handle, char *fontname) |
5966 { | 5975 { |
5967 char *fontcopy = strdup(fontname); | 5976 char *fontcopy = strdup(fontname); |
5968 char *name = strchr(fontcopy, '.'); | 5977 char *name = strchr(fontcopy, '.'); |
5969 if(name) | 5978 if(name) |
5970 { | 5979 { |
5971 int size = atoi(fontcopy); | 5980 int size = atoi(fontcopy); |
5972 *name = 0; | 5981 *name = 0; |
5973 name++; | 5982 name++; |
5974 NSFont *font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size]; | 5983 NSFont *font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size]; |
5975 if(font) | 5984 if(font) |
5976 { | 5985 { |
5977 id object = handle; | 5986 id object = handle; |
5978 if([object window]) | 5987 if([object window]) |
5979 { | 5988 { |
5982 [object unlockFocus]; | 5991 [object unlockFocus]; |
5983 } | 5992 } |
5984 if([object isKindOfClass:[NSControl class]]) | 5993 if([object isKindOfClass:[NSControl class]]) |
5985 { | 5994 { |
5986 [object setFont:font]; | 5995 [object setFont:font]; |
5996 [[object cell] setFont:font]; | |
5987 } | 5997 } |
5988 } | 5998 } |
5989 } | 5999 } |
5990 free(fontcopy); | 6000 free(fontcopy); |
5991 return 0; | 6001 return 0; |
5992 } | 6002 } |
5993 | 6003 |
5994 /* | 6004 /* |
5995 * Returns the current font for the specified window | 6005 * Returns the current font for the specified window |
5996 * Parameters: | 6006 * Parameters: |
7487 /* Create a default main menu, with just the application menu */ | 7497 /* Create a default main menu, with just the application menu */ |
7488 DWMainMenu = _generate_main_menu(); | 7498 DWMainMenu = _generate_main_menu(); |
7489 [DWMainMenu retain]; | 7499 [DWMainMenu retain]; |
7490 [DWApp setMainMenu:DWMainMenu]; | 7500 [DWApp setMainMenu:DWMainMenu]; |
7491 DWObj = [[DWObject alloc] init]; | 7501 DWObj = [[DWObject alloc] init]; |
7502 DWDefaultFont = [[NSFont fontWithName:@"Geneva" size:10.0] retain]; | |
7492 /* Create mutexes for thread safety */ | 7503 /* Create mutexes for thread safety */ |
7493 DWRunMutex = dw_mutex_new(); | 7504 DWRunMutex = dw_mutex_new(); |
7494 DWThreadMutex = dw_mutex_new(); | 7505 DWThreadMutex = dw_mutex_new(); |
7495 DWThreadMutex2 = dw_mutex_new(); | 7506 DWThreadMutex2 = dw_mutex_new(); |
7496 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ | 7507 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ |