Move the colour well border drawing into GSTheme.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28986 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-11-09 18:00:54 +00:00
parent 17ef668924
commit 882cecd516
4 changed files with 68 additions and 50 deletions

View file

@ -1,3 +1,10 @@
2009-11-09 Fred Kiefer <FredKiefer@gmx.de>
* Headers/Additions/GNUstepGUI/GSTheme.h,
* Source/GSThemeDrawing.m,
* Source/NSColorWell.m: Move colour well border drawing into GSTheme.
This change makes the dragable area of the well a bit smaller.
2009-11-09 Fred Kiefer <FredKiefer@gmx.de>
* Headers/Additions/GNUstepGUI/GSTheme.h,

View file

@ -151,6 +151,7 @@
@class NSButton;
@class NSColor;
@class NSColorList;
@class NSColorWell;
@class NSDictionary;
@class NSImage;
@class NSMenuItemCell;
@ -707,6 +708,10 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
state: (GSThemeControlState)state
isHorizontal: (BOOL)isHorizontal;
// NSColorWell drawing method
- (NSRect) drawColorWellBorder: (NSColorWell*)well
withBounds: (NSRect)bounds
withClip: (NSRect)clipRect;
// Table drawing methods
- (void) drawTableCornerView: (NSView*)cornerView

View file

@ -34,6 +34,7 @@
#import "AppKit/NSCell.h"
#import "AppKit/NSColor.h"
#import "AppKit/NSColorList.h"
#import "AppKit/NSColorWell.h"
#import "AppKit/NSGraphics.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSMenuItemCell.h"
@ -728,6 +729,56 @@
}
}
// NSColorWell drawing method
- (NSRect) drawColorWellBorder: (NSColorWell*)well
withBounds: (NSRect)bounds
withClip: (NSRect)clipRect
{
NSRect aRect = bounds;
if ([well isBordered])
{
/*
* Draw border.
*/
[self drawButton: aRect withClip: clipRect];
/*
* Fill in control color.
*/
if ([well isActive])
{
[[NSColor selectedControlColor] set];
}
else
{
[[NSColor controlColor] set];
}
aRect = NSInsetRect(aRect, 2.0, 2.0);
NSRectFill(NSIntersectionRect(aRect, clipRect));
/*
* Set an inset rect for the color area
*/
aRect = NSInsetRect(bounds, 8.0, 8.0);
}
/*
* OpenStep 4.2 behavior is to omit the inner border for
* non-enabled NSColorWell objects.
*/
if ([well isEnabled])
{
/*
* Draw inner frame.
*/
[self drawGrayBezel: aRect withClip: clipRect];
aRect = NSInsetRect(aRect, 2.0, 2.0);
}
return aRect;
}
// Table drawing methods
- (void) drawTableCornerView: (NSView*)cornerView
withClip: (NSRect)aRect

View file

@ -166,60 +166,15 @@ static NSString *GSColorWellDidBecomeExclusiveNotification =
- (void) drawRect: (NSRect)clipRect
{
NSRect aRect = _bounds;
if (NSIntersectsRect(aRect, clipRect) == NO)
if (NSIntersectsRect(_bounds, clipRect) == NO)
{
return;
}
if (_is_bordered == YES)
{
/*
* Draw border.
*/
[[GSTheme theme] drawButton: aRect withClip: clipRect];
/*
* Fill in control color.
*/
aRect = NSInsetRect(aRect, 2.0, 2.0);
if (_is_active == YES)
{
[[NSColor selectedControlColor] set];
}
else
{
[[NSColor controlColor] set];
}
NSRectFill(NSIntersectionRect(aRect, clipRect));
/*
* Set an inset rect for the color area
*/
_wellRect = NSInsetRect(_bounds, 8.0, 8.0);
}
else
{
_wellRect = _bounds;
}
aRect = _wellRect;
/*
* OpenStep 4.2 behavior is to omit the inner border for
* non-enabled NSColorWell objects.
*/
if ([self isEnabled])
{
/*
* Draw inner frame.
*/
[[GSTheme theme] drawGrayBezel: aRect withClip: clipRect];
aRect = NSInsetRect(aRect, 2.0, 2.0);
}
[self drawWellInside: NSIntersectionRect(aRect, clipRect)];
_wellRect = [[GSTheme theme] drawColorWellBorder: self
withBounds: _bounds
withClip: clipRect];
[self drawWellInside: NSIntersectionRect(_wellRect, clipRect)];
}
/**<p>Draws the NSColorWell inside the rectangle <var>insideRect</var>.</p>