/* * outlineRect - draw the outline of a rectangle */ static void outlineRect( statwnd *sw, WPI_PRES pres, WPI_RECT *r ) { WPI_POINT pt; WPI_RECTDIM left; WPI_RECTDIM right; WPI_RECTDIM top; WPI_RECTDIM bottom; HPEN oldpen; sw = sw; _wpi_getrectvalues( *r, &left, &top, &right, &bottom ); _wpi_setpoint( &pt, left, bottom - 1 ); _wpi_cvth_pt( &pt, sw->wndHeight ); _wpi_movetoex( pres, &pt, NULL ); oldpen = _wpi_selectobject( pres, penLight ); pt.x = right - 1; _wpi_lineto( pres, &pt ); pt.y = _wpi_cvth_y( top, sw->wndHeight ); _wpi_lineto( pres, &pt ); _wpi_selectobject( pres, penShade ); pt.x = left; _wpi_lineto( pres, &pt ); pt.y = _wpi_cvth_y( bottom - 1, sw->wndHeight ); _wpi_lineto( pres, &pt ); _wpi_selectobject( pres, oldpen ); } /* outlineRect */
/* * paintPalette - repaint the color palette */ static void paintPalette( HWND hwnd ) { WPI_PRES hdc; WPI_POINT pt; HPEN holdpen; HPEN hgraypen; HPEN hwhitepen; PAINTSTRUCT rect; WPI_RECT client; int height; hdc = _wpi_beginpaint( hwnd, NULL, &rect ); #ifdef __OS2_PM__ WinFillRect( hdc, &rect, CLR_PALEGRAY ); #endif _wpi_torgbmode( hdc ); GetClientRect( hwnd, &client ); height = _wpi_getheightrect( client ); #if defined( __NT__ ) FillRect( (HDC)hdc, (CONST RECT*)&client, hbrush ); #endif #if defined( __NT__ ) hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) ); #else hgraypen = _wpi_createpen( PS_SOLID, 0, DKGRAY ); #endif holdpen = _wpi_selectobject( hdc, hgraypen ); pt.x = 2; pt.y = 50; _wpi_cvth_pt( &pt, height ); _wpi_movetoex( hdc, &pt, NULL ); pt.y = 6; _wpi_cvth_pt( &pt, height ); _wpi_lineto( hdc, &pt ); pt.x = 90; _wpi_lineto( hdc, &pt ); _wpi_selectobject( hdc, holdpen ); _wpi_deleteobject( hgraypen ); #if defined( __NT__ ) hwhitepen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNHIGHLIGHT ) ); #else hwhitepen = _wpi_createpen( PS_SOLID, 0, WHITE ); #endif holdpen = _wpi_selectobject( hdc, hwhitepen ); pt.y = 50; _wpi_cvth_pt( &pt, height ); _wpi_lineto( hdc, &pt ); pt.x = 2; _wpi_lineto( hdc, &pt ); _wpi_selectobject( hdc, holdpen ); _wpi_deleteobject( hwhitepen ); _wpi_endpaint( hwnd, hdc, &rect ); } /* paintPalette */
/* * LineXorAnd - draw the line on the XOR and the AND bitmaps */ void LineXorAnd( COLORREF xorcolor, COLORREF andcolor, WPI_POINT *startpt, WPI_POINT *endpt ) { HPEN oldpen; HPEN hpen; HDC memdc; WPI_PRES pres; WPI_PRES mempres; HBITMAP oldbitmap; HDC anddc; anddc = anddc; 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, xorcolor ); oldpen = _wpi_selectobject( mempres, hpen ); oldbitmap = _wpi_selectobject( mempres, activeImage->hxorbitmap ); _wpi_movetoex( mempres, startpt, NULL ); _wpi_lineto( mempres, endpt ); _wpi_setpixel( mempres, endpt->x, endpt->y, xorcolor ); _wpi_selectobject( mempres, oldpen ); _wpi_deleteobject( hpen ); _wpi_selectobject( mempres, oldbitmap ); if( activeImage->imgtype == BITMAP_IMG ) { _wpi_deletecompatiblepres( mempres, memdc ); return; } hpen = _wpi_createpen( PS_SOLID, 0, andcolor ); oldpen = _wpi_selectobject( mempres, hpen ); oldbitmap = _wpi_selectobject( mempres, activeImage->handbitmap ); _wpi_movetoex( mempres, startpt, NULL ); _wpi_lineto( mempres, endpt ); _wpi_setpixel( mempres, endpt->x, endpt->y, andcolor ); _wpi_selectobject( mempres, oldpen ); _wpi_deleteobject( hpen ); _wpi_selectobject( mempres, oldbitmap ); _wpi_deletecompatiblepres( mempres, anddc ); } /* LineXorAnd */
/* * OutlineLine - outline the line before it is drawn */ void OutlineLine( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, WPI_POINT *prev_pt, BOOL firsttime ) { WPI_POINT startpt; WPI_POINT endpt; WPI_POINT prevpt; int prevROP2; HPEN holdpen; HPEN hwhitepen; WPI_PRES pres; CheckBounds( hwnd, start_pt ); CheckBounds( hwnd, end_pt ); startpt.x = MAKELOGPTX( start_pt->x ) + pointSize.x / 2; startpt.y = MAKELOGPTY( start_pt->y ) + pointSize.y / 2; endpt.x = MAKELOGPTX( end_pt->x ) + pointSize.x / 2; endpt.y = MAKELOGPTY( end_pt->y ) + pointSize.y / 2; pres = _wpi_getpres( hwnd ); _wpi_torgbmode( pres ); hwhitepen = _wpi_createpen( PS_SOLID, 0, WHITE ); holdpen = _wpi_selectobject( pres, hwhitepen ); prevROP2 = _wpi_setrop2( pres, R2_XORPEN ); if( !firsttime ) { CheckBounds( hwnd, prev_pt ); prevpt.x = MAKELOGPTX( prev_pt->x ) + pointSize.x / 2; prevpt.y = MAKELOGPTY( prev_pt->y ) + pointSize.y / 2; _wpi_movetoex( pres, &startpt, NULL ); _wpi_lineto( pres, &prevpt ); } _wpi_movetoex( pres, &startpt, NULL ); _wpi_lineto( pres, &endpt ); _wpi_setrop2( pres, prevROP2 ); _wpi_selectobject( pres, holdpen ); _wpi_deleteobject( hwhitepen ); _wpi_releasepres( hwnd, pres ); } /* OutlineLine */
void _wline( /**********/ int px, int py, BOOL fill_last, BOOL rgn_on, BOOL line_with_two_boxes ) { WPI_POINT initial_pos; _wpi_getcurrpos( Win_dc, &initial_pos ); #if 0 if( Save_style_on ) { wide_line_to_style( Win_dc, px, py, Set_wl_width, Set_wl_style, Set_color, &Save_style, Set_end_marker ); } else { wide_line_to( Win_dc, px, py, Set_wl_width, Set_wl_style, Set_color ); } if( rgn_on ) { if( line_with_two_boxes ) { rgn_line_boxes( initial_pos.x, initial_pos.y, px, py ); } else { rgn_line( initial_pos.x, initial_pos.y, px, py ); } } #else rgn_on = rgn_on; line_with_two_boxes = line_with_two_boxes; { WPI_POINT pt; pt.x = px; pt.y = py; _wpi_lineto( Win_dc, &pt ); } #endif #ifdef PLAT_WIN if( fill_last ) { _wpi_setpixel( Win_dc, px, py, Set_color ); } #else /* in OS/2, the last pixel is always filled. Don't need to do this crap. */ fill_last = fill_last; #endif }
/* * 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 */
/* * showGrid - Display the grid on the draw area. */ static void showGrid( HWND hwnd, WPI_PRES mempres ) { short i; short psx; short psy; WPI_RECT rcclient; HPEN hblackpen; HPEN holdpen; img_node *node; short width; short height; IMGED_DIM left; IMGED_DIM right; IMGED_DIM top; IMGED_DIM bottom; WPI_PRES pres; WPI_POINT startpt; WPI_POINT endpt; node = SelectImage( hwnd ); _wpi_torgbmode( mempres ); GetClientRect( hwnd, &rcclient ); width = (short)( _wpi_getwidthrect(rcclient) ); height = (short)( _wpi_getheightrect(rcclient) ); if (((width / node->width) < POINTSIZE_MIN) || ((height / node->height) < POINTSIZE_MIN)) { psx = 0; psy = 0; } else { psx = width / node->width; psy = height / node->height; hblackpen = _wpi_createpen( PS_SOLID, 0, BLACK ); holdpen = _wpi_selectobject( mempres, hblackpen ); _wpi_getrectvalues( rcclient, &left, &top, &right, &bottom ); for (i=0; i < width; i = i + psx) { _wpi_setpoint( &startpt, i, top ); _wpi_setpoint( &endpt, i, bottom ); _wpi_movetoex( mempres, &startpt, NULL ); _wpi_lineto( mempres, &endpt ); } for (i=0; i <= height; i = i + psy) { _wpi_setpoint( &startpt, left, i ); _wpi_setpoint( &endpt, right, i ); _wpi_movetoex( mempres, &startpt, NULL ); _wpi_lineto( mempres, &endpt ); } _wpi_selectobject( mempres, holdpen ); _wpi_deleteobject( hblackpen ); } pres = _wpi_getpres( hwnd ); _wpi_bitblt( pres, 0, 0, width, height, mempres, 0, 0, SRCCOPY ); _wpi_releasepres( hwnd, pres ); RedrawPrevClip(hwnd); // Redraws if there was a clip region specified. } /* showGrid */
static bool DrawLine( gui_window *wnd, gui_point *start, gui_point *end, gui_line_styles style, gui_ord thickness, WPI_COLOUR colour ) { gui_point my_start; gui_point my_end; HPEN pen; int win_style; gui_coord coord; HPEN old_pen; int hscroll; int vscroll; WPI_POINT pt; int win_height; my_start = *start; my_end = *end; GUIScaleToScreenRPt( &my_start ); GUIScaleToScreenRPt( &my_end ); if( GUI_DO_VSCROLL( wnd ) ) { vscroll = GUIGetScrollPos( wnd, SB_VERT ); } else { vscroll = 0; } if( GUI_DO_HSCROLL( wnd ) ) { hscroll = GUIGetScrollPos( wnd, SB_HORZ ); } else { hscroll = 0; } switch( style ) { case GUI_PEN_SOLID : win_style = PS_SOLID; coord.x = thickness; GUIScaleToScreenR( &coord ); break; case GUI_PEN_DASH : coord.x = 1; win_style = PS_DASH; break; case GUI_PEN_DOT : coord.x = 1; win_style = PS_DOT; break; case GUI_PEN_DASHDOT : coord.x = 1; win_style = PS_DASHDOT; break; case GUI_PEN_DASHDOTDOT : coord.x = 1; win_style = PS_DASHDOTDOT; break; default: coord.x = 0; win_style = 0; break; } pen = _wpi_createpen( win_style, coord.x, colour ); old_pen = _wpi_selectpen( wnd->hdc, pen ); win_height = _wpi_getheightrect( wnd->hwnd_client_rect ); pt.x = my_start.x - hscroll; pt.y = my_start.y - vscroll; pt.y = _wpi_cvth_y_plus1( pt.y, win_height ); _wpi_movetoex( wnd->hdc, &pt, &pt ); pt.x = my_end.x - hscroll; pt.y = my_end.y - vscroll; pt.y = _wpi_cvth_y_plus1( pt.y, win_height ); _wpi_lineto( wnd->hdc, &pt ); if( old_pen != NULLHANDLE ) { _wpi_getoldpen( wnd->hdc, old_pen ); } _wpi_deletepen( pen ); return( true ); }