/* ================ rvGEApp::HandleInitMenu Handles the initialization of the main menu ================ */ int rvGEApp::HandleInitMenu ( WPARAM wParam, LPARAM lParam ) { int cMenuItems = GetMenuItemCount((HMENU)wParam); int nPos; int id; UINT flags; rvGEWorkspace* workspace; HMENU hmenu; hmenu = (HMENU) wParam; workspace = GetActiveWorkspace ( ); // Run through all the menu items in the menu and see if any of them need // modification in any way for (nPos = 0; nPos < cMenuItems; nPos++) { id = GetMenuItemID(hmenu, nPos); flags = 0; // Handle popup menus too if ( id < 0 ) { HMENU sub = GetSubMenu ( hmenu, nPos ); if ( sub ) { HandleInitMenu ( (WPARAM) sub, 0 ); continue; } } // Menu items that are completely unrelated to the workspace switch ( id ) { case ID_GUIED_VIEW_STATUSBAR: flags = MF_BYCOMMAND | (mOptions.GetStatusBarVisible()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; case ID_GUIED_WINDOW_SHOWNAVIGATOR: flags = MF_BYCOMMAND | (mOptions.GetNavigatorVisible()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; case ID_GUIED_WINDOW_SHOWPROPERTIES: flags = MF_BYCOMMAND | (mOptions.GetPropertiesVisible()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; case ID_GUIED_WINDOW_SHOWTRANSFORMER: flags = MF_BYCOMMAND | (mOptions.GetTransformerVisible()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; } // Handle the basic case where an item is disabled because // there is no workspace available if ( !workspace ) { switch ( id ) { case ID_GUIED_EDIT_UNDO: case ID_GUIED_EDIT_REDO: case ID_GUIED_VIEW_SHOWGRID: case ID_GUIED_VIEW_SNAPTOGRID: case ID_GUIED_VIEW_HIDESELECTED: case ID_GUIED_VIEW_UNHIDESELECTED: case ID_GUIED_EDIT_DELETE: case ID_GUIED_WINDOW_TILE: case ID_GUIED_WINDOW_CASCADE: case ID_GUIED_ITEM_NEWWINDOWDEF: case ID_GUIED_ITEM_NEWEDITDEF: case ID_GUIED_ITEM_NEWHTMLDEF: case ID_GUIED_ITEM_ARRANGEBRINGTOFRONT: case ID_GUIED_ITEM_ARRANGEBRINGFORWARD: case ID_GUIED_ITEM_ARRANGESENDTOBACK: case ID_GUIED_ITEM_ARRANGESENDBACKWARD: case ID_GUIED_ITEM_PROPERTIES: case ID_GUIED_ITEM_SCRIPTS: case ID_GUIED_VIEW_ZOOMIN: case ID_GUIED_VIEW_ZOOMOUT: case ID_GUIED_ITEM_ALIGNLEFTS: case ID_GUIED_ITEM_ALIGNCENTERS: case ID_GUIED_ITEM_ALIGNRIGHTS: case ID_GUIED_ITEM_ALIGNBOTTOMS: case ID_GUIED_ITEM_ALIGNMIDDLES: case ID_GUIED_ITEM_ALIGNTOPS: case ID_GUIED_ITEM_MAKESAMESIZEHEIGHT: case ID_GUIED_ITEM_MAKESAMESIZEWIDTH: case ID_GUIED_ITEM_MAKESAMESIZEBOTH: case ID_GUIED_FILE_SAVE: case ID_GUIED_FILE_SAVEAS: case ID_GUIED_EDIT_COPY: case ID_GUIED_EDIT_PASTE: case ID_GUIED_ITEM_ARRANGEMAKECHILD: case ID_GUIED_SOURCECONTROL_GETLATESTVERSION: case ID_GUIED_SOURCECONTROL_CHECKIN: case ID_GUIED_SOURCECONTROL_CHECKOUT: case ID_GUIED_SOURCECONTROL_UNDOCHECKOUT: case ID_GUIED_FILE_CLOSE: EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION ); break; } continue; } switch (id) { // Undo is greyed out when there is noting to undo and the text is // modified to include the name of the modifier that will be undone case ID_GUIED_EDIT_UNDO: { MENUITEMINFO info; idStr undo; info.cbSize = sizeof(info); info.fMask = MIIM_STATE|MIIM_TYPE; info.fType = MFT_STRING; if ( !workspace->GetModifierStack().CanUndo ( ) ) { undo = "Undo\tCtrl+Z"; info.fState = MFS_GRAYED; } else { undo = "Undo "; undo.Append ( workspace->GetModifierStack().GetUndoModifier()->GetName ( ) ); undo.Append ( "\tCtrl+Z" ); info.fState = MFS_ENABLED; } info.dwTypeData = (LPSTR)undo.c_str(); info.cch = undo.Length ( ); SetMenuItemInfo ( hmenu, id, FALSE, &info ); break; } case ID_GUIED_EDIT_REDO: { MENUITEMINFO info; idStr undo; info.cbSize = sizeof(info); info.fMask = MIIM_STATE|MIIM_TYPE; info.fType = MFT_STRING; if ( !workspace || !workspace->GetModifierStack().CanRedo ( ) ) { undo = "Redo\tCtrl+Y"; info.fState = MFS_GRAYED; } else { undo = "Redo "; undo.Append ( workspace->GetModifierStack().GetRedoModifier()->GetName ( ) ); undo.Append ( "\tCtrl+Y" ); info.fState = MFS_ENABLED; } info.dwTypeData = (LPSTR)undo.c_str(); info.cch = undo.Length ( ); SetMenuItemInfo ( hmenu, id, FALSE, &info ); break; } case ID_GUIED_VIEW_SHOWGRID: flags = MF_BYCOMMAND | (mOptions.GetGridVisible()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; case ID_GUIED_VIEW_SNAPTOGRID: flags = MF_BYCOMMAND | (mOptions.GetGridSnap()?MF_CHECKED:MF_UNCHECKED); CheckMenuItem ( hmenu, id, flags ); break; // All menu items that are greyed out when there is no workspace case ID_GUIED_WINDOW_TILE: case ID_GUIED_WINDOW_CASCADE: case ID_GUIED_ITEM_NEWWINDOWDEF: case ID_GUIED_ITEM_NEWEDITDEF: case ID_GUIED_ITEM_NEWHTMLDEF: case ID_GUIED_VIEW_ZOOMIN: case ID_GUIED_VIEW_ZOOMOUT: case ID_GUIED_FILE_SAVE: case ID_GUIED_FILE_SAVEAS: case ID_GUIED_FILE_CLOSE: EnableMenuItem ( hmenu, nPos, MF_ENABLED|MF_BYPOSITION); break; // All menu items that are greyed out unless an item is selected case ID_GUIED_VIEW_HIDESELECTED: case ID_GUIED_VIEW_UNHIDESELECTED: case ID_GUIED_EDIT_DELETE: case ID_GUIED_EDIT_COPY: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()>0?MF_ENABLED:MF_GRAYED) ); break; // Enable paste if the clipboard has something in it case ID_GUIED_EDIT_PASTE: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetClipboard().Num()>0?MF_ENABLED:MF_GRAYED) ); break; // All menu items that are greyed out unless a single item is selected case ID_GUIED_ITEM_ARRANGEBRINGTOFRONT: case ID_GUIED_ITEM_ARRANGEBRINGFORWARD: case ID_GUIED_ITEM_ARRANGESENDTOBACK: case ID_GUIED_ITEM_ARRANGESENDBACKWARD: case ID_GUIED_ITEM_PROPERTIES: case ID_GUIED_ITEM_SCRIPTS: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()==1?MF_ENABLED:MF_GRAYED) ); break; // All menu items that are greyed out unless multiple itmes are selected case ID_GUIED_ITEM_ALIGNLEFTS: case ID_GUIED_ITEM_ALIGNCENTERS: case ID_GUIED_ITEM_ALIGNRIGHTS: case ID_GUIED_ITEM_ALIGNBOTTOMS: case ID_GUIED_ITEM_ALIGNMIDDLES: case ID_GUIED_ITEM_ALIGNTOPS: case ID_GUIED_ITEM_MAKESAMESIZEHEIGHT: case ID_GUIED_ITEM_MAKESAMESIZEBOTH: case ID_GUIED_ITEM_MAKESAMESIZEWIDTH: case ID_GUIED_ITEM_ARRANGEMAKECHILD: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|(workspace->GetSelectionMgr().Num()>1?MF_ENABLED:MF_GRAYED) ); break; case ID_GUIED_SOURCECONTROL_CHECKIN: case ID_GUIED_SOURCECONTROL_UNDOCHECKOUT: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|((workspace->GetSourceControlState()==rvGEWorkspace::SCS_CHECKEDOUT)?MF_ENABLED:MF_GRAYED) ); break; case ID_GUIED_SOURCECONTROL_CHECKOUT: EnableMenuItem ( hmenu, nPos, MF_BYPOSITION|((workspace->GetSourceControlState()==rvGEWorkspace::SCS_CHECKEDIN)?MF_ENABLED:MF_GRAYED) ); break; default: continue; } } return 0; }
/* * MainWindowProc - procedure for main (root) window */ WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { RECT rect; vi_rc rc; HANDLE hfileinfo; int cnt, i; char *buff; switch( msg ) { case WM_CREATE: Root = hwnd; GetClientRect( hwnd, &rect ); EditContainer = CreateContainerWindow( &rect ); InitWindows(); DragAcceptFiles( hwnd, TRUE ); timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL ); break; case WM_DROPFILES: hfileinfo = (HANDLE) wparam; cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 ); buff = alloca( FILENAME_MAX + 2 ); /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */ if( buff != NULL ) { buff[0] = '"'; /* one " at the beginning of the filename */ for( i = 0; i < cnt; i++ ) { if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) { break; } strcat( buff, "\"" ); rc = EditFile( buff, FALSE ); if( rc > ERR_NO_ERR ) { Error( GetErrorMsg( rc ) ); } } } DragFinish( hfileinfo ); break; case WM_TIMER: UpdateStatusWindow(); break; case WM_KEYDOWN: if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) { return( 0 ); } break; case WM_SIZE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); RootState = wparam; if( wparam != SIZE_MINIMIZED ) { ResizeRoot(); GetWindowRect( hwnd, &RootRect ); if( wparam != SIZE_MAXIMIZED ) { RootState = 0; } } return( 0 ); case WM_MOVE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); if( RootState != SIZE_MINIMIZED ) { GetWindowRect( hwnd, &RootRect ); } return( 0 ); case WM_ACTIVATEAPP: if( BAD_ID( CurrentWindow ) ) { break; } SetFocus( Root ); #if 0 if( !wparam ) { InactiveWindow( CurrentWindow ); } else { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); } #endif if( wparam ) { ResetEditWindowCursor( CurrentWindow ); } else { GoodbyeCursor( CurrentWindow ); } break; case WM_MOUSEACTIVATE: SetFocus( hwnd ); return( MA_ACTIVATE ); case WM_SETFOCUS: if( BAD_ID( CurrentWindow ) ) { break; } if( !IsIconic( CurrentWindow ) ) { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); DCUpdate(); SetWindowCursor(); SetWindowCursorForReal(); return( 0 ); } break; case WM_NCLBUTTONDBLCLK: break; case WM_COMMAND: if( LOWORD( wparam ) > 0xF000 ) { break; } else { rc = MenuCommand( LOWORD( wparam ) ); if( rc != MENU_COMMAND_NOT_HANDLED ) { DCUpdateAll(); if( rc > ERR_NO_ERR ) { char *msg; msg = GetErrorMsg( rc ); Error( msg ); } } SetWindowCursor(); } return( 0 ); case WM_INITMENU: if( (HMENU)wparam == GetMenu( hwnd ) ) { HandleInitMenu( (HMENU)wparam ); } else { ResetMenuBits(); } break; case WM_MENUSELECT: HandleMenuSelect( wparam, lparam ); break; case WM_ENDSESSION: if( wparam ) { ExitEditor( 0 ); // will not return } return( 0 ); case WM_QUERYENDSESSION: return( ExitWithPrompt( FALSE, TRUE ) ); case WM_CLOSE: ExitWithPrompt( TRUE, TRUE ); return( 0 ); #ifdef __NT__ case WM_MOUSEWHEEL: { int i, increment; ULONG linesPerNotch; HWND activeWnd; activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 ); SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 ); increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120; // see WM_MOUSEWHEEL-documentation for information about the "120" if( increment > 0 ) { for( i = 0; i < increment * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 ); } } else { for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 ); } } } return( 0 ); #endif case WM_DESTROY: DestroyToolBar(); DragAcceptFiles( hwnd, FALSE ); EditContainer = 0; if( timerID ) { KillTimer( hwnd, TIMER_ID ); } return( 0 ); } return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) ); } /* MainWindowProc */
static BOOL CALLBACK TPack_DlgProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { TPack_WindowData *pData = TPack_GetWindowData (hwnd); switch (msg) { case WM_INITDIALOG : return TPack_InitializeDialog (hwnd); case WM_DESTROY : TPack_ShutdownAll (hwnd, pData); PostQuitMessage (0); break; case WM_COMMAND : { WORD wNotifyCode = HIWORD (wParam); WORD wID = LOWORD (wParam); HWND hwndCtl = (HWND)lParam; return wm_Command (hwnd, pData, wNotifyCode, wID, hwndCtl); } case MSG_DELETE_BITMAP: { BitmapEntry * Entry; Entry = FindBitmap(pData, (const char *)lParam); assert(Entry); if (Entry->Name) { free(Entry->Name); Entry->Name = NULL; } if (Entry->Bitmap) geBitmap_Destroy(&Entry->Bitmap); if (Entry->WinBitmap) DeleteObject(Entry->WinBitmap); Entry->Flags |= ENTRY_DELETED; pData->Dirty = TRUE; return 0; } case MSG_SELECT_BITMAP: { char Buff[128]; int Index; char TextureName[MAX_TEXTURE_NAME_LENGTH]; BitmapEntry * Entry; Index = SendDlgItemMessage(pData->hwnd, IDC_TEXTURELIST, LB_GETCURSEL, (WPARAM)0, (LPARAM)0); if (Index == LB_ERR) { Entry = NULL; } else { SendDlgItemMessage(pData->hwnd, IDC_TEXTURELIST, LB_GETTEXT, (WPARAM)Index, (LPARAM)&TextureName[0]); Entry = FindBitmap(pData, TextureName); assert(Entry); if (!Entry->WinBitmap) { HWND PreviewWnd; HBITMAP hbm; HDC hDC; PreviewWnd = GetDlgItem(pData->hwnd, IDC_PREVIEW); hDC = GetDC(PreviewWnd); hbm = CreateHBitmapFromgeBitmap(Entry->Bitmap, hDC); Entry->WinBitmap = hbm; ReleaseDC(PreviewWnd, hDC); } if (!Entry->WinBitmap) { NonFatalError("Memory allocation error creating bitmap"); return 0; } } InvalidateRect(GetDlgItem(hwnd, IDC_PREVIEW), NULL, TRUE); pData->SelectedEntry = Entry; if (Entry) sprintf(Buff, "%dx%d", geBitmap_Width(Entry->Bitmap), geBitmap_Height(Entry->Bitmap)); else Buff[0] = '\0'; SetWindowText(GetDlgItem(hwnd, IDC_TEXTURESIZE), Buff); return 0; } case WM_DROPFILES : { // Files dropped. HDROP hDrop; UINT FileCount; char Buff[MAX_PATH]; hDrop = (HDROP)wParam; FileCount = DragQueryFile (hDrop, 0xffffffff, Buff, sizeof (Buff)); while (FileCount--) { DragQueryFile (hDrop, FileCount, Buff, sizeof (Buff)); AddTexture(pData, NULL, Buff); } pData->Dirty = TRUE; DragFinish (hDrop); return 0; } // Initialize the pulldown // Added DJT (see revision note - 4/18/99) case WM_INITMENU: if (GetMenu(hwnd) == (HMENU)wParam) HandleInitMenu(pData, (HMENU)wParam); break; default : break; } return FALSE; }