void GUIError( const char *str ) { HWND focus; focus = _wpi_getfocus(); if( focus != NULLHANDLE ) { _wpi_messagebox( focus, str, NULL, ERROR_STYLE ); } }
/* * lastChanceSave - is called when the user quits and the current image * is not yet saved. Returns FALSE if CANCEL * is selected, otherwise, it returns TRUE. */ static BOOL lastChanceSave( img_node *node ) { int retcode; int how; HMENU hmenu; char *title; char *text; char *msg_text; char filename[ _MAX_PATH ]; if( !node ) return( TRUE ); IECheckIfActiveWindow(); if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) { GetFnameFromPath( node->fname, filename ); how = SB_SAVE; } else { strcpy( filename, node->fname ); how = SB_SAVE_AS; } retcode = IDCANCEL; title = IEAllocRCString( WIE_EXITTITLE ); if( ImgedIsDDE ) { text = IEAllocRCString( WIE_QUERYIMAGEUPDATE ); } else { text = IEAllocRCString( WIE_QUERYIMAGESAVE ); } if( text ) { msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 ); if( msg_text ) { sprintf( msg_text, text, filename ); retcode = _wpi_messagebox( HMainWindow, msg_text, title, MB_YESNOCANCEL | MB_ICONQUESTION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title ) { IEFreeRCString( title ); } if (retcode == IDYES) { if( ImgedIsDDE ) { #ifndef __OS2_PM__ if( IEUpdateDDEEditSession() ) { SetIsSaved( node->hwnd, TRUE ); } else { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } #else PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); #endif } else { if (!SaveFile( how )) { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } else { hmenu = _wpi_getmenu( HMainWindow ); _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); SetIsSaved( node->hwnd, TRUE ); } } } else if (retcode == IDCANCEL) { return (FALSE); } return (TRUE); } /* lastChanceSave */
/* * 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 */
/* * lastChanceSave - called when the user quits and the current image * is not yet saved * - return FALSE if CANCEL is selected * - otherwise, it return TRUE */ static BOOL lastChanceSave( HWND hwnd ) { int retcode; int how; HMENU hmenu; img_node *node; img_node *icon; char *title; char *text; char *msg_text; char filename[_MAX_PATH]; if( !DoImagesExist() ) { return( TRUE ); } node = SelectImage( hwnd ); if( node == NULL ) { return( TRUE ); } icon = GetImageNode( hwnd ); while( icon != NULL ) { if( icon->issaved ) { return( TRUE ); } icon = icon->nexticon; } if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) { GetFnameFromPath( node->fname, filename ); how = SB_SAVE; } else { strcpy( filename, node->fname ); how = SB_SAVE_AS; } retcode = WPI_IDCANCEL; title = IEAllocRCString( WIE_CLOSETITLE ); text = IEAllocRCString( WIE_QUERYIMAGESAVE ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, filename ); retcode = _wpi_messagebox( HMainWindow, msg_text, title, MB_YESNOCANCEL | MB_ICONQUESTION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } if( retcode == WPI_IDYES ) { if( !SaveFile( how ) ) { PrintHintTextByID( WIE_FILENOTSAVED, NULL ); return( FALSE ); } else { hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); SetIsSaved( hwnd, TRUE ); } } else if( retcode == WPI_IDCANCEL ) { return( FALSE ); } return( TRUE ); } /* lastChanceSave */