mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +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
ed14212586
commit
dedbc0c159
5 changed files with 187 additions and 441 deletions
|
@ -536,18 +536,12 @@ typedef struct {
|
|||
void (*NSRectFillList__)(NSGraphicsContext*, SEL, const NSRect *rects, int count);
|
||||
void (*NSRectFillListWithGrays___)(NSGraphicsContext*, SEL, const NSRect *rects,
|
||||
const float *grays, int count);
|
||||
void (*NSRectFillUsingOperation__)(NSGraphicsContext*, SEL,
|
||||
NSRect aRect, NSCompositingOperation op);
|
||||
|
||||
/*
|
||||
* Draw a Bordered Rectangle
|
||||
*/
|
||||
void (*NSDrawButton__)(NSGraphicsContext*, SEL, const NSRect aRect, const NSRect clipRect);
|
||||
void (*NSDrawGrayBezel__)(NSGraphicsContext*, SEL, const NSRect aRect, const NSRect clipRect);
|
||||
void (*NSDrawBezel__)(NSGraphicsContext*, SEL, const NSRect aRect, const NSRect clipRect);
|
||||
void (*NSDrawGroove__)(NSGraphicsContext*, SEL, const NSRect aRect, const NSRect clipRect);
|
||||
NSRect (*NSDrawTiledRects_____)(NSGraphicsContext*, SEL, NSRect aRect, const NSRect clipRect,
|
||||
const NSRectEdge *sides, const float *grays,
|
||||
int count);
|
||||
void (*NSDrawWhiteBezel__)(NSGraphicsContext*, SEL, const NSRect aRect, const NSRect clipRect);
|
||||
void (*NSDottedFrameRect_)(NSGraphicsContext*, SEL, const NSRect aRect);
|
||||
void (*NSFrameRect_)(NSGraphicsContext*, SEL, const NSRect aRect);
|
||||
void (*NSFrameRectWithWidth__)(NSGraphicsContext*, SEL, const NSRect aRect, float frameWidth);
|
||||
|
|
|
@ -162,54 +162,19 @@ NSRectFillListWithGrays(const NSRect *rects,const float *grays,int count)
|
|||
(ctxt, @selector(NSRectFillListWithGrays:::), rects, grays, count);
|
||||
}
|
||||
|
||||
static inline void
|
||||
NSDrawButton(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSDrawButton__)
|
||||
(ctxt, @selector(NSDrawButton::), aRect, clipRect);
|
||||
}
|
||||
NSRect NSDrawTiledRects(NSRect aRect,const NSRect clipRect,
|
||||
const NSRectEdge * sides,
|
||||
const float *grays, int count);
|
||||
void NSDrawButton(const NSRect aRect, const NSRect clipRect);
|
||||
void NSDrawGrayBezel(const NSRect aRect, const NSRect clipRect);
|
||||
void NSDrawGroove(const NSRect aRect, const NSRect clipRect);
|
||||
void NSDrawWhiteBezel(const NSRect aRect, const NSRect clipRect);
|
||||
|
||||
// This is from an old version of the specification
|
||||
static inline void
|
||||
NSDrawGrayBezel(const NSRect aRect, const NSRect clipRect)
|
||||
NSDrawBezel(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSDrawGrayBezel__)
|
||||
(ctxt, @selector(NSDrawGrayBezel::), aRect, clipRect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
NSDrawGroove(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSDrawGroove__)
|
||||
(ctxt, @selector(NSDrawGroove::), aRect, clipRect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
NSDrawWhiteBezel(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSDrawWhiteBezel__)
|
||||
(ctxt, @selector(NSDrawWhiteBezel::), aRect, clipRect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
NSDrawBezel(NSRect aRect, NSRect clipRect)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSDrawGrayBezel__)
|
||||
(ctxt, @selector(NSDrawGrayBezel::), aRect, clipRect);
|
||||
}
|
||||
|
||||
static inline NSRect
|
||||
NSDrawTiledRects(NSRect boundsRect, NSRect clipRect,
|
||||
const NSRectEdge *sides, const float *grays, int count)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
return (ctxt->methods->NSDrawTiledRects_____)
|
||||
(ctxt, @selector(NSDrawTiledRects:::::), boundsRect, clipRect,
|
||||
sides, grays, count);
|
||||
NSDrawGrayBezel(aRect, clipRect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -352,7 +317,15 @@ NSRect NSDrawColorTiledRects(NSRect boundsRect, NSRect clipRect,
|
|||
void NSDrawDarkBezel(NSRect aRect, NSRect clipRect);
|
||||
void NSDrawLightBezel(NSRect aRect, NSRect clipRect);
|
||||
void NSRectFillListWithColors(const NSRect *rects, NSColor **colors, int count);
|
||||
void NSRectFillUsingOperation(NSRect aRect, NSCompositingOperation op);
|
||||
|
||||
static inline void
|
||||
NSRectFillUsingOperation(NSRect aRect, NSCompositingOperation op)
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
(ctxt->methods->NSRectFillUsingOperation__)
|
||||
(ctxt, @selector(NSRectFillUsingOperation::), aRect, op);
|
||||
}
|
||||
|
||||
void NSRectFillListUsingOperation(const NSRect *rects, int count,
|
||||
NSCompositingOperation op);
|
||||
void NSRectFillListWithColorsUsingOperation(const NSRect *rects,
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <Foundation/NSSet.h>
|
||||
|
||||
#include <AppKit/NSDragging.h>
|
||||
#include <AppKit/GSMethodTable.h>
|
||||
|
||||
|
||||
@class NSDate;
|
||||
|
@ -83,6 +82,10 @@ typedef enum _NSCompositingOperation
|
|||
|
||||
} NSCompositingOperation;
|
||||
|
||||
// We have to load this after the NSCompositingOperation are defined!!!
|
||||
#include <AppKit/GSMethodTable.h>
|
||||
|
||||
|
||||
/*
|
||||
* Window ordering
|
||||
*/
|
||||
|
@ -463,18 +466,11 @@ NSGraphicsContext *GSCurrentContext();
|
|||
- (void) NSRectFillList: (const NSRect *)rects : (int) count;
|
||||
- (void) NSRectFillListWithGrays: (const NSRect *)rects : (const float *)grays
|
||||
:(int) count;
|
||||
- (NSRect) NSDrawTiledRects: (NSRect) aRect : (const NSRect) clipRect
|
||||
: (const NSRectEdge *) sides
|
||||
: (const float *)grays : (int) count;
|
||||
- (void) NSRectFillUsingOperation: (NSRect) aRect : (NSCompositingOperation) op;
|
||||
|
||||
/*
|
||||
* Draw a Bordered Rectangle
|
||||
*/
|
||||
- (void) NSDrawButton: (const NSRect) aRect : (const NSRect) clipRect;
|
||||
- (void) NSDrawGrayBezel: (const NSRect) aRect : (const NSRect) clipRect;
|
||||
- (void) NSDrawBezel: (const NSRect) aRect : (const NSRect) clipRect;
|
||||
- (void) NSDrawGroove: (const NSRect) aRect : (const NSRect) clipRect;
|
||||
- (void) NSDrawWhiteBezel: (const NSRect) aRect : (const NSRect) clipRect;
|
||||
- (void) NSDottedFrameRect: (const NSRect) aRect;
|
||||
- (void) NSFrameRect: (const NSRect) aRect;
|
||||
- (void) NSFrameRectWithWidth: (const NSRect) aRect : (float) frameWidth;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <AppKit/NSGraphicsContext.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/DPSOperators.h>
|
||||
|
||||
#ifdef STRICT_OPENSTEP
|
||||
// This is used for the old text functions.
|
||||
|
@ -317,13 +318,6 @@ NSRectFillListWithColors(const NSRect *rects, NSColor **colors, int count)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
NSRectFillUsingOperation(NSRect aRect, NSCompositingOperation op)
|
||||
{
|
||||
// FIXME
|
||||
NSRectFill(aRect);
|
||||
}
|
||||
|
||||
void
|
||||
NSRectFillListUsingOperation(const NSRect *rects, int count,
|
||||
NSCompositingOperation op)
|
||||
|
@ -352,6 +346,45 @@ NSRectFillListWithColorsUsingOperation(const NSRect *rects,
|
|||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
NSRect
|
||||
NSDrawColorTiledRects(NSRect boundsRect, NSRect clipRect,
|
||||
const NSRectEdge *sides, NSColor **colors,
|
||||
|
@ -380,6 +413,121 @@ NSDrawColorTiledRects(NSRect boundsRect, NSRect clipRect,
|
|||
return remainder;
|
||||
}
|
||||
|
||||
void
|
||||
NSDrawButton(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
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;
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
if (GSWViewIsFlipped(ctxt) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 6);
|
||||
}
|
||||
|
||||
DPSsetgray(ctxt, NSLightGray);
|
||||
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
}
|
||||
|
||||
void
|
||||
NSDrawGrayBezel(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
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;
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
if (GSWViewIsFlipped(ctxt) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(ctxt, NSLightGray);
|
||||
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
}
|
||||
|
||||
void
|
||||
NSDrawGroove(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
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;
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
if (GSWViewIsFlipped(ctxt) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(ctxt, NSLightGray);
|
||||
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
}
|
||||
|
||||
void
|
||||
NSDrawWhiteBezel(const NSRect aRect, const NSRect clipRect)
|
||||
{
|
||||
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;
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
if (GSWViewIsFlipped(ctxt) == YES)
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
down_sides, grays, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = NSDrawTiledRects(aRect, clipRect,
|
||||
up_sides, grays, 8);
|
||||
}
|
||||
|
||||
DPSsetgray(ctxt, NSWhite);
|
||||
DPSrectfill(ctxt, NSMinX(rect), NSMinY(rect),
|
||||
NSWidth(rect), NSHeight(rect));
|
||||
}
|
||||
|
||||
void
|
||||
NSDrawDarkBezel(NSRect aRect, NSRect clipRect)
|
||||
{
|
||||
|
|
|
@ -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…
Reference in a new issue