41 #ifdef __APPLE_QUARTZ__ 42 extern float fl_quartz_line_width_;
43 #define USINGQUARTZPRINTER (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) 49 #define SHRT_MAX (32767) 116 static int clip_to_short(
int &
x,
int &
y,
int &w,
int &h) {
120 int kmax = SHRT_MAX - lw;
122 if (w <= 0 || h <= 0)
return 1;
123 if (
x+w < kmin ||
y+h < kmin)
return 1;
124 if (
x > kmax ||
y > kmax)
return 1;
126 if (
x < kmin) { w -= (kmin-
x);
x = kmin; }
127 if (
y < kmin) { h -= (kmin-
y);
y = kmin; }
128 if (
x+w > kmax) w = kmax -
x;
129 if (
y+h > kmax) h = kmax -
y;
142 static int clip_x (
int x) {
146 int kmax = SHRT_MAX - lw;
160 if (w<=0 || h<=0)
return;
162 if (!clip_to_short(
x,
y, w, h))
170 #elif defined(__APPLE_QUARTZ__) 171 if ( (!USINGQUARTZPRINTER) && fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
172 CGRect
rect = CGRectMake(
x,
y, w-1, h-1);
174 if ( (!USINGQUARTZPRINTER) && fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
176 # error unsupported platform 181 if (w<=0 || h<=0)
return;
183 if (!clip_to_short(
x,
y, w, h))
190 #elif defined(__APPLE_QUARTZ__) 191 CGRect
rect = CGRectMake(
x - 0.5,
y - 0.5, w , h);
194 # error unsupported platform 203 #elif defined(__APPLE_QUARTZ__) 204 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
206 CGContextAddLineToPoint(
fl_gc, x1,
y);
207 CGContextStrokePath(
fl_gc);
208 if (Fl_Display_Device::high_resolution()) {
216 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
218 # error unsupported platform 223 #if defined (USE_X11) 225 p[0].x = clip_x(
x);
p[0].y =
p[1].y = clip_x(
y);
226 p[1].x =
p[2].x = clip_x(x1);
p[2].y = clip_x(y2);
233 LineTo(
fl_gc, x1, y2);
234 #elif defined(__APPLE_QUARTZ__) 235 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
237 CGContextAddLineToPoint(
fl_gc, x1,
y);
238 CGContextAddLineToPoint(
fl_gc, x1, y2);
239 CGContextStrokePath(
fl_gc);
240 if (Fl_Display_Device::high_resolution()) {
244 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
246 #error unsupported platform 253 p[0].x = clip_x(
x);
p[0].y =
p[1].y = clip_x(
y);
254 p[1].x =
p[2].x = clip_x(x1);
p[2].y =
p[3].y = clip_x(y2);
262 LineTo(
fl_gc, x1, y2);
263 LineTo(
fl_gc, x3, y2);
264 #elif defined(__APPLE_QUARTZ__) 265 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
267 CGContextAddLineToPoint(
fl_gc, x1,
y);
268 CGContextAddLineToPoint(
fl_gc, x1, y2);
269 CGContextAddLineToPoint(
fl_gc, x3, y2);
270 CGContextStrokePath(
fl_gc);
271 if (Fl_Display_Device::high_resolution()) {
275 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
277 # error unsupported platform 288 #elif defined(__APPLE_QUARTZ__) 289 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
291 CGContextAddLineToPoint(
fl_gc,
x, y1);
292 CGContextStrokePath(
fl_gc);
293 if (Fl_Display_Device::high_resolution()) {
297 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
299 # error unsupported platform 306 p[0].x =
p[1].x = clip_x(
x);
p[0].y = clip_x(
y);
307 p[1].y =
p[2].y = clip_x(y1);
p[2].x = clip_x(x2);
314 LineTo(
fl_gc, x2, y1);
315 #elif defined(__APPLE_QUARTZ__) 316 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
318 CGContextAddLineToPoint(
fl_gc,
x, y1);
319 CGContextAddLineToPoint(
fl_gc, x2, y1);
320 CGContextStrokePath(
fl_gc);
321 if (Fl_Display_Device::high_resolution()) {
325 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
327 # error unsupported platform 334 p[0].x =
p[1].x = clip_x(
x);
p[0].y = clip_x(
y);
335 p[1].y =
p[2].y = clip_x(y1);
p[2].x =
p[3].x = clip_x(x2);
343 LineTo(
fl_gc, x2, y1);
344 LineTo(
fl_gc, x2, y3);
345 #elif defined(__APPLE_QUARTZ__) 346 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
348 CGContextAddLineToPoint(
fl_gc,
x, y1);
349 CGContextAddLineToPoint(
fl_gc, x2, y1);
350 CGContextAddLineToPoint(
fl_gc, x2, y3);
351 CGContextStrokePath(
fl_gc);
352 if (Fl_Display_Device::high_resolution()) {
356 if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
358 # error unsupported platform 367 LineTo(
fl_gc, x1, y1);
371 #elif defined(__APPLE_QUARTZ__) 372 if (fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
374 CGContextAddLineToPoint(
fl_gc, x1, y1);
375 CGContextStrokePath(
fl_gc);
376 if (fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
378 # error unsupported platform 385 p[0].x =
x;
p[0].y =
y;
386 p[1].x = x1;
p[1].y = y1;
387 p[2].x = x2;
p[2].y = y2;
391 LineTo(
fl_gc, x1, y1);
392 LineTo(
fl_gc, x2, y2);
396 #elif defined(__APPLE_QUARTZ__) 397 if (fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
true);
399 CGContextAddLineToPoint(
fl_gc, x1, y1);
400 CGContextAddLineToPoint(
fl_gc, x2, y2);
401 CGContextStrokePath(
fl_gc);
402 if (fl_quartz_line_width_ > 1.5
f) CGContextSetShouldAntialias(
fl_gc,
false);
404 # error unsupported platform 411 p[0].x =
x;
p[0].y =
y;
412 p[1].x = x1;
p[1].y = y1;
413 p[2].x = x2;
p[2].y = y2;
414 p[3].x =
x;
p[3].y =
y;
418 LineTo(
fl_gc, x1, y1);
419 LineTo(
fl_gc, x2, y2);
421 #elif defined(__APPLE_QUARTZ__) 422 CGContextSetShouldAntialias(
fl_gc,
true);
424 CGContextAddLineToPoint(
fl_gc, x1, y1);
425 CGContextAddLineToPoint(
fl_gc, x2, y2);
427 CGContextStrokePath(
fl_gc);
428 CGContextSetShouldAntialias(
fl_gc,
false);
430 # error unsupported platform 437 p[0].x =
x;
p[0].y =
y;
438 p[1].x = x1;
p[1].y = y1;
439 p[2].x = x2;
p[2].y = y2;
440 p[3].x = x3;
p[3].y = y3;
441 p[4].x =
x;
p[4].y =
y;
445 LineTo(
fl_gc, x1, y1);
446 LineTo(
fl_gc, x2, y2);
447 LineTo(
fl_gc, x3, y3);
449 #elif defined(__APPLE_QUARTZ__) 450 CGContextSetShouldAntialias(
fl_gc,
true);
452 CGContextAddLineToPoint(
fl_gc, x1, y1);
453 CGContextAddLineToPoint(
fl_gc, x2, y2);
454 CGContextAddLineToPoint(
fl_gc, x3, y3);
456 CGContextStrokePath(
fl_gc);
457 CGContextSetShouldAntialias(
fl_gc,
false);
459 # error unsupported platform 465 p[0].x =
x;
p[0].y =
y;
466 p[1].x = x1;
p[1].y = y1;
467 p[2].x = x2;
p[2].y = y2;
468 #if defined (USE_X11) 469 p[3].x =
x;
p[3].y =
y;
475 #elif defined(__APPLE_QUARTZ__) 476 CGContextSetShouldAntialias(
fl_gc,
true);
478 CGContextAddLineToPoint(
fl_gc, x1, y1);
479 CGContextAddLineToPoint(
fl_gc, x2, y2);
482 CGContextSetShouldAntialias(
fl_gc,
false);
484 # error unsupported platform 490 p[0].x =
x;
p[0].y =
y;
491 p[1].x = x1;
p[1].y = y1;
492 p[2].x = x2;
p[2].y = y2;
493 p[3].x = x3;
p[3].y = y3;
495 p[4].x =
x;
p[4].y =
y;
501 #elif defined(__APPLE_QUARTZ__) 502 CGContextSetShouldAntialias(
fl_gc,
true);
504 CGContextAddLineToPoint(
fl_gc, x1, y1);
505 CGContextAddLineToPoint(
fl_gc, x2, y2);
506 CGContextAddLineToPoint(
fl_gc, x3, y3);
509 CGContextSetShouldAntialias(
fl_gc,
false);
511 # error unsupported platform 520 #elif defined(__APPLE_QUARTZ__) 523 # error unsupported platform 529 #if !defined(WIN32) && !defined(__APPLE__) 534 clip_to_short(
x,
y, w, h);
535 R.x =
x; R.y =
y; R.width = w; R.height = h;
537 XUnionRectWithRegion(&R, r, r);
550 SelectClipRgn(
fl_gc, r);
551 #elif defined(__APPLE_QUARTZ__) 553 Fl_X::q_clear_clipping();
554 Fl_X::q_fill_context();
557 CGContextClipToRects(
fl_gc, r->rects, r->count);
561 # error unsupported platform 567 if (oldr) XDestroyRegion(oldr);
578 if (w > 0 && h > 0) {
584 XIntersectRegion(current, r, temp);
588 CombineRgn(r,r,current,RGN_AND);
589 #elif defined(__APPLE_QUARTZ__) 591 r = Fl_X::intersect_region_and_rect(current,
x,
y,w,h);
593 # error unsupported platform 600 r = CreateRectRgn(0,0,0,0);
601 #elif defined(__APPLE_QUARTZ__) 604 # error unsupported platform 608 else Fl::warning(
"fl_push_clip: clip stack overflow!\n");
615 else Fl::warning(
"fl_push_no_clip: clip stack overflow!\n");
623 if (oldr) XDestroyRegion(oldr);
624 }
else Fl::warning(
"fl_pop_clip: clip stack underflow!\n");
629 if (
x+w <= 0 ||
y+h <= 0)
return 0;
632 #if defined (USE_X11) 634 if (clip_to_short(
x,
y,w,h))
return 0;
635 return XRectInRegion(r,
x,
y, w, h);
639 POINT pt[2] = { {
x,
y}, {
x + w,
y + h} };
640 LPtoDP(
fl_gc, pt, 2);
641 rect.left = pt[0].x;
rect.top = pt[0].y;
rect.right = pt[1].x;
rect.bottom = pt[1].y;
645 return RectInRegion(r,&
rect);
646 #elif defined(__APPLE_QUARTZ__) 647 CGRect
arg = fl_cgrectmake_cocoa(
x,
y, w, h);
648 for (
int i = 0; i < r->count; i++) {
649 CGRect test = CGRectIntersection(r->rects[i],
arg);
650 if (!CGRectIsEmpty(test))
return 1;
654 # error unsupported platform 660 X =
x;
Y =
y; W = w;
H = h;
664 switch (XRectInRegion(r,
x,
y, w, h)) {
675 XIntersectRegion(r, rr, temp);
677 XClipBox(temp, &
rect);
679 XDestroyRegion(temp);
690 if (CombineRgn(temp, rr, r, RGN_AND) == NULLREGION) {
693 }
else if (EqualRgn(temp, rr)) {
697 GetRgnBox(temp, &
rect);
700 DPtoLP(
fl_gc, pt, 2);
701 X = pt[0].x;
Y = pt[0].y; W = pt[1].x - X;
H = pt[1].y -
Y;
711 #elif defined(__APPLE_QUARTZ__) 712 CGRect
arg = fl_cgrectmake_cocoa(
x,
y, w, h);
713 CGRect u = CGRectMake(0,0,0,0);
715 for(
int i = 0; i < r->count; i++) {
716 test = CGRectIntersection(r->rects[i],
arg);
717 if( ! CGRectIsEmpty(test) ) {
718 if(CGRectIsEmpty(u)) u = test;
719 else u = CGRectUnion(u, test);
722 X = int(u.origin.x + 0.5);
723 Y = int(u.origin.y + 0.5);
724 W = int(u.size.width + 0.5);
725 H = int(u.size.height + 0.5);
726 if(CGRectIsEmpty(u)) W =
H = 0;
727 return ! CGRectEqualToRect(
arg, u);
729 # error unsupported platform