* Source/NSButtonCell.m:

* Source/NSMenuItemCell.m: Make a shared -themeControlState in
NSButtonCell and eliminate duplicated code.
* Source/NSPopUpButtonCell.m: Add private declaration for
-[NSButtonCell themeControlState]


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37236 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2013-10-15 18:41:17 +00:00
parent 7e6fef4418
commit 74bd902874
4 changed files with 23 additions and 40 deletions

View file

@ -1,3 +1,11 @@
2013-10-15 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSButtonCell.m:
* Source/NSMenuItemCell.m: Make a shared -themeControlState in
NSButtonCell and eliminate duplicated code.
* Source/NSPopUpButtonCell.m: Add private declaration for
-[NSButtonCell themeControlState]
2013-10-15 Eric Wasylishen <ewasylishen@gmail.com>
* ColorPickers/GSColorSliderCell.m (-drawBarInside:flipped:):

View file

@ -933,7 +933,7 @@ typedef struct _GSButtonCellFlags
ASSIGN(_backgroundColor, color);
}
- (void) drawBezelWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
- (GSThemeControlState) themeControlState
{
unsigned mask;
GSThemeControlState buttonState = GSThemeNormalState;
@ -976,7 +976,8 @@ typedef struct _GSButtonCellFlags
first responder state. Note that GSThemeDisabledState
doesn't have a first responder variant, currently. */
if (_cell.shows_first_responder
&& [[controlView window] firstResponder] == controlView)
&& [[[self controlView] window] firstResponder] == [self controlView]
&& [self controlView] != nil)
{
if (buttonState == GSThemeSelectedState)
buttonState = GSThemeSelectedFirstResponderState;
@ -986,6 +987,13 @@ typedef struct _GSButtonCellFlags
buttonState = GSThemeFirstResponderState;
}
return buttonState;
}
- (void) drawBezelWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
GSThemeControlState buttonState = [self themeControlState];
[[GSTheme theme] drawButton: cellFrame
in: self
view: controlView

View file

@ -54,6 +54,10 @@ static NSString *alternateKeyString = @"+";
static NSString *shiftKeyString = @"/";
static NSString *commandKeyString = @"#";
@interface NSMenuItemCell (Private)
- (GSThemeControlState) themeControlState;
@end
@implementation NSMenuItemCell
+ (void) initialize
@ -666,43 +670,6 @@ static NSString *commandKeyString = @"#";
}
}
- (GSThemeControlState) themeControlState
{
unsigned mask;
GSThemeControlState state = GSThemeNormalState;
// set the mask
if (_cell.is_highlighted)
{
mask = _highlightsByMask;
if (_cell.state)
{
mask &= ~_showAltStateMask;
}
}
else if (_cell.state)
mask = _showAltStateMask;
else
mask = NSNoCellMask;
/* Determine the background color.
We draw when there is a border or when highlightsByMask
is NSChangeBackgroundCellMask or NSChangeGrayCellMask,
as required by our nextstep-like look and feel. */
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
{
state = GSThemeHighlightedState;
}
/* Pushed in buttons contents are displaced to the bottom right 1px. */
if (mask & NSPushInCellMask)
{
state = GSThemeSelectedState;
}
return state;
}
//
// Drawing.
//

View file

@ -48,7 +48,7 @@
* and so on. */
static NSImage *_pbc_image[5];
@interface NSMenuItemCell (Private)
@interface NSButtonCell (Private)
- (GSThemeControlState) themeControlState;
@end