comparison gtk/dw.c @ 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 dfecd7b3c81e
children fe92a6f6d3e7
comparison
equal deleted inserted replaced
1274:885b55c0d7d7 1275:0b34e2cf0706
7943 7943
7944 /* Draw a closed polygon on a window (preferably a render window). 7944 /* Draw a closed polygon on a window (preferably a render window).
7945 * Parameters: 7945 * Parameters:
7946 * handle: Handle to the window. 7946 * handle: Handle to the window.
7947 * pixmap: Handle to the pixmap. (choose only one of these) 7947 * pixmap: Handle to the pixmap. (choose only one of these)
7948 * fill: if true filled 7948 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
7949 * number of points 7949 * number of points
7950 * x[]: X coordinates. 7950 * x[]: X coordinates.
7951 * y[]: Y coordinates. 7951 * y[]: Y coordinates.
7952 */ 7952 */
7953 void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y) 7953 void dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
7954 { 7954 {
7955 int _locked_by_me = FALSE; 7955 int _locked_by_me = FALSE;
7956 int i; 7956 int i;
7957 GdkGC *gc = NULL; 7957 GdkGC *gc = NULL;
7958 GdkPoint *points = NULL; 7958 GdkPoint *points = NULL;
7977 cairo_move_to(cr, x[0], y[0]); 7977 cairo_move_to(cr, x[0], y[0]);
7978 for(i=1;i<npoints;i++) 7978 for(i=1;i<npoints;i++)
7979 { 7979 {
7980 cairo_line_to(cr, x[i], y[i]); 7980 cairo_line_to(cr, x[i], y[i]);
7981 } 7981 }
7982 if(fill) 7982 if(flags & DW_DRAW_FILL)
7983 cairo_fill(cr); 7983 cairo_fill(cr);
7984 cairo_stroke(cr); 7984 cairo_stroke(cr);
7985 cairo_destroy(cr); 7985 cairo_destroy(cr);
7986 } 7986 }
7987 #endif 7987 #endif
7995 { 7995 {
7996 points[i].x = x[i]; 7996 points[i].x = x[i];
7997 points[i].y = y[i]; 7997 points[i].y = y[i];
7998 } 7998 }
7999 7999
8000 gdk_draw_polygon(handle ? handle->window : pixmap->pixmap, gc, fill, points, npoints ); 8000 gdk_draw_polygon(handle ? handle->window : pixmap->pixmap, gc, (flags & DW_DRAW_FILL), points, npoints );
8001 gdk_gc_unref(gc); 8001 gdk_gc_unref(gc);
8002 } 8002 }
8003 DW_MUTEX_UNLOCK; 8003 DW_MUTEX_UNLOCK;
8004 } 8004 }
8005 8005
8006 /* Draw a rectangle on a window (preferably a render window). 8006 /* Draw a rectangle on a window (preferably a render window).
8007 * Parameters: 8007 * Parameters:
8008 * handle: Handle to the window. 8008 * handle: Handle to the window.
8009 * pixmap: Handle to the pixmap. (choose only one of these) 8009 * pixmap: Handle to the pixmap. (choose only one of these)
8010 * fill: if true filled 8010 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
8011 * x: X coordinate. 8011 * x: X coordinate.
8012 * y: Y coordinate. 8012 * y: Y coordinate.
8013 * width: Width of rectangle. 8013 * width: Width of rectangle.
8014 * height: Height of rectangle. 8014 * height: Height of rectangle.
8015 */ 8015 */
8016 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) 8016 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
8017 { 8017 {
8018 int _locked_by_me = FALSE; 8018 int _locked_by_me = FALSE;
8019 GdkGC *gc = NULL; 8019 GdkGC *gc = NULL;
8020 #if GTK_CHECK_VERSION(2,10,0) 8020 #if GTK_CHECK_VERSION(2,10,0)
8021 cairo_t *cr = NULL; 8021 cairo_t *cr = NULL;
8037 cairo_set_line_width(cr, 1); 8037 cairo_set_line_width(cr, 1);
8038 cairo_move_to(cr, x, y); 8038 cairo_move_to(cr, x, y);
8039 cairo_line_to(cr, x, y + height); 8039 cairo_line_to(cr, x, y + height);
8040 cairo_line_to(cr, x + width, y + height); 8040 cairo_line_to(cr, x + width, y + height);
8041 cairo_line_to(cr, x + width, y); 8041 cairo_line_to(cr, x + width, y);
8042 if(fill) 8042 if(flags & DW_DRAW_FILL)
8043 cairo_fill(cr); 8043 cairo_fill(cr);
8044 cairo_stroke(cr); 8044 cairo_stroke(cr);
8045 cairo_destroy(cr); 8045 cairo_destroy(cr);
8046 } 8046 }
8047 #endif 8047 #endif
8048 if(gc) 8048 if(gc)
8049 { 8049 {
8050 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); 8050 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, (flags & DW_DRAW_FILL), x, y, width, height);
8051 gdk_gc_unref(gc); 8051 gdk_gc_unref(gc);
8052 } 8052 }
8053 DW_MUTEX_UNLOCK; 8053 DW_MUTEX_UNLOCK;
8054 } 8054 }
8055 8055
8056 /* Draw an arc on a window (preferably a render window). 8056 /* Draw an arc on a window (preferably a render window).
8057 * Parameters: 8057 * Parameters:
8058 * handle: Handle to the window. 8058 * handle: Handle to the window.
8059 * pixmap: Handle to the pixmap. (choose only one of these) 8059 * pixmap: Handle to the pixmap. (choose only one of these)
8060 * flags: For future use. 8060 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
8061 * DW_DRAW_FULL will draw a complete circle/elipse.
8061 * xorigin: X coordinate of center of arc. 8062 * xorigin: X coordinate of center of arc.
8062 * yorigin: Y coordinate of center of arc. 8063 * yorigin: Y coordinate of center of arc.
8063 * x1: X coordinate of first segment of arc. 8064 * x1: X coordinate of first segment of arc.
8064 * y1: Y coordinate of first segment of arc. 8065 * y1: Y coordinate of first segment of arc.
8065 * x2: X coordinate of second segment of arc. 8066 * x2: X coordinate of second segment of arc.