static void del_obj_settings( /***************************/ int fill_type, HPEN pen, HBRUSH brush ) { if (Old_pen) { _wpi_getoldpen( Win_dc, Old_pen ); } if (Old_brush) { _wpi_getoldbrush( Win_dc, Old_brush ); } switch( fill_type ) { case FILL_BORDER: // border only: interior not touched (pen) _wpi_deletepen( pen ); _wpi_deletenullbrush( brush ); break; case FILL_INTERIOR: // interior only: border not touched (brush) _wpi_deletenullpen( pen ); _wpi_deletebrush( brush ); break; case FILL_BORDER_CLEAR: // border WITH interior erased to bkgd (pen) case FILL_BORDER_FILL: // border and interior (pen & brush) _wpi_deletepen( pen ); _wpi_deletebrush( brush ); break; } }
/* * OutlineRectangle - outline a rectangle with the XOR pen */ void OutlineRectangle( bool firsttime, WPI_PRES pres, WPI_RECT *prevrc, WPI_RECT *newrc ) { int prevrop2; HBRUSH holdbrush; HBRUSH nullbrush; HPEN holdpen; HPEN whitepen; int left, top, right, bottom; _wpi_torgbmode( pres ); nullbrush = _wpi_createnullbrush(); whitepen = _wpi_createpen( PS_SOLID, 0, WHITE ); holdbrush = _wpi_selectobject( pres, nullbrush ); holdpen = _wpi_selectobject( pres, whitepen ); prevrop2 = _wpi_setrop2( pres, R2_XORPEN ); if( !firsttime ) { _wpi_getintrectvalues( *prevrc, &left, &top, &right, &bottom ); /* * In this case don't call _wpi_convertheight because of the * way the rectangle values are set in iedraw.c */ _wpi_rectangle( pres, left, top, right, bottom ); } _wpi_getintrectvalues( *newrc, &left, &top, &right, &bottom ); _wpi_rectangle( pres, left, top, right, bottom ); _wpi_selectobject( pres, holdbrush ); _wpi_selectobject( pres, holdpen ); _wpi_setrop2( pres, prevrop2 ); _wpi_deleteobject( whitepen ); _wpi_deletenullbrush( nullbrush ); } /* OutlineRectangle */
/* * drawBorder - draw the border for the view window */ static void drawBorder( img_node *node ) { WPI_PRES presborder; HPEN hgraypen; HPEN hwhitepen; HPEN hblackpen; HPEN holdpen; WPI_RECT rcclient; HBRUSH hnewbrush; HBRUSH holdbrush; HBRUSH nullbrush; int width; int height; #ifndef __NT__ WPI_POINT pt; #endif int top; int bottom; presborder = _wpi_getpres( node->viewhwnd ); #if defined( __NT__ ) hwhitepen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNHIGHLIGHT ) ); hblackpen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNTEXT ) ); #else hwhitepen = _wpi_createpen( PS_SOLID, 0, CLR_WHITE ); hblackpen = _wpi_createpen( PS_SOLID, 0, CLR_BLACK ); #endif GetClientRect( node->viewhwnd, &rcclient ); width = _wpi_getwidthrect( rcclient ); height = _wpi_getheightrect( rcclient ); if( node->imgtype != BITMAP_IMG ) { #if defined( __NT__ ) hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) ); #else hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_DARKGRAY ); #endif holdpen = _wpi_selectobject( presborder, hgraypen ); #if defined( __NT__ ) hnewbrush = _wpi_createsolidbrush( GetSysColor( COLOR_BTNFACE ) ); #else hnewbrush = _wpi_createsolidbrush( CLR_PALEGRAY ); #endif holdbrush = _wpi_selectobject( presborder, hnewbrush ); top = 0; bottom = height; top = _wpi_cvth_y( top, height ); bottom = _wpi_cvth_y( bottom, height ); _wpi_rectangle( presborder, 0, top, width, bottom ); /* * Draw black border and selected background color in the view window. */ _wpi_selectobject( presborder, hblackpen ); _wpi_selectobject( presborder, holdbrush ); _wpi_deleteobject( hnewbrush ); hnewbrush = _wpi_createsolidbrush( bkgroundColor ); _wpi_selectobject( presborder, hnewbrush ); top = BORDER_WIDTH - 1; bottom = height - BORDER_WIDTH + 1; top = _wpi_cvth_y( top, height ); bottom = _wpi_cvth_y( bottom, height ); #ifndef __NT__ /* * Draw the border relative to the size of the object being displayed, * not the window containing it. */ _wpi_rectangle( presborder, BORDER_WIDTH - 1, top, node->width + BORDER_WIDTH + 1, top + node->height + 2 ); #endif _wpi_selectobject( presborder, holdbrush ); _wpi_selectobject( presborder, holdpen ); _wpi_deleteobject( hnewbrush ); } else { #ifdef __OS2_PM__ // I can't seem to get the thick pen to work so I'm using this // method. hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_PALEGRAY ); holdpen = _wpi_selectobject( presborder, hgraypen ); hnewbrush = _wpi_createsolidbrush( CLR_PALEGRAY ); holdbrush = _wpi_selectobject( presborder, hnewbrush ); _wpi_rectangle( presborder, 0, 0, width + 1, BORDER_WIDTH + 1 ); _wpi_rectangle( presborder, 0, 0, BORDER_WIDTH + 1, height + 1 ); _wpi_rectangle( presborder, 0, height - BORDER_WIDTH, width + 1, height + 1 ); _wpi_rectangle( presborder, width - BORDER_WIDTH, 0, width + 1, height + 1 ); _wpi_selectobject( presborder, holdbrush ); _wpi_deleteobject( hnewbrush ); _wpi_selectobject( presborder, holdpen ); _wpi_deleteobject( hgraypen ); #else #if defined( __NT__ ) hgraypen = _wpi_createpen( PS_INSIDEFRAME, BORDER_WIDTH, GetSysColor( COLOR_BTNFACE ) ); #else hgraypen = _wpi_createpen( PS_INSIDEFRAME, BORDER_WIDTH, CLR_PALEGRAY ); #endif holdpen = _wpi_selectobject( presborder, hgraypen ); nullbrush = _wpi_createnullbrush(); holdbrush = _wpi_selectbrush( presborder, nullbrush ); _wpi_rectangle( presborder, 0, 0, rcclient.right, rcclient.bottom ); _wpi_getoldbrush( presborder, holdbrush ); _wpi_selectobject( presborder, holdpen ); _wpi_deleteobject( hgraypen ); _wpi_deletenullbrush( nullbrush ); #endif nullbrush = _wpi_createnullbrush(); #if defined( __NT__ ) hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) ); #else hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_DARKGRAY ); #endif holdbrush = _wpi_selectbrush( presborder, nullbrush ); holdpen = _wpi_selectobject( presborder, hgraypen ); top = 0; bottom = height; top = _wpi_cvth_y( top, height ); bottom = _wpi_cvth_y( bottom, height ); _wpi_rectangle( presborder, 0, top, width, bottom ); _wpi_selectobject( presborder, hblackpen ); top = BORDER_WIDTH - 1; bottom = height - BORDER_WIDTH + 1; top = _wpi_cvth_y( top, height ); bottom = _wpi_cvth_y( bottom, height ); #ifndef __NT__ /* * Draw the border relative to the size of the object being displayed, * not the window containing it. */ _wpi_rectangle( presborder, BORDER_WIDTH - 1, top, node->width + BORDER_WIDTH + 1, top + node->height + 2 ); #endif _wpi_selectobject( presborder, holdpen ); _wpi_selectbrush( presborder, holdbrush ); _wpi_deletenullbrush( nullbrush ); } /* * Give the view window the 3D effect. */ #ifndef __NT__ holdpen = _wpi_selectobject( presborder, hwhitepen ); _wpi_setpoint( &pt, 0, height - 1 ); _wpi_cvth_pt( &pt, height ); _wpi_movetoex( presborder, &pt, NULL ); _wpi_setpoint( &pt, 0, 0 ); _wpi_cvth_pt( &pt, height ); _wpi_lineto( presborder, &pt ); pt.x = width; _wpi_lineto( presborder, &pt ); _wpi_setpoint( &pt, width - BORDER_WIDTH + 1, BORDER_WIDTH - 2 ); _wpi_cvth_pt( &pt, height ); _wpi_movetoex( presborder, &pt, NULL ); pt.y = height - BORDER_WIDTH + 1; _wpi_cvth_pt( &pt, height ); _wpi_lineto( presborder, &pt ); pt.x = BORDER_WIDTH - 2; _wpi_lineto( presborder, &pt ); _wpi_selectobject( presborder, hgraypen ); _wpi_setpoint( &pt, BORDER_WIDTH - 2, BORDER_WIDTH - 2 ); _wpi_cvth_pt( &pt, height ); _wpi_lineto( presborder, &pt ); pt.x = width - BORDER_WIDTH + 1; _wpi_lineto( presborder, &pt ); _wpi_selectobject( presborder, holdpen ); #endif _wpi_deleteobject( hgraypen ); _wpi_deleteobject( hwhitepen ); _wpi_deleteobject( hblackpen ); _wpi_releasepres( node->viewhwnd, presborder ); } /* drawBorder */
/* * RegionXorAnd - Draws a filled or framed region (ellipse or rectangle) in * the View window. */ void RegionXorAnd( COLORREF xorcolour, COLORREF andcolour, BOOL fFillRgn, WPI_RECT *r, BOOL is_rect ) { HBRUSH oldbrush; HBRUSH hbrush; HPEN oldpen; HPEN hpen; WPI_PRES mempres; HDC memdc; WPI_PRES pres; HBITMAP oldbitmap; int left; int top; int right; int bottom; pres = _wpi_getpres( HWND_DESKTOP ); mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); _wpi_releasepres( HWND_DESKTOP, pres ); _wpi_torgbmode( mempres ); hpen = _wpi_createpen( PS_SOLID, 0, xorcolour ); oldpen = _wpi_selectobject( mempres, hpen ); oldbitmap = _wpi_selectobject( mempres, activeImage->hxorbitmap ); if ( fFillRgn ) { hbrush = _wpi_createsolidbrush( xorcolour ); } else { hbrush = _wpi_createnullbrush(); } oldbrush = _wpi_selectobject( mempres, hbrush ); _wpi_getintrectvalues( *r, &left, &top, &right, &bottom ); if (is_rect) { _wpi_rectangle( mempres, left, top, right, bottom ); } else { _wpi_ellipse( mempres, left, top, right, bottom ); } _wpi_selectobject( mempres, oldpen ); _wpi_deletepen( hpen ); _wpi_selectobject( mempres, oldbrush ); _wpi_selectobject( mempres, oldbitmap ); if (fFillRgn) { _wpi_deleteobject( hbrush ); } else { _wpi_deletenullbrush( hbrush ); } if( activeImage->imgtype == BITMAP_IMG ) { _wpi_deletecompatiblepres( mempres, memdc ); return; } hpen = _wpi_createpen( PS_SOLID, 0, andcolour ); oldpen = _wpi_selectobject( mempres, hpen ); oldbitmap = _wpi_selectobject( mempres, activeImage->handbitmap ); if ( fFillRgn ) { hbrush = _wpi_createsolidbrush( andcolour ); } else { hbrush = _wpi_createnullbrush(); } oldbrush = _wpi_selectobject( mempres, hbrush ); if (is_rect) { _wpi_rectangle( mempres, left, top, right, bottom ); } else { _wpi_ellipse( mempres, left, top, right, bottom ); } _wpi_selectobject( mempres, oldpen ); _wpi_deletepen( hpen ); _wpi_selectobject( mempres, oldbrush ); _wpi_selectobject( mempres, oldbitmap ); if (fFillRgn) { _wpi_deleteobject( hbrush ); } else { _wpi_deletenullbrush( hbrush ); } _wpi_deletecompatiblepres( mempres, memdc ); } /* RegionXorAnd */