/* * ChooseBkColor - choose the color to represent the background */ void ChooseBkColor( void ) { WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; screenColor.color = GetViewBkColor(); dlgproc = _wpi_makedlgprocinstance( SelColorDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELBKCOLOR, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == IDCANCEL ) { return; } SetViewBkColor( screenColor.color ); SetScreenClr( screenColor.color ); PrintHintTextByID( WIE_NEWBKCOLORSELECTED, NULL ); } /* ChooseBkColor */
bool GUICreateDialogFromRes( res_name_or_id dlg_id, gui_window *parent_wnd, GUICALLBACK *gui_call_back, void *extra ) { WPI_DLGPROC dlgproc; HWND parent_hwnd; /* unused parameters */ (void)gui_call_back; parent_hwnd = parent_wnd->hwnd; if( parent_hwnd == NULLHANDLE ) parent_hwnd = HWND_DESKTOP; dlgproc = _wpi_makedlgprocinstance( GUIDialogDlgProc, GUIMainHInst ); if( dlgproc == NULL ) { return( false ); } if( _wpi_dialogbox( parent_hwnd, dlgproc, GUIResHInst, dlg_id, extra ) == -1 ) { _wpi_freedlgprocinstance( dlgproc ); return( false ); } _wpi_freedlgprocinstance( dlgproc ); return( true ); }
/* * NewImage - create a new image and return the image type (bitmap, icon, or cursor) */ int NewImage( int img_type, const char *filename ) { WPI_DLGPROC dlgproc; INT_PTR button_type; short width; short height; short bcount; img_node node; char ext[_MAX_EXT]; // If filename is not NULL and we don't know the image type, // then guess based on the file extesion. if( filename != NULL && img_type == UNDEF_IMG ) { _splitpath( filename, NULL, NULL, NULL, ext ); if( stricmp( ext, ".bmp" ) == 0 ) { img_type = BITMAP_IMG; } else if( stricmp( ext, ".ico" ) == 0 ) { img_type = ICON_IMG; } else if( stricmp( ext, ".cur" ) == 0 ) { img_type = CURSOR_IMG; } } if( img_type == UNDEF_IMG ) { dlgproc = _wpi_makedlgprocinstance( SelImgDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELECTIMAGE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { return( FALSE ); } } else { imgType = img_type; } imageCount++; switch( imgType ) { case BITMAP_IMG: dlgproc = _wpi_makedlgprocinstance( SelBitmapDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, BITMAPTYPE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { imgType = UNDEF_IMG; imageCount--; return( imgType ); } else if( button_type == SEL_SELECT ) { #ifdef __OS2_PM__ IEDisplayErrorMsg( WIE_NOTE, WIE_NOTIMPLEMENTED, MB_OK | MB_ICONINFORMATION ); return( FALSE ); #else if( !SelectDynamicBitmap( &node, imageCount, filename ) ) { return( FALSE ); } #endif } else { initializeImage( &node, filename ); } break; case ICON_IMG: if( !CreateNewIcon( &width, &height, &bcount, TRUE ) ) { imgType = UNDEF_IMG; return( imgType ); } imgWidth = width; imgHeight = height; bitCount = bcount; initializeImage( &node, filename ); break; case CURSOR_IMG: #ifdef __OS2_PM__ if( !CreateNewIcon( &width, &height, &bcount, FALSE ) ) { imgType = UNDEF_IMG; return( imgType ); } imgWidth = width; imgHeight = height; bitCount = bcount; #else dlgproc = MakeProcInstance_DLG( SelCursorDlgProc, Instance ); button_type = JDialogBox( Instance, "CURSORTYPE", HMainWindow, dlgproc ); FreeProcInstance_DLG( dlgproc ); if( button_type == IDCANCEL ) { imgType = UNDEF_IMG; return( imgType ); } #endif initializeImage( &node, filename ); break; default: return( FALSE ); } node.wrinfo = NULL; node.lnode = NULL; CreateNewDrawPad( &node ); SetupMenuAfterOpen(); return( imgType ); } /* NewImage */
/* * ChangeImageSize - changes the size of the current image being edited */ void ChangeImageSize( void ) { img_node *node; WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; img_node new_node; WPI_PRES pres; HDC srcdc; WPI_PRES srcpres; HDC destdc; WPI_PRES destpres; HBITMAP oldsrc; HBITMAP olddest; int retcode; WPI_PARAM2 lparam; WPI_RECT rc; short new_width; short new_height; int y_src; int y_dest; char *title; char *text; node = GetCurrentNode(); if( node == NULL ) { return; } if( node->imgtype != BITMAP_IMG ) { return; } imgHeight = node->height; imgWidth = node->width; dlgproc = _wpi_makedlgprocinstance( ChangeSizeDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, IMAGESIZE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { return; } if( imgWidth == node->width && imgHeight == node->height ) { PrintHintTextByID( WIE_IMAGESIZEUNCHANGED, NULL ); return; } title = IEAllocRCString( WIE_INFORMATIONTEXT ); text = IEAllocRCString( WIE_RESETUNDOSTACKWARNING ); retcode = _wpi_messagebox( HMainWindow, text, title, MB_YESNO | MB_ICONINFORMATION ); if( text != NULL ) { IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } if( retcode == WPI_IDNO ) { return; } new_node.width = (short)imgWidth; new_node.height = (short)imgHeight; new_node.bitcount = node->bitcount; new_node.imgtype = BITMAP_IMG; MakeBitmap( &new_node, TRUE ); pres = _wpi_getpres( HWND_DESKTOP ); srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc ); destpres = _wpi_createcompatiblepres( pres, Instance, &destdc ); _wpi_releasepres( HWND_DESKTOP, pres ); oldsrc = _wpi_selectbitmap( srcpres, node->hxorbitmap ); olddest = _wpi_selectbitmap( destpres, new_node.hxorbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { #ifdef __OS2_PM__ y_src = node->height - imgHeight; if( y_src < 0 ) { y_src = 0; y_dest = imgHeight - node->height; } else { y_dest = 0; } #else y_src = 0; y_dest = 0; #endif _wpi_bitblt( destpres, 0, y_dest, node->width, node->height, srcpres, 0, y_src, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); oldsrc = _wpi_selectbitmap( srcpres, node->handbitmap ); _wpi_getoldbitmap( destpres, olddest ); olddest = _wpi_selectbitmap( destpres, new_node.handbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { _wpi_bitblt( destpres, 0, 0, node->width, node->height, srcpres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); _wpi_getoldbitmap( destpres, olddest ); _wpi_deletebitmap( node->hxorbitmap ); _wpi_deletebitmap( node->handbitmap ); _wpi_deletecompatiblepres( srcpres, srcdc ); _wpi_deletecompatiblepres( destpres, destdc ); node->hxorbitmap = new_node.hxorbitmap; node->handbitmap = new_node.handbitmap; node->width = (short)imgWidth; node->height = (short)imgHeight; SetIsSaved( node->hwnd, FALSE ); ResetUndoStack( node ); RePositionViewWnd( node ); _wpi_getclientrect( node->hwnd, &rc ); new_width = (short)_wpi_getwidthrect( rc ); new_height = (short)_wpi_getheightrect( rc ); lparam = WPI_MAKEP2( new_width, new_height ); ResizeChild( lparam, node->hwnd, false ); DisplayImageText( node ); WriteSetSizeText( WIE_NEWIMAGESIZE, imgWidth, imgHeight ); } /* ChangeImageSize */