diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2004-08-26 22:24:24 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2004-08-26 22:24:24 +0000 |
| commit | c29b4b5e16e87199846a0f97bc3bd2d80b6c0c07 (patch) | |
| tree | 921e93044d419a6efe403a644ad771a5663efd93 /src/fl_rect.cxx | |
| parent | 157bf815062e52baef3efc27d8e5d80bbc0cd093 (diff) | |
FLTK1.1 Quartz support:
- added a 'test/unittests' which wil check for identical drawing on all
platforms. This was desperatly needed to fix tremendous problems in
getting the Quartz drawing routines right
- disabled anti-aliasing for functions that draw straight lines at integer
coordinates
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3788 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_rect.cxx')
| -rw-r--r-- | src/fl_rect.cxx | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index 5510bb648..d7b2549e2 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $" +// "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $" // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // @@ -46,8 +46,10 @@ void fl_rect(int x, int y, int w, int h) { SetRect(&rect, x, y, x+w, y+h); FrameRect(&rect); #elif defined(__APPLE_QUARTZ__) - CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h); + CGContextSetShouldAntialias(fl_gc, false); + CGRect rect = CGRectMake(x, y, w-1, h-1); CGContextStrokeRect(fl_gc, rect); + CGContextSetShouldAntialias(fl_gc, true); #else XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1); #endif @@ -65,8 +67,10 @@ void fl_rectf(int x, int y, int w, int h) { SetRect(&rect, x, y, x+w, y+h); PaintRect(&rect); #elif defined(__APPLE_QUARTZ__) - CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h); + CGContextSetShouldAntialias(fl_gc, false); + CGRect rect = CGRectMake(x, y, w-1, h-1); CGContextFillRect(fl_gc, rect); + CGContextSetShouldAntialias(fl_gc, true); #else if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h); #endif @@ -78,9 +82,11 @@ void fl_xyline(int x, int y, int x1) { #elif defined(__APPLE_QD__) MoveTo(x, y); LineTo(x1, y); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y); #endif @@ -98,10 +104,12 @@ void fl_xyline(int x, int y, int x1, int y2) { LineTo(x1, y); LineTo(x1, y2); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y2); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XPoint p[3]; p[0].x = x; p[0].y = p[1].y = y; @@ -124,11 +132,13 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) { LineTo(x1, y2); LineTo(x3, y2); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y); CGContextAddLineToPoint(fl_gc, x1, y2); CGContextAddLineToPoint(fl_gc, x3, y2); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XPoint p[4]; p[0].x = x; p[0].y = p[1].y = y; @@ -146,9 +156,11 @@ void fl_yxline(int x, int y, int y1) { #elif defined(__APPLE_QD__) MoveTo(x, y); LineTo(x, y1); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y1); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1); #endif @@ -166,10 +178,12 @@ void fl_yxline(int x, int y, int y1, int x2) { LineTo(x, y1); LineTo(x2, y1); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x2, y1); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XPoint p[3]; p[0].x = p[1].x = x; p[0].y = y; @@ -192,11 +206,13 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) { LineTo(x2, y1); LineTo(x2, y3); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y1); CGContextAddLineToPoint(fl_gc, x2, y1); CGContextAddLineToPoint(fl_gc, x2, y3); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XPoint p[4]; p[0].x = p[1].x = x; p[0].y = y; @@ -217,9 +233,11 @@ void fl_line(int x, int y, int x1, int y1) { MoveTo(x, y); LineTo(x1, y1); #elif defined(__APPLE_QUARTZ__) + if ( x==x1 || y==y1 ) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1); #endif @@ -376,9 +394,11 @@ void fl_point(int x, int y) { #elif defined(__APPLE_QD__) MoveTo(x, y); Line(0, 0); #elif defined(__APPLE_QUARTZ__) + CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x, y); CGContextStrokePath(fl_gc); + CGContextSetShouldAntialias(fl_gc, true); #else XDrawPoint(fl_display, fl_window, fl_gc, x, y); #endif @@ -642,5 +662,5 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ } // -// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $". +// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.15 2004/08/26 22:24:24 matthiaswm Exp $". // |
