changeset 1275:0b34e2cf0706

Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc. The fill parameter has been replaced by flags which should be backwards compatible. Also updated the source comments to reflect these changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 30 Oct 2011 10:14:49 +0000
parents 885b55c0d7d7
children 1cdc18d760e0
files gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c readme template/dw.c win/dw.c
diffstat 7 files changed, 60 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sun Oct 30 02:13:47 2011 +0000
+++ b/gtk/dw.c	Sun Oct 30 10:14:49 2011 +0000
@@ -7945,12 +7945,12 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: if true filled
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       number of points
  *       x[]: X coordinates.
  *       y[]: Y coordinates.
  */
-void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y)
+void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
 {
    int _locked_by_me = FALSE;
    int i;
@@ -7979,7 +7979,7 @@
       {
          cairo_line_to(cr, x[i], y[i]);
       }
-      if(fill)
+      if(flags & DW_DRAW_FILL)
          cairo_fill(cr);
       cairo_stroke(cr);
       cairo_destroy(cr);
@@ -7997,7 +7997,7 @@
          points[i].y = y[i];
       }
 
-      gdk_draw_polygon(handle ? handle->window : pixmap->pixmap, gc, fill, points, npoints );
+      gdk_draw_polygon(handle ? handle->window : pixmap->pixmap, gc, (flags & DW_DRAW_FILL), points, npoints );
       gdk_gc_unref(gc);
    }
    DW_MUTEX_UNLOCK;
@@ -8007,13 +8007,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: if true filled
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
+void dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
    int _locked_by_me = FALSE;
    GdkGC *gc = NULL;
@@ -8039,7 +8039,7 @@
       cairo_line_to(cr, x, y + height);
       cairo_line_to(cr, x + width, y + height);
       cairo_line_to(cr, x + width, y);
-      if(fill)
+      if(flags & DW_DRAW_FILL)
          cairo_fill(cr);
       cairo_stroke(cr);
       cairo_destroy(cr);
@@ -8047,7 +8047,7 @@
 #endif
    if(gc)
    {
-      gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
+      gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, (flags & DW_DRAW_FILL), x, y, width, height);
       gdk_gc_unref(gc);
    }
    DW_MUTEX_UNLOCK;
@@ -8057,7 +8057,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.
--- a/gtk3/dw.c	Sun Oct 30 02:13:47 2011 +0000
+++ b/gtk3/dw.c	Sun Oct 30 10:14:49 2011 +0000
@@ -6832,12 +6832,12 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: if true filled
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       number of points
  *       x[]: X coordinates.
  *       y[]: Y coordinates.
  */
-void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y)
+void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
 {
    int _locked_by_me = FALSE;
    cairo_t *cr = NULL;
@@ -6868,7 +6868,7 @@
       {
          cairo_line_to(cr, x[z], y[z]);
       }
-      if(fill)
+      if(flags & DW_DRAW_FILL)
          cairo_fill(cr);
       cairo_stroke(cr);
       cairo_destroy(cr);
@@ -6880,13 +6880,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: if true filled
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
+void dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
    int _locked_by_me = FALSE;
    cairo_t *cr = NULL;
@@ -6915,7 +6915,7 @@
       cairo_line_to(cr, x, y + height);
       cairo_line_to(cr, x + width, y + height);
       cairo_line_to(cr, x + width, y);
-      if(fill)
+      if(flags & DW_DRAW_FILL)
          cairo_fill(cr);
       cairo_stroke(cr);
       cairo_destroy(cr);
@@ -6927,7 +6927,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.
--- a/mac/dw.m	Sun Oct 30 02:13:47 2011 +0000
+++ b/mac/dw.m	Sun Oct 30 10:14:49 2011 +0000
@@ -5117,13 +5117,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y )
+void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y )
 {
     int _locked_by_me = FALSE;
     DW_MUTEX_LOCK;
@@ -5156,7 +5156,7 @@
         [aPath lineToPoint:NSMakePoint(x[z], y[z])];
     }
     [aPath closePath];
-    if(fill)
+    if(flags & DW_DRAW_FILL)
     {
         [aPath fill];
     }
@@ -5176,13 +5176,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
+void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
     int _locked_by_me = FALSE;
     DW_MUTEX_LOCK;
@@ -5213,7 +5213,7 @@
     [aPath lineToPoint:NSMakePoint(x + width, y + height)];
     [aPath lineToPoint:NSMakePoint(x + width, y)];
     [aPath closePath];
-    if(fill)
+    if(flags & DW_DRAW_FILL)
        [aPath fill];
     [aPath stroke];
     if(pixmap)
@@ -5231,7 +5231,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.
@@ -5267,7 +5268,7 @@
     NSColor *color = pthread_getspecific(_dw_fg_color_key);
     [color set];
 
-    /* Special state of a full circle/oval */
+    /* Special case of a full circle/oval */
     if(flags & DW_DRAW_FULL)
     {
         [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2, y2)];
--- a/os2/dw.c	Sun Oct 30 02:13:47 2011 +0000
+++ b/os2/dw.c	Sun Oct 30 10:14:49 2011 +0000
@@ -8557,13 +8557,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y )
+void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y )
 {
    HPS hps;
    int thisheight;
@@ -8591,7 +8591,7 @@
    /*
     * For a filled polygon we need to start an area
     */
-   if ( fill )
+   if ( flags & DW_DRAW_FILL )
       GpiBeginArea( hps, 0L );
    if ( npoints )
    {
@@ -8611,7 +8611,7 @@
       }
       GpiPolyLine( hps, npoints-1, pptl );
 
-      if ( fill )
+      if ( flags & DW_DRAW_FILL )
          GpiEndArea( hps );
    }
    if ( !pixmap )
@@ -8623,7 +8623,7 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
@@ -8653,8 +8653,13 @@
    ptl[1].x = x + width - 1;
    ptl[1].y = thisheight - y - height;
 
+   /* For a filled arc we need to start an area */
+   if(flags & DW_DRAW_FILL)
+       GpiBeginArea(hps, 0L);
    GpiMove(hps, &ptl[0]);
    GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0);
+   if(flags & DW_DRAW_FILL)
+       GpiEndArea(hps);
 
    if(!pixmap)
       WinReleasePS(hps);
@@ -8669,7 +8674,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.
@@ -8690,7 +8696,7 @@
    if(flags & DW_DRAW_FULL)
    {
        /* Draw one half... */
-	   dw_draw_arc(handle, pixmap, flags & ~DW_DRAW_FULL, xorigin, yorigin, x2, y2, x1, y1);
+    dw_draw_arc(handle, pixmap, flags & ~DW_DRAW_FULL, xorigin, yorigin, x2, y2, x1, y1);
        /* ... then continue to draw the other half */
    }
 
@@ -8707,7 +8713,7 @@
    else
       return;
 
-   /* For a filled polygon we need to start an area */
+   /* For a filled arc we need to start an area */
    if(flags & DW_DRAW_FILL)
        GpiBeginArea(hps, 0L);
    /* Setup the arc info on the presentation space */
--- a/readme	Sun Oct 30 02:13:47 2011 +0000
+++ b/readme	Sun Oct 30 10:14:49 2011 +0000
@@ -55,6 +55,11 @@
    Currently Mac, Win and GTK are supported.
 Added taskbar support on the Mac, GTK (Gnome) and OS/2 (e/XCenter+Systray).
 Added PNG/JPG/GIF/TIFF support on Windows via GDI+.
+Added dw_draw_arc() function for drawing arcs, ellipses and circles.
+Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL flags which can be passed
+   to dw_draw_arc(), dw_draw_rect() and dw_draw_polygon().  The fill parameter
+   in the latter two has been replaced with flags where DW_DRAW_FILL is the
+   same as TRUE so code using the old scheme should still work unchanged.
 Improved container optimization on Mac, header width now taken into account.
 Fixes for incorrect return codes from the dw_event_* functions on Windows.
 Fixes for incorrect behavior on key_press callbacks on Mac and Windows.
--- a/template/dw.c	Sun Oct 30 02:13:47 2011 +0000
+++ b/template/dw.c	Sun Oct 30 10:14:49 2011 +0000
@@ -1506,12 +1506,12 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       npoints: Number of points passed in.
  *       x: Pointer to array of X coordinates.
  *       y: Pointer to array of Y coordinates.
  */
-void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y )
+void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y )
 {
 }
 
@@ -1519,13 +1519,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: Fill box TRUE or FALSE.
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
+void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
 }
 
@@ -1533,7 +1533,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.
--- a/win/dw.c	Sun Oct 30 02:13:47 2011 +0000
+++ b/win/dw.c	Sun Oct 30 10:14:49 2011 +0000
@@ -8727,12 +8727,12 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       fill: if true filled
+ *       flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
  *       number of points
  *       x[]: X coordinates.
  *       y[]: Y coordinates.
  */
-void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y)
+void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
 {
    HDC hdcPaint;
    HBRUSH oldBrush;
@@ -8775,7 +8775,7 @@
 
    oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
    oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
-   if ( fill )
+   if ( flags & DW_DRAW_FILL )
       Polygon( hdcPaint, points, npoints );
    else
       Polyline( hdcPaint, points, npoints );
@@ -8790,12 +8790,13 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
+ *       flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
  *       x: X coordinate.
  *       y: Y coordinate.
  *       width: Width of rectangle.
  *       height: Height of rectangle.
  */
-void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
+void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
    HDC hdcPaint;
    RECT Rect;
@@ -8808,7 +8809,7 @@
       return;
 
    SetRect(&Rect, x, y, x + width , y + height );
-   if(fill)
+   if(flags & DW_DRAW_FILL)
       FillRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
    else
       FrameRect(hdcPaint, &Rect, TlsGetValue(_hBrush));
@@ -8820,7 +8821,8 @@
  * Parameters:
  *       handle: Handle to the window.
  *       pixmap: Handle to the pixmap. (choose only one of these)
- *       flags: For future use.
+ *       flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
+ *              DW_DRAW_FULL will draw a complete circle/elipse.
  *       xorigin: X coordinate of center of arc.
  *       yorigin: Y coordinate of center of arc.
  *       x1: X coordinate of first segment of arc.