mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +00:00
Implemented the button, bezel and groove drawing with
NSDrawTiledRects. The old implemention is still here. It should be deleted later on. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9749 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
046f1f19b5
commit
0bb86e273d
1 changed files with 105 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <Foundation/NSGeometry.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
|
@ -2543,6 +2544,33 @@ NSGraphicsContext *GSCurrentContext()
|
||||||
*/
|
*/
|
||||||
- (void) NSDrawButton: (const NSRect) aRect : (const NSRect) clipRect
|
- (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;
|
float x, y, w, h, v;
|
||||||
|
|
||||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||||
|
@ -2591,10 +2619,35 @@ NSGraphicsContext *GSCurrentContext()
|
||||||
DPSrlineto(self, w, 0);
|
DPSrlineto(self, w, 0);
|
||||||
DPSrlineto(self, 0, h);
|
DPSrlineto(self, 0, h);
|
||||||
DPSstroke(self);
|
DPSstroke(self);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) NSDrawGrayBezel: (const NSRect) aRect : (const NSRect) clipRect
|
- (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;
|
float x, y, w, h, v;
|
||||||
|
|
||||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||||
|
@ -2650,15 +2703,41 @@ NSGraphicsContext *GSCurrentContext()
|
||||||
DPSrlineto(self, w-2, 0);
|
DPSrlineto(self, w-2, 0);
|
||||||
DPSrlineto(self, 0, h-2*v);
|
DPSrlineto(self, 0, h-2*v);
|
||||||
DPSstroke(self);
|
DPSstroke(self);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) NSDrawBezel: (const NSRect) aRect : (const NSRect) clipRect
|
- (void) NSDrawBezel: (const NSRect) aRect : (const NSRect) clipRect
|
||||||
{
|
{
|
||||||
|
// This method is never called, but optimized away in NSGraphics.h
|
||||||
NSDrawGrayBezel(aRect, clipRect);
|
NSDrawGrayBezel(aRect, clipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) NSDrawGroove: (const NSRect) aRect : (const NSRect) 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;
|
float x, y, w, h, v;
|
||||||
|
|
||||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||||
|
@ -2703,10 +2782,35 @@ NSGraphicsContext *GSCurrentContext()
|
||||||
// Draw remaining white lines using a single white rect
|
// Draw remaining white lines using a single white rect
|
||||||
DPSsetgray(self, 1.0);
|
DPSsetgray(self, 1.0);
|
||||||
DPSrectstroke(self, x+1, y-v, w, h);
|
DPSrectstroke(self, x+1, y-v, w, h);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) NSDrawWhiteBezel: (const NSRect) aRect : (const NSRect) clipRect
|
- (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;
|
float x, y, w, h, v;
|
||||||
|
|
||||||
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
if (!NSIsEmptyRect(clipRect) && NSIntersectsRect(aRect, clipRect) == NO)
|
||||||
|
@ -2761,6 +2865,7 @@ NSGraphicsContext *GSCurrentContext()
|
||||||
DPSrlineto(self, w-2, 0);
|
DPSrlineto(self, w-2, 0);
|
||||||
DPSrlineto(self, 0, h-3*v);
|
DPSrlineto(self, 0, h-3*v);
|
||||||
DPSstroke(self);
|
DPSstroke(self);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) NSDottedFrameRect: (const NSRect) aRect
|
- (void) NSDottedFrameRect: (const NSRect) aRect
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue