# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1326834296 0 # Node ID d84a690448c3d7d2ec937f83d7cd6f24c2f47c9b # Parent 90fdfc8aa16df900d12839c8cc810865bf6d246a Attempted fix at border calculation on Mac for status text fields. Subclass the text fields so user data can be set on those widgets. diff -r 90fdfc8aa16d -r d84a690448c3 mac/dw.m --- 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];