mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 00:20:49 +00:00
Made all the button, bezel and groove methods functions again.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9781 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bd27fa12ac
commit
7a49124373
5 changed files with 187 additions and 441 deletions
|
@ -856,23 +856,13 @@ NSGraphicsContext *GSCurrentContext()
|
|||
GET_IMP(@selector(NSRectFillList::));
|
||||
methodTable.NSRectFillListWithGrays___ =
|
||||
GET_IMP(@selector(NSRectFillListWithGrays:::));
|
||||
methodTable.NSRectFillUsingOperation__ =
|
||||
GET_IMP(@selector(NSRectFillUsingOperation::));
|
||||
|
||||
/*
|
||||
* Draw a Bordered Rectangle
|
||||
*/
|
||||
|
||||
methodTable.NSDrawButton__ =
|
||||
GET_IMP(@selector(NSDrawButton::));
|
||||
methodTable.NSDrawGrayBezel__ =
|
||||
GET_IMP(@selector(NSDrawGrayBezel::));
|
||||
methodTable.NSDrawBezel__ =
|
||||
GET_IMP(@selector(NSDrawBezel::));
|
||||
methodTable.NSDrawGroove__ =
|
||||
GET_IMP(@selector(NSDrawGroove::));
|
||||
methodTable.NSDrawTiledRects_____ =
|
||||
GET_IMP(@selector(NSDrawTiledRects:::::));
|
||||
methodTable.NSDrawWhiteBezel__ =
|
||||
GET_IMP(@selector(NSDrawWhiteBezel::));
|
||||
methodTable.NSDottedFrameRect_ =
|
||||
GET_IMP(@selector(NSDottedFrameRect:));
|
||||
methodTable.NSFrameRect_ =
|
||||
|
@ -2502,371 +2492,16 @@ NSGraphicsContext *GSCurrentContext()
|
|||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Draws an unfilled rectangle, clipped by clipRect, whose border
|
||||
// is defined by the parallel arrays sides and grays, both of length
|
||||
// count. Each element of sides specifies an edge of the rectangle,
|
||||
// which is drawn with a width of 1.0 using the corresponding gray level
|
||||
// from grays. If the edges array contains recurrences of the same edge,
|
||||
// each is inset within the previous edge.
|
||||
//
|
||||
//*****************************************************************************
|
||||
- (NSRect) NSDrawTiledRects: (NSRect) aRect : (const NSRect) clipRect
|
||||
: (const NSRectEdge *) sides
|
||||
: (const float *)grays : (int) count
|
||||
- (void) NSRectFillUsingOperation: (NSRect) aRect : (NSCompositingOperation) op;
|
||||
{
|
||||
int i;
|
||||
NSRect slice;
|
||||
NSRect remainder = aRect;
|
||||
NSRect rects[count];
|
||||
BOOL hasClip = !NSIsEmptyRect(clipRect);
|
||||
|
||||
if (hasClip && NSIntersectsRect(aRect, clipRect) == NO)
|
||||
return remainder;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSDivideRect(remainder, &slice, &remainder, 1.0, sides[i]);
|
||||
if (hasClip)
|
||||
rects[i] = NSIntersectionRect(slice, clipRect);
|
||||
else
|
||||
rects[i] = slice;
|
||||
}
|
||||
|
||||
NSRectFillListWithGrays(rects, grays, count);
|
||||
|
||||
return remainder;
|
||||
// FIXME:
|
||||
NSRectFill(aRect);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a Bordered Rectangle
|
||||
*/
|
||||
- (void) NSDrawButton: (const NSRect) aRect : (const NSRect) clipRect
|
||||
{
|
||||
#if 1
|
||||
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge,
|
||||
NSMaxXEdge, NSMinYEdge,
|
||||
NSMaxXEdge, NSMinYEdge};
|
||||
NSRectEdge down_sides[] = {NSMinXEdge, NSMinYEdge,
|
||||
NSMaxXEdge, NSMaxYEdge,
|
||||
NSMaxXEdge, NSMaxYEdge};
|
||||
float grays[] = {NSWhite, NSWhite,
|
||||
NSBlack, NSBlack,
|
||||
NSDarkGray, NSDarkGray};
|
||||
NSRect rect;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 6);
|
||||
}
|
||||
|
||||
DPSsetgray(self, NSLightGray);
|
||||
DPSrectfill(self, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
#else
|
||||
float x, y, w, h, v;
|
||||
|
||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||
return;
|
||||
|
||||
/* The lines drawn should be offset by half a linewidth inwards so
|
||||
that the entire line gets drawn inside the rectangle. */
|
||||
x = NSMinX(aRect);
|
||||
y = NSMinY(aRect);
|
||||
w = NSWidth(aRect) - 1.0;
|
||||
h = NSHeight(aRect) - 1.0;
|
||||
v = 1.0;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
y += h;
|
||||
h = -h;
|
||||
v = -v;
|
||||
}
|
||||
else
|
||||
y++;
|
||||
|
||||
DPSsetlinewidth(self, 1.0);
|
||||
|
||||
// Fill the inner rectangle in light gray
|
||||
DPSsetgray(self, 0.667);
|
||||
DPSrectfill(self, x, y, w, h);
|
||||
|
||||
// Top and left outer line in white
|
||||
DPSsetgray(self, 1.0);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, 0, h);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right inner line in dark grey
|
||||
DPSsetgray(self, 0.333);
|
||||
DPSmoveto(self, x+1, y+v);
|
||||
DPSrlineto(self, w-2, 0);
|
||||
DPSrlineto(self, 0, h-2*v);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right outer line in black
|
||||
DPSsetgray(self, 0.0);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSrlineto(self, 0, h);
|
||||
DPSstroke(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) NSDrawGrayBezel: (const NSRect) aRect : (const NSRect) clipRect
|
||||
{
|
||||
#if 1
|
||||
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge, NSMinXEdge, NSMaxYEdge,
|
||||
NSMaxXEdge, NSMinYEdge, NSMaxXEdge, NSMinYEdge};
|
||||
NSRectEdge down_sides[] = {NSMinXEdge, NSMinYEdge, NSMinXEdge, NSMinYEdge,
|
||||
NSMaxXEdge, NSMaxYEdge, NSMaxXEdge, NSMaxYEdge};
|
||||
float grays[] = {NSDarkGray, NSDarkGray, NSBlack, NSBlack,
|
||||
NSWhite, NSWhite, NSLightGray, NSLightGray};
|
||||
NSRect rect;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(self, NSLightGray);
|
||||
DPSrectfill(self, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
#else
|
||||
float x, y, w, h, v;
|
||||
|
||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||
return;
|
||||
|
||||
/* The lines drawn should be offset by half a linewidth inwards so
|
||||
that the entire line gets drawn inside the rectangle. */
|
||||
x = NSMinX(aRect);
|
||||
y = NSMinY(aRect);
|
||||
w = NSWidth(aRect) - 1.0;
|
||||
h = NSHeight(aRect) - 1.0;
|
||||
v = 1.0;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
y += h;
|
||||
h = -h;
|
||||
v = -v;
|
||||
}
|
||||
else
|
||||
y++;
|
||||
|
||||
DPSsetlinewidth(self, 1.0);
|
||||
|
||||
// Fill the inner rectangle in light gray
|
||||
DPSsetgray(self, 0.667);
|
||||
DPSrectfill(self, x, y, w, h);
|
||||
|
||||
// Top and left outer line in dark grey
|
||||
DPSsetgray(self, 0.333);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, 0, h);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Top and left inner line in black
|
||||
DPSsetgray(self, 0.0);
|
||||
DPSmoveto(self, x+1, y+v);
|
||||
DPSrlineto(self, 0, h-2*v);
|
||||
DPSrlineto(self, w-2, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right outer line in white
|
||||
DPSsetgray(self, 1.0);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSrlineto(self, 0, h-v);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right inner line in light grey
|
||||
DPSsetgray(self, 0.667);
|
||||
DPSmoveto(self, x+1, y+v);
|
||||
DPSrlineto(self, w-2, 0);
|
||||
DPSrlineto(self, 0, h-2*v);
|
||||
DPSstroke(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) NSDrawBezel: (const NSRect) aRect : (const NSRect) clipRect
|
||||
{
|
||||
// This method is never called, but optimized away in NSGraphics.h
|
||||
NSDrawGrayBezel(aRect, clipRect);
|
||||
}
|
||||
|
||||
- (void) NSDrawGroove: (const NSRect) aRect : (const NSRect) clipRect
|
||||
{
|
||||
#if 1
|
||||
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge, NSMinXEdge, NSMaxYEdge,
|
||||
NSMaxXEdge, NSMinYEdge, NSMaxXEdge, NSMinYEdge};
|
||||
NSRectEdge down_sides[] = {NSMinXEdge, NSMinYEdge, NSMinXEdge, NSMinYEdge,
|
||||
NSMaxXEdge, NSMaxYEdge, NSMaxXEdge, NSMaxYEdge};
|
||||
float grays[] = {NSDarkGray, NSDarkGray, NSWhite, NSWhite,
|
||||
NSWhite, NSWhite, NSDarkGray, NSDarkGray};
|
||||
NSRect rect;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(self, NSLightGray);
|
||||
DPSrectfill(self, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
#else
|
||||
float x, y, w, h, v;
|
||||
|
||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||
return;
|
||||
|
||||
/* The lines drawn should be offset by half a linewidth inwards so
|
||||
that the entire line gets drawn inside the rectangle. */
|
||||
x = NSMinX(aRect);
|
||||
y = NSMinY(aRect);
|
||||
w = NSWidth(aRect) - 1.0;
|
||||
h = NSHeight(aRect) - 1.0;
|
||||
v = 1.0;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
y += h;
|
||||
h = -h;
|
||||
v = -v;
|
||||
}
|
||||
else
|
||||
y++;
|
||||
|
||||
DPSsetlinewidth(self, 1.0);
|
||||
|
||||
// Fill the inner rectangle in light gray
|
||||
DPSsetgray(self, 0.667);
|
||||
DPSrectfill(self, x, y, w, h);
|
||||
|
||||
// Top and left outer line in dark gray
|
||||
DPSsetgray(self, 0.333);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, 0, h);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right inner line in dark gray (too)
|
||||
DPSmoveto(self, x+2, y+v);
|
||||
DPSrlineto(self, w-3, 0);
|
||||
DPSrlineto(self, 0, h-3*v);
|
||||
DPSstroke(self);
|
||||
|
||||
// Draw remaining white lines using a single white rect
|
||||
DPSsetgray(self, 1.0);
|
||||
DPSrectstroke(self, x+1, y-v, w, h);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) NSDrawWhiteBezel: (const NSRect) aRect : (const NSRect) clipRect
|
||||
{
|
||||
#if 1
|
||||
NSRectEdge up_sides[] = {NSMinXEdge, NSMaxYEdge, NSMinXEdge, NSMaxYEdge,
|
||||
NSMaxXEdge, NSMinYEdge, NSMaxXEdge, NSMinYEdge};
|
||||
NSRectEdge down_sides[] = {NSMinXEdge, NSMinYEdge, NSMinXEdge, NSMinYEdge,
|
||||
NSMaxXEdge, NSMaxYEdge, NSMaxXEdge, NSMaxYEdge};
|
||||
float grays[] = {NSDarkGray, NSDarkGray, NSDarkGray, NSDarkGray,
|
||||
NSWhite, NSWhite, NSLightGray, NSLightGray};
|
||||
NSRect rect;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(self, NSWhite);
|
||||
DPSrectfill(self, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
#else
|
||||
float x, y, w, h, v;
|
||||
|
||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||
return;
|
||||
|
||||
/* The lines drawn should be offset by half a linewidth inwards so
|
||||
that the entire line gets drawn inside the rectangle. */
|
||||
x = NSMinX(aRect);
|
||||
y = NSMinY(aRect);
|
||||
w = NSWidth(aRect) - 1.0;
|
||||
h = NSHeight(aRect) - 1.0;
|
||||
v = 1.0;
|
||||
|
||||
if (GSWViewIsFlipped(self) == YES)
|
||||
{
|
||||
y += h;
|
||||
h = -h;
|
||||
v = -v;
|
||||
}
|
||||
else
|
||||
y++;
|
||||
|
||||
DPSsetlinewidth(self, 1.0);
|
||||
|
||||
// Fill the inner rectangle in white
|
||||
DPSsetgray(self, 1.0);
|
||||
DPSrectfill(self, x, y, w, h);
|
||||
|
||||
// Top and left outer line in dark grey
|
||||
DPSsetgray(self, 0.333);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, 0, h);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Top and left inner line in dark gray (too)
|
||||
DPSmoveto(self, x+1, y+v);
|
||||
DPSrlineto(self, 0, h-2*v);
|
||||
DPSrlineto(self, w-2, 0);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right outer line in white
|
||||
DPSsetgray(self, 1.0);
|
||||
DPSmoveto(self, x, y);
|
||||
DPSrlineto(self, w, 0);
|
||||
DPSrlineto(self, 0, h-v);
|
||||
DPSstroke(self);
|
||||
|
||||
// Bottom and right inner line in light grey
|
||||
DPSsetgray(self, 0.667);
|
||||
DPSmoveto(self, x+1, y+v);
|
||||
DPSrlineto(self, w-2, 0);
|
||||
DPSrlineto(self, 0, h-3*v);
|
||||
DPSstroke(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) NSDottedFrameRect: (const NSRect) aRect
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue