Author: mlytwyn Date: Sun Aug 9 18:55:04 2015 New Revision: 38866 URL: http://svn.gna.org/viewcvs/gnustep?rev=38866&view=rev Log: Use different button margins if requested (GSUseInternalThemeMargins)
Modified: plugins/themes/WinUXTheme/WinNSButton.m Modified: plugins/themes/WinUXTheme/WinNSButton.m URL: http://svn.gna.org/viewcvs/gnustep/plugins/themes/WinUXTheme/WinNSButton.m?rev=38866&r1=38865&r2=38866&view=diff ============================================================================== --- plugins/themes/WinUXTheme/WinNSButton.m (original) +++ plugins/themes/WinUXTheme/WinNSButton.m Sun Aug 9 18:55:04 2015 @@ -47,6 +47,16 @@ } } +- (NSRect)insetFrame:(NSRect)frame withMargins:(GSThemeMargins)margins +{ + NSRect result = frame; + result.origin.x += margins.left; + result.origin.y += margins.bottom; + result.size.width -= (margins.left + margins.right); + result.size.height -= (margins.top + margins.bottom); + return(result); +} + - (void) drawButton: (NSRect) frame in: (NSCell*) cell view: (NSView*) view @@ -65,9 +75,17 @@ HTHEME hTheme = [self themeWithClassName: @"button"]; int drawState = _ButtonStateForThemeControlState(state); + GSThemeMargins margins = [self buttonMarginsForCell: cell style: style state: state]; + NSRect drawFrame = [self insetFrame:frame withMargins:margins]; + +#if 0 + NSLog(@"%s:title: %@ frame: %@ drawFrame: %@", __PRETTY_FUNCTION__, [cell title], + NSStringFromRect(frame), NSStringFromRect(drawFrame)); +#endif + if (![self drawThemeBackground: hTheme - inRect: frame + inRect: drawFrame part: BP_PUSHBUTTON state: drawState]) { @@ -81,7 +99,63 @@ [self releaseTheme: hTheme]; } -- (GSThemeMargins) buttonMarginsForCell: (NSCell*)cell +- (GSThemeMargins) gsButtonMarginsForCell: (NSCell*)cell + style: (int)style + state: (GSThemeControlState)state +{ + GSThemeMargins margins = { 0 }; + + switch (style) + { + case NSRoundRectBezelStyle: + break; + case NSTexturedRoundedBezelStyle: + case NSRoundedBezelStyle: + { + if ([cell controlSize] == NSRegularControlSize) + { + margins.left = 10; margins.top = 8; margins.right = 10; margins.bottom = 8; + } + else if ([cell controlSize] == NSSmallControlSize) + { + margins.left = 8; margins.top = 6; margins.right = 8; margins.bottom = 6; + } + } + break; + case NSTexturedSquareBezelStyle: + margins.left = 3; margins.top = 3; margins.right = 3; margins.bottom = 3; + break; + case NSSmallSquareBezelStyle: + case NSRegularSquareBezelStyle: + case NSShadowlessSquareBezelStyle: + margins.left = 2; margins.top = 2; margins.right = 2; margins.bottom = 2; + break; + case NSThickSquareBezelStyle: + margins.left = 3; margins.top = 3; margins.right = 3; margins.bottom = 3; + break; + case NSThickerSquareBezelStyle: + margins.left = 4; margins.top = 4; margins.right = 4; margins.bottom = 4; + break; + case NSCircularBezelStyle: + margins.left = 5; margins.top = 5; margins.right = 5; margins.bottom = 5; + break; + case NSHelpButtonBezelStyle: + margins.left = 2; margins.top = 3; margins.right = 2; margins.bottom = 3; + break; + case NSDisclosureBezelStyle: + case NSRoundedDisclosureBezelStyle: + case NSRecessedBezelStyle: + // FIXME + margins.left = 0; margins.top = 0; margins.right = 0; margins.bottom = 0; + break; + default: + margins.left = 3; margins.top = 3; margins.right = 3; margins.bottom = 3; + break; + } + return margins; +} + +- (GSThemeMargins) windowsButtonMarginsForCell: (NSCell*)cell style: (int)style state: (GSThemeControlState)state { @@ -132,4 +206,15 @@ state: state]; } +- (GSThemeMargins) buttonMarginsForCell: (NSCell*)cell + style: (int)style + state: (GSThemeControlState)state +{ + NSUserDefaults *userDefs = [NSUserDefaults standardUserDefaults]; + + if ([userDefs boolForKey: @"GSUseInternalThemeMargins"]) + return [self gsButtonMarginsForCell: cell style: style state: state]; + return [self windowsButtonMarginsForCell: cell style: style state: state]; +} + @end _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs