Let NSStepperCell respect colour settings.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22700 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2006-03-24 00:00:27 +00:00
parent e4f615e760
commit f427f9482b
4 changed files with 88 additions and 105 deletions

View file

@ -1,3 +1,13 @@
2006-03-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSStepperCell.m: Rewrote all button drawing functions to
use new helper function DrawLightButton to honour colour settings.
Based on patch idea by Ingolf Jandt <i.jandt@web.de>.
* Source/NSStepperCell.m (-highlight:upButton:withFrame:inView:):
Simplified to use [drawWithFrame:inView:].
* Source/NSColorPanel.m (-_initWithoutGModel): Enable colour wells
in bottom list.
2006-03-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSMenuView.m: ([-rectOfItemAtIndex:]) remove unused code and

View file

@ -129,6 +129,8 @@ NSResponder.m \
NSRulerMarker.m \
NSRulerView.m \
NSSavePanel.m \
NSSearchField.m \
NSSearchFieldCell.m \
NSScreen.m \
NSScroller.m \
NSScrollView.m \
@ -295,6 +297,8 @@ NSResponder.h \
NSRulerMarker.h \
NSRulerView.h \
NSSavePanel.h \
NSSearchField.h \
NSSearchFieldCell.h \
NSScreen.h \
NSScrollView.h \
NSScroller.h \

View file

@ -323,7 +323,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
well = [[NSColorWell alloc] initWithFrame: NSMakeRect(i * 13 + 5, 5, 12, 12)];
[well setColor: colour];
[well setBordered: NO];
[well setEnabled: NO];
[well setEnabled: YES];
[well setTarget: _colorWell];
[well setAction: @selector(_bottomWellAction:)];
[swatchView addSubview: well];

View file

@ -32,6 +32,7 @@
#include "AppKit/NSGraphics.h"
#include "AppKit/NSStepperCell.h"
#include "AppKit/NSText.h"
#include "GNUstepGUI/GSDrawFunctions.h"
@implementation NSStepperCell
+ (void) initialize
@ -124,21 +125,37 @@
return c;
}
static inline void DrawUpButton(NSRect aRect)
static inline NSRect DrawLightButton(NSRect border, NSRect clip)
{
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite,
NSDarkGray, NSDarkGray};
NSRect rect;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
rect = NSDrawTiledRects(aRect, NSZeroRect,
up_sides, grays, 4);
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
/*
NSRect highlightRect = NSInsetRect(border, 1., 1.);
[GSDrawFunctions drawButton: border : clip];
return highlightRect;
*/
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
NSMinXEdge, NSMaxYEdge};
NSRectEdge dn_sides[] = {NSMaxXEdge, NSMaxYEdge,
NSMinXEdge, NSMinYEdge};
// These names are role names not the actual colours
NSColor *dark = [NSColor controlShadowColor];
NSColor *white = [NSColor controlLightHighlightColor];
NSColor *colors[] = {dark, dark, white, white};
if ([[NSView focusView] isFlipped] == YES)
{
return NSDrawColorTiledRects(border, clip, dn_sides, colors, 4);
}
else
{
return NSDrawColorTiledRects(border, clip, up_sides, colors, 4);
}
}
static inline void DrawUpButton(NSRect aRect)
{
NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetgray(NSDarkGray);
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
@ -156,20 +173,10 @@ static inline void DrawUpButton(NSRect aRect)
static inline void HighlightUpButton(NSRect aRect)
{
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite,
NSDarkGray, NSDarkGray};
NSRect rect;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
NSRect highlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
rect = NSDrawTiledRects(aRect, NSZeroRect,
up_sides, grays, 4);
DPSsetgray(ctxt, NSWhite);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
PSsetgray(NSLightGray);
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
@ -186,19 +193,9 @@ static inline void HighlightUpButton(NSRect aRect)
static inline void DrawDownButton(NSRect aRect)
{
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite,
NSDarkGray, NSDarkGray};
NSRect rect;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
rect = NSDrawTiledRects(aRect, NSZeroRect,
up_sides, grays, 4);
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetlinewidth(1.0);
PSsetgray(NSDarkGray);
@ -217,19 +214,9 @@ static inline void DrawDownButton(NSRect aRect)
static inline void HighlightDownButton(NSRect aRect)
{
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite,
NSDarkGray, NSDarkGray};
NSRect rect;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
rect = NSDrawTiledRects(aRect, NSZeroRect,
up_sides, grays, 4);
DPSsetgray(ctxt, NSWhite);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
NSRect highlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
PSsetlinewidth(1.0);
PSsetgray(NSLightGray);
@ -252,35 +239,31 @@ static inline void HighlightDownButton(NSRect aRect)
NSRect upRect;
NSRect downRect;
NSRect twoButtons;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
upRect = [self upButtonRectWithFrame: cellFrame];
downRect = [self downButtonRectWithFrame: cellFrame];
twoButtons = downRect;
twoButtons.origin.y--;
twoButtons.size.width++;
twoButtons.size.height = 23;
if (highlightUp)
HighlightUpButton(upRect);
else
DrawUpButton(upRect);
if (highlightDown)
HighlightDownButton(downRect);
else
DrawDownButton(downRect);
{
upRect = [self upButtonRectWithFrame: cellFrame];
downRect = [self downButtonRectWithFrame: cellFrame];
twoButtons = downRect;
twoButtons.origin.y--;
twoButtons.size.width++;
twoButtons.size.height = 23;
if (highlightUp)
HighlightUpButton(upRect);
else
DrawUpButton(upRect);
if (highlightDown)
HighlightDownButton(downRect);
else
DrawDownButton(downRect);
{
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
float grays[] = {NSBlack, NSBlack};
NSDrawTiledRects(twoButtons, NSZeroRect,
up_sides, grays, 2);
}
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
float grays[] = {NSBlack, NSBlack};
NSDrawTiledRects(twoButtons, NSZeroRect,
up_sides, grays, 2);
}
}
@ -289,30 +272,16 @@ static inline void HighlightDownButton(NSRect aRect)
withFrame: (NSRect) frame
inView: (NSView*) controlView
{
NSRect upRect;
NSRect downRect;
NSGraphicsContext *ctxt;
ctxt = GSCurrentContext();
{
upRect = [self upButtonRectWithFrame: frame];
downRect = [self downButtonRectWithFrame: frame];
if (upButton)
{
highlightUp = highlight;
if (highlightUp)
HighlightUpButton(upRect);
else
DrawUpButton(upRect);
}
else
{
highlightDown = highlight;
if (highlightDown)
HighlightDownButton(downRect);
else
DrawDownButton(downRect);
}
}
if (upButton)
{
highlightUp = highlight;
}
else
{
highlightDown = highlight;
}
[self drawWithFrame: frame inView: controlView];
}
- (NSRect) upButtonRectWithFrame: (NSRect) frame