Mercurial > dwindows
comparison mac/dw.m @ 739:a0aec9a56914
Font and color improvements... including implementing dw_window_set_font().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Mar 2011 01:34:36 +0000 |
parents | 52d5ed00f892 |
children | bb3b2d804f0e |
comparison
equal
deleted
inserted
replaced
738:52d5ed00f892 | 739:a0aec9a56914 |
---|---|
5781 * fore: Foreground color in DW_RGB format or a default color index. | 5781 * fore: Foreground color in DW_RGB format or a default color index. |
5782 * back: Background color in DW_RGB format or a default color index. | 5782 * back: Background color in DW_RGB format or a default color index. |
5783 */ | 5783 */ |
5784 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) | 5784 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
5785 { | 5785 { |
5786 id object = handle; | 5786 id object = handle; |
5787 unsigned long _fore = _get_color(fore); | 5787 unsigned long _fore = _get_color(fore); |
5788 unsigned long _back = _get_color(back); | 5788 unsigned long _back = _get_color(back); |
5789 | 5789 NSColor *fg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]; |
5790 if([object isMemberOfClass:[NSTextFieldCell class]]) | 5790 NSColor *bg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_back)/255.0 green: DW_GREEN_VALUE(_back)/255.0 blue: DW_BLUE_VALUE(_back)/255.0 alpha: 1]; |
5791 { | 5791 |
5792 NSTextFieldCell *text = object; | 5792 if([object isMemberOfClass:[NSTextFieldCell class]]) |
5793 [text setTextColor:[NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]]; | 5793 { |
5794 } | 5794 NSTextFieldCell *text = object; |
5795 else if([object isMemberOfClass:[DWBox class]]) | 5795 [text setTextColor:fg]; |
5796 { | 5796 } |
5797 else if([object isMemberOfClass:[DWBox class]]) | |
5798 { | |
5797 DWBox *box = object; | 5799 DWBox *box = object; |
5798 | 5800 |
5799 [box setColor:_back]; | 5801 [box setColor:_back]; |
5800 } | 5802 } |
5801 return 0; | 5803 else if([object isMemberOfClass:[DWButton class]]) |
5804 { | |
5805 DWButton *button = object; | |
5806 | |
5807 [[button cell] setBackgroundColor:bg]; | |
5808 } | |
5809 return 0; | |
5802 } | 5810 } |
5803 | 5811 |
5804 /* | 5812 /* |
5805 * Sets the font used by a specified window (widget) handle. | 5813 * Sets the font used by a specified window (widget) handle. |
5806 * Parameters: | 5814 * Parameters: |
5971 { | 5979 { |
5972 [object lockFocus]; | 5980 [object lockFocus]; |
5973 [font set]; | 5981 [font set]; |
5974 [object unlockFocus]; | 5982 [object unlockFocus]; |
5975 } | 5983 } |
5976 if([object isMemberOfClass:[NSControl class]]) | 5984 if([object isKindOfClass:[NSControl class]]) |
5977 { | 5985 { |
5978 [object setFont:font]; | 5986 [object setFont:font]; |
5979 } | 5987 } |
5980 } | 5988 } |
5981 } | 5989 } |
5988 * Parameters: | 5996 * Parameters: |
5989 * handle: The window handle from which to obtain the font. | 5997 * handle: The window handle from which to obtain the font. |
5990 */ | 5998 */ |
5991 char * API dw_window_get_font(HWND handle) | 5999 char * API dw_window_get_font(HWND handle) |
5992 { | 6000 { |
5993 NSLog(@"dw_window_get_font() unimplemented\n"); | 6001 id object = handle; |
5994 return "8.Monaco"; | 6002 |
6003 if([object isKindOfClass:[NSControl class]]) | |
6004 { | |
6005 NSControl *control = object; | |
6006 NSFont *font = [control font]; | |
6007 NSString *fontname = [font fontName]; | |
6008 NSString *output = [NSString stringWithFormat:@"%d.%s", (int)[font pointSize], [fontname UTF8String]]; | |
6009 return strdup([output UTF8String]); | |
6010 } | |
6011 return NULL; | |
5995 } | 6012 } |
5996 | 6013 |
5997 /* | 6014 /* |
5998 * Destroys a window and all of it's children. | 6015 * Destroys a window and all of it's children. |
5999 * Parameters: | 6016 * Parameters: |