From bcd5a37605327456208dd2015943d5460b46a99f Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 27 Feb 2006 15:01:54 +0000 Subject: [PATCH] Dynamic menus in Python: * hardcode standard main menu IDs --- src/LightApp/LightApp_Application.cxx | 2 +- src/LightApp/LightApp_Application.h | 1 + src/STD/STD_Application.cxx | 36 +++++++++++++-------------- src/STD/STD_Application.h | 16 +++++++++--- src/STD/STD_MDIDesktop.cxx | 2 +- src/STD/STD_MDIDesktop.h | 1 + src/STD/STD_TabDesktop.cxx | 2 +- src/STD/STD_TabDesktop.h | 1 + 8 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index c63f918bc..8e2614edb 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -451,7 +451,7 @@ void LightApp_Application::createActions() SUIT_Tools::simplifySeparators( modTBar ); // New window - int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 ); int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 ); createMenu( separator(), windowMenu, -1, 1 ); diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 6af7ef767..35d9f070c 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -44,6 +44,7 @@ class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application public: typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; + enum { MenuWindowId = 6 }; enum { NewGLViewId = CAM_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId, PreferencesId, MRUId, RenameId, UserID }; public: diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index a3ab1739e..68b7b1a06 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -199,32 +199,32 @@ void STD_Application::createActions() // Create menus - int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 ); - int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 ); - int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1, 10 ); - int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); + int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 ); + int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 10 ); + int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, MenuViewId, 10 ); + int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, MenuHelpId, 1000 ); // Create menu items - createMenu( FileNewId, fileMenu, 0 ); - createMenu( FileOpenId, fileMenu, 0 ); - createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" - createMenu( FileCloseId, fileMenu, 0 ); - createMenu( separator(), fileMenu, -1, 0 ); - createMenu( FileSaveId, fileMenu, 0 ); + createMenu( FileNewId, fileMenu, 0 ); + createMenu( FileOpenId, fileMenu, 0 ); + createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" + createMenu( FileCloseId, fileMenu, 0 ); + createMenu( separator(), fileMenu, -1, 0 ); + createMenu( FileSaveId, fileMenu, 0 ); createMenu( FileSaveAsId, fileMenu, 0 ); - createMenu( separator(), fileMenu, -1, 0 ); + createMenu( separator(), fileMenu, -1, 0 ); - createMenu( separator(), fileMenu ); - createMenu( FileExitId, fileMenu ); + createMenu( separator(), fileMenu ); + createMenu( FileExitId, fileMenu ); - createMenu( EditCopyId, editMenu ); + createMenu( EditCopyId, editMenu ); createMenu( EditPasteId, editMenu ); createMenu( separator(), editMenu ); - createMenu( ViewWindowsId, viewMenu ); + createMenu( ViewWindowsId, viewMenu ); createMenu( ViewStatusBarId, viewMenu ); - createMenu( separator(), viewMenu ); + createMenu( separator(), viewMenu ); createMenu( HelpAboutId, helpMenu ); createMenu( separator(), helpMenu ); @@ -547,8 +547,8 @@ void STD_Application::setEditEnabled( bool theEnable ) for ( int i = EditCopyId; i <= EditPasteId; i++ ) { - mMgr->setShown( i, myEditEnabled ); - tMgr->setShown( i, myEditEnabled ); + mMgr->setShown( mMgr->actionId(action(i)), myEditEnabled ); + tMgr->setShown( tMgr->actionId(action(i)), myEditEnabled ); } } diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index c8e3b4ad5..cd63268bd 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -120,9 +120,19 @@ private slots: virtual void onViewManagerActivated( SUIT_ViewManager* ); protected: - enum { FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, - FileExitId, EditCutId, EditCopyId, EditPasteId, ViewStatusBarId, - NewWindowId, HelpAboutId, ViewWindowsId, FileLoadId, UserID }; + enum { MenuFileId = 1, + MenuViewId = 2, + MenuEditId = 3, + MenuHelpId = 7 + }; + + enum { FileNewId, FileOpenId, FileLoadId, FileCloseId, + FileSaveId, FileSaveAsId, FileExitId, + ViewStatusBarId, ViewWindowsId, NewWindowId, + EditCutId, EditCopyId, EditPasteId, + HelpAboutId, + UserID + }; protected: virtual void createActions(); diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index aec25bb59..214e8a767 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -183,7 +183,7 @@ void STD_MDIDesktop::createActions() if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkspaceAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); } diff --git a/src/STD/STD_MDIDesktop.h b/src/STD/STD_MDIDesktop.h index 25ec9cb08..e61f5c3d5 100755 --- a/src/STD/STD_MDIDesktop.h +++ b/src/STD/STD_MDIDesktop.h @@ -37,6 +37,7 @@ class STD_EXPORT STD_MDIDesktop: public SUIT_Desktop Q_OBJECT public: + enum { MenuWindowId = 6 }; enum { Cascade, Tile, HTile, VTile }; public: diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 24dfd5ccf..5fdfce584 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -177,7 +177,7 @@ void STD_TabDesktop::createActions() if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkstackAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); } diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index f3b1d1282..c91b6e08e 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -38,6 +38,7 @@ class STD_EXPORT STD_TabDesktop: public SUIT_Desktop Q_OBJECT public: + enum { MenuWindowId = 6 }; enum { VSplit, HSplit }; public: -- 2.39.2