Extract cell border drawing into helper method.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24928 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-03-23 22:34:02 +00:00
parent c77c8ab90b
commit d00b0fcb89
5 changed files with 45 additions and 66 deletions

View file

@ -1,3 +1,12 @@
2007-03-23 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-drawWithFrame:inView:): Extract helper methods
for border and focus drawing.
* Source/NSButtonCell.m: Override the border drawing method.
* Source/NSMenuItemCell.m: Override the border drawing method and
set default focus ring to none.
* Source/NSPopupButtonCell.m: Set default focus ring to default.
2007-03-23 Sergii Stoian <stoyan255@gmail.com>
* Source/NSAlert.m: (-_initWithoutGModel): Set selected text

View file

@ -920,49 +920,13 @@ typedef struct _GSButtonCellFlags
inFrame: frame];
}
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
// Private helper method overridden in subclasses
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
// Save last view drawn to
if (_control_view != controlView)
_control_view = controlView;
// transparent buttons never draw
if (_buttoncell_is_transparent)
return;
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
if ((_cell.is_bordered)
&& (!_shows_border_only_while_mouse_inside || _mouse_inside))
{
[self drawBezelWithFrame: cellFrame inView: controlView];
}
[self drawInteriorWithFrame: cellFrame inView: controlView];
// Draw first responder
if (_cell.shows_first_responder
&& [[controlView window] firstResponder] == controlView)
{
switch (_cell.focus_ring_type)
{
case NSFocusRingTypeDefault:
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds:
cellFrame]
view: controlView];
break;
case NSFocusRingTypeExterior:
[[GSTheme theme] drawFocusFrame: cellFrame
view: controlView];
break;
case NSFocusRingTypeNone:
default:
break;
}
[self drawBezelWithFrame: cellFrame inView: controlView];
}
}

View file

@ -1994,15 +1994,9 @@ static NSColor *shadowCol;
// prettyfying
}
/**<p>Draws the cell in <var>controlView</var></p>
*/
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
// Private helper method overridden in subclasses
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
if (_cell.is_bordered)
{
[shadowCol set];
@ -2012,10 +2006,11 @@ static NSColor *shadowCol;
{
[[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect];
}
}
[self drawInteriorWithFrame: cellFrame inView: controlView];
// Draw first responder
// Private helper method
- (void) _drawFocusRingWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
if (_cell.shows_first_responder
&& [[controlView window] firstResponder] == controlView)
{
@ -2037,6 +2032,22 @@ static NSColor *shadowCol;
}
}
/**<p>Draws the cell in <var>controlView</var></p>
*/
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
// do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// draw the border if needed
[self _drawBorderAndBackgroundWithFrame: cellFrame inView: controlView];
// draw interior
[self drawInteriorWithFrame: cellFrame inView: controlView];
// Draw first responder
[self _drawFocusRingWithFrame: cellFrame inView: controlView];
}
/**<p>Sets whether the NSCell is highlighted.</p>
<p>See Also: -isHighlighted</p>
*/

View file

@ -59,6 +59,11 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
}
}
+ (NSFocusRingType) defaultFocusRingType
{
return NSFocusRingTypeNone;
}
- (id) init
{
[super init];
@ -742,24 +747,9 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
}
}
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
// Save last view drawn to
if (_control_view != controlView)
_control_view = controlView;
// Transparent buttons never draw
if (_buttoncell_is_transparent)
return;
// Do nothing if cell's frame rect is zero
if (NSIsEmptyRect(cellFrame))
return;
// Draw the border if needed
[self drawBorderAndBackgroundWithFrame: cellFrame inView: controlView];
[self drawInteriorWithFrame: cellFrame inView: controlView];
}
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView

View file

@ -56,6 +56,11 @@ static NSImage *_pbc_image[2];
return YES;
}
+ (NSFocusRingType) defaultFocusRingType
{
return NSFocusRingTypeDefault;
}
// Initialization
/**
* Initialize a blank cell.