summaryrefslogtreecommitdiff
path: root/src/fl_rect.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl_rect.cxx')
-rw-r--r--src/fl_rect.cxx202
1 files changed, 186 insertions, 16 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index fb7fe0f05..0709f2ff9 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -59,10 +59,18 @@ void fl_rect(int x, int y, int w, int h) {
LineTo(fl_gc, x, y+h-1);
LineTo(fl_gc, x, y);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextStrokeRect(fl_gc, rect);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -81,10 +89,18 @@ void fl_rectf(int x, int y, int w, int h) {
rect.right = x + w; rect.bottom = y + h;
FillRect(fl_gc, &rect, fl_brush());
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextFillRect(fl_gc, rect);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -99,11 +115,19 @@ void fl_xyline(int x, int y, int x1) {
#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -125,12 +149,20 @@ void fl_xyline(int x, int y, int x1, int y2) {
LineTo(fl_gc, x1, y);
LineTo(fl_gc, x1, y2);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
#error unsupported platform
#endif
@@ -155,13 +187,21 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
LineTo(fl_gc, x1, y2);
LineTo(fl_gc, x3, y2);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextAddLineToPoint(fl_gc, x3, y2);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -178,11 +218,19 @@ void fl_yxline(int x, int y, int y1) {
else y1++;
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -204,12 +252,20 @@ void fl_yxline(int x, int y, int y1, int x2) {
LineTo(fl_gc, x, y1);
LineTo(fl_gc, x2, y1);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -234,13 +290,21 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
LineTo(fl_gc, x2, y1);
LineTo(fl_gc, x2, y3);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextAddLineToPoint(fl_gc, x2, y3);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -259,11 +323,19 @@ void fl_line(int x, int y, int x1, int y1) {
// functions will not draw the last point ("it's a feature!"...)
SetPixel(fl_gc, x1, y1, fl_RGB());
#elif defined(__APPLE_QUARTZ__)
- if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -287,12 +359,20 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
// functions will not draw the last point ("it's a feature!"...)
SetPixel(fl_gc, x2, y2, fl_RGB());
#elif defined(__APPLE_QUARTZ__)
- if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextStrokePath(fl_gc);
- if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, true);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -315,11 +395,17 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
LineTo(fl_gc, x2, y2);
LineTo(fl_gc, x, y);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, true);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, false);
+#endif
#else
# error unsupported platform
#endif
@@ -344,12 +430,18 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
LineTo(fl_gc, x3, y3);
LineTo(fl_gc, x, y);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, true);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextAddLineToPoint(fl_gc, x3, y3);
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, false);
+#endif
#else
# error unsupported platform
#endif
@@ -371,11 +463,17 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
SelectObject(fl_gc, fl_brush());
Polygon(fl_gc, p, 3);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, true);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, false);
+#endif
#else
# error unsupported platform
#endif
@@ -398,12 +496,18 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
SelectObject(fl_gc, fl_brush());
Polygon(fl_gc, p, 4);
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, true);
+#endif
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextAddLineToPoint(fl_gc, x2, y2);
CGContextAddLineToPoint(fl_gc, x3, y3);
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
+#ifdef __APPLE_COCOA__
+ CGContextSetShouldAntialias(fl_gc, false);
+#endif
#else
# error unsupported platform
#endif
@@ -418,11 +522,19 @@ void fl_point(int x, int y) {
#elif defined(WIN32)
SetPixel(fl_gc, x, y, fl_RGB());
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
+#endif
CGContextMoveToPoint(fl_gc, x-.5, y); // Quartz needs a line that is one pixel long, or it will not draw anything
CGContextAddLineToPoint(fl_gc, x+.5, y);
CGContextStrokePath(fl_gc);
+#ifdef __APPLE_COCOA__
+ if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
+#else
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
+#endif
#else
# error unsupported platform
#endif
@@ -467,7 +579,17 @@ void fl_restore_clip() {
#elif defined(__APPLE_QUARTZ__)
if ( fl_window ) // clipping for a true window
{
- GrafPtr port = GetWindowPort( fl_window );
+#ifdef __APPLE_COCOA__
+ Fl_X::q_clear_clipping();
+ Fl_X::q_fill_context();//flip coords and translate if subwindow
+ //apply window's clip
+ CGContextClipToRects(fl_gc, fl_window_region->rects, fl_window_region->count );
+ //apply additional program clip
+ if(r) {
+ CGContextClipToRects(fl_gc, r->rects, r->count);
+ }
+#else
+ GrafPtr port = GetWindowPort( fl_window );
if ( port ) {
RgnHandle portClip = NewRgn();
CopyRgn( fl_window_region, portClip ); // changed
@@ -479,16 +601,22 @@ void fl_restore_clip() {
Fl_X::q_fill_context();
DisposeRgn( portClip );
}
+#endif
} else if (fl_gc) { // clipping for an offscreen drawing world (CGBitmap)
- Rect portRect;
- portRect.top = 0;
- portRect.left = 0;
- portRect.bottom = CGBitmapContextGetHeight(fl_gc);
- portRect.right = CGBitmapContextGetWidth(fl_gc);
- Fl_X::q_clear_clipping();
- if (r)
- ClipCGContextToRegion(fl_gc, &portRect, r);
- Fl_X::q_fill_context();
+ Rect portRect;
+ portRect.top = 0;
+ portRect.left = 0;
+ portRect.bottom = CGBitmapContextGetHeight(fl_gc);
+ portRect.right = CGBitmapContextGetWidth(fl_gc);
+ Fl_X::q_clear_clipping();
+ if (r) {
+#ifdef __APPLE_COCOA__
+ CGContextClipToRects(fl_gc, r->rects, r->count);
+#else
+ ClipCGContextToRegion(fl_gc, &portRect, r);
+#endif
+ }
+ Fl_X::q_fill_context();
}
#else
# error unsupported platform
@@ -534,19 +662,33 @@ void fl_push_clip(int x, int y, int w, int h) {
#elif defined(WIN32)
CombineRgn(r,r,current,RGN_AND);
#elif defined(__APPLE_QUARTZ__)
- SectRgn(r, current, r);
+#ifdef __APPLE_COCOA__
+ XDestroyRegion(r);
+ r = MacRectRegionIntersect(current, x,y,w,h);
+#else
+ SectRgn(r, current, r);
+#endif
#else
# error unsupported platform
#endif
}
+#if defined(__APPLE_QUARTZ__)
+ else {
+ r = XRectangleRegion(x,y,w,h);
+ }
+#endif
} else { // make empty clip region:
#if defined(USE_X11)
r = XCreateRegion();
#elif defined(WIN32)
r = CreateRectRgn(0,0,0,0);
#elif defined(__APPLE_QUARTZ__)
- r = NewRgn();
- SetEmptyRgn(r);
+#ifdef __APPLE_COCOA__
+ r = NULL;
+#else
+ r = NewRgn();
+ SetEmptyRgn(r);
+#endif
#else
# error unsupported platform
#endif
@@ -604,9 +746,18 @@ int fl_not_clipped(int x, int y, int w, int h) {
return RectInRegion(r,&rect);
#elif defined(__APPLE_QUARTZ__)
if (!r) return 1;
+#ifdef __APPLE_COCOA__
+ CGRect arg = CGRectMake(x,y,w - 1,h - 1);
+ for(int i = 0; i < r->count; i++) {
+ CGRect test = CGRectIntersection(r->rects[i], arg);
+ if( ! CGRectIsEmpty(test)) return 1;
+ }
+ return 0;
+#else
Rect rect;
rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
return RectInRgn(&rect, r);
+#endif
#else
# error unsupported platform
#endif
@@ -673,6 +824,24 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
DeleteObject(rr);
return ret;
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ CGRect arg = CGRectMake(x,y,w - 1,h - 1);
+ CGRect u = CGRectMake(0,0,0,0);
+ CGRect test;
+ for(int i = 0; i < r->count; i++) {
+ test = CGRectIntersection(r->rects[i], arg);
+ if( ! CGRectIsEmpty(test) ) {
+ if(CGRectIsEmpty(u)) u = test;
+ else u = CGRectUnion(u, test);
+ }
+ }
+ X = u.origin.x;
+ Y = u.origin.y;
+ W = u.size.width;
+ H = u.size.height;
+ if(CGRectIsEmpty(u)) W = H = 0;
+ return ! CGRectEqualToRect(arg, u);
+#else
RgnHandle rr = NewRgn();
SetRectRgn( rr, x, y, x+w, y+h );
SectRgn( r, rr, rr );
@@ -685,6 +854,7 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
if ( H==0 ) return 2;
if ( h==H && w==W ) return 0;
return 0;
+#endif
#else
# error unsupported platform
#endif