Mercurial > dwindows
changeset 1564:d84a690448c3
Attempted fix at border calculation on Mac for status text fields.
Subclass the text fields so user data can be set on those widgets.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 17 Jan 2012 21:04:56 +0000 |
parents | 90fdfc8aa16d |
children | 007ed833ac79 |
files | mac/dw.m |
diffstat | 1 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Tue Jan 17 18:36:39 2012 +0000 +++ b/mac/dw.m Tue Jan 17 21:04:56 2012 +0000 @@ -1160,6 +1160,23 @@ -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } @end +/* Subclass for a text and status text type */ +@interface DWText : NSTextField +{ + void *userdata; + id clickDefault; +} +-(void *)userdata; +-(void)setUserdata:(void *)input; +@end + +@implementation DWText +-(void *)userdata { return userdata; } +-(void)setUserdata:(void *)input { userdata = input; } +-(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } +@end + + /* Subclass for a entryfield password type */ @interface DWEntryFieldPassword : NSSecureTextField { @@ -3625,22 +3642,25 @@ else if([ object isKindOfClass:[ NSControl class ] ]) nsstr = [object stringValue]; + /* If we have a string... + * calculate the size with the current font. + */ + if(nsstr && [nsstr length]) + dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); + /* Handle static text fields */ if([object isKindOfClass:[ NSTextField class ]] && ![object isEditable]) { /* Handle status bar field */ if([object isBordered] || (DWOSMinor > 5 && [object isBezeled])) + { extrawidth = 12; + extraheight = 4; + } else extrawidth = 10; } - /* If we have a string... - * calculate the size with the current font. - */ - if(nsstr && [nsstr length]) - dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); - /* Set the requested sizes */ if(width) *width = thiswidth + extrawidth; @@ -5046,7 +5066,7 @@ */ HWND API dw_text_new(char *text, ULONG cid) { - NSTextField *textfield = [[NSTextField alloc] init]; + DWText *textfield = [[DWText alloc] init]; [textfield setEditable:NO]; [textfield setSelectable:NO]; [textfield setBordered:NO];