comparison mac/dw.m @ 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 9e477efbacca
children 107e38a29eeb
comparison
equal deleted inserted replaced
1274:885b55c0d7d7 1275:0b34e2cf0706
5115 5115
5116 /* Draw a polygon on a window (preferably a render window). 5116 /* Draw a polygon on a window (preferably a render window).
5117 * Parameters: 5117 * Parameters:
5118 * handle: Handle to the window. 5118 * handle: Handle to the window.
5119 * pixmap: Handle to the pixmap. (choose only one of these) 5119 * pixmap: Handle to the pixmap. (choose only one of these)
5120 * fill: Fill box TRUE or FALSE. 5120 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
5121 * x: X coordinate. 5121 * x: X coordinate.
5122 * y: Y coordinate. 5122 * y: Y coordinate.
5123 * width: Width of rectangle. 5123 * width: Width of rectangle.
5124 * height: Height of rectangle. 5124 * height: Height of rectangle.
5125 */ 5125 */
5126 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y ) 5126 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y )
5127 { 5127 {
5128 int _locked_by_me = FALSE; 5128 int _locked_by_me = FALSE;
5129 DW_MUTEX_LOCK; 5129 DW_MUTEX_LOCK;
5130 id image = handle; 5130 id image = handle;
5131 int z; 5131 int z;
5154 for(z=1;z<npoints;z++) 5154 for(z=1;z<npoints;z++)
5155 { 5155 {
5156 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; 5156 [aPath lineToPoint:NSMakePoint(x[z], y[z])];
5157 } 5157 }
5158 [aPath closePath]; 5158 [aPath closePath];
5159 if(fill) 5159 if(flags & DW_DRAW_FILL)
5160 { 5160 {
5161 [aPath fill]; 5161 [aPath fill];
5162 } 5162 }
5163 [aPath stroke]; 5163 [aPath stroke];
5164 if(pixmap) 5164 if(pixmap)
5174 5174
5175 /* Draw a rectangle on a window (preferably a render window). 5175 /* Draw a rectangle on a window (preferably a render window).
5176 * Parameters: 5176 * Parameters:
5177 * handle: Handle to the window. 5177 * handle: Handle to the window.
5178 * pixmap: Handle to the pixmap. (choose only one of these) 5178 * pixmap: Handle to the pixmap. (choose only one of these)
5179 * fill: Fill box TRUE or FALSE. 5179 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
5180 * x: X coordinate. 5180 * x: X coordinate.
5181 * y: Y coordinate. 5181 * y: Y coordinate.
5182 * width: Width of rectangle. 5182 * width: Width of rectangle.
5183 * height: Height of rectangle. 5183 * height: Height of rectangle.
5184 */ 5184 */
5185 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) 5185 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
5186 { 5186 {
5187 int _locked_by_me = FALSE; 5187 int _locked_by_me = FALSE;
5188 DW_MUTEX_LOCK; 5188 DW_MUTEX_LOCK;
5189 id image = handle; 5189 id image = handle;
5190 if(pixmap) 5190 if(pixmap)
5211 [aPath moveToPoint:NSMakePoint(x, y)]; 5211 [aPath moveToPoint:NSMakePoint(x, y)];
5212 [aPath lineToPoint:NSMakePoint(x, y + height)]; 5212 [aPath lineToPoint:NSMakePoint(x, y + height)];
5213 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; 5213 [aPath lineToPoint:NSMakePoint(x + width, y + height)];
5214 [aPath lineToPoint:NSMakePoint(x + width, y)]; 5214 [aPath lineToPoint:NSMakePoint(x + width, y)];
5215 [aPath closePath]; 5215 [aPath closePath];
5216 if(fill) 5216 if(flags & DW_DRAW_FILL)
5217 [aPath fill]; 5217 [aPath fill];
5218 [aPath stroke]; 5218 [aPath stroke];
5219 if(pixmap) 5219 if(pixmap)
5220 { 5220 {
5221 [NSGraphicsContext restoreGraphicsState]; 5221 [NSGraphicsContext restoreGraphicsState];
5229 5229
5230 /* Draw an arc on a window (preferably a render window). 5230 /* Draw an arc on a window (preferably a render window).
5231 * Parameters: 5231 * Parameters:
5232 * handle: Handle to the window. 5232 * handle: Handle to the window.
5233 * pixmap: Handle to the pixmap. (choose only one of these) 5233 * pixmap: Handle to the pixmap. (choose only one of these)
5234 * flags: For future use. 5234 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
5235 * DW_DRAW_FULL will draw a complete circle/elipse.
5235 * xorigin: X coordinate of center of arc. 5236 * xorigin: X coordinate of center of arc.
5236 * yorigin: Y coordinate of center of arc. 5237 * yorigin: Y coordinate of center of arc.
5237 * x1: X coordinate of first segment of arc. 5238 * x1: X coordinate of first segment of arc.
5238 * y1: Y coordinate of first segment of arc. 5239 * y1: Y coordinate of first segment of arc.
5239 * x2: X coordinate of second segment of arc. 5240 * x2: X coordinate of second segment of arc.
5265 NSBezierPath* aPath = [NSBezierPath bezierPath]; 5266 NSBezierPath* aPath = [NSBezierPath bezierPath];
5266 [aPath setLineWidth: 0.5]; 5267 [aPath setLineWidth: 0.5];
5267 NSColor *color = pthread_getspecific(_dw_fg_color_key); 5268 NSColor *color = pthread_getspecific(_dw_fg_color_key);
5268 [color set]; 5269 [color set];
5269 5270
5270 /* Special state of a full circle/oval */ 5271 /* Special case of a full circle/oval */
5271 if(flags & DW_DRAW_FULL) 5272 if(flags & DW_DRAW_FULL)
5272 { 5273 {
5273 [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2, y2)]; 5274 [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2, y2)];
5274 } 5275 }
5275 else 5276 else