Corrected bezel drawing and keyed archiving of popup menu item cell.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18560 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-02-08 13:07:24 +00:00
parent 27ed3ba5e0
commit 75dc38c6aa
4 changed files with 92 additions and 19 deletions

View file

@ -1,3 +1,12 @@
2004-02-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/Function.m
Corrected NSDrawWhiteBezel(), NSDrawDarkBezel() and
NSDrawLightBezel() to be almost identical to their Cocoa counterparts.
* Source/NSMenuItemCell.m
* Source/NSPopUpButtonCell.m
Corrected keyed decoding.
2004-02-08 01:36 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSNib.m: Added implmentation for this class.

View file

@ -645,12 +645,12 @@ NSDrawGroove(const NSRect aRect, const NSRect clipRect)
void
NSDrawWhiteBezel(const NSRect aRect, const NSRect clipRect)
{
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge};
NSRectEdge down_sides[] = {NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge,
NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite, NSDarkGray, NSDarkGray,
NSLightGray, NSLightGray, NSDarkGray, NSDarkGray};
NSRectEdge up_sides[] = {NSMaxYEdge, NSMaxXEdge, NSMinYEdge, NSMinXEdge,
NSMaxYEdge, NSMaxXEdge, NSMinYEdge, NSMinXEdge};
NSRectEdge down_sides[] = {NSMinYEdge, NSMaxXEdge, NSMaxYEdge, NSMinXEdge,
NSMinYEdge, NSMaxXEdge, NSMaxYEdge, NSMinXEdge};
float grays[] = {NSDarkGray, NSWhite, NSWhite, NSDarkGray,
NSDarkGray, NSLightGray, NSLightGray, NSDarkGray};
NSRect rect;
NSGraphicsContext *ctxt = GSCurrentContext();
@ -673,15 +673,75 @@ NSDrawWhiteBezel(const NSRect aRect, const NSRect clipRect)
void
NSDrawDarkBezel(NSRect aRect, NSRect clipRect)
{
// FIXME
NSDrawGrayBezel(aRect, clipRect);
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge};
NSRectEdge down_sides[] = {NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge,
NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge};
// FIXME: The actual colour used for the 3 + 4 line
// (and the two additional points) is a bit darker.
float grays[] = {NSWhite, NSWhite, NSLightGray, NSLightGray,
NSLightGray, NSLightGray, NSBlack, NSBlack};
NSRect rect;
NSGraphicsContext *ctxt = GSCurrentContext();
if (GSWViewIsFlipped(ctxt) == YES)
{
rect = NSDrawTiledRects(aRect, clipRect,
down_sides, grays, 8);
// to give a really clean look we add 2 light gray points
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(aRect) + 1., NSMaxY(aRect) - 2., 1., 1.);
DPSrectfill(ctxt, NSMaxX(aRect) - 2., NSMinY(aRect) + 1., 1., 1.);
}
else
{
rect = NSDrawTiledRects(aRect, clipRect,
up_sides, grays, 8);
// to give a really clean look we add 2 light gray points
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(aRect) + 1., NSMinY(aRect) + 1., 1., 1.);
DPSrectfill(ctxt, NSMaxX(aRect) - 2., NSMaxY(aRect) - 2., 1., 1.);
}
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
}
void
NSDrawLightBezel(NSRect aRect, NSRect clipRect)
{
// FIXME
NSDrawWhiteBezel(aRect, clipRect);
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge,
NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge};
NSRectEdge down_sides[] = {NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge,
NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge};
float grays[] = {NSWhite, NSWhite, NSGray, NSGray,
NSBlack, NSBlack, NSBlack, NSBlack};
NSRect rect;
NSGraphicsContext *ctxt = GSCurrentContext();
if (GSWViewIsFlipped(ctxt) == YES)
{
rect = NSDrawTiledRects(aRect, clipRect,
down_sides, grays, 8);
// to give a really clean look we add 2 light gray points
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(aRect), NSMaxY(aRect) - 1., 1., 1.);
DPSrectfill(ctxt, NSMaxX(aRect) - 1., NSMinY(aRect), 1., 1.);
}
else
{
rect = NSDrawTiledRects(aRect, clipRect,
up_sides, grays, 8);
// to give a really clean look we add 2 light gray points
DPSsetgray(ctxt, NSLightGray);
DPSrectfill(ctxt, NSMinX(aRect), NSMinY(aRect), 1., 1.);
DPSrectfill(ctxt, NSMaxX(aRect) - 1., NSMaxY(aRect) - 1., 1., 1.);
}
DPSsetgray(ctxt, NSWhite);
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
}
void

View file

@ -642,16 +642,22 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
- (id) initWithCoder: (NSCoder*)aDecoder
{
[super initWithCoder: aDecoder];
self = [super initWithCoder: aDecoder];
ASSIGN (_menuItem, [aDecoder decodeObject]);
if ([aDecoder versionForClassName: @"NSMenuItemCell"] < 2)
if ([aDecoder allowsKeyedCoding])
{
/* In version 1, we used to encode the _menuView here. */
[aDecoder decodeObject];
[self setMenuItem: [aDecoder decodeObjectForKey: @"NSMenuItem"]];
}
else
{
ASSIGN (_menuItem, [aDecoder decodeObject]);
if ([aDecoder versionForClassName: @"NSMenuItemCell"] < 2)
{
/* In version 1, we used to encode the _menuView here. */
[aDecoder decodeObject];
}
}
_needs_sizing = YES;
return self;

View file

@ -812,7 +812,6 @@ static NSImage *_pbc_image[2];
- (id) initWithCoder: (NSCoder*)aDecoder
{
id<NSMenuItem> selectedItem;
NSMenu *menu;
self = [super initWithCoder: aDecoder];
@ -847,11 +846,11 @@ static NSImage *_pbc_image[2];
menu = [aDecoder decodeObjectForKey: @"NSMenu"];
[self setMenu: menu];
selectedItem = [aDecoder decodeObjectForKey: @"NSMenuItem"];
}
else
{
int flag;
id<NSMenuItem> selectedItem;
int version = [aDecoder versionForClassName:
@"NSPopUpButtonCell"];
@ -895,7 +894,6 @@ static NSImage *_pbc_image[2];
}
[self setEnabled: YES];
}
[self selectItem: selectedItem];
}
return self;