Mercurial > dwindows
comparison os2/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 | 885b55c0d7d7 |
children | 1cdc18d760e0 |
comparison
equal
deleted
inserted
replaced
1274:885b55c0d7d7 | 1275:0b34e2cf0706 |
---|---|
8555 | 8555 |
8556 /* Draw a polygon on a window (preferably a render window). | 8556 /* Draw a polygon on a window (preferably a render window). |
8557 * Parameters: | 8557 * Parameters: |
8558 * handle: Handle to the window. | 8558 * handle: Handle to the window. |
8559 * pixmap: Handle to the pixmap. (choose only one of these) | 8559 * pixmap: Handle to the pixmap. (choose only one of these) |
8560 * fill: Fill box TRUE or FALSE. | 8560 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0). |
8561 * x: X coordinate. | 8561 * x: X coordinate. |
8562 * y: Y coordinate. | 8562 * y: Y coordinate. |
8563 * width: Width of rectangle. | 8563 * width: Width of rectangle. |
8564 * height: Height of rectangle. | 8564 * height: Height of rectangle. |
8565 */ | 8565 */ |
8566 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y ) | 8566 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y ) |
8567 { | 8567 { |
8568 HPS hps; | 8568 HPS hps; |
8569 int thisheight; | 8569 int thisheight; |
8570 POINTL *pptl; | 8570 POINTL *pptl; |
8571 POINTL start; | 8571 POINTL start; |
8589 if ( pptl == NULL ) | 8589 if ( pptl == NULL ) |
8590 return; | 8590 return; |
8591 /* | 8591 /* |
8592 * For a filled polygon we need to start an area | 8592 * For a filled polygon we need to start an area |
8593 */ | 8593 */ |
8594 if ( fill ) | 8594 if ( flags & DW_DRAW_FILL ) |
8595 GpiBeginArea( hps, 0L ); | 8595 GpiBeginArea( hps, 0L ); |
8596 if ( npoints ) | 8596 if ( npoints ) |
8597 { | 8597 { |
8598 /* | 8598 /* |
8599 * Move to the first point of the polygon | 8599 * Move to the first point of the polygon |
8609 pptl[i-1].x = x[i]; | 8609 pptl[i-1].x = x[i]; |
8610 pptl[i-1].y = thisheight - y[i] - 1; | 8610 pptl[i-1].y = thisheight - y[i] - 1; |
8611 } | 8611 } |
8612 GpiPolyLine( hps, npoints-1, pptl ); | 8612 GpiPolyLine( hps, npoints-1, pptl ); |
8613 | 8613 |
8614 if ( fill ) | 8614 if ( flags & DW_DRAW_FILL ) |
8615 GpiEndArea( hps ); | 8615 GpiEndArea( hps ); |
8616 } | 8616 } |
8617 if ( !pixmap ) | 8617 if ( !pixmap ) |
8618 WinReleasePS(hps); | 8618 WinReleasePS(hps); |
8619 free( pptl ); | 8619 free( pptl ); |
8621 | 8621 |
8622 /* Draw a rectangle on a window (preferably a render window). | 8622 /* Draw a rectangle on a window (preferably a render window). |
8623 * Parameters: | 8623 * Parameters: |
8624 * handle: Handle to the window. | 8624 * handle: Handle to the window. |
8625 * pixmap: Handle to the pixmap. (choose only one of these) | 8625 * pixmap: Handle to the pixmap. (choose only one of these) |
8626 * fill: Fill box TRUE or FALSE. | 8626 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0). |
8627 * x: X coordinate. | 8627 * x: X coordinate. |
8628 * y: Y coordinate. | 8628 * y: Y coordinate. |
8629 * width: Width of rectangle. | 8629 * width: Width of rectangle. |
8630 * height: Height of rectangle. | 8630 * height: Height of rectangle. |
8631 */ | 8631 */ |
8651 ptl[0].x = x; | 8651 ptl[0].x = x; |
8652 ptl[0].y = thisheight - y - 1; | 8652 ptl[0].y = thisheight - y - 1; |
8653 ptl[1].x = x + width - 1; | 8653 ptl[1].x = x + width - 1; |
8654 ptl[1].y = thisheight - y - height; | 8654 ptl[1].y = thisheight - y - height; |
8655 | 8655 |
8656 /* For a filled arc we need to start an area */ | |
8657 if(flags & DW_DRAW_FILL) | |
8658 GpiBeginArea(hps, 0L); | |
8656 GpiMove(hps, &ptl[0]); | 8659 GpiMove(hps, &ptl[0]); |
8657 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0); | 8660 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0); |
8661 if(flags & DW_DRAW_FILL) | |
8662 GpiEndArea(hps); | |
8658 | 8663 |
8659 if(!pixmap) | 8664 if(!pixmap) |
8660 WinReleasePS(hps); | 8665 WinReleasePS(hps); |
8661 } | 8666 } |
8662 | 8667 |
8667 | 8672 |
8668 /* Draw an arc on a window (preferably a render window). | 8673 /* Draw an arc on a window (preferably a render window). |
8669 * Parameters: | 8674 * Parameters: |
8670 * handle: Handle to the window. | 8675 * handle: Handle to the window. |
8671 * pixmap: Handle to the pixmap. (choose only one of these) | 8676 * pixmap: Handle to the pixmap. (choose only one of these) |
8672 * flags: For future use. | 8677 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0). |
8678 * DW_DRAW_FULL will draw a complete circle/elipse. | |
8673 * xorigin: X coordinate of center of arc. | 8679 * xorigin: X coordinate of center of arc. |
8674 * yorigin: Y coordinate of center of arc. | 8680 * yorigin: Y coordinate of center of arc. |
8675 * x1: X coordinate of first segment of arc. | 8681 * x1: X coordinate of first segment of arc. |
8676 * y1: Y coordinate of first segment of arc. | 8682 * y1: Y coordinate of first segment of arc. |
8677 * x2: X coordinate of second segment of arc. | 8683 * x2: X coordinate of second segment of arc. |
8688 | 8694 |
8689 /* Handle full circle/ellipse */ | 8695 /* Handle full circle/ellipse */ |
8690 if(flags & DW_DRAW_FULL) | 8696 if(flags & DW_DRAW_FULL) |
8691 { | 8697 { |
8692 /* Draw one half... */ | 8698 /* Draw one half... */ |
8693 dw_draw_arc(handle, pixmap, flags & ~DW_DRAW_FULL, xorigin, yorigin, x2, y2, x1, y1); | 8699 dw_draw_arc(handle, pixmap, flags & ~DW_DRAW_FULL, xorigin, yorigin, x2, y2, x1, y1); |
8694 /* ... then continue to draw the other half */ | 8700 /* ... then continue to draw the other half */ |
8695 } | 8701 } |
8696 | 8702 |
8697 if(handle) | 8703 if(handle) |
8698 { | 8704 { |
8705 thisheight = pixmap->height; | 8711 thisheight = pixmap->height; |
8706 } | 8712 } |
8707 else | 8713 else |
8708 return; | 8714 return; |
8709 | 8715 |
8710 /* For a filled polygon we need to start an area */ | 8716 /* For a filled arc we need to start an area */ |
8711 if(flags & DW_DRAW_FILL) | 8717 if(flags & DW_DRAW_FILL) |
8712 GpiBeginArea(hps, 0L); | 8718 GpiBeginArea(hps, 0L); |
8713 /* Setup the arc info on the presentation space */ | 8719 /* Setup the arc info on the presentation space */ |
8714 GpiSetArcParams(hps, &ap); | 8720 GpiSetArcParams(hps, &ap); |
8715 pts[0].x = x1; | 8721 pts[0].x = x1; |