/* * CheckForClipboard - check to see if the paste menu item can be enabled */ void CheckForClipboard( HMENU hmenu ) { unsigned long format; format = 0; if( _wpi_isclipboardformatavailable( Instance, CF_BITMAP, &format ) && DoImagesExist() ) { _wpi_enablemenuitem( hmenu, IMGED_PASTE, TRUE, FALSE ); } else { _wpi_enablemenuitem( hmenu, IMGED_PASTE, FALSE, FALSE ); } } /* CheckForClipboard */
bool GUIAddToSystemMenu( gui_window *wnd, HWND hwnd, int num_menus, gui_menu_struct *menu, gui_create_styles style ) { HMENU system; gui_ctl_idx num; if( !( style & GUI_SYSTEM_MENU ) ) { return( true ); } system = _wpi_getsystemmenu( hwnd ); if( system == NULLHANDLE ) { return( false ); } if( GUIMDI && ( _wpi_getparent( hwnd ) != NULLHANDLE ) ) { num = _wpi_getmenuitemcount( system ); #ifndef __OS2_PM__ ModifyMenu( system, num - 1, MF_STRING | MF_BYPOSITION | MF_GRAYED, SC_NEXTWINDOW, LIT( NexXt ) ); // add \tCtrl+F6" ); ModifyMenu( system, num - 3, MF_STRING | MF_BYPOSITION | MF_ENABLED, SC_CLOSE, LIT( XClose ) ); // add \tctrl+f4" ); #endif } if( !( style & GUI_CLOSEABLE ) ) { _wpi_enablemenuitem( system, SC_CLOSE, FALSE, FALSE ); } if( style & GUI_CHANGEABLE_FONT ) { if( _wpi_appendmenu( system, MF_SEPARATOR, 0, 0, NULLHANDLE, NULL ) ) { _wpi_appendmenu( system, MF_STRING, MF_ENABLED, GUIHint[GUI_MENU_FONT].id, NULLHANDLE, GUIHint[GUI_MENU_FONT].label ); } } if( num_menus > 0 ) { if( _wpi_appendmenu( system, MF_SEPARATOR, 0, 0, NULLHANDLE, NULL ) ) { return( AppendMenus( wnd, system, num_menus, menu ) ); } } return( true ); }
/* * SetNewPalette - set a new palette from a loaded file */ void SetNewPalette( a_pal_file *pal_file ) { int i; wie_clrtype type; HMENU hmenu; if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) { return; } leftColorIndex = getColorIndex( GetSelectedColor( LMOUSEBUTTON, NULL, &type ) ); rightColorIndex = getColorIndex( GetSelectedColor( RMOUSEBUTTON, NULL, &type ) ); for( i = 0; i < PALETTE_SIZE - 1; i++ ) { palette[currentPalIndex][i].rgbRed = pal_file->rgbqs[i].rgbBlue; palette[currentPalIndex][i].rgbGreen = pal_file->rgbqs[i].rgbGreen; palette[currentPalIndex][i].rgbBlue = pal_file->rgbqs[i].rgbRed; ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed, palette[currentPalIndex][i].rgbGreen, palette[currentPalIndex][i].rgbBlue ), FALSE ); restorePalette[i] = palette[currentPalIndex][i]; } palette[currentPalIndex][i].rgbRed = pal_file->rgbqs[i].rgbBlue; palette[currentPalIndex][i].rgbGreen = pal_file->rgbqs[i].rgbGreen; palette[currentPalIndex][i].rgbBlue = pal_file->rgbqs[i].rgbRed; restorePalette[i] = palette[currentPalIndex][i]; ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed, palette[currentPalIndex][i].rgbGreen, palette[currentPalIndex][i].rgbBlue ), TRUE ); SetCurrentColors( TRUE ); if( HMainWindow != NULL ) { hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE ); } } /* SetNewPalette */
/* * SetNumColors - set the number of colors in the image and repaint the window */ void SetNumColors( int number_of_colors ) { HMENU hmenu; HWND frame; if( numberOfColors == number_of_colors ) { return; } SetCurrentNumColors( number_of_colors ); numberOfColors = number_of_colors; initPaletteBoxes( FALSE ); _wpi_invalidaterect( hColorsWnd, NULL, FALSE ); if( numberOfColors == 2 ) { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); if( _wpi_isitemenabled( hmenu, IMGED_RCOLOR ) ) { prevRestoreState = TRUE; } else { prevRestoreState = FALSE; } _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, FALSE, FALSE ); } } else { if( HMainWindow != NULL ) { frame = _wpi_getframe( HMainWindow ); hmenu = GetMenu( frame ); _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, prevRestoreState, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, TRUE, FALSE ); } } } /* SetNumColors */
/* * SetMenus - set the menu options for the new image */ void SetMenus( img_node *node ) { HMENU hmenu; hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_SNAP, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CUT, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_COPY, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLEAR, TRUE, FALSE ); #ifndef __OS2_PM__ SetColorMenus( node ); #endif if( node->imgtype == BITMAP_IMG ) { DisplayScreenClrs( FALSE ); AddHotSpotTool( FALSE ); _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SIZE, TRUE, FALSE ); } else if( node->imgtype == ICON_IMG ) { DisplayScreenClrs( TRUE ); AddHotSpotTool( FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE ); if( node->num_of_images < NUM_OF_ICONS ) { _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, TRUE, FALSE ); } else { _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE ); } if( node->num_of_images > 1 ) { _wpi_enablemenuitem( hmenu, IMGED_DELIMG, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE ); } else { _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE ); } _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE ); SetIconInfo( node ); } else if( node->imgtype == CURSOR_IMG ) { DisplayScreenClrs( TRUE ); AddHotSpotTool( TRUE ); _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE ); } } /* SetMenus */
/* * GrayEditOptions - gray the edit options (at the beginning and when an * image is closed) */ void GrayEditOptions( void ) { HMENU hmenu; if( HMainWindow == NULL ) { return; } hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_UNDO, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_REDO, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_REST, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CUT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_COPY, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_PASTE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SNAP, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLEAR, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RIGHT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LEFT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_UP, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DOWN, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPHORZ, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPVERT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECC, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECL, FALSE, FALSE ); } /* GrayEditOptions */
/* * 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 */
/* * enableMainItems - enable menu items */ static void enableMainItems( HMENU hmenu ) { img_node *node; if( hmenu == NULL ) { return; } node = GetCurrentNode(); if( !DoImagesExist() ) { _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SAVE_AS, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSEALL, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ARRANGE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_TILE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CASCADE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECC, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECL, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPHORZ, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPVERT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_UP, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DOWN, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RIGHT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LEFT, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_MAXIMIZE, FALSE, FALSE ); } else if( node != NULL ) { CheckForClipboard( hmenu ); CheckForUndo( node ); _wpi_enablemenuitem( hmenu, IMGED_SAVE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SAVE_AS, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSEALL, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ARRANGE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_TILE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CASCADE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECC, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ROTATECL, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPHORZ, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_FLIPVERT, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_UP, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_DOWN, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_RIGHT, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_LEFT, TRUE, FALSE ); if( node->imgtype != BITMAP_IMG ) { _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE ); } else { _wpi_enablemenuitem( hmenu, IMGED_SIZE, TRUE, FALSE ); } _wpi_enablemenuitem( hmenu, IMGED_MAXIMIZE, TRUE, FALSE ); } else { _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SAVE_AS, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CLOSEALL, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_ARRANGE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_TILE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_CASCADE, TRUE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_MAXIMIZE, FALSE, FALSE ); } if( FusionCalled ) { _wpi_enablemenuitem( hmenu, IMGED_NEW, FALSE, FALSE ); _wpi_enablemenuitem( hmenu, IMGED_OPEN, FALSE, FALSE ); } } /* enableMainItems */
/* * 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 */
static void EnablePopup( HMENU hmenu, gui_ctl_idx position, bool enable ) { _wpi_enablemenuitem( hmenu, position, ( enable ) ? TRUE : FALSE, TRUE ); }
static void EnableItem( HMENU hmenu, gui_ctl_id id, bool enable ) { _wpi_enablemenuitem( hmenu, id, ( enable ) ? TRUE : FALSE, FALSE ); }
/* * copyImageToClipboard - copies the image to the clipboard */ static void copyImageToClipboard( short width, short height, img_node *node ) { HMENU hmenu; WPI_PRES pres; WPI_PRES mempres; HDC memdc; WPI_PRES clippres; HDC clipdc; HBITMAP hbitmap; HBITMAP oldbitmap; HBITMAP oldclipbitmap; HBITMAP viewbitmap; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; int clip_width, clip_height; CleanupClipboard(); pres = _wpi_getpres( node->viewhwnd ); mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc ); hbitmap = _wpi_createcompatiblebitmap( pres, width, height ); viewbitmap = CreateViewBitmap( node ); oldbitmap = _wpi_selectbitmap( mempres, viewbitmap ); oldclipbitmap = _wpi_selectbitmap( clippres, hbitmap ); clip_width = _wpi_getwidthrect( clipRect.rect ); clip_height = _wpi_getheightrect( clipRect.rect ); /* * use getwrectvalues because we want top and left to be our origins * (i.e. in PM the origin is the bottom) */ _wpi_getwrectvalues( clipRect.rect, &left, &top, &right, &bottom ); _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY ); _wpi_openclipboard( Instance, HMainWindow ); _wpi_emptyclipboard( Instance ); _wpi_setclipboarddata( Instance, CF_BITMAP, hbitmap, TRUE ); _wpi_closeclipboard( Instance ); _wpi_getoldbitmap( clippres, oldclipbitmap ); _wpi_deletecompatiblepres( clippres, clipdc ); clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc ); hXorClipped = _wpi_createcompatiblebitmap( pres, width, height ); _wpi_getoldbitmap( mempres, oldbitmap ); oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap ); oldclipbitmap = _wpi_selectbitmap( clippres, hXorClipped ); _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY ); _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_getoldbitmap( clippres, oldclipbitmap ); hAndClipped = _wpi_createcompatiblebitmap( pres, width, height ); oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap ); oldclipbitmap = _wpi_selectbitmap( clippres, hAndClipped ); _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY ); _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_getoldbitmap( clippres, oldclipbitmap ); _wpi_deletecompatiblepres( mempres, memdc ); _wpi_deletecompatiblepres( clippres, clipdc ); _wpi_deletebitmap( viewbitmap ); _wpi_releasepres( node->viewhwnd, pres ); hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); _wpi_enablemenuitem( hmenu, IMGED_PASTE, TRUE, FALSE ); } /* copyImageToClipboard */
/* * RestoreColorPalette - restore the color palette to the hard-coded colors * in the initialization routine */ void RestoreColorPalette( void ) { int i; COLORREF leftcolor; COLORREF rightcolor; COLORREF color; WPI_PRES pres; int leftindex; int rightindex; wie_clrtype lefttype; wie_clrtype righttype; HMENU hmenu; HWND frame; if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) { return; } leftcolor = GetSelectedColor( LMOUSEBUTTON, NULL, &lefttype ); rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &righttype ); leftindex = getColorIndex( leftcolor ); rightindex = getColorIndex( rightcolor ); InitPalette(); for( i = 0; i < PALETTE_SIZE - 1; i++ ) { ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed, palette[currentPalIndex][i].rgbGreen, palette[currentPalIndex][i].rgbBlue ), FALSE ); } /* * We do the last one separately to invalidate the window. */ ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed, palette[currentPalIndex][i].rgbGreen, palette[currentPalIndex][i].rgbBlue ), TRUE ); if( lefttype == NORMAL_CLR ) { color = RGB( palette[currentPalIndex][leftindex].rgbRed, palette[currentPalIndex][leftindex].rgbGreen, palette[currentPalIndex][leftindex].rgbBlue ); pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); SetColor( LMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR ); _wpi_releasepres( HWND_DESKTOP, pres ); } if( righttype == NORMAL_CLR ) { color = RGB( palette[currentPalIndex][rightindex].rgbRed, palette[currentPalIndex][rightindex].rgbGreen, palette[currentPalIndex][rightindex].rgbBlue ); pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); SetColor( RMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR ); _wpi_releasepres( HWND_DESKTOP, pres ); } PrintHintTextByID( WIE_PALETTERESTORED, NULL ); if( HMainWindow != NULL ) { frame = _wpi_getframe( _wpi_getframe( HMainWindow ) ); hmenu = GetMenu( frame ); _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE ); } } /* RestoreColorPalette */
/* * 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 */