mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-21 00:30:58 +00:00
Simplified mask definition in [drawInteriorWithFrame:inView:] and
[cellSize]. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8454 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1b19044765
commit
7465643efd
1 changed files with 27 additions and 32 deletions
|
@ -370,26 +370,32 @@
|
||||||
case NSMomentaryLight:
|
case NSMomentaryLight:
|
||||||
[self setHighlightsBy: NSChangeBackgroundCellMask];
|
[self setHighlightsBy: NSChangeBackgroundCellMask];
|
||||||
[self setShowsStateBy: NSNoCellMask];
|
[self setShowsStateBy: NSNoCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSMomentaryPushButton:
|
case NSMomentaryPushButton:
|
||||||
[self setHighlightsBy: NSPushInCellMask | NSChangeGrayCellMask];
|
[self setHighlightsBy: NSPushInCellMask | NSChangeGrayCellMask];
|
||||||
[self setShowsStateBy: NSNoCellMask];
|
[self setShowsStateBy: NSNoCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSMomentaryChangeButton:
|
case NSMomentaryChangeButton:
|
||||||
[self setHighlightsBy: NSContentsCellMask];
|
[self setHighlightsBy: NSContentsCellMask];
|
||||||
[self setShowsStateBy: NSNoCellMask];
|
[self setShowsStateBy: NSNoCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSPushOnPushOffButton:
|
case NSPushOnPushOffButton:
|
||||||
[self setHighlightsBy: NSPushInCellMask | NSChangeGrayCellMask];
|
[self setHighlightsBy: NSPushInCellMask | NSChangeGrayCellMask];
|
||||||
[self setShowsStateBy: NSChangeBackgroundCellMask];
|
[self setShowsStateBy: NSChangeBackgroundCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSOnOffButton:
|
case NSOnOffButton:
|
||||||
[self setHighlightsBy: NSChangeBackgroundCellMask];
|
[self setHighlightsBy: NSChangeBackgroundCellMask];
|
||||||
[self setShowsStateBy: NSChangeBackgroundCellMask];
|
[self setShowsStateBy: NSChangeBackgroundCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSToggleButton:
|
case NSToggleButton:
|
||||||
[self setHighlightsBy: NSPushInCellMask | NSContentsCellMask];
|
[self setHighlightsBy: NSPushInCellMask | NSContentsCellMask];
|
||||||
[self setShowsStateBy: NSContentsCellMask];
|
[self setShowsStateBy: NSContentsCellMask];
|
||||||
|
[self setImageDimsWhenDisabled: YES];
|
||||||
break;
|
break;
|
||||||
case NSSwitchButton:
|
case NSSwitchButton:
|
||||||
[self setHighlightsBy: NSContentsCellMask];
|
[self setHighlightsBy: NSContentsCellMask];
|
||||||
|
@ -398,6 +404,9 @@
|
||||||
[self setAlternateImage: [NSImage imageNamed: @"common_SwitchOn"]];
|
[self setAlternateImage: [NSImage imageNamed: @"common_SwitchOn"]];
|
||||||
[self setImagePosition: NSImageLeft];
|
[self setImagePosition: NSImageLeft];
|
||||||
[self setAlignment: NSLeftTextAlignment];
|
[self setAlignment: NSLeftTextAlignment];
|
||||||
|
[self setBordered: NO];
|
||||||
|
[self setBezeled: NO];
|
||||||
|
[self setImageDimsWhenDisabled: NO];
|
||||||
break;
|
break;
|
||||||
case NSRadioButton:
|
case NSRadioButton:
|
||||||
[self setHighlightsBy: NSContentsCellMask];
|
[self setHighlightsBy: NSContentsCellMask];
|
||||||
|
@ -406,6 +415,9 @@
|
||||||
[self setAlternateImage: [NSImage imageNamed: @"common_RadioOn"]];
|
[self setAlternateImage: [NSImage imageNamed: @"common_RadioOn"]];
|
||||||
[self setImagePosition: NSImageLeft];
|
[self setImagePosition: NSImageLeft];
|
||||||
[self setAlignment: NSLeftTextAlignment];
|
[self setAlignment: NSLeftTextAlignment];
|
||||||
|
[self setBordered: NO];
|
||||||
|
[self setBezeled: NO];
|
||||||
|
[self setImageDimsWhenDisabled: NO];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +508,6 @@
|
||||||
|
|
||||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
{
|
{
|
||||||
BOOL showAlternate = NO;
|
|
||||||
unsigned mask;
|
unsigned mask;
|
||||||
NSImage *imageToDisplay;
|
NSImage *imageToDisplay;
|
||||||
NSRect imageRect;
|
NSRect imageRect;
|
||||||
|
@ -517,30 +528,23 @@
|
||||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
|
|
||||||
|
if (_cell.is_highlighted)
|
||||||
|
mask = _highlightsByMask;
|
||||||
|
else if (_cell.state)
|
||||||
|
mask = _showAltStateMask;
|
||||||
|
else
|
||||||
|
mask = NSNoCellMask;
|
||||||
|
|
||||||
// pushed in buttons contents are displaced to the bottom right 1px
|
// pushed in buttons contents are displaced to the bottom right 1px
|
||||||
if (_cell.is_bordered && _cell.is_highlighted
|
if (_cell.is_bordered && (mask & NSPushInCellMask))
|
||||||
&& (_highlightsByMask & NSPushInCellMask))
|
|
||||||
{
|
{
|
||||||
cellFrame = NSOffsetRect(cellFrame, 1., flippedView ? 1. : -1.);
|
cellFrame = NSOffsetRect(cellFrame, 1., flippedView ? 1. : -1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine the background color
|
// determine the background color
|
||||||
if (_cell.state)
|
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||||
{
|
{
|
||||||
if (_showAltStateMask
|
backgroundColor = [NSColor selectedControlColor];
|
||||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
|
||||||
{
|
|
||||||
backgroundColor = [NSColor selectedControlColor];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_cell.is_highlighted)
|
|
||||||
{
|
|
||||||
if (_highlightsByMask
|
|
||||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
|
||||||
{
|
|
||||||
backgroundColor = [NSColor selectedControlColor];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backgroundColor == nil)
|
if (backgroundColor == nil)
|
||||||
|
@ -557,14 +561,7 @@
|
||||||
* if highlighting is set (when a button is pushed it's
|
* if highlighting is set (when a button is pushed it's
|
||||||
* content is changed to the face of reversed state).
|
* content is changed to the face of reversed state).
|
||||||
*/
|
*/
|
||||||
if (_cell.is_highlighted)
|
|
||||||
mask = _highlightsByMask;
|
|
||||||
else
|
|
||||||
mask = _showAltStateMask;
|
|
||||||
if (mask & NSContentsCellMask)
|
if (mask & NSContentsCellMask)
|
||||||
showAlternate = _cell.state;
|
|
||||||
|
|
||||||
if (showAlternate || _cell.is_highlighted)
|
|
||||||
{
|
{
|
||||||
imageToDisplay = _altImage;
|
imageToDisplay = _altImage;
|
||||||
if (!imageToDisplay)
|
if (!imageToDisplay)
|
||||||
|
@ -749,7 +746,6 @@
|
||||||
{
|
{
|
||||||
NSSize s;
|
NSSize s;
|
||||||
NSSize borderSize;
|
NSSize borderSize;
|
||||||
BOOL showAlternate = NO;
|
|
||||||
unsigned mask;
|
unsigned mask;
|
||||||
NSImage *imageToDisplay;
|
NSImage *imageToDisplay;
|
||||||
NSString *titleToDisplay;
|
NSString *titleToDisplay;
|
||||||
|
@ -758,16 +754,15 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following code must be kept in sync with -drawInteriorWithFrame
|
* The following code must be kept in sync with -drawInteriorWithFrame
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (_cell.is_highlighted)
|
if (_cell.is_highlighted)
|
||||||
mask = _highlightsByMask;
|
mask = _highlightsByMask;
|
||||||
else
|
else if (_cell.state)
|
||||||
mask = _showAltStateMask;
|
mask = _showAltStateMask;
|
||||||
|
else
|
||||||
|
mask = NSNoCellMask;
|
||||||
|
|
||||||
if (mask & NSContentsCellMask)
|
if (mask & NSContentsCellMask)
|
||||||
showAlternate = _cell.state;
|
|
||||||
|
|
||||||
if (showAlternate || _cell.is_highlighted)
|
|
||||||
{
|
{
|
||||||
imageToDisplay = _altImage;
|
imageToDisplay = _altImage;
|
||||||
if (!imageToDisplay)
|
if (!imageToDisplay)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue