/* * CloseCurrentImage - Gets the current image the user is editing and deletes * the node from the linked list and sends a message to * destroy the mdi child (this will activate another * child then). */ void CloseCurrentImage( HWND hwnd ) { img_node *node; char file_name[ _MAX_PATH ]; BOOL ret; node = SelectImage( hwnd ); if (!node) return; ret = DestroyWindow( _wpi_getframe(node->viewhwnd) ); GetFnameFromPath( node->fname, file_name ); DeleteUndoStack( hwnd ); if ( !DeleteNode(hwnd) ) { WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_002 ); return; } DeleteActiveImage(); ClearImageText(); GrayEditOptions(); PrintHintTextByID( WIE_FILEHASBEENCLOSED, file_name ); SetWindowText( _wpi_getframe(HMainWindow), IEAppTitle ); #ifdef __OS2_PM__ ret = DestroyWindow( _wpi_getframe(hwnd) ); #else SendMessage(ClientWindow, WM_MDIDESTROY, (WPARAM)hwnd, 0L); #endif } /* CloseCurrentImage */
/* * closeTheImage - get the current image the user is editing, delete * the node from the linked list, and send a message to * destroy the MDI child (this will activate another child) */ static void closeTheImage( img_node *node ) { char file_name[_MAX_PATH]; BOOL ret; HWND hwnd; if( node == NULL ) { return; } ret = _wpi_destroywindow( _wpi_getframe( node->viewhwnd ) ); GetFnameFromPath( node->fname, file_name ); hwnd = node->hwnd; DeleteUndoStack( hwnd ); if( !DeleteNode( hwnd ) ) { WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_002 ); return; } #ifdef __OS2_PM__ ret = DestroyWindow( _wpi_getframe( hwnd ) ); #else SendMessage( ClientWindow, WM_MDIDESTROY, (WPARAM)hwnd, 0L ); #endif } /* closeTheImage */
/* * ViewWindowProc - window procedure for the view window */ WPI_MRESULT CALLBACK ViewWindowProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static HMENU sysmenu; static HWND hframe; HMENU hmenu; WPI_RECT rcview; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; switch ( msg ) { case WM_CREATE: hframe = _wpi_getframe( hwnd ); sysmenu = _wpi_getcurrentsysmenu( hframe ); _wpi_deletemenu( sysmenu, SC_RESTORE, FALSE ); _wpi_deletemenu( sysmenu, SC_SIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_MINIMIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_MAXIMIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_TASKLIST, FALSE ); #ifdef __OS2_PM__ _wpi_deletemenu( sysmenu, SC_HIDE, FALSE ); #endif _wpi_deletesysmenupos( sysmenu, 1 ); _wpi_deletesysmenupos( sysmenu, 2 ); break; case WM_PAINT: redrawViewWnd( hwnd ); return( 0 ); case WM_MOVE: _wpi_getwindowrect( _wpi_getframe( hwnd ), &rcview ); _wpi_getrectvalues( rcview, &left, &top, &right, &bottom ); ImgedConfigInfo.view_xpos = (short)left; ImgedConfigInfo.view_ypos = (short)top; break; case WM_CLOSE: hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); if( fOneViewWindow ) { CheckViewItem( hmenu ); } else { PrintHintTextByID( WIE_USEOPTIONSTOHIDEALL, NULL ); } break; case WM_DESTROY: hViewWindow = NULL; break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return( 0 ); } /* ViewWindowProc */
/* * 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 */
/* * CheckViewItem - handle when the view window option is selected from the menu */ void CheckViewItem( HMENU hmenu ) { WPI_ENUMPROC fp_enum; if( _wpi_isitemchecked( hmenu, IMGED_VIEW ) ) { _wpi_checkmenuitem( hmenu, IMGED_VIEW, MF_UNCHECKED, FALSE ); showState = SW_HIDE; ImgedConfigInfo.show_state &= ~SET_SHOW_VIEW; } else { _wpi_checkmenuitem( hmenu, IMGED_VIEW, MF_CHECKED, FALSE ); showState = SW_SHOWNORMAL; ImgedConfigInfo.show_state |= SET_SHOW_VIEW; } if( hViewWindow == NULL ) { return; } ShowWindow( _wpi_getframe( hViewWindow ), showState ); if( _wpi_iswindow( Instance, ClientWindow ) ) { fp_enum = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); _wpi_enumchildwindows( ClientWindow, fp_enum, 0L ); _wpi_freeprocinstance( fp_enum ); } } /* CheckViewItem */
/* * RePositionViewWnd - reposition the size of the window (for when a * different icon is selected) */ void RePositionViewWnd( img_node *node ) { WPI_RECT location; int h_adj; int v_adj; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; HWND frame; frame = _wpi_getframe( node->viewhwnd ); _wpi_getwindowrect( frame, &location ); h_adj = 2 * _wpi_getsystemmetrics( SM_CXDLGFRAME ) + 2 * BORDER_WIDTH; v_adj = 2 * _wpi_getsystemmetrics( SM_CYDLGFRAME ) + #ifndef __NT__ _wpi_getsystemmetrics( SM_CYCAPTION ) + 2 * BORDER_WIDTH - 1; #else _wpi_getsystemmetrics( SM_CYSMCAPTION ) + 2 * BORDER_WIDTH - 1; #endif _wpi_getrectvalues( location, &left, &top, &right, &bottom ); #ifdef __OS2_PM__ SetWindowPos( frame, NULL, left, bottom, h_adj + node->width, v_adj + node->height, SWP_SIZE | SWP_MOVE | SWP_NOZORDER | SWP_HIDEWINDOW ); #else SetWindowPos( node->viewhwnd, NULL, left, top, h_adj + node->width, v_adj + node->height, SWP_SIZE | SWP_MOVE | SWP_NOZORDER | SWP_HIDEWINDOW ); #endif hViewWindow = node->viewhwnd; ShowWindow( frame, showState ); SetFocus( HMainWindow ); InvalidateRect( hViewWindow, NULL, TRUE ); } /* RePositionViewWnd */
/* * 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 */
/* * HideViewWindow - hide the view window when a draw pad is minimized */ void HideViewWindow( HWND hwnd ) { img_node *node; node = SelectImage( hwnd ); if( node == NULL ) { return; } ShowWindow( _wpi_getframe( node->viewhwnd ), SW_HIDE ); } /* HideViewWindow */
/* * 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 */
/* * CreateColorPal - create the color palette window depending on the OS * we're compiling for */ void CreateColorPal( void ) { HMENU hmenu; #ifdef __OS2_PM__ PM_CreateColorPal(); #else Win_CreateColorPal(); #endif hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); if( ImgedConfigInfo.show_state & SET_SHOW_CLR ) { CheckPaletteItem( hmenu ); } CreateCurrentWnd( HColorPalette ); CreateColorControls( HColorPalette ); } /* CreateColorPal */
/* * CloseAllImages - used in the close all menu option */ void CloseAllImages( void ) { img_node *head; img_node *current; WPI_PARAM1 p1; HWND parent; head = GetHeadNode(); if( !head ) { PrintHintTextByID( WIE_NOIMAGESTOCLOSE, NULL ); return; } current = head; while( current ) { if( !(current->issaved) ) { p1 = WPI_MAKEP1( current->hwnd, 0 ); parent = _wpi_getparent( current->hwnd ); #ifdef __OS2_PM__ _wpi_sendmessage(parent, WM_ACTIVATE, (WPI_PARAM1)p1, 0L); #else _wpi_sendmessage( parent, WM_MDIRESTORE, (WPI_PARAM1)p1, 0L ); _wpi_sendmessage(ClientWindow, WM_MDIACTIVATE, (WPI_PARAM1)p1, 0L); #endif if( !(lastChanceSave(current)) ) { return; } } current = current->next; } DeleteActiveImage(); while( head ) { closeTheImage( head ); head = GetHeadNode(); } ClearImageText(); GrayEditOptions(); PrintHintTextByID( WIE_ALLIMAGESCLOSED, NULL ); _wpi_setwindowtext( _wpi_getframe(HMainWindow), IEAppTitle ); } /* CloseAllImages */
/* * SelectOptions - bring up the current settings dialog box */ void SelectOptions( void ) { WPI_PROC fp; WPI_DLGRESULT button_type; HMENU hmenu; fp = _wpi_makeprocinstance( (WPI_PROC)CurrentSettingsProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, (WPI_DLGPROC)fp, Instance, CURRENT_SETTINGS, 0L ); _wpi_freeprocinstance( fp ); if( button_type == DLGID_CANCEL ) { return; } hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); if( fCheckSquareGrid ) { CheckSquareGrid( hmenu ); } } /* SelectOptions */
/* * FocusOnImage - Selects one of the mdi children. */ void FocusOnImage( HWND hwnd ) { char current_file[ _MAX_PATH ]; char *text; if (activeImage) { RedrawPrevClip(activeImage->hwnd); SetRectExists( FALSE ); } activeImage = SelectImage( hwnd ); if (!activeImage) { WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_001 ); return; } ResetViewWindow( activeImage->viewhwnd ); CreateDrawnImage( activeImage ); SetMenus( activeImage ); SetNumColours( 1<<(activeImage->bitcount) ); SetHotSpot( activeImage ); DisplayImageText( activeImage ); CheckForUndo( activeImage ); GetFnameFromPath( activeImage->fname, current_file ); text = (char *) MemAlloc( strlen( IEAppTitle ) + strlen( current_file ) + 3 + 1 ); if( text ) { strcpy( text, IEAppTitle ); strcat( text, " - " ); strcat( text, current_file ); _wpi_setwindowtext( _wpi_getframe(HMainWindow), text ); MemFree( text ); } #ifndef __OS2_PM__ RedrawWindow( hwnd, NULL, NULL, RDW_UPDATENOW ); #endif } /* FocusOnImage */
/* * CheckPaletteItem - handle when the color palette menu item has been selected */ void CheckPaletteItem( HMENU hmenu ) { HWND frame_wnd; if( HColorPalette == NULL ) { _wpi_checkmenuitem( hmenu, IMGED_COLOR, MF_CHECKED, FALSE ); return; } frame_wnd = _wpi_getframe( HColorPalette ); if( _wpi_isitemchecked( hmenu, IMGED_COLOR ) ) { _wpi_checkmenuitem( hmenu, IMGED_COLOR, MF_UNCHECKED, FALSE ); ShowWindow( frame_wnd, SW_HIDE ); ImgedConfigInfo.show_state &= ~SET_SHOW_CLR; } else { _wpi_checkmenuitem( hmenu, IMGED_COLOR, MF_CHECKED, FALSE ); ShowWindow( frame_wnd, SW_SHOWNA ); _wpi_setfocus( HMainWindow ); ImgedConfigInfo.show_state |= SET_SHOW_CLR; } } /* CheckPaletteItem */
/* * 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 */
/* * 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 */
/* * DeleteActiveImage - sets the active image to null. */ void DeleteActiveImage( void ) { activeImage = NULL; _wpi_setwindowtext( _wpi_getframe(HMainWindow), IEAppTitle ); } /* DeleteActiveImage */
WPI_MRESULT CALLBACK GUIWindowProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { gui_window *wnd; gui_window *root; WORD param; WPI_POINT currentpoint; gui_coord point; gui_coord size; WPI_MRESULT ret; WPI_MINMAXINFO _W386FAR *info; WPI_RECT rect; HWND parent; CREATESTRUCT FAR *lpcs; wmcreate_info _W386FAR *wmcreateinfo; gui_create_info *createinfo; bool use_defproc; unsigned control_id; HWND win; #ifndef __OS2_PM__ gui_key_state key_state; RECT rc; #endif root = NULL; ret = 0L; use_defproc = FALSE; if( msg == WM_CREATE ) { lpcs = ( CREATESTRUCT FAR * )MK_FP32( (void *)lparam ); wmcreateinfo = (wmcreate_info _W386FAR *)MK_FP32( _wpi_getcreateparms( lpcs ) ); if ( wmcreateinfo != NULL ) { wnd = wmcreateinfo->wnd; createinfo = wmcreateinfo->info; if( wnd->hwnd == NULLHANDLE ) { #ifdef __OS2_PM__ if( wnd->root_frame != NULLHANDLE && wnd->root == NULLHANDLE ) { wnd->root = hwnd; } else { wnd->hwnd = hwnd; } #else if( _wpi_getparent( hwnd ) == HWND_DESKTOP ) { wnd->root = hwnd; wnd->root_frame = hwnd; } else { wnd->hwnd = hwnd; wnd->hwnd_frame = hwnd; } #endif } DoSetWindowLong( hwnd, wnd ); } } wnd = GUIGetWindow( hwnd ); if( wnd == NULL ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } if( GUIMDIProcessMessage( wnd, hwnd, msg, wparam, lparam, &ret ) ) { return( ret ); } if( wnd->root == hwnd ) { /* message for root window */ switch( msg ) { case WM_CREATE : #ifdef __OS2_PM__ wnd->root_pinfo.normal_pres = _wpi_createos2normpres( GUIMainHInst, hwnd ); #endif _wpi_getclientrect( wnd->root_frame, &wnd->root_client ); if( CreateBackgroundWnd( wnd, createinfo ) ) { return( 0 ); } return( (WPI_MRESULT)WPI_ERROR_ON_CREATE ); break; case WM_DESTROY : wnd->flags |= DOING_DESTROY; GUICloseToolBar( wnd ); //ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam ); //wnd->root = NULL; //wnd->root_frame = NULL; return( 0L ); } } else if( ( wnd->root != NULLHANDLE ) && ( hwnd == wnd->hwnd ) ) { /* message for container window */ switch( msg ) { case WM_SIZE : if( !_wpi_isiconic( _wpi_getframe( hwnd ) ) ) { size.x = _wpi_getwmsizex( wparam, lparam ); size.y = _wpi_getwmsizey( wparam, lparam ); GUIDoResize( wnd, hwnd, &size ); } return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); break; case WM_MOVE : return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); break; case WM_VSCROLL : case WM_HSCROLL : case WM_CLOSE : return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); break; } } switch( msg ) { case WM_CREATE : #ifdef __OS2_PM__ wnd->hwnd_pinfo.normal_pres = _wpi_createos2normpres( GUIMainHInst, hwnd ); #endif NumWindows++; // even if -1 is returned, window will get WM_DESTROY win = GUIGetParentFrameHWND( wnd ); if( ( wnd->root_frame != NULLHANDLE ) || ( createinfo->style & GUI_POPUP ) ) { if( !GUIAddToSystemMenu( wnd, win, 0, NULL, createinfo->style ) ) { return( (WPI_MRESULT)WPI_ERROR_ON_CREATE ); } } else { if( !GUIAddToSystemMenu( wnd, win, createinfo->num_menus, createinfo->menu, createinfo->style ) ) { return( (WPI_MRESULT)WPI_ERROR_ON_CREATE ); } } _wpi_getclientrect( hwnd, &wnd->hwnd_client ); GUISetRowCol( wnd, NULL ); if( ( hwnd == wnd->hwnd ) && ( wnd->root == NULLHANDLE ) ) { GUIMDINewWindow( hwnd ); } if( GUIEVENTWND( wnd, GUI_INIT_WINDOW, NULL ) ) { wnd->flags |= SENT_INIT; GUISetScroll( wnd ); /* initalize scroll ranges */ GUIBringToFront( wnd ); return( 0 ); } else { /* app decided not to create window */ return( (WPI_MRESULT)WPI_ERROR_ON_CREATE ); } break; #if defined(__NT__) || defined(WILLOWS) case WM_CTLCOLORBTN : case WM_CTLCOLORDLG : //case WM_CTLCOLORLISTBOX : case WM_CTLCOLORSTATIC : //case WM_CTLCOLOREDIT : ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam ); if( ret == (HBRUSH)NULL ) { SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam, GUIGetBack( wnd, GUI_BACKGROUND ) ) ); ret = (WPI_MRESULT)wnd->bk_brush; } return( ret ); #elif !defined( __OS2_PM__ ) case WM_CTLCOLOR : switch( HIWORD( lparam ) ) { case CTLCOLOR_BTN : case CTLCOLOR_DLG : case CTLCOLOR_EDIT : case CTLCOLOR_LISTBOX : case CTLCOLOR_MSGBOX : case CTLCOLOR_STATIC : ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam ); if( ret == (HBRUSH)NULL ) { SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam, GUIGetBack( wnd, GUI_BACKGROUND ) ) ); ret = (WPI_MRESULT)wnd->bk_brush; } break; } return( ret ); #endif #ifndef __OS2_PM__ case WM_INITMENUPOPUP : return( GUIProcessInitMenuPopup( wnd, hwnd, msg, wparam, lparam ) ); case WM_MENUSELECT : return( GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam ) ); #endif case WM_GETMINMAXINFO : info = (WPI_MINMAXINFO _W386FAR *)MK_FP32( (void *)lparam ); ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam ); if( wnd->root == NULLHANDLE ) { parent = _wpi_getparent( hwnd ); _wpi_getclientrect( parent, &rect ); _wpi_setmaxposition( *info, 0, 0 ); _wpi_setmaxtracksize( info, _wpi_getwidthrect( rect ), _wpi_getheightrect( rect ) ); } return( ret ); case WM_ERASEBKGND: #ifdef __OS2_PM__ //GUIInvalidatePaintHandles( wnd ); return( (WPI_MRESULT)TRUE ); #else if( !_wpi_isiconic( hwnd ) ) { GetClientRect( hwnd, &rc ); FillRect( (HDC)wparam, &rc, wnd->bk_brush ); } use_defproc = TRUE; break; #endif #if !defined(__OS2_PM__) && !defined(WILLOWS) case WM_PAINTICON : { HICON old; old = SET_HICON( wnd->hwnd, wnd->icon ); ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam ); SET_HICON( wnd->hwnd, old ); return( ret ); } #endif case WM_PAINT: if( _wpi_isiconic( hwnd ) ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } else { GUIPaint( wnd, hwnd, FALSE ); } break; #ifndef __OS2_PM__ case WM_ACTIVATEAPP : root = GUIGetRootWindow(); ActivateNC( root, wparam ); if( GUICurrWnd != NULL ) { ActivateNC( GUICurrWnd, wparam ); } use_defproc = (bool)wparam; // I'm cheating and using 'use_defproc' // outside of its self-documented purpose if( root ) GUIEVENTWND( root, GUI_ACTIVATEAPP, &use_defproc ); use_defproc = TRUE; break; #if 0 // this repaints the nc client area when the window loses focus to // a window that is not a descendant of a GUI window case WM_KILLFOCUS : if( !GUIIsGUIChild( (HWND)wparam ) ) { ActivateNC( wnd, FALSE ); } break; #endif case WM_SETFOCUS : if( !_wpi_ismsgsetfocus( msg, lparam ) ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } if( !EditControlHasFocus ) { if( SetFocusToParent() ) { return( 0L ); } } break; #endif case WM_VSCROLL : case WM_HSCROLL : GUIProcessScrollMsg( wnd, msg, wparam, lparam ); return( 0L ); #ifdef __NT__ case WM_MOUSEWHEEL : { // Try to handle mousewheel messages... // Fake them into GUIProcessScrollMsg() // as "normal" vertical scroll messages. short gcWheelDelta; //wheel delta from roll WORD wKey; // The wnd I get is not the same as WM_VSCROLL : above gets... // Note to self: Fix it... // Seems like the main app window gets the message, rather than // the MDI clients... gcWheelDelta = HIWORD(wparam); wKey = LOWORD(wparam); // Scroll wheel upwards gives 120 // " " downward " -120 if( wnd != GUICurrWnd ) // Send to child window with focus wnd = GUICurrWnd; if( gcWheelDelta > 0 ) { // positive - scroll up if( wKey == MK_CONTROL || wKey == MK_SHIFT ) GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEUP, 0L ); else GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEUP, 0L ); } else { // negative - scroll down if( wKey == MK_CONTROL || wKey == MK_SHIFT ) GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEDOWN, 0L ); else GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEDOWN, 0L ); } // Inform GUI system we are done with scrolling for now. GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_ENDSCROLL, 0 ); } return( 0L ); #endif case WM_MOVE : use_defproc = TRUE; if( wnd->flags & DOING_CLOSE ) { break; } if( !GUIParentHasFlags( wnd, IS_MINIMIZED ) ) { GUIEVENTWND( wnd, GUI_MOVE, NULL ); } use_defproc = TRUE; break; case WM_SIZE: use_defproc = TRUE; if( wnd->flags & DOING_CLOSE ) { break; } if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) { wnd->flags |= IS_MINIMIZED; if( wnd->style & GUI_CHANGEABLE_FONT ) { GUIEnableSysMenuItem( wnd, GUI_CHANGE_FONT, FALSE ); } GUIEVENTWND( wnd, GUI_ICONIFIED, NULL ); if( GUIMDI ) { GUIBringNewToFront( wnd ); } } else { wnd->flags &= ~IS_MINIMIZED; size.x = _wpi_getwmsizex( wparam, lparam ); size.y = _wpi_getwmsizey( wparam, lparam ); GUIDoResize( wnd, hwnd, &size ); if( wnd->flags & IS_ROOT ) { win = GUIGetParentFrameHWND( wnd ); if( !_wpi_isiconic( win ) ) { GUIMaximizeZoomedChildren( wnd ); } } } //Call back to tell about resizing so system tray can be used WndSizeChange( hwnd, wparam, lparam ); break; case WM_MOUSEMOVE: currentpoint.x = GET_WM_MOUSEMOVE_POSX( wparam, lparam ); currentpoint.y = GET_WM_MOUSEMOVE_POSY( wparam, lparam ); point.x = currentpoint.x; point.y = currentpoint.y; GUIScreenToScaleR( &point ); if( ( currentpoint.x != prevpoint.x ) || ( currentpoint.y != prevpoint.y ) ) { prevpoint.x = currentpoint.x; prevpoint.y = currentpoint.y; SendPointEvent( wparam, lparam, wnd, GUI_MOUSEMOVE, TRUE ); } break; #ifndef __OS2_PM__ case WM_NCLBUTTONDOWN : case WM_NCMBUTTONDOWN : case WM_NCRBUTTONDOWN : CheckDoFront( wnd ); use_defproc = TRUE; break; case WM_RBUTTONDOWN: _wpi_setcapture( hwnd ); CheckDoFront( wnd ); SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE ); break; #else case WM_RBUTTONDOWN : WPI_MAKEPOINT( wparam, lparam, currentpoint ); win = PM1632WinWindowFromPoint( hwnd, ¤tpoint, FALSE ); if( ( win != (HWND)NULL) && ( win != hwnd ) ) { control_id = _wpi_getdlgctrlid( win ); if( control_id != 0 ) { GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id ); } } else { _wpi_setcapture( hwnd ); CheckDoFront( wnd ); SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE ); } break; #endif case WM_LBUTTONDOWN: _wpi_setcapture( hwnd ); CheckDoFront( wnd ); SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDOWN, TRUE ); use_defproc = TRUE; break; case WM_LBUTTONUP: _wpi_releasecapture(); SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONUP, TRUE ); use_defproc = TRUE; break; case WM_RBUTTONUP: _wpi_releasecapture(); SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONUP, TRUE ); break; case WM_LBUTTONDBLCLK: CheckDoFront( wnd ); SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDBLCLK, TRUE ); break; case WM_RBUTTONDBLCLK: CheckDoFront( wnd ); SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDBLCLK, TRUE ); break; case WM_SYSCOMMAND: param = _wpi_getid( wparam ); switch( param ) { case SC_NEXTWINDOW : if( GUIMDI ) { NextWndToFront( hwnd ); return( 0L ); } default : if( ( param & 0xf000 ) == ( SC_NEXTWINDOW & 0xf000 ) ) { /* top value same for all SC_* values */ return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } else { ProcessMenu( wnd, param ); } break; } break; #ifdef __OS2_PM__ case WM_CONTROL : GUIProcessControlNotification( SHORT1FROMMP(wparam), SHORT2FROMMP(wparam), wnd ); break; #else case WM_PARENTNOTIFY: if( ( LOWORD(wparam) == WM_RBUTTONDOWN ) || ( LOWORD(wparam) == WM_LBUTTONDOWN ) || ( LOWORD(wparam) == WM_MBUTTONDOWN ) ) { if( wnd->root == NULLHANDLE ) { CheckDoFront( wnd ); } } if( LOWORD(wparam) == WM_RBUTTONDOWN ) { WPI_MAKEPOINT( wparam, lparam, currentpoint ); MapWindowPoints( hwnd, (HWND)NULL, ¤tpoint, 1 ); win = _wpi_windowfrompoint( currentpoint ); control_id = _wpi_getdlgctrlid( win ); if( control_id != 0 ) { if( _wpi_getparent(win) == hwnd ) { GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id ); } } } break; case WM_ENDSESSION : { gui_end_session es; es.endsession = (bool)wparam; es.logoff = (bool)( lparam == 0x80000000L ); GUIEVENTWND( wnd, GUI_ENDSESSION, &es ); return( 0L ); } case WM_QUERYENDSESSION : { gui_end_session es; es.endsession = (bool)wparam; es.logoff = (bool)( lparam == 0x80000000L ); // ENDSESSION_LOGOFF if( !GUIEVENTWND( wnd, GUI_QUERYENDSESSION, &es ) ) { return( TRUE ); } return( 0L ); } #endif case WM_COMMAND: if( _wpi_ismenucommand( wparam, lparam ) || IsToolBarCommand( wnd, wparam, lparam ) ) { /* from menu or toolbar */ ProcessMenu( wnd, _wpi_getid( wparam ) ); //SetFocusToParent(); } else { GUIProcessControlMsg( wparam, lparam, wnd, NULL ); } use_defproc = TRUE; break; #ifndef __OS2_PM__ case WM_VKEYTOITEM : use_defproc = FALSE; ret = -1; GUIGetKeyState( &key_state.state ); if( ( GUIWindowsMapKey( wparam, lparam, &key_state.key ) ) ) { ret = GUIEVENTWND( wnd, GUI_KEYTOITEM, &key_state ); } break; #endif #ifdef __OS2_PM__ case WM_CHAR : case WM_TRANSLATEACCEL : #else case WM_MENUCHAR : case WM_SYSKEYDOWN : case WM_SYSKEYUP : case WM_KEYUP : case WM_KEYDOWN : #endif return( GUIProcesskey( hwnd, msg, wparam, lparam ) ); case WM_CLOSE : if( wnd->flags & DOING_CLOSE ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } else if( wnd->style & GUI_CLOSEABLE ) { if( GUIEVENTWND( wnd, GUI_CLOSE, NULL ) ) { wnd->flags |= DOING_CLOSE; if( wnd->flags & IS_ROOT ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } else { _wpi_destroywindow( wnd->hwnd_frame ); } } } return( 0L ); // Message to deal with tray icons (Win 95 and NT 4.0 ). case WM_TRAYCALLBACK : TrayCallBack( hwnd, wparam, lparam ); return( 0L ); case WM_DESTROY : wnd->flags |= DOING_DESTROY; NumWindows--; GUIEVENTWND( wnd, GUI_DESTROY, NULL ); //ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam ); GUIDestroyAllChildren( wnd ); if( wnd->flags & IS_ROOT ) { GUIDestroyAllPopupsWithNoParent(); } GUIFreeWindowMemory( wnd, FALSE, FALSE ); if( NumWindows == 0 ) { _wpi_postquitmessage( 0 ); Posted = TRUE; } return( 0L ); default: use_defproc = TRUE; } if( use_defproc ) { return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) ); } else { return( ret ); } }
/* * 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 */
/* * SetToolType - set the tool type */ int SetToolType( int toolid ) { HMENU hmenu; int i; int prev_tool; img_node *node; if( toolType == IMGED_CLIP ) { node = GetCurrentNode(); if( node != NULL ) { RedrawPrevClip( node->hwnd ); SetRectExists( FALSE ); } } prev_tool = toolType; toolType = toolid; if( toolid == IMGED_PASTE || toolid == IMGED_SNAP ) { return( prev_tool ); } if( HMainWindow == NULL ) { return( 0 ); } hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) ); switch( toolid ) { case IMGED_FREEHAND: setTheCursor( PENCIL_CUR, NULL ); break; case IMGED_LINE: setTheCursor( CROSS_CUR, NULL ); break; case IMGED_HOTSPOT: setTheCursor( HOTSPOT_CUR, NULL ); break; case IMGED_RECTO: setTheCursor( CROSS_CUR, NULL ); break; case IMGED_RECTF: setTheCursor( CROSS_CUR, NULL ); break; case IMGED_CIRCLEO: setTheCursor( CROSS_CUR, NULL ); break; case IMGED_CIRCLEF: setTheCursor( CROSS_CUR, NULL ); break; case IMGED_FILL: setTheCursor( FILL_CUR, NULL ); break; case IMGED_BRUSH: setTheCursor( BRUSH_CUR, NULL ); if( prev_tool != IMGED_PASTE && prev_tool !=IMGED_SNAP ) { WriteSetSizeText( WIE_BRUSHSIZEIS, ImgedConfigInfo.brush_size, ImgedConfigInfo.brush_size ); } break; case IMGED_CLIP: setTheCursor( CROSS_CUR, NULL ); break; default: setTheCursor( PENCIL_CUR, NULL ); toolType = IMGED_FREEHAND; break; } for( i = IMGED_CLIP; i <= IMGED_HOTSPOT; i++ ) { #if 0 if( _wpi_isitemenabled( hmenu, i ) ) { _wpi_checkmenuitem( hmenu, i, FALSE, FALSE ); } #else if( _wpi_isitemchecked( hmenu, i ) ) { _wpi_checkmenuitem( hmenu, i, FALSE, FALSE ); } #endif } _wpi_checkmenuitem( hmenu, toolType, TRUE, FALSE ); SetDrawTool( toolType ); return( prev_tool ); } /* SetToolType */
/* * 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 */
/* * 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 */
/* * SetIsSaved - set whether the given MDI child has been saved */ void SetIsSaved( HWND hwnd, BOOL fissaved ) { img_node *node; img_node *next_icon; char fname[_MAX_FNAME]; char dir[_MAX_DIR]; char ext[_MAX_EXT]; char drive[_MAX_DRIVE]; char title[_MAX_EXT + _MAX_FNAME + 2]; char *main_title; node = GetImageNode( hwnd ); if( node == NULL ) { return; } // We do not check whether or not the image needs to have its // title bars updated here because sometimes we will save images // that are not modified to different files. #if 0 if( fissaved == node->issaved ) { return; } #endif next_icon = node; while( next_icon != NULL ) { next_icon->issaved = fissaved; next_icon = next_icon->nexticon; } if( fissaved ) { _wpi_getwindowtext( _wpi_getframe( node->hwnd ), title, sizeof( title ) ); if( strnicmp( title, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 && strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) { return; } _splitpath( node->fname, drive, dir, fname, ext ); strcpy( title, strupr( fname ) ); strcat( title, strupr( ext ) ); _wpi_setwindowtext( _wpi_getframe( node->hwnd ), (LPSTR)title ); main_title = (char *)MemAlloc( strlen( IEAppTitle ) + strlen( title ) + 3 + 1 ); if( main_title != NULL ) { strcpy( main_title, IEAppTitle ); strcat( main_title, " - " ); strcat( main_title, title ); _wpi_setwindowtext( HMainWindow, main_title ); MemFree( main_title ); } } else { _wpi_getwindowtext( _wpi_getframe( node->hwnd ), title, sizeof( title ) ); if( strnicmp( title, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) { return; } else if( title[strlen( title ) - 1] == '*' ) { return; } else { strcat( title, "*" ); _wpi_setwindowtext( _wpi_getframe( node->hwnd ), (LPSTR)title ); } } } /* SetIsSaved */
/* * imgEditInit - initialization */ static BOOL imgEditInit( HAB hab ) { ULONG flags; BOOL maximized; HWND frame; char clientclass[] = { "IMGEDClientClass" }; HWND hwnd; WPI_RECT rect; HMENU hmenu; // Change this to use the querycaps routine ColourPlanes = 1; BitsPerPixel = 4; Instance.hab = hab; Instance.mod_handle = NULL; /* * set up window class */ if (!WinRegisterClass( hab, className, (PFNWP)ImgEdFrameProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, clientclass, (PFNWP)ClientProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, PaletteClass, (PFNWP)ColourPalWinProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, CURRENT_CLASS, (PFNWP)CurrentWndProc, CS_SIZEREDRAW | CS_SYNCPAINT, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, AVAIL_CLASS, (PFNWP)ColoursWndProc, CS_SIZEREDRAW | CS_SYNCPAINT, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, SCREEN_CLASS, (PFNWP)ScreenWndProc, CS_SIZEREDRAW, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassB, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassI, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, DrawAreaClassC, (PFNWP)DrawAreaWinProc, CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS, 0 )) { return( FALSE ); } if (!WinRegisterClass( hab, ViewWinClass, (PFNWP)ViewWindowProc, CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0 )) { return( FALSE ); } LoadImgedConfig(); maximized = ImgedConfigInfo.ismaximized; InitPalette(); /* * now make the main window */ flags = FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX | FCF_SYSMENU | FCF_TASKLIST | FCF_ICON | FCF_MENU; frame = WinCreateStdWindow( HWND_DESKTOP, 0L, &flags, className, ImgEdName, 0L, (HMODULE)0, IMGED_MAIN, &HMainWindow); WinSetWindowPos(frame, HWND_TOP, ImgedConfigInfo.x_pos, ImgedConfigInfo.y_pos, ImgedConfigInfo.width, ImgedConfigInfo.height, SWP_MOVE | SWP_SHOW | SWP_SIZE); _wpi_getclientrect( HMainWindow, &rect ); flags = 0L; /* * N.B. - NOTE that ClientWindow is actually a FRAME WINDOW!!!!! The * name is a bit misleading and it is unlike HMainWindow which * is a client window. */ ClientWindow = WinCreateStdWindow( HMainWindow, 0L, &flags, clientclass, "", 0L, (HMODULE)0, 0, &hwnd); WinSetWindowPos(ClientWindow, HWND_TOP, 0, STATUS_WIDTH, _wpi_getwidthrect( rect ), _wpi_getheightrect(rect) -STATUS_WIDTH -FUNCTIONBAR_WIDTH -1, SWP_MOVE | SWP_SHOW | SWP_SIZE); CreateColourPal(); InitFunctionBar( HMainWindow ); InitTools( _wpi_getframe(HMainWindow) ); hmenu = _wpi_getmenu( frame ); if (ImgedConfigInfo.grid_on) { CheckGridItem(hmenu); } SetHintText("Open Watcom Image Editor."); WinSetFocus( HWND_DESKTOP, _wpi_getframe(HMainWindow) ); return( TRUE ); } /* imgEditInit */
/* * 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 bool guiToolBarProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { gui_window *wnd; toolbarinfo *tbar; HMENU hmenu; gui_ctl_id id; wnd = GetToolWnd( hwnd ); if( wnd == NULL ) { return( false ); } tbar = wnd->tbinfo; if( tbar == NULL ) { return( false ); } switch( msg ) { case WM_CREATE : hwnd = _wpi_getframe( hwnd ); hmenu = _wpi_getsystemmenu( hwnd ); if( hmenu != NULLHANDLE ) { if( _wpi_appendmenu( hmenu, MF_SEPARATOR, 0, 0, NULLHANDLE, NULL ) ) { _wpi_appendmenu( hmenu, MF_ENABLED|MF_SYSMENU, 0, GUIHint[GUI_MENU_FIX_TOOLBAR].id, NULLHANDLE, GUIHint[GUI_MENU_FIX_TOOLBAR].label ); } } break; #ifdef __OS2_PM__ case WM_CHAR : case WM_TRANSLATEACCEL : #else case WM_SYSKEYDOWN : case WM_SYSKEYUP : case WM_KEYUP : case WM_KEYDOWN : #endif return( GUIProcesskey( hwnd, msg, wparam, lparam ) != 0 ); case WM_MENUSELECT : GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam ); return( true ); case WM_SYSCOMMAND : id = _wpi_getid( wparam ); switch( id ) { case GUI_FIX_TOOLBAR : GUIChangeToolBar( wnd ); } break; #ifndef __OS2_PM__ case WM_NCLBUTTONDBLCLK : #endif case WM_RBUTTONDBLCLK : case WM_LBUTTONDBLCLK : /* flip the current state of the toolbar - * if we are fixed then start to float or vice versa */ if( !HasToolAtPoint( tbar->hdl, wparam, lparam ) ) { #ifdef __OS2_PM__ // Hack: For some reason we will get here with bogus coords, // we need to ignore the event. Should really find out where // the message is coming from. if( (ULONG)wparam != 0x0FFFFFFF ) GUIChangeToolBar( wnd ); #else GUIChangeToolBar( wnd ); #endif return( true ); } break; case WM_MOVE: case WM_SIZE: // Whenever we are moved or sized as a floating toolbar, we remember our position // so that we can restore it when dbl. clicked if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) { hwnd = _wpi_getframe( hwnd ); _wpi_getwindowrect( hwnd, &tbar->floatrect ); } break; case WM_GETMINMAXINFO: { #ifdef __WINDOWS_386__ WPI_MINMAXINFO __far *minmax= (WPI_MINMAXINFO __far *)MK_FP32( (void *)lparam ); #else WPI_MINMAXINFO *minmax = (WPI_MINMAXINFO *)lparam; #endif _wpi_setmintracksize( minmax, ( tbar->info.border_size.x + _wpi_getsystemmetrics( SM_CXFRAME ) ) * 2 + tbar->info.button_size.x, ( tbar->info.border_size.y + _wpi_getsystemmetrics( SM_CYFRAME ) ) * 2 + tbar->info.button_size.y + _wpi_getsystemmetrics( SM_CYCAPTION ) ); } break; case WM_CLOSE : GUICloseToolBar( wnd ); return( true ); break; } return( 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 */
/* * ColorPalWinProc - handle messages for the color palette */ WPI_MRESULT CALLBACK ColorPalWinProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 mp1, WPI_PARAM2 mp2 ) { HMENU sysmenu; WPI_RECT rcpal; WPI_RECTDIM left; WPI_RECTDIM right; WPI_RECTDIM top; WPI_RECTDIM bottom; static HMENU menu; static HWND hframe; switch( msg ) { case WM_CREATE: hframe = _wpi_getframe( hwnd ); sysmenu = _wpi_getcurrentsysmenu( hframe ); _wpi_deletemenu( sysmenu, SC_RESTORE, FALSE ); _wpi_deletemenu( sysmenu, SC_SIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_MINIMIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_MAXIMIZE, FALSE ); _wpi_deletemenu( sysmenu, SC_TASKLIST, FALSE ); #ifdef __OS2_PM__ _wpi_deletemenu( sysmenu, SC_HIDE, FALSE ); #endif _wpi_deletesysmenupos( sysmenu, 1 ); _wpi_deletesysmenupos( sysmenu, 2 ); hbrush = _wpi_createsolidbrush( LTGRAY ); menu = GetMenu( _wpi_getframe( HMainWindow ) ); break; case WM_PAINT: _wpi_deleteobject( hbrush ); SetBkColor( (HDC)mp1, GetSysColor( COLOR_BTNFACE ) ); SetTextColor( (HDC)mp1, GetSysColor( COLOR_BTNTEXT ) ); hbrush = _wpi_createsolidbrush( GetSysColor( COLOR_BTNFACE ) ); paintPalette( hwnd ); break; #ifndef __OS2_PM__ #ifdef __NT__ case WM_SYSCOLORCHANGE: case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: _wpi_deleteobject( hbrush ); hbrush = _wpi_createsolidbrush( GetSysColor( COLOR_BTNFACE ) ); SetBkColor( (HDC)mp1, GetSysColor( COLOR_BTNFACE ) ); SetTextColor( (HDC)mp1, GetSysColor( COLOR_BTNTEXT ) ); return( (WPI_MRESULT)hbrush ); #else case WM_CTLCOLOR: if( HIWORD( mp2 ) == CTLCOLOR_STATIC || HIWORD( mp2 ) == CTLCOLOR_BTN ) { SetBkColor( (HDC)LOWORD( mp1 ), LTGRAY ); SetTextColor( (HDC)LOWORD( mp1 ), BLACK ); return( (WPI_MRESULT)hbrush ); } break; #endif #endif case WM_MOVE: _wpi_getwindowrect( _wpi_getframe( hwnd ), &rcpal ); _wpi_getrectvalues( rcpal, &left, &top, &right, &bottom ); ImgedConfigInfo.pal_xpos = (short)left; ImgedConfigInfo.pal_ypos = (short)top; break; case WM_CLOSE: CheckPaletteItem( menu ); break; case WM_DESTROY: _wpi_deleteobject( hbrush ); break; default: return( DefWindowProc( hwnd, msg, mp1, mp2 ) ); } return( 0 ); } /* ColorPalWinProc */