/* * SelCursorDlgProc - select the target device to use the cursor on */ INT_PTR CALLBACK SelCursorDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { static HWND hlistbox; char *mono32x32; int index; bool ret; lparam = lparam; ret = false; switch( msg ) { case WM_INITDIALOG: hlistbox = GetDlgItem( hwnd, TARGETLISTBOX ); mono32x32 = IEAllocRCString( WIE_MONO32X32 ); if( mono32x32 != NULL ) { SendMessage( hlistbox, LB_INSERTSTRING, 0, (LPARAM)(LPCSTR)mono32x32 ); IEFreeRCString( mono32x32 ); } else { SendMessage( hlistbox, LB_INSERTSTRING, 0, (LPARAM)(LPCSTR)"Monochrome, 32x32" ); } SendMessage( hlistbox, LB_SETCURSEL, 0, 0L ); ret = true; break; case WM_SYSCOLORCHANGE: IECtl3dColorChange(); break; case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: index = (int)SendMessage( hlistbox, LB_GETCURSEL, 0, 0L ); if( index == 0 ) { imgWidth = 32; imgHeight = 32; bitCount = 1; EndDialog( hwnd, TRUE ); } break; case IDCANCEL: EndDialog( hwnd, IDCANCEL ); break; case IDB_HELP: IEHelpRoutine(); break; } break; case WM_CLOSE: EndDialog( hwnd, IDCANCEL ); ret = true; break; } return( ret ); } /* SelCursorDlgProc */
/* * 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 */
/* * PrintHintTextByID */ void PrintHintTextByID( DWORD id, char *fname ) { char *msg; msg = IEAllocRCString( id ); if( msg != NULL ) { PrintHintText( msg, fname ); IEFreeRCString( msg ); } } /* PrintHintTextByID */
void WriteIconLoadedText( char *filename, int num ) { char *text; char msg[ _MAX_PATH ]; text = IEAllocRCString( WIE_ICONOPENEDTEXT ); if( text ) { sprintf( msg, text, filename, num ); SetHintText( msg ); IEFreeRCString( text ); } }
/* * DisplayScreenClrs - depending on the parameter, display the screen color * and the inverse color (for icons and cursors but * not for bitmaps) */ void DisplayScreenClrs( BOOL fdisplay ) { HWND frame; char *text; frame = _wpi_getframe( hScreenWnd ); if( !fdisplay ) { if( fShowScreenClr ) { ChangeCurrentColor(); } SetWindowText( hScreenTxt, "" ); SetWindowText( hInverseTxt, "" ); fShowScreenClr = FALSE; ShowWindow( frame, SW_HIDE ); } else { text = IEAllocRCString( WIE_SCREENTEXT ); if( text != NULL ) { SetWindowText( hScreenTxt, text ); IEFreeRCString( text ); } else { SetWindowText( hScreenTxt, "Screen:" ); } text = IEAllocRCString( WIE_INVERSETEXT ); if( text != NULL ) { SetWindowText( hInverseTxt, text ); IEFreeRCString( text ); } else { SetWindowText( hInverseTxt, "Inverse:" ); } fShowScreenClr = TRUE; ShowWindow( frame, SW_SHOWNORMAL ); #ifdef __OS2_PM__ InvalidateRect( hScreenWnd, NULL, TRUE ); #endif } } /* DisplayScreenClrs */
/* * IEPrintAmtText */ void IEPrintAmtText( DWORD message, int amt ) { char *text; char *msg; text = IEAllocRCString( message ); if( text != NULL ) { msg = (char *)MemAlloc( strlen( text ) + 10 + 1 ); if( msg != NULL ) { sprintf( msg, text, amt ); SetHintText( msg ); MemFree( msg ); } IEFreeRCString( text ); } } /* IEPrintAmtText */
/* * WriteSetSizeText */ void WriteSetSizeText( DWORD msg, int x, int y ) { char *text; char *msg_text; text = IEAllocRCString( msg ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + 20 + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, x, y ); SetHintText( msg_text ); MemFree( msg_text ); } IEFreeRCString( text ); } } /* WriteSetSizeText */
/* * FiniStatusLine - close up the status line */ void FiniStatusLine( void ) { DestroyWindow( statusBarWnd ); StatusWndDestroy( statusBar ); StatusWndFini(); if( PosText != NULL ) { IEFreeRCString( PosText ); } if( SizeText != NULL ) { IEFreeRCString( SizeText ); } if( SetPosText != NULL ) { IEFreeRCString( SetPosText ); } if( SetHotSpotText != NULL ) { IEFreeRCString( SetHotSpotText ); } if( SetBitmapText != NULL ) { IEFreeRCString( SetBitmapText ); } if( SetCursorText != NULL ) { IEFreeRCString( SetCursorText ); } if( SetIconText != NULL ) { IEFreeRCString( SetIconText ); } if( PositionText != NULL ) { MemFree( PositionText ); } if( HotSpotText != NULL ) { MemFree( HotSpotText ); } if( SetSizeText != NULL ) { MemFree( SetSizeText ); } if( PositionSizeText != NULL ) { MemFree( PositionSizeText ); } if( ImageText != NULL ) { MemFree( ImageText ); } } /* FiniStatusLine */
/* * CurrentSettingsProc - display the current settings and allows for change */ WPI_DLGRESULT CALLBACK CurrentSettingsProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { BOOL err; char *title; char *text; char *msg_text; short new_shift; static BOOL keepsquare; if( _wpi_dlg_command( hwnd, &msg, &wparam, &lparam ) ) { switch( LOWORD( wparam ) ) { case DLGID_OK: new_shift = _wpi_getdlgitemshort( hwnd, SHIFT_AMOUNT, &err, TRUE ); if( new_shift > MAX_DIM || new_shift < MIN_DIM ) { title = IEAllocRCString( WIE_NOTE ); text = IEAllocRCString( WIE_SHIFTBETWEEN ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + 20 + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, MIN_DIM, MAX_DIM ); MessageBox( hwnd, msg_text, title, MB_OK | MB_ICONINFORMATION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } return( FALSE ); } ImgedConfigInfo.shift = new_shift; fKeepSelectedArea = _wpi_isbuttonchecked( hwnd, LEAVE_AREA ); fSaveSettings = _wpi_isbuttonchecked( hwnd, SAVE_SETTINGS ); fSavePosition = _wpi_isbuttonchecked( hwnd, SAVE_POSITION ); if( _wpi_isbuttonchecked( hwnd, KEEP_SQUARE ) && !keepsquare ) { fCheckSquareGrid = TRUE; } else if( !_wpi_isbuttonchecked( hwnd, KEEP_SQUARE ) && keepsquare ) { fCheckSquareGrid = TRUE; } else { fCheckSquareGrid = FALSE; } if( _wpi_isbuttonchecked( hwnd, STRETCH_PASTE ) ) { stretchClipPaste = STRETCH_PASTE; } else { stretchClipPaste = CLIP_PASTE; } if( _wpi_isbuttonchecked( hwnd, STRETCH_ROTATE ) ) { rotateType = STRETCH_ROTATE; } else if( _wpi_isbuttonchecked( hwnd, SIMPLE_ROTATE ) ) { rotateType = SIMPLE_ROTATE; } else { rotateType = CLIP_ROTATE; } fWrapShift = _wpi_isbuttonchecked( hwnd, WRAP_SHIFT ); SetViewWindow( _wpi_isbuttonchecked( hwnd, SHOW_ONE ) ); _wpi_enddialog( hwnd, DLGID_OK ); break; case DLGID_CANCEL: _wpi_enddialog( hwnd, DLGID_CANCEL ); break; case SETTINGS_HELP: IEHelpRoutine(); return( FALSE ); default: return( FALSE ); } } else { switch( msg ) { case WM_INITDIALOG: _wpi_checkradiobutton( hwnd, STRETCH_PASTE, CLIP_PASTE, stretchClipPaste ); _wpi_checkradiobutton( hwnd, SIMPLE_ROTATE, CLIP_ROTATE, rotateType ); if( IsOneViewWindow() ) { _wpi_checkradiobutton( hwnd, SHOW_ONE, SHOW_ALL, SHOW_ONE ); } else { _wpi_checkradiobutton( hwnd, SHOW_ONE, SHOW_ALL, SHOW_ALL ); } _wpi_checkdlgbutton( hwnd, LEAVE_AREA, ( fKeepSelectedArea ) ? BST_CHECKED : BST_UNCHECKED ); _wpi_checkdlgbutton( hwnd, SAVE_SETTINGS, ( fSaveSettings ) ? BST_CHECKED : BST_UNCHECKED ); _wpi_checkdlgbutton( hwnd, SAVE_POSITION, ( fSavePosition ) ? BST_CHECKED : BST_UNCHECKED ); if( ImgedConfigInfo.square_grid ) { keepsquare = TRUE; } else { keepsquare = FALSE; } _wpi_checkdlgbutton( hwnd, KEEP_SQUARE, ( keepsquare ) ? BST_CHECKED : BST_UNCHECKED ); _wpi_setdlgitemshort( hwnd, SHIFT_AMOUNT, ImgedConfigInfo.shift, FALSE ); if( fWrapShift ) { _wpi_checkradiobutton( hwnd, WRAP_SHIFT, CLIP_SHIFT, WRAP_SHIFT ); } else { _wpi_checkradiobutton( hwnd, WRAP_SHIFT, CLIP_SHIFT, CLIP_SHIFT ); } return( TRUE ); #ifndef __OS2_PM__ case WM_SYSCOLORCHANGE: IECtl3dColorChange(); break; #endif case WM_CLOSE: _wpi_enddialog( hwnd, IDCANCEL ); break; default: return( _wpi_defdlgproc( hwnd, msg, wparam, lparam ) ); } } _wpi_dlgreturn( FALSE ); } /* CurrentSettingsProc */
/* * 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 */
/* * 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 */
/* * 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 */
/* * Win_CreateColorCtrls - create the controls in the color palette for the Windows version */ void Win_CreateColorCtrls( HWND hpar, HWND *colors, HWND *screenclrs, HWND *screentxt, HWND *inversetxt ) { HWND hwnd1; HWND hwnd2; char *text; *colors = CreateWindow( AVAIL_CLASS, /* Window class name */ "", WS_CHILD | WS_VISIBLE, /* control styles */ COL_WND_X, /* Initial X position */ COL_WND_Y, /* Initial Y position */ COL_WND_WIDTH, /* Initial X size */ COL_WND_HEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( *colors, SW_NORMAL ); UpdateWindow( *colors ); SendMessage( *colors, WM_SETFONT, (DWORD)SmallFont, 0L ); *screenclrs = CreateWindow( SCREEN_CLASS, /* Window class name */ "", WS_CHILD | WS_VISIBLE, /* Control styles */ SCRN_WND_X, /* Initial X position */ SCRN_WND_Y, /* Initial Y position */ SCRN_WND_WIDTH, /* Initial X size */ SCRN_WND_HEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( *screenclrs, SW_HIDE ); SendMessage( *screenclrs, WM_SETFONT, (DWORD)SmallFont, 0L ); hwnd1 = CreateWindow( "STATIC", /* Window class name */ "", SS_RIGHT | WS_CHILD | WS_VISIBLE, /* Control styles */ TEXT1X, /* Initial X position */ TEXT1Y, /* Initial Y position */ TEXT_WIDTH, /* Initial X size */ TEXTHEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( hwnd1, SW_NORMAL ); UpdateWindow( hwnd1 ); SendMessage( hwnd1, WM_SETFONT, (DWORD)SmallFont, 0L ); hwnd2 = CreateWindow( "STATIC", /* Window class name */ "", SS_RIGHT | WS_CHILD | WS_VISIBLE, /* Control styles */ TEXT1X, /* Initial X position */ TEXT2Y, /* Initial Y position */ TEXT_WIDTH, /* Initial X size */ TEXTHEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( hwnd2, SW_NORMAL ); UpdateWindow( hwnd2 ); SendMessage( hwnd2, WM_SETFONT, (DWORD)SmallFont, 0L ); *screentxt = CreateWindow( "STATIC", /* Window class name */ "", SS_RIGHT | WS_CHILD | WS_VISIBLE, /* Control styles */ LINE1X, /* Initial X position */ LINE1Y, /* Initial Y position */ LINE_WIDTH, /* Initial X size */ TEXTHEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( *screentxt, SW_NORMAL ); UpdateWindow( *screentxt ); SendMessage( *screentxt, WM_SETFONT, (DWORD)SmallFont, 0L ); *inversetxt = CreateWindow( "STATIC", /* Window class name */ "", SS_RIGHT | WS_CHILD | WS_VISIBLE, /* Control styles */ LINE1X, /* Initial X position */ LINE2Y, /* Initial Y position */ LINE_WIDTH, /* Initial X size */ TEXTHEIGHT, /* Initial Y size */ hpar, /* Parent window handle */ (HMENU)NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ ShowWindow( *inversetxt, SW_NORMAL ); UpdateWindow( *inversetxt ); SendMessage( *inversetxt, WM_SETFONT, (DWORD)SmallFont, 0L ); text = IEAllocRCString( WIE_DRAWTEXT ); if( text != NULL ) { SetWindowText( hwnd1, text ); IEFreeRCString( text ); } else { SetWindowText( hwnd1, "Draw:" ); } text = IEAllocRCString( WIE_FILLTEXT ); if( text != NULL ) { SetWindowText( hwnd2, text ); IEFreeRCString( text ); } else { SetWindowText( hwnd2, "Fill:" ); } } /* Win_CreateColorCtrls */
/* * InitStatusLine - initializes the status line ... */ BOOL InitStatusLine( HWND parent ) { WPI_RECT client; WPI_RECT rcsize; status_block_desc sbd[4]; WPI_PRES pres; char *text; char next_block[3]; int len; CreateStatusFont(); sprintf( leftBlock, "%c%c", STATUS_ESC_CHAR, STATUS_FORMAT_LEFT ); sprintf( next_block, "%c%c", STATUS_ESC_CHAR, STATUS_NEXT_BLOCK ); strcpy( nextBlock, next_block ); strcat( nextBlock, leftBlock ); strcpy( hotspotPosition, next_block ); strcat( hotspotPosition, next_block ); strcat( hotspotPosition, leftBlock ); PosText = IEAllocRCString( WIE_STATUSPOSTEXT ); SizeText = IEAllocRCString( WIE_STATUSSIZETEXT ); SetPosText = IEAllocRCString( WIE_STATUSPOSINFO ); if( SetPosText != NULL ) { PositionText = (char *)MemAlloc( strlen( leftBlock ) + strlen( SetPosText ) + 20 + 1 ); text = IEAllocRCString( WIE_STATUSSIZEINFO ); if( text != NULL ) { SetSizeText = (char *)MemAlloc( strlen( SetPosText ) + strlen( text ) + 1 ); if( SetSizeText != NULL ) { strcpy( SetSizeText, SetPosText ); strcat( SetSizeText, text ); PositionSizeText = (char *)MemAlloc( strlen( leftBlock ) + strlen( SetSizeText ) + strlen( nextBlock ) + 40 + 1 ); } IEFreeRCString( text ); } } SetHotSpotText = IEAllocRCString( WIE_STATUSHOTSPOTINFO ); if( SetHotSpotText != NULL ) { HotSpotText = (char *)MemAlloc( strlen( hotspotPosition ) + strlen( SetHotSpotText ) + 20 + 1 ); } SetBitmapText = IEAllocRCString( WIE_BITMAPIMAGETEXT ); SetCursorText = IEAllocRCString( WIE_CURSORIMAGETEXT ); SetIconText = IEAllocRCString( WIE_ICONIMAGETEXT ); if( SetBitmapText != NULL && SetCursorText != NULL && SetIconText != NULL ) { len = max( strlen( SetBitmapText ), strlen( SetCursorText ) ); len = max( len, strlen( SetIconText ) ); len += strlen( imgSizePosition ) + 30 + 1; ImageText = (char *)MemAlloc( len ); } StatusWndInit( Instance, (statushook)NULL, sizeof( LPVOID ), NULL ); statusBar = StatusWndStart(); GetClientRect( parent, &client ); #ifdef __OS2_PM__ rcsize.xLeft = -1; rcsize.xRight = client.xRight + 1; rcsize.yBottom = -1; rcsize.yTop = INIT_STATUS_WIDTH - 1; #else rcsize.left = -1; rcsize.right = client.right + 1; rcsize.bottom = client.bottom + 1; rcsize.top = client.bottom - INIT_STATUS_WIDTH + 1; #endif sbd[0].separator_width = 5; sbd[0].width = 82; sbd[0].width_is_percent = 0; sbd[0].width_is_pixels = 1; sbd[1].separator_width = 5; sbd[1].width = 168; sbd[1].width_is_percent = 0; sbd[1].width_is_pixels = 1; sbd[2].separator_width = 5; sbd[2].width = 255; sbd[2].width_is_percent = 0; sbd[2].width_is_pixels = 1; sbd[3].separator_width = 5; sbd[3].width = 400; sbd[3].width_is_percent = 0; sbd[3].width_is_pixels = 1; StatusWndSetSeparators( statusBar, 4, &sbd ); strcpy( imgSizePosition, next_block ); strcat( imgSizePosition, next_block ); strcat( imgSizePosition, next_block ); strcat( imgSizePosition, leftBlock ); strcpy( hintTextPosition, next_block ); strcat( hintTextPosition, next_block ); strcat( hintTextPosition, next_block ); strcat( hintTextPosition, next_block ); strcat( hintTextPosition, leftBlock ); statusBarWnd = StatusWndCreate( statusBar, parent, &rcsize, Instance, (LPVOID)NULL ); text = NULL; if( PosText != NULL && SizeText != NULL ) { text = (char *)MemAlloc( strlen( PosText ) + strlen( SizeText ) + strlen( leftBlock ) + strlen( nextBlock ) + 1 ); } if( text != NULL ) { sprintf( text, "%s%s%s%s", leftBlock, PosText, nextBlock, SizeText ); pres = _wpi_getpres( statusBarWnd ); StatusWndDrawLine( statusBar, pres, SmallFont, text, -1 ); _wpi_releasepres( statusBarWnd, pres ); MemFree( text ); } GetWindowRect( statusBarWnd, &rcsize ); StatusWidth = rcsize.bottom - rcsize.top; return( TRUE ); } /* InitStatusLine */
/* * 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 */
/* * ChangeSizeDlgProc - change the size of the image being edited */ WPI_DLGRESULT CALLBACK ChangeSizeDlgProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { BOOL trnslate; char *title; char *text; char *msg_text; bool ret; ret = false; if( _wpi_dlg_command( hwnd, &msg, &wparam, &lparam ) ) { switch( LOWORD( wparam ) ) { case DLGID_OK: imgHeight = _wpi_getdlgitemint( hwnd, SIZE_HEIGHT, &trnslate, TRUE ); imgWidth = _wpi_getdlgitemint( hwnd, SIZE_WIDTH, &trnslate, TRUE ); if( !trnslate ) { break; } if( imgHeight > MAX_DIM || imgHeight < MIN_DIM || imgWidth > MAX_DIM || imgWidth < MIN_DIM ) { title = IEAllocRCString( WIE_NOTE ); text = IEAllocRCString( WIE_DIMENSIONSBETWEEN ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + 20 + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, MIN_DIM, MAX_DIM ); MessageBox( hwnd, msg_text, title, MB_OK | MB_ICONINFORMATION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } break; } if( _wpi_isbuttonchecked( hwnd, SIZE_STRETCH ) ) { stretchImage = TRUE; } else { stretchImage = FALSE; } _wpi_enddialog( hwnd, DLGID_OK ); break; case DLGID_CANCEL: _wpi_enddialog( hwnd, DLGID_CANCEL ); break; case IDB_HELP: IEHelpRoutine(); break; } } else { switch( msg ) { case WM_INITDIALOG: _wpi_setdlgitemint( hwnd, SIZE_HEIGHT, imgHeight, FALSE ); _wpi_setdlgitemint( hwnd, SIZE_WIDTH, imgWidth, FALSE ); if( stretchImage ) { _wpi_checkradiobutton( hwnd, SIZE_STRETCH, SIZE_CLIP, SIZE_STRETCH ); } else { _wpi_checkradiobutton( hwnd, SIZE_STRETCH, SIZE_CLIP, SIZE_CLIP ); } ret = true; break; #ifndef __OS2_PM__ case WM_SYSCOLORCHANGE: IECtl3dColorChange(); break; #endif case WM_CLOSE: _wpi_enddialog( hwnd, IDCANCEL ); break; default: return( _wpi_defdlgproc( hwnd, msg, wparam, lparam ) ); } } _wpi_dlgreturn( ret ); } /* ChangeSizeDlgProc */
/* * SelBitmapDlgProc - select options for the bitmap (size and color scheme) */ WPI_DLGRESULT CALLBACK SelBitmapDlgProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { char *title; char *text; char *msg_text; BOOL err; bool ret; ret = false; if( _wpi_dlg_command( hwnd, &msg, &wparam, &lparam ) ) { switch( LOWORD( wparam ) ) { case SEL_SELECT: _wpi_enddialog( hwnd, SEL_SELECT ); break; case DLGID_OK: imgHeight = _wpi_getdlgitemshort( hwnd, BMP_HEIGHT, &err, FALSE ); imgWidth = _wpi_getdlgitemshort( hwnd, BMP_WIDTH, &err, FALSE ); if( imgHeight > MAX_DIM || imgHeight < MIN_DIM || imgWidth > MAX_DIM || imgWidth < MIN_DIM ) { title = IEAllocRCString( WIE_NOTE ); text = IEAllocRCString( WIE_DIMENSIONSBETWEEN ); if( text != NULL ) { msg_text = (char *)MemAlloc( strlen( text ) + 20 + 1 ); if( msg_text != NULL ) { sprintf( msg_text, text, MIN_DIM, MAX_DIM ); MessageBox( hwnd, msg_text, title, MB_OK | MB_ICONINFORMATION ); MemFree( msg_text ); } IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } break; } if( _wpi_isbuttonchecked( hwnd, BMP_TRUECOLOR ) ) { bitCount = 24; } else if( _wpi_isbuttonchecked( hwnd, BMP_256COLOR ) ) { bitCount = 8; } else if( _wpi_isbuttonchecked( hwnd, BMP_16COLOR ) ) { bitCount = 4; } else if( _wpi_isbuttonchecked( hwnd, BMP_2COLOR ) ) { bitCount = 1; } _wpi_enddialog( hwnd, DLGID_OK ); break; case DLGID_CANCEL: _wpi_enddialog( hwnd, DLGID_CANCEL ); break; case IDB_HELP: IEHelpRoutine(); break; } } else { switch( msg ) { case WM_INITDIALOG: // WS_GROUP _wpi_setdlgitemshort( hwnd, BMP_HEIGHT, imgHeight, FALSE ); _wpi_setdlgitemshort( hwnd, BMP_WIDTH, imgWidth, FALSE ); if( bitCount == 1 ) { _wpi_checkradiobutton( hwnd, BMP_TRUECOLOR, BMP_2COLOR, BMP_2COLOR ); } else if( bitCount == 4 ) { _wpi_checkradiobutton( hwnd, BMP_TRUECOLOR, BMP_2COLOR, BMP_16COLOR ); } else if( bitCount == 8 ) { _wpi_checkradiobutton( hwnd, BMP_TRUECOLOR, BMP_2COLOR, BMP_256COLOR ); } else { _wpi_checkradiobutton( hwnd, BMP_TRUECOLOR, BMP_2COLOR, BMP_TRUECOLOR ); } ret = true; break; #ifndef __OS2_PM__ case WM_SYSCOLORCHANGE: IECtl3dColorChange(); break; #endif case WM_CLOSE: _wpi_enddialog( hwnd, IDCANCEL ); break; default: return( _wpi_defdlgproc( hwnd, msg, wparam, lparam ) ); } } _wpi_dlgreturn( ret ); } /* SelBitmapDlgProc */