summaryrefslogtreecommitdiff
path: root/src/fl_rect.cxx
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2008-10-13 23:10:43 +0000
committerFabien Costantini <fabien@onepost.net>2008-10-13 23:10:43 +0000
commit92051890f1127429142cc0b60e3e9a1e567bf01d (patch)
tree4c0e7f28192914b24202d08aa3eaa72a7bf5f7e4 /src/fl_rect.cxx
parent8e9c1d1ab030dc7beed522f368c467dd94e1f8bb (diff)
Quickdraw removal: option removed from configure, all Qd code removed from sources. Also took this opportunity to sort the ifdef clauses so that USE_X11 shows first. Also added error pragma to enforce proper target checking, thus make even less assumptions.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6423 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_rect.cxx')
-rw-r--r--src/fl_rect.cxx358
1 files changed, 136 insertions, 222 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index 71937f507..1edeecce2 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -50,23 +50,21 @@ extern float fl_quartz_line_width_;
*/
void fl_rect(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
-#ifdef WIN32
+#if defined(USE_X11)
+ XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x+w-1, y);
LineTo(fl_gc, x+w-1, y+h-1);
LineTo(fl_gc, x, y+h-1);
LineTo(fl_gc, x, y);
-#elif defined(__APPLE_QD__)
- Rect rect;
- SetRect(&rect, x, y, x+w, y+h);
- FrameRect(&rect);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextStrokeRect(fl_gc, rect);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
+# error unsupported platform
#endif
}
@@ -75,22 +73,20 @@ void fl_rect(int x, int y, int w, int h) {
*/
void fl_rectf(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
-#ifdef WIN32
+#if defined(USE_X11)
+ if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
+#elif defined(WIN32)
RECT rect;
rect.left = x; rect.top = y;
rect.right = x + w; rect.bottom = y + h;
FillRect(fl_gc, &rect, fl_brush());
-#elif defined(__APPLE_QD__)
- Rect rect;
- SetRect(&rect, x, y, x+w, y+h);
- PaintRect(&rect);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextFillRect(fl_gc, rect);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
+# error unsupported platform
#endif
}
@@ -98,10 +94,10 @@ void fl_rectf(int x, int y, int w, int h) {
Draw horizontal line from x,y to x1,y
*/
void fl_xyline(int x, int y, int x1) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y); LineTo(x1, y);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -109,7 +105,7 @@ void fl_xyline(int x, int y, int x1) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y);
+# error unsupported platform
#endif
}
@@ -117,16 +113,17 @@ void fl_xyline(int x, int y, int x1) {
Draw horizontal line from x,y to x1,y, then vertical from x1,y to x1,y2
*/
void fl_xyline(int x, int y, int x1, int y2) {
-#ifdef WIN32
+#if defined (USE_X11)
+ XPoint p[3];
+ p[0].x = x; p[0].y = p[1].y = y;
+ p[1].x = p[2].x = x1; p[2].y = y2;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+#elif defined(WIN32)
if (y2 < y) y2--;
else y2++;
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y);
LineTo(fl_gc, x1, y2);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y);
- LineTo(x1, y2);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -135,10 +132,7 @@ void fl_xyline(int x, int y, int x1, int y2) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XPoint p[3];
- p[0].x = x; p[0].y = p[1].y = y;
- p[1].x = p[2].x = x1; p[2].y = y2;
- XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+#error unsupported platform
#endif
}
@@ -147,18 +141,19 @@ void fl_xyline(int x, int y, int x1, int y2) {
and then another horizontal from x1,y2 to x3,y2
*/
void fl_xyline(int x, int y, int x1, int y2, int x3) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[4];
+ p[0].x = x; p[0].y = p[1].y = y;
+ p[1].x = p[2].x = x1; p[2].y = p[3].y = y2;
+ p[3].x = x3;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+#elif defined(WIN32)
if(x3 < x1) x3--;
else x3++;
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y);
LineTo(fl_gc, x1, y2);
LineTo(fl_gc, x3, y2);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y);
- LineTo(x1, y2);
- LineTo(x3, y2);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -168,11 +163,7 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XPoint p[4];
- p[0].x = x; p[0].y = p[1].y = y;
- p[1].x = p[2].x = x1; p[2].y = p[3].y = y2;
- p[3].x = x3;
- XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+# error unsupported platform
#endif
}
@@ -180,12 +171,12 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
Draw a vertical line from x,y to x,y1
*/
void fl_yxline(int x, int y, int y1) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1);
+#elif defined(WIN32)
if (y1 < y) y1--;
else y1++;
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y); LineTo(x, y1);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -193,7 +184,7 @@ void fl_yxline(int x, int y, int y1) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1);
+# error unsupported platform
#endif
}
@@ -201,16 +192,17 @@ void fl_yxline(int x, int y, int y1) {
Draw a vertical line from x,y to x,y1 then a horizontal from x,y1 to x2,y1
*/
void fl_yxline(int x, int y, int y1, int x2) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[3];
+ p[0].x = p[1].x = x; p[0].y = y;
+ p[1].y = p[2].y = y1; p[2].x = x2;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+#elif defined(WIN32)
if (x2 > x) x2++;
else x2--;
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x, y1);
LineTo(fl_gc, x2, y1);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x, y1);
- LineTo(x2, y1);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -219,10 +211,7 @@ void fl_yxline(int x, int y, int y1, int x2) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XPoint p[3];
- p[0].x = p[1].x = x; p[0].y = y;
- p[1].y = p[2].y = y1; p[2].x = x2;
- XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+# error unsupported platform
#endif
}
@@ -231,18 +220,19 @@ void fl_yxline(int x, int y, int y1, int x2) {
then another vertical from x2,y1 to x2,y3
*/
void fl_yxline(int x, int y, int y1, int x2, int y3) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[4];
+ p[0].x = p[1].x = x; p[0].y = y;
+ p[1].y = p[2].y = y1; p[2].x = p[3].x = x2;
+ p[3].y = y3;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+#elif defined(WIN32)
if(y3<y1) y3--;
else y3++;
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x, y1);
LineTo(fl_gc, x2, y1);
LineTo(fl_gc, x2, y3);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x, y1);
- LineTo(x2, y1);
- LineTo(x2, y3);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -252,11 +242,7 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XPoint p[4];
- p[0].x = p[1].x = x; p[0].y = y;
- p[1].y = p[2].y = y1; p[2].x = p[3].x = x2;
- p[3].y = y3;
- XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+# error unsupported platform
#endif
}
@@ -264,15 +250,14 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
Draw a line from x,y to x1,y1
*/
void fl_line(int x, int y, int x1, int y1) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y1);
// Draw the last point *again* because the GDI line drawing
// functions will not draw the last point ("it's a feature!"...)
SetPixel(fl_gc, x1, y1, fl_RGB());
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y1);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -280,7 +265,7 @@ void fl_line(int x, int y, int x1, int y1) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1);
+# error unsupported platform
#endif
}
@@ -288,17 +273,19 @@ void fl_line(int x, int y, int x1, int y1) {
Draw a line from x,y to x1,y1 and another from x1,y1 to x2,y2
*/
void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[3];
+ p[0].x = x; p[0].y = y;
+ p[1].x = x1; p[1].y = y1;
+ p[2].x = x2; p[2].y = y2;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y1);
LineTo(fl_gc, x2, y2);
// Draw the last point *again* because the GDI line drawing
// functions will not draw the last point ("it's a feature!"...)
SetPixel(fl_gc, x2, y2, fl_RGB());
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y1);
- LineTo(x2, y2);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -307,11 +294,7 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, true);
#else
- XPoint p[3];
- p[0].x = x; p[0].y = y;
- p[1].x = x1; p[1].y = y1;
- p[2].x = x2; p[2].y = y2;
- XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0);
+# error unsupported platform
#endif
}
@@ -319,16 +302,18 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
Outline a 3-sided polygon with lines
*/
void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[4];
+ p[0].x = x; p[0].y = y;
+ p[1].x = x1; p[1].y = y1;
+ p[2].x = x2; p[2].y = y2;
+ p[3].x = x; p[3].y = y;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y1);
LineTo(fl_gc, x2, y2);
LineTo(fl_gc, x, y);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y1);
- LineTo(x2, y2);
- LineTo(x, y);
#elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
@@ -336,12 +321,7 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
#else
- XPoint p[4];
- p[0].x = x; p[0].y = y;
- p[1].x = x1; p[1].y = y1;
- p[2].x = x2; p[2].y = y2;
- p[3].x = x; p[3].y = y;
- XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+# error unsupported platform
#endif
}
@@ -349,18 +329,20 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
Outline a 4-sided polygon with lines
*/
void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XPoint p[5];
+ p[0].x = x; p[0].y = y;
+ p[1].x = x1; p[1].y = y1;
+ p[2].x = x2; p[2].y = y2;
+ p[3].x = x3; p[3].y = y3;
+ p[4].x = x; p[4].y = y;
+ XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0);
+#elif defined(WIN32)
MoveToEx(fl_gc, x, y, 0L);
LineTo(fl_gc, x1, y1);
LineTo(fl_gc, x2, y2);
LineTo(fl_gc, x3, y3);
LineTo(fl_gc, x, y);
-#elif defined(__APPLE_QD__)
- MoveTo(x, y);
- LineTo(x1, y1);
- LineTo(x2, y2);
- LineTo(x3, y3);
- LineTo(x, y);
#elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
@@ -369,13 +351,7 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
#else
- XPoint p[5];
- p[0].x = x; p[0].y = y;
- p[1].x = x1; p[1].y = y1;
- p[2].x = x2; p[2].y = y2;
- p[3].x = x3; p[3].y = y3;
- p[4].x = x; p[4].y = y;
- XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0);
+# error unsupported platform
#endif
}
@@ -387,19 +363,13 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
p[0].x = x; p[0].y = y;
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
-#ifdef WIN32
+#if defined (USE_X11)
+ p[3].x = x; p[3].y = y;
+ XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0);
+ XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+#elif defined(WIN32)
SelectObject(fl_gc, fl_brush());
Polygon(fl_gc, p, 3);
-#elif defined(__APPLE_QD__)
- PolyHandle poly = OpenPoly();
- MoveTo(x, y);
- LineTo(x1, y1);
- LineTo(x2, y2);
- LineTo(x, y);
- ClosePoly();
- PaintPoly(poly);
- FramePoly(poly);
- KillPoly(poly);
#elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
@@ -407,9 +377,7 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
#else
- p[3].x = x; p[3].y = y;
- XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0);
- XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0);
+# error unsupported platform
#endif
}
@@ -422,20 +390,13 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
p[1].x = x1; p[1].y = y1;
p[2].x = x2; p[2].y = y2;
p[3].x = x3; p[3].y = y3;
-#ifdef WIN32
+#if defined(USE_X11)
+ p[4].x = x; p[4].y = y;
+ XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0);
+ XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0);
+#elif defined(WIN32)
SelectObject(fl_gc, fl_brush());
Polygon(fl_gc, p, 4);
-#elif defined(__APPLE_QD__)
- PolyHandle poly = OpenPoly();
- MoveTo(x, y);
- LineTo(x1, y1);
- LineTo(x2, y2);
- LineTo(x3, y3);
- LineTo(x, y);
- ClosePoly();
- PaintPoly(poly);
- FramePoly(poly);
- KillPoly(poly);
#elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
@@ -444,9 +405,7 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
#else
- p[4].x = x; p[4].y = y;
- XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0);
- XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0);
+# error unsupported platform
#endif
}
@@ -454,10 +413,10 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
Draw a single pixel at the given coordinates
*/
void fl_point(int x, int y) {
-#ifdef WIN32
+#if defined(USE_X11)
+ XDrawPoint(fl_display, fl_window, fl_gc, x, y);
+#elif defined(WIN32)
SetPixel(fl_gc, x, y, fl_RGB());
-#elif defined(__APPLE_QD__)
- MoveTo(x, y); Line(0, 0);
#elif defined(__APPLE_QUARTZ__)
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
@@ -465,7 +424,7 @@ void fl_point(int x, int y) {
CGContextStrokePath(fl_gc);
if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
- XDrawPoint(fl_display, fl_window, fl_gc, x, y);
+# error unsupported platform
#endif
}
@@ -489,51 +448,22 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) {
}
#endif
-#ifdef __APPLE_QD__
-extern Fl_Region fl_window_region;
-#elif defined(__APPLE_QUARTZ__)
+#if defined(__APPLE_QUARTZ__)
// warning: the Quartz implementation currently uses Quickdraw calls to achieve
// clipping. A future version should instead use 'CGContectClipToRect'
// and friends.
extern Fl_Region fl_window_region;
#endif
-// undo any clobbering of clip done by your program:
+/** Undoes any clobbering of clip done by your program */
void fl_restore_clip() {
fl_clip_state_number++;
Fl_Region r = rstack[rstackptr];
-#ifdef WIN32
+#if defined(USE_X11)
+ if (r) XSetRegion(fl_display, fl_gc, r);
+ else XSetClipMask(fl_display, fl_gc, 0);
+#elif defined(WIN32)
SelectClipRgn(fl_gc, r); //if r is NULL, clip is automatically cleared
-#elif defined(__APPLE_QD__)
-# if 1
- // This code is required to allow true subwindows to work on Mac.
- // During regular operation however, this seems overkill.
- // See also: Fl_Window::make_current()
- if ( fl_window ) {
- GrafPtr port = GetWindowPort( fl_window );
- if ( port ) { // port will be NULL if we are using a GWorld (and fl_window_region is invalid)
- RgnHandle portClip = NewRgn();
- CopyRgn( fl_window_region, portClip ); // changed
- if ( r )
- SectRgn( portClip, r, portClip );
- SetPortClipRegion( port, portClip );
- DisposeRgn( portClip );
- }
- } else {
- if (r)
- SetClip(r);
- else {
- Rect rect; rect.left=0; rect.top=0; rect.right=0x7fff; rect.bottom=0x7fff;
- ClipRect(&rect);
- }
- }
-# else
- if (r) SetClip(r);
- else {
- Rect rect; rect.left=0; rect.top=0; rect.right=0x7fff; rect.bottom=0x7fff;
- ClipRect(&rect);
- }
-# endif
#elif defined(__APPLE_QUARTZ__)
if ( fl_window ) // clipping for a true window
{
@@ -561,8 +491,7 @@ void fl_restore_clip() {
Fl_X::q_fill_context();
}
#else
- if (r) XSetRegion(fl_display, fl_gc, r);
- else XSetClipMask(fl_display, fl_gc, 0);
+# error unsupported platform
#endif
}
@@ -596,30 +525,29 @@ void fl_push_clip(int x, int y, int w, int h) {
r = XRectangleRegion(x,y,w,h);
Fl_Region current = rstack[rstackptr];
if (current) {
-#ifdef WIN32
- CombineRgn(r,r,current,RGN_AND);
-#elif defined(__APPLE_QD__)
- SectRgn(r, current, r);
-#elif defined(__APPLE_QUARTZ__)
- SectRgn(r, current, r);
-#else
+#if defined(USE_X11)
Fl_Region temp = XCreateRegion();
XIntersectRegion(current, r, temp);
XDestroyRegion(r);
r = temp;
+#elif defined(WIN32)
+ CombineRgn(r,r,current,RGN_AND);
+#elif defined(__APPLE_QUARTZ__)
+ SectRgn(r, current, r);
+#else
+# error unsupported platform
#endif
}
} else { // make empty clip region:
-#ifdef WIN32
+#if defined(USE_X11)
+ r = XCreateRegion();
+#elif defined(WIN32)
r = CreateRectRgn(0,0,0,0);
-#elif defined(__APPLE_QD__)
- r = NewRgn();
- SetEmptyRgn(r);
#elif defined(__APPLE_QUARTZ__)
r = NewRgn();
SetEmptyRgn(r);
#else
- r = XCreateRegion();
+# error unsupported platform
#endif
}
if (rstackptr < STACK_MAX) rstack[++rstackptr] = r;
@@ -665,23 +593,20 @@ void fl_pop_clip() {
int fl_not_clipped(int x, int y, int w, int h) {
if (x+w <= 0 || y+h <= 0) return 0;
Fl_Region r = rstack[rstackptr];
-#ifdef WIN32
+#if defined (USE_X11)
+ return r ? XRectInRegion(r, x, y, w, h) : 1;
+#elif defined(WIN32)
if (!r) return 1;
RECT rect;
rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
return RectInRegion(r,&rect);
-#elif defined(__APPLE_QD__)
- if (!r) return 1;
- Rect rect;
- rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
- return RectInRgn(&rect, r);
#elif defined(__APPLE_QUARTZ__)
if (!r) return 1;
Rect rect;
rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
return RectInRgn(&rect, r);
#else
- return r ? XRectInRegion(r, x, y, w, h) : 1;
+# error unsupported platform
#endif
}
@@ -703,7 +628,26 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
X = x; Y = y; W = w; H = h;
Fl_Region r = rstack[rstackptr];
if (!r) return 0;
-#ifdef WIN32
+#if defined(USE_X11)
+ switch (XRectInRegion(r, x, y, w, h)) {
+ case 0: // completely outside
+ W = H = 0;
+ return 2;
+ case 1: // completely inside:
+ return 0;
+ default: // partial:
+ break;
+ }
+ Fl_Region rr = XRectangleRegion(x,y,w,h);
+ Fl_Region temp = XCreateRegion();
+ XIntersectRegion(r, rr, temp);
+ XRectangle rect;
+ XClipBox(temp, &rect);
+ X = rect.x; Y = rect.y; W = rect.width; H = rect.height;
+ XDestroyRegion(temp);
+ XDestroyRegion(rr);
+ return 1;
+#elif defined(WIN32)
// The win32 API makes no distinction between partial and complete
// intersection, so we have to check for partial intersection ourselves.
// However, given that the regions may be composite, we have to do
@@ -725,19 +669,6 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
DeleteObject(temp);
DeleteObject(rr);
return ret;
-#elif defined(__APPLE_QD__)
- RgnHandle rr = NewRgn();
- SetRectRgn( rr, x, y, x+w, y+h );
- SectRgn( r, rr, rr );
- Rect rp; GetRegionBounds(rr, &rp);
- X = rp.left;
- Y = rp.top;
- W = rp.right - X;
- H = rp.bottom - Y;
- DisposeRgn( rr );
- if ( H==0 ) return 2;
- if ( h==H && w==W ) return 0;
- return 0;
#elif defined(__APPLE_QUARTZ__)
RgnHandle rr = NewRgn();
SetRectRgn( rr, x, y, x+w, y+h );
@@ -752,24 +683,7 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
if ( h==H && w==W ) return 0;
return 0;
#else
- switch (XRectInRegion(r, x, y, w, h)) {
- case 0: // completely outside
- W = H = 0;
- return 2;
- case 1: // completely inside:
- return 0;
- default: // partial:
- break;
- }
- Fl_Region rr = XRectangleRegion(x,y,w,h);
- Fl_Region temp = XCreateRegion();
- XIntersectRegion(r, rr, temp);
- XRectangle rect;
- XClipBox(temp, &rect);
- X = rect.x; Y = rect.y; W = rect.width; H = rect.height;
- XDestroyRegion(temp);
- XDestroyRegion(rr);
- return 1;
+# error unsupported platform
#endif
}