void GUISetMenu( gui_window *wnd, HMENU hmenu ) { HWND frame; WPI_RECT rect; gui_coord size; int height; #ifndef __OS2_PM__ HMENU omenu; #endif #ifndef __OS2_PM__ omenu = GUIGetHMENU( wnd ); #endif frame = GUIGetParentFrameHWND( wnd ); _wpi_getclientrect( frame, &rect ); height = _wpi_getheightrect( rect ); _wpi_setmenu( frame, hmenu ); _wpi_getclientrect( frame, &rect ); if( height != ( size.y = _wpi_getheightrect( rect ) ) ) { size.x = _wpi_getwidthrect( rect ); GUIDoResize( wnd, GUIGetParentHWND( wnd ), &size ); } #ifndef __OS2_PM__ if( omenu != (HMENU)NULL ) { _wpi_destroymenu( omenu ); } #endif }
/* * ResetDrawArea - Resets the drawing area when a new image is selected from * the select icon menu option. (only for icon files). */ void ResetDrawArea( img_node *node ) { WPI_RECT rcclient; WPI_RECT rc; WPI_PARAM2 lparam; short new_width; short new_height; GetClientRect( node->hwnd, &rcclient ); pointSize.x = max (1, _wpi_getwidthrect(rcclient) / node->width); pointSize.y = max (1, _wpi_getheightrect(rcclient) / node->height); if (ImgedConfigInfo.square_grid) { GetClientRect( ClientWindow, &rc ); if (pointSize.y * node->height > _wpi_getheightrect(rc) ) { pointSize.y = pointSize.x; } else { pointSize.x = pointSize.y; } /* * I add 1 to cause ResizeChild to resize the window. */ new_width = (short)(pointSize.x*node->width+1); new_height = (short)(pointSize.y*node->height+1); lparam = WPI_MAKEP2(new_width, new_height); ResizeChild(lparam, node->hwnd, TRUE ); } BlowupImage( node->hwnd, NULL ); } /* ResetDrawArea */
void GUIResizeToolBar( gui_window *wnd ) { WPI_RECT rect; GUI_RECTDIM left, top, right, bottom; GUI_RECTDIM height; GUI_RECTDIM t, h; toolbarinfo *tbar; tbar = wnd->tbinfo; if( tbar != NULL ) { rect = wnd->root_client_rect; if( wnd->root == NULLHANDLE ) { rect = wnd->hwnd_client_rect; } _wpi_rationalize_rect( &rect ); if( tbar->info.is_fixed ) { height = _wpi_getheightrect( tbar->fixedrect ); h = _wpi_getheightrect( rect ); _wpi_getrectvalues( rect, &left, &top, &right, &bottom ); t = _wpi_cvth_y_plus1( top, h ); bottom = _wpi_cvth_y_plus1( height, h ); _wpi_setwrectvalues( &tbar->fixedrect, left, t, right, bottom ); t = _wpi_cvth_y_size_plus1( top, h, height ); _wpi_movewindow( ToolBarWindow( tbar->hdl ), left, t, right - left, height, TRUE ); } } }
/* * Win_CreateColorPal - create the color palette for the Windows version */ void Win_CreateColorPal( void ) { char *title; title = IEAllocRCString( WIE_COLORPALETTETITLE ); #ifndef __NT__ HColorPalette = CreateWindow( PaletteClass, /* Window class name */ title, WS_POPUPWINDOW | WS_CAPTION, /* Window style */ ImgedConfigInfo.pal_xpos, /* Initial X position */ ImgedConfigInfo.pal_ypos, /* Initial Y position */ CP_WIDTH + 2, /* Initial X size */ CP_HEIGHT + 15, /* Initial Y size */ HMainWindow, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ #else HColorPalette = CreateWindowEx( WS_EX_TOOLWINDOW, PaletteClass, /* Window class name */ title, WS_POPUPWINDOW | WS_CAPTION, /* Window style */ ImgedConfigInfo.pal_xpos, /* Initial X position */ ImgedConfigInfo.pal_ypos, /* Initial Y position */ CP_WIDTH + 2, /* Initial X size */ CP_HEIGHT + 15, /* Initial Y size */ HMainWindow, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ #endif if( title != NULL ) { IEFreeRCString( title ); } if( HColorPalette != (HWND)NULL ) { RECT rect; int w, h; _wpi_getclientrect( HColorPalette, &rect ); w = _wpi_getwidthrect( rect ); h = _wpi_getheightrect( rect ); if( w < CP_WIDTH || h < CP_HEIGHT ) { GetWindowRect( HColorPalette, &rect ); w = _wpi_getwidthrect( rect ) + (CP_WIDTH - w); h = _wpi_getheightrect( rect ) + (CP_HEIGHT - h); SetWindowPos( HColorPalette, HWND_TOP, 0, 0, w, h, SWP_SIZE | SWP_NOZORDER | SWP_NOMOVE ); } } SendMessage( HColorPalette, WM_SETFONT, (DWORD)SmallFont, 0L ); } /* Win_CreateColorPal */
void GUIResizeBackground( gui_window *wnd, bool force_msg ) { WPI_RECT status; int t_height, s_height; GUI_RECTDIM left, top, right, bottom; gui_coord size; if( wnd->root == NULLHANDLE ) { if( wnd->hwnd != NULLHANDLE ) { _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client ); } return; } t_height = 0; s_height = 0; if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->info.is_fixed ) ) { t_height = _wpi_getheightrect( wnd->toolbar->fixedrect ); } if( wnd->status != NULLHANDLE ) { _wpi_getwindowrect( wnd->status, &status ); s_height = _wpi_getheightrect( status ); } _wpi_getclientrect( wnd->root_frame, &wnd->root_client ); _wpi_getrectvalues( wnd->root_client, &left, &top, &right, &bottom ); bottom -= top; right -= left; top = left = 0; #ifdef __OS2_PM__ top += s_height; bottom -= t_height; #else top += t_height; bottom -= s_height; #endif /* if the root client is a separate window resize it too */ _wpi_movewindow( wnd->hwnd, left, top, right - left, bottom - top, TRUE ); _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client ); if( force_msg && ( wnd->flags & SENT_INIT ) ) { size.x = right - left; size.y = bottom - top; GUIScreenToScaleR( &size ); GUIEVENTWND( wnd, GUI_RESIZE, &size ); } }
/* * CreateColorControls - create controls in the color palette window */ void CreateColorControls( HWND hparent ) { WPI_RECT rect; #ifdef __OS2_PM__ PM_CreateColorCtrls( hparent, &hColorsWnd, &hScreenWnd, &hScreenTxt, &hInverseTxt ); #else Win_CreateColorCtrls( hparent, &hColorsWnd, &hScreenWnd, &hScreenTxt, &hInverseTxt ); #endif _wpi_getclientrect( hColorsWnd, &rect ); colorsHeight = _wpi_getheightrect( rect ); _wpi_getclientrect( hScreenWnd, &rect ); screenHeight =_wpi_getheightrect( rect ); } /* CreateColorControls */
/* * GetPointSize - returns the point size. */ WPI_POINT GetPointSize( HWND hwnd ) { WPI_POINT pt = {0, 0}; img_node *node; WPI_RECT rc; int width; int height; node = SelectImage( hwnd ); if (!node) return( pt ); GetClientRect( hwnd, &rc ); width = _wpi_getwidthrect(rc); height = _wpi_getheightrect(rc); pt.x = width / node->width; pt.y = height / node->height; if( pt.x == 0 ) { pt.x = 1; } if( pt.y == 0 ) { pt.y = 1; } return( pt ); } /* GetPointSize */
/* * IECopyImage - copy the current clipping rectangle to the clipboard * * 1) Copy the bitmap to the clipboard (so other apps can use it). * 2) Make a copy of the XOR bitmap and the AND bitmaps so that if * screen colors are involved, they will be preserved. * Later, we check the owner of the clipboard to see if we really * want to use the XOR/AND bitmaps or not. */ void IECopyImage( void ) { short width; short height; img_node *node; node = GetCurrentNode(); if( node == NULL ) { return; } if( !fEnableCutCopy ) { _wpi_setwrectvalues( &clipRect.rect, 0, 0, node->width, node->height ); width = node->width; height = node->height; } else { width = _wpi_getwidthrect( clipRect.rect ); height = _wpi_getheightrect( clipRect.rect ); } copyImageToClipboard( width, height, node ); if( !fEnableCutCopy ) { PrintHintTextByID( WIE_ENTIREIMAGECOPIED, NULL ); } else { PrintHintTextByID( WIE_AREACOPIED, NULL ); RedrawPrevClip( node->hwnd ); fEnableCutCopy = FALSE; } } /* IECopyImage */
/* * MaximizeCurrentChild - make the current edit window as large as it can possibly be */ void MaximizeCurrentChild( void ) { short max_width; short max_height; WPI_POINT max_pt_size; WPI_RECT client; WPI_RECT rect; WPI_RECT rc; img_node *node; short x_adjustment; short y_adjustment; node = GetCurrentNode(); if( node == NULL ) { return; } GetClientRect( node->hwnd, &rc ); GetWindowRect( node->hwnd, &rect ); x_adjustment = _wpi_getwidthrect( rect ) - _wpi_getwidthrect( rc ); y_adjustment = _wpi_getheightrect( rect ) - _wpi_getheightrect( rc ); GetClientRect( ClientWindow, &client ); max_width = (short)_wpi_getwidthrect( client ); max_height = (short)_wpi_getheightrect( client ); max_pt_size.x = max_width / node->width; max_pt_size.y = max_height / node->height; if( ImgedConfigInfo.square_grid ) { if( max_pt_size.x > max_pt_size.y ) max_pt_size.x = max_pt_size.y; max_pt_size.y = max_pt_size.x; } if( max_pt_size.x <= pointSize.x && max_pt_size.y <= pointSize.y ) { return; } max_width = max_pt_size.x * node->width + x_adjustment; max_height = max_pt_size.y * node->height + y_adjustment; SetWindowPos( node->hwnd, HWND_TOP, 0, 0, max_width, max_height, SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_SHOWWINDOW ); } /* MaximizeCurrentChild */
/* * 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 */
/* * CalculateDims - calculate the size of the "pixel" in the drawing * area and establish the device draw area size */ void CalculateDims( short img_width, short img_height, short *area_width, short *area_height ) { int point_size1; int point_size2; int max_width; int max_height; WPI_RECT rcclient; int x_adj; int y_adj; GetClientRect( ClientWindow, &rcclient ); x_adj = (short)(2 * _wpi_getsystemmetrics( SM_CXFRAME )); y_adj = (short)(2 * _wpi_getsystemmetrics( SM_CYFRAME ) + _wpi_getsystemmetrics( SM_CYCAPTION )); #if 0 max_width = _wpi_getwidthrect( rcclient ) - x_adj - origin->x; max_height = _wpi_getheightrect( rcclient ) - y_adj - origin->y; #else max_width = _wpi_getwidthrect( rcclient ) - x_adj; max_height = _wpi_getheightrect( rcclient ) - y_adj; #endif point_size1 = max( 1, max_width / img_width ); point_size2 = max( 1, max_height / img_height ); if( point_size1 < 1 ) { point_size1 = 1; } if( point_size2 < 1 ) { point_size2 = 1; } pointSize.x = min( point_size1, point_size2 ); while( pointSize.x * img_width < MIN_DRAW_WIN_WIDTH ) { pointSize.x++; } pointSize.y = pointSize.x; *area_width = (short)(pointSize.x * img_width); *area_height = (short)(pointSize.y * img_height); } /* CalculateDims */
/* * CutImage - cuts the current clipping rectangle to the clipboard */ void CutImage( void ) { WPI_PRES pres; WPI_PRES mempres; HDC memdc; HBITMAP oldbitmap; short width; short height; img_node *node; WPI_RECTDIM left; WPI_RECTDIM right; WPI_RECTDIM top; WPI_RECTDIM bottom; node = GetCurrentNode(); if( node == NULL ) { return; } if( !fEnableCutCopy ) { _wpi_setwrectvalues( &clipRect.rect, 0, 0, node->width, node->height ); width = node->width; height = node->height; } else { width = (short)_wpi_getwidthrect( clipRect.rect ); height = (short)_wpi_getheightrect( clipRect.rect ); } copyImageToClipboard( width, height, node ); pres = _wpi_getpres( node->viewhwnd ); mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); _wpi_releasepres( node->viewhwnd, pres ); oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap ); _wpi_getrectvalues( clipRect.rect, &left, &top, &right, &bottom ); _wpi_patblt( mempres, left, top, width, height, WHITENESS ); _wpi_getoldbitmap( mempres, oldbitmap ); oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap ); _wpi_patblt( mempres, left, top, width, height, BLACKNESS ); _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_deletecompatiblepres( mempres, memdc ); InvalidateRect( node->viewhwnd, NULL, FALSE ); RecordImage( node->hwnd ); if( !fEnableCutCopy ) { PrintHintTextByID( WIE_ENTIREIMAGECUT, NULL ); } else { PrintHintTextByID( WIE_AREACUT, NULL ); fEnableCutCopy = FALSE; } BlowupImage( node->hwnd, NULL ); } /* CutImage */
/* * ClearImage - clear the XOR and the AND bitmaps */ void ClearImage( void ) { WPI_PRES pres; WPI_PRES xorpres; WPI_PRES andpres; HDC xormemdc; HDC andmemdc; HBITMAP oldxor; HBITMAP oldand; img_node *node; WPI_RECT clear_area; IMGED_DIM left; IMGED_DIM top; IMGED_DIM right; IMGED_DIM bottom; int width; int height; node = GetCurrentNode(); if( node == NULL ) { return; } if( DoesRectExist( &clear_area ) ) { SetRectExists( FALSE ); } else { _wpi_setwrectvalues( &clear_area, 0, 0, node->width, node->height ); } pres = _wpi_getpres( HWND_DESKTOP ); xorpres = _wpi_createcompatiblepres( pres, Instance, &xormemdc ); andpres = _wpi_createcompatiblepres( pres, Instance, &andmemdc ); _wpi_releasepres( HWND_DESKTOP, pres ); oldxor = _wpi_selectobject( xorpres, node->hxorbitmap ); oldand = _wpi_selectobject( andpres, node->handbitmap ); _wpi_getwrectvalues( clear_area, &left, &top, &right, &bottom ); width = _wpi_getwidthrect( clear_area ); height = _wpi_getheightrect( clear_area ); _wpi_patblt( xorpres, left, top, width, height, WHITENESS ); _wpi_patblt( andpres, left, top, width, height, BLACKNESS ); _wpi_selectobject( xorpres, oldxor ); _wpi_selectobject( andpres, oldand ); _wpi_deletecompatiblepres( xorpres, xormemdc ); _wpi_deletecompatiblepres( andpres, andmemdc ); InvalidateRect( node->viewhwnd, NULL, TRUE ); RecordImage( node->hwnd ); BlowupImage( node->hwnd, NULL ); PrintHintTextByID( WIE_AREACLEARED, NULL ); } /* ClearImage */
/* * BlowupImage - stretch the view window into the window given by hwnd */ void BlowupImage( HWND hmdiwnd, WPI_PRES pres ) { HDC memdc; WPI_PRES mempres; WPI_RECT client; HBITMAP oldbitmap; HBITMAP newbitmap; HWND hwnd; img_node *node; BOOL new_pres; if( hmdiwnd != NULL ) { hwnd = hmdiwnd; } else { node = GetCurrentNode(); if( node == NULL ) { return; } hwnd = node->hwnd; } newbitmap = EnlargeImage( hwnd ); if( newbitmap == NULL ) { return; } new_pres = FALSE; if( pres == (WPI_PRES)NULL ) { pres = _wpi_getpres( hwnd ); new_pres = TRUE; } mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); oldbitmap = _wpi_selectobject( mempres, newbitmap ); if( ImgedConfigInfo.grid_on ) { showGrid( hwnd, mempres ); } else { GetClientRect( hwnd, &client ); _wpi_bitblt( pres, 0, 0, _wpi_getwidthrect( client ), _wpi_getheightrect( client ), mempres, 0, 0, SRCCOPY ); RedrawPrevClip( hwnd ); // Redraw if there was a clip region specified. } _wpi_selectobject( mempres, oldbitmap ); _wpi_deletebitmap( newbitmap ); _wpi_deletecompatiblepres( mempres, memdc ); if( new_pres ) { _wpi_releasepres( hwnd, pres ); } } /* BlowupImage */
void GUISetRowCol( gui_window *wnd, gui_coord *size ) { gui_coord my_size; if( size == NULL ) { my_size.y = _wpi_getheightrect( wnd->hwnd_client_rect ); my_size.x = _wpi_getwidthrect( wnd->hwnd_client_rect ); } else { my_size = *size; } GUIToText( &my_size, wnd ); wnd->num_rows = my_size.y; wnd->num_cols = my_size.x; }
/* * CreateDrawnImage - Creates the enlarged image in the drawing area. (used * when activating a new image or selecting a new image). */ void CreateDrawnImage( img_node *node ) { WPI_RECT rcclient; int cx; int cy; GetClientRect( node->hwnd, &rcclient ); hDrawArea = node->hwnd; cx = _wpi_getwidthrect(rcclient); cy = _wpi_getheightrect(rcclient); cx = cx / node->width; cy = cy / node->height; pointSize.x = max (1, cx); pointSize.y = max (1, cy); } /* CreateDrawnImage */
/* * ResetViewWindow - when a new MDI child is activated, reset the position * of the view window * - first check if only 1 view window is being shown, or all of them */ void ResetViewWindow( HWND hwnd ) { WPI_RECT currentloc; WPI_RECT newloc; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; HWND hframe; HWND currentframe; hframe = _wpi_getframe( hwnd ); if( hViewWindow != NULL ) { currentframe = _wpi_getframe( hViewWindow ); } else { currentframe = NULL; } if( fOneViewWindow ) { _wpi_getwindowrect( hframe, &newloc ); if( hViewWindow != NULL ) { _wpi_getwindowrect( currentframe, ¤tloc ); ShowWindow( currentframe, SW_HIDE ); } else { currentloc = newloc; } _wpi_getrectvalues( currentloc, &left, &top, &right, &bottom ); SetWindowPos( hframe, NULL, left, top, _wpi_getwidthrect( newloc ), _wpi_getheightrect( newloc ), SWP_MOVE | SWP_SIZE | SWP_NOZORDER | SWP_HIDEWINDOW ); hViewWindow = hwnd; ShowWindow( hframe, showState ); } else { hViewWindow = hwnd; ShowWindow( hframe, showState ); _wpi_bringwindowtotop( hframe ); } #ifndef __OS2_PM__ RedrawWindow( hwnd, NULL, NULL, RDW_UPDATENOW ); #endif } /* ResetViewWindow */
/* * CreateCurrentWnd - create the window with the current selection in it */ void CreateCurrentWnd( HWND hparent ) { WPI_RECT rect; lButton.color = BLACK; lButton.solid = BLACK; lButton.type = NORMAL_CLR; rButton.color = WHITE; rButton.solid = WHITE; rButton.type = NORMAL_CLR; #ifdef __OS2_PM__ hCurrentWnd = PM_CreateCurrentDisp( hparent ); #else hCurrentWnd = Win_CreateCurrentDisp( hparent ); #endif _wpi_getclientrect( hCurrentWnd, &rect ); currentHeight = _wpi_getheightrect( rect ); } /* CreateCurrentWnd */
/* * ResizeChild - resizes the draw area of the child window. */ void ResizeChild( WPI_PARAM2 lparam, HWND hwnd, BOOL firsttime ) { short min_width; short width; short height; img_node *node; short x_adjustment; short y_adjustment; short new_width; short new_height; WPI_POINT point_size; WPI_POINT max; HWND frame; HMENU hmenu; WPI_RECT rc; WPI_RECT rect; frame = _wpi_getframe( hwnd ); width = LOWORD( lparam ); #ifdef __OS2_PM__ height = SHORT2FROMMP( lparam ); #else height = HIWORD( lparam ); #endif GetClientRect( hwnd, &rc ); GetWindowRect( hwnd, &rect ); if( frame ) { GetClientRect( frame, &rc ); GetWindowRect( frame, &rect ); } max.x = _wpi_getsystemmetrics( SM_CXSCREEN ); max.y = _wpi_getsystemmetrics( SM_CYSCREEN ); x_adjustment = _wpi_getwidthrect( rect ) - _wpi_getwidthrect( rc ); y_adjustment = _wpi_getheightrect( rect ) - _wpi_getheightrect( rc ); #if 1 min_width = MIN_DRAW_WIN_WIDTH; #else min_width = (short)(2*_wpi_getsystemmetrics(SM_CXSIZE)) + x_adjustment + 8; // fudge factor to allow some of title bar to show #endif #ifdef __OS2_PM__ ++y_adjustment; #endif node = SelectImage( hwnd ); if (!node) return; // the following assumes that max.x >> min_width point_size.x = min( max.x / node->width, width / node->width ); point_size.x = max( min_width / node->width + 1, point_size.x ); point_size.y = min( max.y / node->height, height / node->height ); point_size.y = max( 1, point_size.y ); if( ImgedConfigInfo.square_grid ) { point_size.x = min( point_size.x, point_size.y ); if( point_size.x < ( min_width / node->width + 1 ) ) { point_size.x = min_width / node->width + 1; } if( point_size.x > ( max.y / node->height ) ) { hmenu = GetMenu( _wpi_getframe(HMainWindow) ); CheckSquareGrid( hmenu ); } else { point_size.y = point_size.x; } } new_width = (short)(point_size.x * node->width + x_adjustment); new_height = (short)(point_size.y * node->height + y_adjustment); pointSize = point_size; if( (pointSize.x*node->width != width) || (pointSize.y*node->height != height) ) { SetWindowPos( frame, HWND_TOP, 0, 0, new_width, new_height, SWP_SIZE | SWP_ZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); SetGridSize( pointSize.x, pointSize.y ); } if( !firsttime ) { BlowupImage( node->hwnd, NULL ); } } /* ResizeChild */
/* * 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 */
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height, int num_toolbar_items, gui_toolbar_struct *toolinfo, bool excl, gui_colour_set *plain, gui_colour_set *standout, gui_rect *float_pos, bool use_tips ) { gui_coord size; gui_coord pos; HWND parent; HWND toolhwnd; toolbarinfo *tbar; int i; TOOLITEMINFO info; int fixed_height; int fixed_width; int adjust_amount; int width; int new_right; int bm_h; int bm_w; GUI_RECTDIM left, top, right, bottom; int h; excl = excl; plain = plain; standout = standout; fixed_height = 0; fixed_width = 0; if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) || ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) { return( false ); } if( wnd->tbinfo != NULL ) { GUICloseToolBar( wnd ); } tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) ); if( tbar == NULL ) { return( false ); } memset( tbar, 0, sizeof( toolbarinfo ) ); parent = wnd->root; tbar->fixedrect = wnd->hwnd_client_rect; tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) ); if( tbar->bitmaps == NULL ) { GUIMemFree( tbar ); wnd->tbinfo = NULL; return( false ); } for( i = 0; i < num_toolbar_items; i++ ) { tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst, _wpi_makeintresource( toolinfo[i].bitmap ) ); if( height == 0 ) { _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h ); if( bm_h > fixed_height ) { fixed_height = bm_h; } if( bm_w > fixed_width ) { fixed_width = bm_w; } } } tbar->info.border_size.x = BORDER_AMOUNT; tbar->info.border_size.y = BORDER_AMOUNT; /* space for border and space before border */ adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT); if( height == 0 ) { /* maintian # of pixels in bitmap */ height = fixed_height + adjust_amount + OUTLINE_AMOUNT; width = fixed_width + OUTLINE_AMOUNT; } else { /* only height of windows given, make bitmaps square */ size.x = 0; size.y = height - 2; GUIScaleToScreenR( &size ); height = size.y; width = size.y; } _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom ); h = _wpi_getheightrect( tbar->fixedrect ); bottom = _wpi_cvth_y_plus1( height, h ); top = _wpi_cvth_y_plus1( top, h ); _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom ); height -= adjust_amount; /* leaving just button size */ tbar->info.button_size.x = width; tbar->info.button_size.y = height; bottom = height + BORDER_AMOUNT * 2 + _wpi_getsystemmetrics( SM_CYCAPTION ) + 2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) - _wpi_getsystemmetrics( SM_CYBORDER ) ); bottom = _wpi_cvth_y_plus1( bottom, h ); #ifdef __OS2_PM__ bottom -= 2; #endif new_right = width * num_toolbar_items - (num_toolbar_items - 1) * tbar->info.border_size.x + left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) + BORDER_AMOUNT * 2; if( new_right < right ) { right = new_right; } _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); if( fixed ) { tbar->info.area = tbar->fixedrect; tbar->info.style = TOOLBAR_FIXED_STYLE; } else { if( float_pos != NULL ) { GUICalcLocation( float_pos, &pos, &size, parent ); _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y, pos.x + size.x, pos.y + size.y ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); } tbar->info.area = tbar->floatrect; tbar->info.style = TOOLBAR_FLOAT_STYLE; } tbar->info.hook = guiToolBarProc; tbar->info.helphook = guiToolBarHelp; tbar->info.background = 0; tbar->info.foreground = 0; tbar->num = num_toolbar_items; tbar->info.is_fixed = fixed; tbar->info.use_tips = use_tips; tbar->hdl = ToolBarInit( parent ); ToolBarDisplay( tbar->hdl, &tbar->info ); GUIResizeBackground( wnd, true ); for( i = 0; i < num_toolbar_items; i++ ) { info.u.bmp = tbar->bitmaps[i]; info.id = toolinfo[i].id; info.flags = 0; if( use_tips && toolinfo[i].tip != NULL ) { strncpy( info.tip, toolinfo[i].tip, MAX_TIP ); } else { info.tip[0] = '\0'; } ToolBarAddItem( tbar->hdl, &info ); } toolhwnd = ToolBarWindow( tbar->hdl ); _wpi_showwindow( toolhwnd, SW_SHOWNORMAL ); _wpi_updatewindow( toolhwnd ); return( true ); }
/* * ImgEdFrameProc - handle messages for the image editor application */ WPI_MRESULT CALLBACK ImgEdFrameProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static BOOL window_destroyed = FALSE; static HMENU hmenu; ctl_id cmdid; img_node *node; WPI_RECT rcmain; #ifndef __OS2_PM__ about_info ai; #endif WPI_RECTDIM left, top; if( !window_destroyed ) { enableMainItems( hmenu ); } switch( msg ) { case UM_EXIT: _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); /* fall through */ case UM_EXIT_NO_SAVE: if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { break; } #ifndef __OS2_PM__ _wpi_destroywindow( _wpi_getframe( hwnd ) ); #else _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 ); #endif break; case UM_SAVE_ALL: SaveAllImages(); break; case WM_CREATE: hmenu = _wpi_getmenu( _wpi_getframe( hwnd ) ); #ifndef __OS2_PM__ createClientWindow( hwnd ); #endif if( !InitStatusLine( hwnd ) ) { return( -1 ); } InitFunctionBar( hwnd ); InitIconInfo(); InitializeCursors(); /* * Set values from profile information ... */ if( ImgedConfigInfo.brush_size <= 5 && ImgedConfigInfo.brush_size >= 2 ) { checkBrushItem( hmenu, IMGED_2x2 - 2 + ImgedConfigInfo.brush_size ); } if( ImgedConfigInfo.grid_on ) { CheckGridItem( hmenu ); } if( ImgedConfigInfo.square_grid ) { CheckSquareGrid( hmenu ); } if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) { CheckViewItem( hmenu ); } _wpi_enablemenuitem( hmenu, IMGED_CRESET, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); #ifndef __OS2_PM__ // not necessary for PM InitMenus( hmenu ); #endif SetHintText( IEAppTitle ); return( 0 ); #ifdef __NT__ case WM_DROPFILES: OpenImage( (HANDLE)wparam ); break; #endif case WM_MOVE: _wpi_getwindowrect( hwnd, &rcmain ); if( !ImgedConfigInfo.ismaximized ) { ImgedConfigInfo.last_xpos = ImgedConfigInfo.x_pos; ImgedConfigInfo.last_ypos = ImgedConfigInfo.y_pos; _wpi_getrectvalues( rcmain, &left, &top, NULL, NULL ); ImgedConfigInfo.x_pos = (short)left; ImgedConfigInfo.y_pos = (short)top; } return( 0 ); case WM_SIZE: ResizeFunctionBar( lparam ); ResizeStatusBar( lparam ); #ifndef __OS2_PM__ if( ClientWindow != NULL ) { setClientSize( hwnd ); } #else resizeClientArea( lparam ); #endif if( !_imgwpi_issizeminimized( wparam ) && !_imgwpi_issizemaximized( wparam ) ) { _wpi_getwindowrect( hwnd, &rcmain ); ImgedConfigInfo.width = (short)_wpi_getwidthrect( rcmain ); ImgedConfigInfo.height = (short)_wpi_getheightrect( rcmain ); ImgedConfigInfo.ismaximized = FALSE; } else { ImgedConfigInfo.x_pos = ImgedConfigInfo.last_xpos; ImgedConfigInfo.y_pos = ImgedConfigInfo.last_ypos; ImgedConfigInfo.ismaximized = _imgwpi_issizemaximized( wparam ); } return( FALSE ); case WM_MENUSELECT: #ifndef __OS2_PM__ if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SEPARATOR ) { break; } if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SYSMENU ) { PrintHintTextByID( WIE_SYSMENUOPERATIONS, NULL ); break; } #endif ShowHintText( LOWORD( wparam ) ); break; case WM_COMMAND: cmdid = LOWORD( wparam ); if( !IEIsMenuIDValid( hmenu, cmdid ) ) { break; } switch( cmdid ) { case IMGED_NEW: if( !ImgedIsDDE ) { if( !NewImage( UNDEF_IMG, NULL ) ) { PrintHintTextByID( WIE_NEIMAGENOTCREATED, NULL ); } } break; case IMGED_CLOSE: node = GetCurrentNode(); if( node != NULL ) { _wpi_sendmessage( node->hwnd, WM_CLOSE, 0, 0L ); } break; case IMGED_CLOSEALL: CloseAllImages(); break; case IMGED_HELP: IEHelpRoutine(); break; case IMGED_HELP_SEARCH: IEHelpSearchRoutine(); break; case IMGED_HELP_ON_HELP: IEHelpOnHelpRoutine(); break; case IMGED_ABOUT: #ifndef __OS2_PM__ ai.owner = hwnd; ai.inst = Instance; ai.name = IEAllocRCString( WIE_ABOUTTEXT ); ai.version = IEAllocRCString( WIE_ABOUTVERSION ); ai.title = IEAllocRCString( WIE_ABOUTTITLE ); DoAbout( &ai ); if( ai.name != NULL ) { IEFreeRCString( ai.name ); } if( ai.version != NULL ) { IEFreeRCString( ai.version ); } if( ai.title != NULL ) { IEFreeRCString( ai.title ); } #endif break; #ifndef __OS2_PM__ case IMGED_DDE_UPDATE_PRJ: IEUpdateDDEEditSession(); break; #endif case IMGED_SAVE_AS: SaveFile( SB_SAVE_AS ); break; case IMGED_SAVE: SaveFile( SB_SAVE ); break; case IMGED_OPEN: if( !ImgedIsDDE ) { OpenImage( NULL ); } break; case IMGED_CLEAR: ClearImage(); break; case IMGED_NEWIMG: AddNewIcon(); break; case IMGED_SELIMG: SelectIconImg(); break; case IMGED_DELIMG: DeleteIconImg(); break; case IMGED_UNDO: UndoOp(); break; case IMGED_REDO: RedoOp(); break; case IMGED_REST: RestoreImage(); break; case IMGED_SNAP: #ifndef __OS2_PM__ SnapPicture(); #endif break; case IMGED_RIGHT: case IMGED_LEFT: case IMGED_UP: case IMGED_DOWN: ShiftImage( cmdid ); break; case IMGED_FLIPHORZ: case IMGED_FLIPVERT: FlipImage( cmdid ); break; case IMGED_ROTATECC: case IMGED_ROTATECL: RotateImage( cmdid ); break; case IMGED_PASTE: PlaceAndPaste(); break; case IMGED_COPY: IECopyImage(); break; case IMGED_CUT: CutImage(); break; case IMGED_COLOR: CheckPaletteItem( hmenu ); break; case IMGED_VIEW: CheckViewItem( hmenu ); break; case IMGED_TOOLBAR: CheckToolbarItem( hmenu ); break; case IMGED_SQUARE: CheckSquareGrid( hmenu ); break; case IMGED_SIZE: ChangeImageSize(); break; case IMGED_GRID: CheckGridItem( hmenu ); break; case IMGED_MAXIMIZE: MaximizeCurrentChild(); break; case IMGED_SETTINGS: SelectOptions(); break; case IMGED_2x2: case IMGED_3x3: case IMGED_4x4: case IMGED_5x5: checkBrushItem( hmenu, cmdid ); break; case IMGED_CEDIT: #ifndef __OS2_PM__ EditColors(); #endif break; case IMGED_CRESET: #ifndef __OS2_PM__ RestoreColors(); #endif break; case IMGED_CSCREEN: ChooseBkColor(); break; case IMGED_SCOLOR: #ifndef __OS2_PM__ SaveColorPalette(); #endif break; case IMGED_LCOLOR: #ifndef __OS2_PM__ if( LoadColorPalette() ) { _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE ); } #endif break; case IMGED_RCOLOR: RestoreColorPalette(); break; case IMGED_FREEHAND: case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_FILL: case IMGED_BRUSH: case IMGED_CLIP: case IMGED_HOTSPOT: SetToolType( cmdid ); PushToolButton( cmdid ); break; case IMGED_ARRANGE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDIICONARRANGE, 0, 0L ); #endif break; case IMGED_TILE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDITILE, MDITILE_VERTICAL, 0L ); #endif break; case IMGED_CASCADE: #ifndef __OS2_PM__ SendMessage( ClientWindow, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0L ); #endif break; case IMGED_EXIT: _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { break; } #ifndef __OS2_PM__ _wpi_destroywindow( _wpi_getframe( hwnd ) ); #else _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 ); #endif break; default: #if 1 return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) ); #else return( 0 ); #endif } return( 0 ); #ifndef __OS2_PM__ case WM_COMPACTING: RelieveUndos(); return 0; #endif case WM_QUERYENDSESSION: if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) { if( ImgedConfigInfo.ismaximized ) { _wpi_maximizewindow( _wpi_getframe( hwnd ) ); } else { _wpi_showwindow( _wpi_getframe( hwnd ), SW_SHOWNORMAL ); } } _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { return( 0 ); } return( (WPI_MRESULT)1 ); case WM_CLOSE: // wParam is non-zero if the DDE connection died if( !wparam && !ImgEdEnableMenuInput ) { // this prevents the user from closing the editor during // DDE initialization return( 0 ); } _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L ); #ifdef __OS2_PM__ return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); #else if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) { return( 0 ); } window_destroyed = TRUE; _wpi_destroywindow( _wpi_getframe( hwnd ) ); return( 0 ); #endif case WM_DESTROY: #ifndef __OS2_PM__ WWinHelp( HMainWindow, "resimg.hlp", HELP_QUIT, 0 ); #endif FiniStatusLine(); CleanupClipboard(); CleanupCursors(); CloseToolBar(); CloseFunctionBar(); _wpi_deletefont( SmallFont ); _wpi_postquitmessage( 0 ); return( 0 ); default: break; } return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) ); } /* ImgEdFrameProc */
/* * WinCreateViewWin - create the view window for the Windows version */ HWND WinCreateViewWin( HWND hviewwnd, BOOL foneview, int *showstate, int width, int height ) { HWND hwnd; RECT location; int x, y; int h_adj; int v_adj; if( hviewwnd != NULL && foneview ) { GetWindowRect( hviewwnd, &location ); x = location.left; y = location.top; } else { x = ImgedConfigInfo.view_xpos; y = ImgedConfigInfo.view_ypos; } width += 2 * BORDER_WIDTH; height += 2 * BORDER_WIDTH; h_adj = 2 * GetSystemMetrics( SM_CXDLGFRAME ); v_adj = 2 * GetSystemMetrics( SM_CYDLGFRAME ) + #ifndef __NT__ GetSystemMetrics( SM_CYCAPTION ) - 1; #else GetSystemMetrics( SM_CYSMCAPTION ) - 1; #endif #ifndef __NT__ hwnd = CreateWindow( ViewWinClass, /* Window class name */ "View", WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_CLIPSIBLINGS | WS_DLGFRAME, /* Window style */ x, /* Initial X position */ y, /* Initial Y position */ h_adj + width, /* Initial X size */ v_adj + height, /* Initial Y size */ HMainWindow, /* Parent window handle */ (HMENU) NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ #else hwnd = CreateWindowEx( WS_EX_TOOLWINDOW, ViewWinClass, /* Window class name */ "View", WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE | WS_CLIPSIBLINGS | WS_DLGFRAME, /* Window style */ x, /* Initial X position */ y, /* Initial Y position */ h_adj + width, /* Initial X size */ v_adj + height, /* Initial Y size */ HMainWindow, /* Parent window handle */ (HMENU) NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ #endif ShowWindow( hwnd, SW_HIDE ); if( hwnd != (HWND)NULL ) { RECT rect; int w, h; _wpi_getclientrect( hwnd, &rect ); w = _wpi_getwidthrect( rect ); h = _wpi_getheightrect( rect ); if( w < width || h < height ) { GetWindowRect( hwnd, &rect ); w = _wpi_getwidthrect( rect ) + (width - w); h = _wpi_getheightrect( rect ) + (height - h); SetWindowPos( hwnd, HWND_TOP, 0, 0, w, h, SWP_SIZE | SWP_NOZORDER | SWP_NOMOVE ); } } if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) { *showstate = SW_SHOWNORMAL; } else { *showstate = SW_HIDE; } return( hwnd ); } /* WinCreateViewWin */
/* * drawPt - Actually draws the point on the drawing region. (uses LineDDA) */ void CALLBACK drawPt( int xpos, int ypos, WPI_PARAM2 lparam ) { HBRUSH colourbrush; HBRUSH oldbrush; HPEN colourpen; HPEN oldpen; COLORREF selected_colour; COLORREF dithered; short mousebutton; WPI_PRES pres; HWND hwnd; short area_x; short area_y; short width; short height; short i; short j; WPI_POINT pt; WPI_RECT rcclient; wie_clrtype type; int brushsize; BOOL gridvisible; hwnd = (HWND)GET_HWND_PARAM2( lparam ); mousebutton = currentMouseButton; _wpi_getclientrect( hwnd, &rcclient ); brushsize = ImgedConfigInfo.brush_size; gridvisible = ImgedConfigInfo.grid_on && (pointSize.x >= POINTSIZE_MIN && pointSize.y >= POINTSIZE_MIN); if ((!gridvisible) && (toolType == IMGED_FREEHAND)) { area_x = xpos * pointSize.x; area_y = ypos * pointSize.y; width = (short)pointSize.x; height = (short)pointSize.y; } else if ((!gridvisible) && (toolType == IMGED_BRUSH)) { area_x = max(0, xpos-brushsize/2) * pointSize.x; area_y = max(0, ypos-brushsize/2) * pointSize.y; width = (short)(brushsize * pointSize.x); height = (short)(brushsize * pointSize.y); /* * We just have to check that we don't spill over the image dimensions */ area_x = min( area_x, _wpi_getwidthrect(rcclient)-width ); area_y = min( area_y, _wpi_getheightrect(rcclient)-width ); } else if ((gridvisible) && (toolType == IMGED_FREEHAND)) { area_x = xpos * pointSize.x+1; area_y = ypos * pointSize.y+1; width = (short)(pointSize.x-1); height = (short)(pointSize.y-1); } else { area_x = max(0, xpos-brushsize/2) * pointSize.x+1; area_y = max(0, ypos-brushsize/2) * pointSize.y+1; width = (short)(pointSize.x - 1); height = (short)(pointSize.y - 1); /* * We just have to check that we don't spill over the image dimensions */ area_x = min( area_x, _wpi_getwidthrect(rcclient) - pointSize.x * brushsize+1 ); area_y = min( area_y, _wpi_getheightrect(rcclient) - pointSize.y * brushsize+1 ); } pres = _wpi_getpres( hwnd ); _wpi_torgbmode( pres ); dithered = GetSelectedColour( mousebutton, &selected_colour, &type ); colourbrush = _wpi_createsolidbrush( selected_colour ); oldbrush = _wpi_selectobject(pres, colourbrush); colourpen = _wpi_createpen(PS_SOLID, 0, selected_colour); oldpen = _wpi_selectobject(pres, colourpen); if (gridvisible && (toolType == IMGED_BRUSH)) { for (i=0; i < brushsize; ++i) { for (j=0; j < brushsize; ++j) { _wpi_patblt(pres, area_x+i*pointSize.x, area_y+j*pointSize.y, width, height, PATCOPY); } } } else { _wpi_patblt(pres, area_x, area_y, width, height, PATCOPY); } _wpi_selectobject(pres, oldbrush); _wpi_selectobject(pres, oldpen); _wpi_releasepres( hwnd, pres ); _wpi_deleteobject( colourbrush ); _wpi_deleteobject( colourpen ); pt.x = area_x / pointSize.x; pt.y = area_y / pointSize.y; if (toolType == IMGED_BRUSH) { if (type == SCREEN_CLR) { BrushThePoints(selected_colour, BLACK, WHITE, &pt, brushsize); } else if (type == INVERSE_CLR) { BrushThePoints(selected_colour, WHITE, WHITE, &pt, brushsize); } else { BrushThePoints(selected_colour, selected_colour, BLACK, &pt, brushsize); } } else { if (type == SCREEN_CLR) { DrawThePoints(selected_colour, BLACK, WHITE, &pt); } else if (type == INVERSE_CLR) { DrawThePoints(selected_colour, WHITE, WHITE, &pt); } else { DrawThePoints(selected_colour, selected_colour, BLACK, &pt); } } } /* drawPt */
/* * ShiftImage - shift the image in the given direction */ void ShiftImage( WORD shiftdirection ) { HBITMAP dup_and; HBITMAP dup_xor; HBITMAP oldbitmap; HBITMAP oldsrcbitmap; WPI_PRES pres; HDC memdc; WPI_PRES mempres; HDC srcdc; WPI_PRES srcpres; short x_src; short y_src; short x_dest; short y_dest; short width; short height; short min_width; short min_height; short rgn_width; short rgn_height; img_node *node; WPI_RECT rect; IMGED_DIM left; IMGED_DIM right; IMGED_DIM top; IMGED_DIM bottom; DWORD message; node = GetCurrentNode(); if( node == NULL ) { return; } dup_and = DuplicateBitmap( node->handbitmap ); dup_xor = DuplicateBitmap( node->hxorbitmap ); pres = _wpi_getpres( HWND_DESKTOP ); mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc ); _wpi_releasepres( HWND_DESKTOP, pres ); _wpi_torgbmode( mempres ); _wpi_torgbmode( srcpres ); if( DoesRectExist( &rect ) ) { width = (short)_wpi_getwidthrect( rect ); height = (short)_wpi_getheightrect( rect ); } else { _wpi_setwrectvalues( &rect, 0, 0, node->width, node->height ); width = node->width; height = node->height; } _wpi_getwrectvalues( rect, &left, &top, &right, &bottom ); oldbitmap = _wpi_selectobject( mempres, node->handbitmap ); _wpi_patblt( mempres, left, top, width, height, BLACKNESS ); _wpi_selectobject( mempres, oldbitmap ); oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap ); _wpi_patblt( mempres, left, top, width, height, WHITENESS ); oldsrcbitmap = _wpi_selectobject( srcpres, dup_xor ); x_src = (short)left; y_src = (short)top; x_dest =(short)left; y_dest = (short)top; min_width = (short)min( ImgedConfigInfo.shift, width ); min_height = (short)min( ImgedConfigInfo.shift, height ); rgn_width = width; rgn_height = height; switch( shiftdirection ) { case IMGED_LEFT: width -= min_width; x_src = x_src + min_width; message = WIE_IMAGESHIFTEDLEFT; break; case IMGED_RIGHT: width -= min_width; x_dest = x_dest + min_width; message = WIE_IMAGESHIFTEDRIGHT; break; case IMGED_UP: #ifndef __OS2_PM__ height -= min_height; y_src = y_src + min_height; #else height += min_height; y_src = y_src - min_height; #endif message = WIE_IMAGESHIFTEDUP; break; case IMGED_DOWN: #ifndef __OS2_PM__ height -= min_height; y_dest = y_dest + min_height; #else height += min_height; y_dest = y_dest - min_height; #endif message = WIE_IMAGESHIFTEDDOWN; break; default: break; } _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY ); _wpi_selectobject( srcpres, oldsrcbitmap ); oldsrcbitmap = _wpi_selectobject( srcpres, dup_and ); _wpi_selectobject( mempres, oldbitmap ); oldbitmap = _wpi_selectobject( mempres, node->handbitmap ); _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY ); if( IsShiftWrap() ) { switch( shiftdirection ) { case IMGED_LEFT: width = min_width; x_src = (short)left; x_dest = (short)(right - width); break; case IMGED_RIGHT: width = min_width; x_dest = (short)left; x_src = (short)(right - width); break; case SHIFT_UP: height = min_height; y_src = (short)top; y_dest = (short)(bottom - height); break; case SHIFT_DOWN: height = min_height; y_dest = (short)top; y_src = (short)(bottom - height); break; default: break; } _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY ); _wpi_selectobject( srcpres, oldsrcbitmap ); _wpi_selectobject( mempres, oldbitmap ); oldsrcbitmap = _wpi_selectobject( srcpres, dup_xor ); oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap ); _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY ); } _wpi_selectobject( srcpres, oldsrcbitmap ); _wpi_selectobject( mempres, oldbitmap ); _wpi_deletecompatiblepres( srcpres, srcdc ); _wpi_deletecompatiblepres( mempres, memdc ); _wpi_deleteobject( dup_xor ); _wpi_deleteobject( dup_and ); RecordImage( node->hwnd ); BlowupImage( node->hwnd, NULL ); InvalidateRect( node->viewhwnd, NULL, FALSE ); IEPrintAmtText( message, ImgedConfigInfo.shift ); } /* ShiftImage */
/* * DrawSinglePoint - needed for when the mouse button is initially pressed. */ void DrawSinglePoint( HWND hwnd, WPI_POINT *pt, short mousebutton ) { HBRUSH colourbrush; HBRUSH oldbrush; HPEN colourpen; HPEN oldpen; COLORREF selected_colour; COLORREF dithered; short truncated_x; short truncated_y; short i; short j; WPI_POINT logical_pt; WPI_RECT rcclient; short width; short height; short wndwidth; short wndheight; wie_clrtype type; WPI_PRES pres; int brushsize; BOOL gridvisible; GetClientRect( hwnd, &rcclient ); wndwidth = _wpi_getwidthrect( rcclient ); wndheight = _wpi_getheightrect( rcclient ); brushsize = ImgedConfigInfo.brush_size; CheckBounds( hwnd, pt ); gridvisible = ImgedConfigInfo.grid_on && (pointSize.x >= POINTSIZE_MIN && pointSize.y >= POINTSIZE_MIN); if (gridvisible) { if (toolType == IMGED_BRUSH) { truncated_x = max(0, (pt->x/pointSize.x - brushsize/2)) * pointSize.x+1; truncated_y = max(0, (pt->y/pointSize.y - brushsize/2)) * pointSize.y+1; width = (short)(pointSize.x - 1); height = (short)(pointSize.y - 1); /* * We just have to check that we don't spill over the image dimensions */ truncated_x = min(truncated_x, wndwidth-pointSize.x*brushsize+1); truncated_y = min(truncated_y, wndheight-pointSize.y*brushsize+1); } else { truncated_x = ( pt->x / pointSize.x) * pointSize.x + 1; truncated_y = ( pt->y / pointSize.y) * pointSize.y + 1; width = (short)(pointSize.x - 1); height = (short)(pointSize.y - 1); } } else { if (toolType == IMGED_BRUSH) { truncated_x = max(0, (pt->x / pointSize.x - brushsize/2)) * pointSize.x; truncated_y = max(0, (pt->y / pointSize.y - brushsize/2)) * pointSize.y; width = (short)(pointSize.x * brushsize); height = (short)(pointSize.y * brushsize); /* * We just have to check that we don't spill over the image dimensions */ truncated_x = min( truncated_x, wndwidth-width ); truncated_y = min( truncated_y, wndheight-width ); } else { truncated_x = ( pt->x / pointSize.x) * pointSize.x; truncated_y = ( pt->y / pointSize.y) * pointSize.y; width = (short)pointSize.x; height = (short)pointSize.y; } } logical_pt.x = truncated_x / pointSize.x; logical_pt.y = truncated_y / pointSize.y; pres = _wpi_getpres( hwnd ); _wpi_torgbmode( pres ); dithered = GetSelectedColour(mousebutton, &selected_colour, &type); colourbrush = _wpi_createsolidbrush( selected_colour ); oldbrush = _wpi_selectobject( pres, colourbrush ); colourpen = _wpi_createpen( PS_SOLID, 0, selected_colour ); oldpen = _wpi_selectobject( pres, colourpen ); if (gridvisible && (toolType == IMGED_BRUSH)) { for (i=0; i < brushsize; ++i) { for (j=0; j < brushsize; ++j) { _wpi_patblt(pres, truncated_x+i*pointSize.x, truncated_y+j*pointSize.y, width, height, PATCOPY); } } } else { _wpi_patblt(pres, truncated_x, truncated_y, width, height, PATCOPY); } _wpi_selectobject( pres, oldbrush ); _wpi_selectobject( pres, oldpen ); _wpi_releasepres( hwnd, pres ); _wpi_deleteobject( colourbrush ); _wpi_deleteobject( colourpen ); /* * draws the points in the view window */ if (toolType == IMGED_BRUSH) { if (type == SCREEN_CLR) { BrushThePoints(selected_colour, BLACK, WHITE, &logical_pt, brushsize); } else if (type == INVERSE_CLR) { BrushThePoints(selected_colour, WHITE, WHITE, &logical_pt, brushsize); } else { BrushThePoints(selected_colour, selected_colour, BLACK, &logical_pt, brushsize); } } else { if (type == SCREEN_CLR) { DrawThePoints(selected_colour, BLACK, WHITE, &logical_pt); } else if (type == INVERSE_CLR) { DrawThePoints(selected_colour, WHITE, WHITE, &logical_pt); } else { DrawThePoints(selected_colour, selected_colour, BLACK, &logical_pt); } } } /* DrawSinglePoint */
/* * 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 */
/* * WinNewDrawPad - create a new drawing pad for Windows version */ HWND WinNewDrawPad( img_node *node ) { MDICREATESTRUCT mdicreate; short y_adjustment; short x_adjustment; short pad_x; short pad_y; int i; img_node *temp; POINT origin; char filename[_MAX_PATH]; HWND drawarea; HMENU sys_menu; node->viewhwnd = CreateViewWin( node->width, node->height ); pad_x = 0; pad_y = 0; temp = node->nexticon; for( i = 1; i < node->num_of_images; i++ ) { temp->viewhwnd = node->viewhwnd; temp = temp->nexticon; } if( node->imgtype == BITMAP_IMG ) { mdicreate.szClass = DrawAreaClassB; } else if( node->imgtype == ICON_IMG ) { mdicreate.szClass = DrawAreaClassI; } else { mdicreate.szClass = DrawAreaClassC; } GetFnameFromPath( node->fname, filename ); mdicreate.szTitle = filename; mdicreate.hOwner = Instance; x_adjustment = (short)(2 * GetSystemMetrics( SM_CXFRAME )); y_adjustment = (short)(2 * GetSystemMetrics( SM_CYFRAME ) + GetSystemMetrics( SM_CYCAPTION ) - 1); origin.x = 0; origin.y = 0; FindOrigin( &origin ); CalculateDims( node->width, node->height, &pad_x, &pad_y ); mdicreate.cx = x_adjustment + pad_x; mdicreate.cy = y_adjustment + pad_y; mdicreate.x = origin.x; mdicreate.y = origin.y; mdicreate.style = WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_CLIPSIBLINGS | WS_DLGFRAME | WS_MINIMIZEBOX | WS_THICKFRAME; mdicreate.lParam = (LPARAM)(LPVOID)node; drawarea = (HWND)SendMessage( ClientWindow, WM_MDICREATE, 0, (LPARAM)(LPVOID)&mdicreate ); if( drawarea != (HWND)NULL ) { RECT rect; int w, h; _wpi_getclientrect( drawarea, &rect ); w = _wpi_getwidthrect( rect ); h = _wpi_getheightrect( rect ); if( w != pad_x || h != pad_y ) { GetWindowRect( drawarea, &rect ); w = _wpi_getwidthrect( rect ) + (pad_x - w); h = _wpi_getheightrect( rect ) + (pad_y - h); SetWindowPos( drawarea, HWND_TOP, 0, 0, w, h, SWP_SIZE | SWP_NOZORDER | SWP_NOMOVE ); } } if( ImgedIsDDE ) { sys_menu = GetSystemMenu( drawarea, FALSE ); if( sys_menu != (HMENU)NULL ) { EnableMenuItem( sys_menu, SC_CLOSE, MF_GRAYED ); } } BlowupImage( NULL, NULL ); return( drawarea ); } /* WinNewDrawPad */
/* * RotateImage - rotate the image either clockwise or counterclockwise */ void RotateImage( WORD whichway ) { img_node *node; HBITMAP rotxorbmp; HBITMAP rotandbmp; HCURSOR prevcursor; int rotate_type; WPI_RECT rotate_rect; BOOL rectexists; short new_width; short new_height; WPI_PRES pres; node = GetCurrentNode(); if( node == NULL ) { return; } prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) ); PrintHintTextByID( WIE_ROTATINGIMAGE, NULL ); if( DoesRectExist( &rotate_rect ) ) { rectexists = TRUE; new_width = (short)_wpi_getheightrect( rotate_rect ); new_height = (short)_wpi_getwidthrect( rotate_rect ); } else { rectexists = FALSE; _wpi_setwrectvalues( &rotate_rect, 0, 0, (IMGED_DIM)node->width, (IMGED_DIM)node->height ); new_width = node->height; new_height = node->width; } if( node->bitcount == 1 ) { rotxorbmp = _wpi_createbitmap( new_width, new_height, 1, 1, NULL ); } else { #if 1 pres = _wpi_getpres( HWND_DESKTOP ); rotxorbmp = _wpi_createcompatiblebitmap( pres, new_width, new_height ); _wpi_releasepres( HWND_DESKTOP, pres ); #else rotxorbmp = _wpi_createbitmap( new_width, new_height, ColorPlanes, BitsPerPixel, NULL ); #endif } rotandbmp = _wpi_createbitmap( new_width, new_height, 1, 1, NULL ); rotateTheImage( node, whichway, &rotate_rect, rotxorbmp, rotandbmp ); rotate_type = GetRotateType(); if( rotate_type == SIMPLE_ROTATE ) { simpleRotate( node, &rotate_rect, rotxorbmp, rotandbmp, rectexists ); } else if( rotate_type == CLIP_ROTATE ) { clipIntoArea( node, &rotate_rect, rotxorbmp, rotandbmp ); } else { stretchIntoArea( node, &rotate_rect, rotxorbmp, rotandbmp ); } _wpi_deleteobject( rotxorbmp ); _wpi_deleteobject( rotandbmp ); if( whichway == IMGED_ROTATECC ) { PrintHintTextByID( WIE_IMAGEROTATEDCCW, NULL ); } else { PrintHintTextByID( WIE_IMAGEROTATEDCW, NULL ); } _wpi_setcursor( prevcursor ); } /* RotateImage */
/* * EnlargeImage - take an MDI window handle and enlarge the view bitmap * that goes with it * - returns a handle to the bitmap * - the bitmap must be deleted by the calling routine */ HBITMAP EnlargeImage( HWND hwnd ) { WPI_PRES pres; WPI_PRES srcpres; WPI_PRES destpres; HDC srcdc; HDC destdc; HBITMAP oldbitmap; HBITMAP newbitmap; HBITMAP olddestbitmap; HBITMAP viewbitmap; img_node *node; WPI_RECT rc; short width; short height; int window_width; int window_height; BITMAP bm; node = SelectImage( hwnd ); if( node == NULL ) { return( NULL ); } viewbitmap = CreateViewBitmap( node ); _wpi_getclientrect( hwnd, &rc ); /* * I add this so that if the window's client rect doesn't fit on the * screen, it will still enlarge to the right size. */ window_width = _wpi_getwidthrect( rc ); window_height = _wpi_getheightrect( rc ); if( window_width < node->width ) { window_width = node->width; } if( window_height < node->height ) { window_height = node->height; } pres = _wpi_getpres( HWND_DESKTOP ); srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc ); destpres = _wpi_createcompatiblepres( pres, Instance, &destdc ); newbitmap = _wpi_createcompatiblebitmap( pres, _wpi_getwidthrect( rc ), _wpi_getheightrect( rc ) ); _wpi_releasepres( HWND_DESKTOP, pres ); GetObject( newbitmap, sizeof( BITMAP ), &bm ); _wpi_torgbmode( destpres ); _wpi_torgbmode( srcpres ); olddestbitmap = _wpi_selectobject( destpres, newbitmap ); oldbitmap = _wpi_selectobject( srcpres, viewbitmap ); height = node->height; width = node->width; IEStretchBlt( destpres, 0, 0, _wpi_getwidthrect( rc ), _wpi_getheightrect( rc ), srcpres, 0, 0, width, height, SRCCOPY, bm.bmBitsPixel ); _wpi_selectobject( srcpres, oldbitmap ); _wpi_deletecompatiblepres( srcpres, srcdc ); _wpi_deleteobject( viewbitmap ); _wpi_selectobject( destpres, olddestbitmap ); _wpi_deletecompatiblepres( destpres, destdc ); return( newbitmap ); } /* EnlargeImage */