@ -50,23 +50,21 @@ extern float fl_quartz_line_width_;
*/
*/
void fl_rect ( int x , int y , int w , int h ) {
void fl_rect ( int x , int y , int w , int h ) {
if ( w < = 0 | | h < = 0 ) return ;
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 ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x + w - 1 , y ) ;
LineTo ( fl_gc , x + w - 1 , y ) ;
LineTo ( fl_gc , x + w - 1 , y + h - 1 ) ;
LineTo ( fl_gc , x + w - 1 , y + h - 1 ) ;
LineTo ( fl_gc , x , y + h - 1 ) ;
LineTo ( fl_gc , x , y + h - 1 ) ;
LineTo ( fl_gc , x , y ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGRect rect = CGRectMake ( x , y , w - 1 , h - 1 ) ;
CGRect rect = CGRectMake ( x , y , w - 1 , h - 1 ) ;
CGContextStrokeRect ( fl_gc , rect ) ;
CGContextStrokeRect ( fl_gc , rect ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XDrawRectangle ( fl_display , fl_window , fl_gc , x , y , w - 1 , h - 1 ) ;
# error unsupported platform
# endif
# 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 ) {
void fl_rectf ( int x , int y , int w , int h ) {
if ( w < = 0 | | h < = 0 ) return ;
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 rect ;
rect . left = x ; rect . top = y ;
rect . left = x ; rect . top = y ;
rect . right = x + w ; rect . bottom = y + h ;
rect . right = x + w ; rect . bottom = y + h ;
FillRect ( fl_gc , & rect , fl_brush ( ) ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGRect rect = CGRectMake ( x , y , w - 1 , h - 1 ) ;
CGRect rect = CGRectMake ( x , y , w - 1 , h - 1 ) ;
CGContextFillRect ( fl_gc , rect ) ;
CGContextFillRect ( fl_gc , rect ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
if ( w & & h ) XFillRectangle ( fl_display , fl_window , fl_gc , x , y , w , h ) ;
# error unsupported platform
# endif
# 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
Draw horizontal line from x , y to x1 , y
*/
*/
void fl_xyline ( int x , int y , int x1 ) {
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 ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -109,7 +105,7 @@ void fl_xyline(int x, int y, int x1) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XDrawLine ( fl_display , fl_window , fl_gc , x , y , x1 , y ) ;
# error unsupported platform
# endif
# 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
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 ) {
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 - - ;
if ( y2 < y ) y2 - - ;
else y2 + + ;
else y2 + + ;
MoveToEx ( fl_gc , x , y , 0L ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y ) ;
LineTo ( fl_gc , x1 , y ) ;
LineTo ( fl_gc , x1 , y2 ) ;
LineTo ( fl_gc , x1 , y2 ) ;
# elif defined(__APPLE_QD__)
MoveTo ( x , y ) ;
LineTo ( x1 , y ) ;
LineTo ( x1 , y2 ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -135,10 +132,7 @@ void fl_xyline(int x, int y, int x1, int y2) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XPoint p [ 3 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
and then another horizontal from x1 , y2 to x3 , y2
*/
*/
void fl_xyline ( int x , int y , int x1 , int y2 , int x3 ) {
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 - - ;
if ( x3 < x1 ) x3 - - ;
else x3 + + ;
else x3 + + ;
MoveToEx ( fl_gc , x , y , 0L ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y ) ;
LineTo ( fl_gc , x1 , y ) ;
LineTo ( fl_gc , x1 , y2 ) ;
LineTo ( fl_gc , x1 , y2 ) ;
LineTo ( fl_gc , x3 , 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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
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 ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XPoint p [ 4 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
Draw a vertical line from x , y to x , y1
*/
*/
void fl_yxline ( int x , int y , int 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 - - ;
if ( y1 < y ) y1 - - ;
else y1 + + ;
else y1 + + ;
MoveToEx ( fl_gc , x , y , 0L ) ; LineTo ( fl_gc , x , 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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -193,7 +184,7 @@ void fl_yxline(int x, int y, int y1) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XDrawLine ( fl_display , fl_window , fl_gc , x , y , x , y1 ) ;
# error unsupported platform
# endif
# 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
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 ) {
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 + + ;
if ( x2 > x ) x2 + + ;
else x2 - - ;
else x2 - - ;
MoveToEx ( fl_gc , x , y , 0L ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x , y1 ) ;
LineTo ( fl_gc , x , y1 ) ;
LineTo ( fl_gc , x2 , y1 ) ;
LineTo ( fl_gc , x2 , y1 ) ;
# elif defined(__APPLE_QD__)
MoveTo ( x , y ) ;
LineTo ( x , y1 ) ;
LineTo ( x2 , y1 ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -219,10 +211,7 @@ void fl_yxline(int x, int y, int y1, int x2) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XPoint p [ 3 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
then another vertical from x2 , y1 to x2 , y3
*/
*/
void fl_yxline ( int x , int y , int y1 , int x2 , int 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 - - ;
if ( y3 < y1 ) y3 - - ;
else y3 + + ;
else y3 + + ;
MoveToEx ( fl_gc , x , y , 0L ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x , y1 ) ;
LineTo ( fl_gc , x , y1 ) ;
LineTo ( fl_gc , x2 , y1 ) ;
LineTo ( fl_gc , x2 , y1 ) ;
LineTo ( fl_gc , x2 , y3 ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
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 ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XPoint p [ 4 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
Draw a line from x , y to x1 , y1
*/
*/
void fl_line ( int x , int y , int x1 , int 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 ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x1 , y1 ) ;
// Draw the last point *again* because the GDI line drawing
// Draw the last point *again* because the GDI line drawing
// functions will not draw the last point ("it's a feature!"...)
// functions will not draw the last point ("it's a feature!"...)
SetPixel ( fl_gc , x1 , y1 , fl_RGB ( ) ) ;
SetPixel ( fl_gc , x1 , y1 , fl_RGB ( ) ) ;
# elif defined(__APPLE_QD__)
MoveTo ( x , y ) ;
LineTo ( x1 , y1 ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -280,7 +265,7 @@ void fl_line(int x, int y, int x1, int y1) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XDrawLine ( fl_display , fl_window , fl_gc , x , y , x1 , y1 ) ;
# error unsupported platform
# endif
# 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
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 ) {
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 ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
// Draw the last point *again* because the GDI line drawing
// Draw the last point *again* because the GDI line drawing
// functions will not draw the last point ("it's a feature!"...)
// functions will not draw the last point ("it's a feature!"...)
SetPixel ( fl_gc , x2 , y2 , fl_RGB ( ) ) ;
SetPixel ( fl_gc , x2 , y2 , fl_RGB ( ) ) ;
# elif defined(__APPLE_QD__)
MoveTo ( x , y ) ;
LineTo ( x1 , y1 ) ;
LineTo ( x2 , y2 ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
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 ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XPoint p [ 3 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
Outline a 3 - sided polygon with lines
*/
*/
void fl_loop ( int x , int y , int x1 , int y1 , int x2 , int y2 ) {
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 ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
LineTo ( fl_gc , x , y ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextAddLineToPoint ( fl_gc , x1 , y1 ) ;
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 ) ;
CGContextClosePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
# else
# else
XPoint p [ 4 ] ;
# error unsupported platform
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 ) ;
# endif
# 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
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 ) {
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 ) ;
MoveToEx ( fl_gc , x , y , 0L ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x1 , y1 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
LineTo ( fl_gc , x2 , y2 ) ;
LineTo ( fl_gc , x3 , y3 ) ;
LineTo ( fl_gc , x3 , y3 ) ;
LineTo ( fl_gc , x , y ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextAddLineToPoint ( fl_gc , x1 , y1 ) ;
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 ) ;
CGContextClosePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
# else
# else
XPoint p [ 5 ] ;
# error unsupported platform
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 ) ;
# endif
# 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 [ 0 ] . x = x ; p [ 0 ] . y = y ;
p [ 1 ] . x = x1 ; p [ 1 ] . y = y1 ;
p [ 1 ] . x = x1 ; p [ 1 ] . y = y1 ;
p [ 2 ] . x = x2 ; p [ 2 ] . y = y2 ;
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 ( ) ) ;
SelectObject ( fl_gc , fl_brush ( ) ) ;
Polygon ( fl_gc , p , 3 ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextAddLineToPoint ( fl_gc , x1 , y1 ) ;
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 ) ;
CGContextClosePath ( fl_gc ) ;
CGContextFillPath ( fl_gc ) ;
CGContextFillPath ( fl_gc ) ;
# else
# else
p [ 3 ] . x = x ; p [ 3 ] . y = y ;
# error unsupported platform
XFillPolygon ( fl_display , fl_window , fl_gc , p , 3 , Convex , 0 ) ;
XDrawLines ( fl_display , fl_window , fl_gc , p , 4 , 0 ) ;
# endif
# 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 [ 1 ] . x = x1 ; p [ 1 ] . y = y1 ;
p [ 2 ] . x = x2 ; p [ 2 ] . y = y2 ;
p [ 2 ] . x = x2 ; p [ 2 ] . y = y2 ;
p [ 3 ] . x = x3 ; p [ 3 ] . y = y3 ;
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 ( ) ) ;
SelectObject ( fl_gc , fl_brush ( ) ) ;
Polygon ( fl_gc , p , 4 ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextAddLineToPoint ( fl_gc , x1 , y1 ) ;
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 ) ;
CGContextClosePath ( fl_gc ) ;
CGContextFillPath ( fl_gc ) ;
CGContextFillPath ( fl_gc ) ;
# else
# else
p [ 4 ] . x = x ; p [ 4 ] . y = y ;
# error unsupported platform
XFillPolygon ( fl_display , fl_window , fl_gc , p , 4 , Convex , 0 ) ;
XDrawLines ( fl_display , fl_window , fl_gc , p , 5 , 0 ) ;
# endif
# 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
Draw a single pixel at the given coordinates
*/
*/
void fl_point ( int x , int y ) {
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 ( ) ) ;
SetPixel ( fl_gc , x , y , fl_RGB ( ) ) ;
# elif defined(__APPLE_QD__)
MoveTo ( x , y ) ; Line ( 0 , 0 ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , false ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
CGContextMoveToPoint ( fl_gc , x , y ) ;
@ -465,7 +424,7 @@ void fl_point(int x, int y) {
CGContextStrokePath ( fl_gc ) ;
CGContextStrokePath ( fl_gc ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
if ( fl_quartz_line_width_ = = 1.0f ) CGContextSetShouldAntialias ( fl_gc , true ) ;
# else
# else
XDrawPoint ( fl_display , fl_window , fl_gc , x , y ) ;
# error unsupported platform
# endif
# endif
}
}
@ -489,51 +448,22 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) {
}
}
# endif
# endif
# ifdef __APPLE_QD__
# if defined(__APPLE_QUARTZ__)
extern Fl_Region fl_window_region ;
# elif defined(__APPLE_QUARTZ__)
// warning: the Quartz implementation currently uses Quickdraw calls to achieve
// warning: the Quartz implementation currently uses Quickdraw calls to achieve
// clipping. A future version should instead use 'CGContectClipToRect'
// clipping. A future version should instead use 'CGContectClipToRect'
// and friends.
// and friends.
extern Fl_Region fl_window_region ;
extern Fl_Region fl_window_region ;
# endif
# endif
// undo any clobbering of clip done by your program:
/** Undoes any clobbering of clip done by your program */
void fl_restore_clip ( ) {
void fl_restore_clip ( ) {
fl_clip_state_number + + ;
fl_clip_state_number + + ;
Fl_Region r = rstack [ rstackptr ] ;
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
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__)
# elif defined(__APPLE_QUARTZ__)
if ( fl_window ) // clipping for a true window
if ( fl_window ) // clipping for a true window
{
{
@ -561,8 +491,7 @@ void fl_restore_clip() {
Fl_X : : q_fill_context ( ) ;
Fl_X : : q_fill_context ( ) ;
}
}
# else
# else
if ( r ) XSetRegion ( fl_display , fl_gc , r ) ;
# error unsupported platform
else XSetClipMask ( fl_display , fl_gc , 0 ) ;
# endif
# endif
}
}
@ -596,30 +525,29 @@ void fl_push_clip(int x, int y, int w, int h) {
r = XRectangleRegion ( x , y , w , h ) ;
r = XRectangleRegion ( x , y , w , h ) ;
Fl_Region current = rstack [ rstackptr ] ;
Fl_Region current = rstack [ rstackptr ] ;
if ( current ) {
if ( current ) {
# ifdef WIN32
# if defined(USE_X11)
CombineRgn ( r , r , current , RGN_AND ) ;
# elif defined(__APPLE_QD__)
SectRgn ( r , current , r ) ;
# elif defined(__APPLE_QUARTZ__)
SectRgn ( r , current , r ) ;
# else
Fl_Region temp = XCreateRegion ( ) ;
Fl_Region temp = XCreateRegion ( ) ;
XIntersectRegion ( current , r , temp ) ;
XIntersectRegion ( current , r , temp ) ;
XDestroyRegion ( r ) ;
XDestroyRegion ( r ) ;
r = temp ;
r = temp ;
# elif defined(WIN32)
CombineRgn ( r , r , current , RGN_AND ) ;
# elif defined(__APPLE_QUARTZ__)
SectRgn ( r , current , r ) ;
# else
# error unsupported platform
# endif
# endif
}
}
} else { // make empty clip region:
} else { // make empty clip region:
# ifdef WIN32
# if defined(USE_X11)
r = XCreateRegion ( ) ;
# elif defined(WIN32)
r = CreateRectRgn ( 0 , 0 , 0 , 0 ) ;
r = CreateRectRgn ( 0 , 0 , 0 , 0 ) ;
# elif defined(__APPLE_QD__)
r = NewRgn ( ) ;
SetEmptyRgn ( r ) ;
# elif defined(__APPLE_QUARTZ__)
# elif defined(__APPLE_QUARTZ__)
r = NewRgn ( ) ;
r = NewRgn ( ) ;
SetEmptyRgn ( r ) ;
SetEmptyRgn ( r ) ;
# else
# else
r = XCreateRegion ( ) ;
# error unsupported platform
# endif
# endif
}
}
if ( rstackptr < STACK_MAX ) rstack [ + + rstackptr ] = r ;
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 ) {
int fl_not_clipped ( int x , int y , int w , int h ) {
if ( x + w < = 0 | | y + h < = 0 ) return 0 ;
if ( x + w < = 0 | | y + h < = 0 ) return 0 ;
Fl_Region r = rstack [ rstackptr ] ;
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 ;
if ( ! r ) return 1 ;
RECT rect ;
RECT rect ;
rect . left = x ; rect . top = y ; rect . right = x + w ; rect . bottom = y + h ;
rect . left = x ; rect . top = y ; rect . right = x + w ; rect . bottom = y + h ;
return RectInRegion ( r , & rect ) ;
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__)
# elif defined(__APPLE_QUARTZ__)
if ( ! r ) return 1 ;
if ( ! r ) return 1 ;
Rect rect ;
Rect rect ;
rect . left = x ; rect . top = y ; rect . right = x + w ; rect . bottom = y + h ;
rect . left = x ; rect . top = y ; rect . right = x + w ; rect . bottom = y + h ;
return RectInRgn ( & rect , r ) ;
return RectInRgn ( & rect , r ) ;
# else
# else
return r ? XRectInRegion ( r , x , y , w , h ) : 1 ;
# error unsupported platform
# endif
# 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 ;
X = x ; Y = y ; W = w ; H = h ;
Fl_Region r = rstack [ rstackptr ] ;
Fl_Region r = rstack [ rstackptr ] ;
if ( ! r ) return 0 ;
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
// The win32 API makes no distinction between partial and complete
// intersection, so we have to check for partial intersection ourselves.
// intersection, so we have to check for partial intersection ourselves.
// However, given that the regions may be composite, we have to do
// 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 ( temp ) ;
DeleteObject ( rr ) ;
DeleteObject ( rr ) ;
return ret ;
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__)
# elif defined(__APPLE_QUARTZ__)
RgnHandle rr = NewRgn ( ) ;
RgnHandle rr = NewRgn ( ) ;
SetRectRgn ( rr , x , y , x + w , y + h ) ;
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 ;
if ( h = = H & & w = = W ) return 0 ;
return 0 ;
return 0 ;
# else
# else
switch ( XRectInRegion ( r , x , y , w , h ) ) {
# error unsupported platform
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 ;
# endif
# endif
}
}