imenuman.h

Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------------
00002 // -----------------------------------------------------------------------------
00003 
00004    FILE: iMenuMan.h
00005 
00006      DESCRIPTION: abstract classes for the menu manager
00007 
00008      CREATED BY: Scott Morrison
00009 
00010      HISTORY: created March 21, 2000
00011 
00012      Copyright (c) 2000, All Rights Reserved
00013 
00014 // -----------------------------------------------------------------------------
00015 // -------------------------------------------------------------------------- */
00016 #pragma once
00017 
00018 #include "iMenus.h"
00019 
00020 typedef int MenuContextId;
00021 
00022 // Define some menu contexts used by the code of MAX
00023 
00024 const MenuContextId kMainMenuBar            = 1;
00025 const MenuContextId kViewportQuad           = 2;
00026 const MenuContextId kSchematicViewQuad      = 3;
00027 const MenuContextId kIReshadeQuad           = 4;
00028 const MenuContextId kIUVWUnwrapQuad         = 5;
00029 const MenuContextId kTrackViewQuad          = 6;
00030 const MenuContextId kTrackViewMenuBar       = 7;
00031 const MenuContextId kSchematicViewMenuBar   = 8;
00032 const MenuContextId kMaterialEditorMenuBar  = 9;
00033 
00034 
00035 enum MenuContextType {
00036     kMenuContextMenuBar = 0,
00037     kMenuContextQuadMenu,
00038     kMenuContextPopupMenu,
00039 };
00040     
00041 
00049 class IMenuContext : public InterfaceServer {
00050 
00051 public:
00053     virtual MenuContextId GetId() = 0;
00062     virtual MenuContextType GetType() = 0;
00064     virtual MSTR& GetName() = 0;
00065 };
00066 
00075 class IMenuBarContext: public IMenuContext {
00076 
00077 public:
00078 
00084     virtual void SetMenu(IMenu* pMenu) = 0;
00085 
00088     virtual IMenu* GetMenu() = 0;
00091     virtual HMENU CreateWindowsMenu() = 0;
00094     virtual void UpdateWindowsMenu() = 0;
00095 
00098     virtual HMENU GetCurWindowsMenu() = 0;
00099 
00105     virtual void ExecuteAction(int cmdId) = 0;
00110     virtual bool CommandIDInRange(int cmdId) = 0;
00111 };
00112 
00121 class IQuadMenuContext: public IMenuContext {
00122 
00123 public:
00124 
00125     // Add a new quad menu to the context.
00133     virtual bool AddQuadMenu(IQuadMenu* pMenu, const MCHAR* pName) = 0;
00134     // Set the quad menu for a slot in the context.
00144     virtual void SetMenu(int index, IQuadMenu* pMenu, const MCHAR* pName) = 0;
00145     // Remove a Quad menu from the context.
00151     virtual void RemoveMenu(int index) = 0; 
00152 
00153     // Accessors for all the Quad menus in the context
00156     virtual int MenuCount() = 0;
00162     virtual IQuadMenu* GetMenu(int index) = 0;
00163 
00164     // Get/Set the index of the current default right-click menu
00167     virtual int GetCurrentMenuIndex() = 0;
00173     virtual void SetCurrentMenuIndex(int index) = 0;
00174 
00175     // Get set the falg that indicates we should display all quads in the menu
00182     virtual bool GetShowAllQuads(int index) = 0;
00191     virtual void SetShowAllQuads(int index, bool showAll) = 0;
00192 
00196     enum RightClickContext {
00197         kNonePressed,                   
00198         kShiftPressed,                  
00199         kAltPressed,                    
00200         kControlPressed,                
00201         kShiftAndAltPressed,            
00202         kShiftAndControlPressed,        
00203         kControlAndAltPressed,          
00204         kShiftAndAltAndControlPressed,  
00205     };
00207 
00208     // This method queries the state of the modifier keys and returns the
00209     // appropriate context.
00213     virtual RightClickContext GetRightClickContext() = 0;
00214 
00215     // Get/Set the right-click menu associated with a context
00222     virtual IQuadMenu* GetRightClickMenu(RightClickContext context) = 0;
00230     virtual void SetRightClickMenu(RightClickContext context, IQuadMenu *pMenu) = 0;
00231 
00232     // return the index for the given quad menu.  Return -1 if the menu is not in the context.
00238     virtual int FindMenu(IQuadMenu* pMenu) = 0;
00239     // Find a Quad menu based on its name
00246     virtual IQuadMenu* FindMenuByTitle(const MCHAR* pTitle) = 0;
00247 
00248 };
00249 
00250 const DWORD kMenuMenuBar  = (1 << 0);
00251 const DWORD kMenuQuadMenu = (1 << 1);
00252 
00253 #define MENU_MGR_INTERFACE  Interface_ID(0xadc20bd, 0x7491741d)
00254 
00259 class IMenuManager : public FPStaticInterface {
00260 
00261 public:
00262     // Add a menu to the manager return false of menu already is registered.
00270     virtual bool RegisterMenu(IMenu* pMenu, DWORD flags = 0) = 0;
00271     // Remove a menu form the mananger.  return false of the menu is not registered
00278     virtual bool UnRegisterMenu(IMenu* pMenu) = 0;
00279 
00280     // Find a menu based on its name
00287     virtual IMenu* FindMenu(const MCHAR* pTitle) = 0;
00288 
00289     // Find a Quad menu based on its name
00296     virtual IQuadMenu* FindQuadMenu(const MCHAR* pTitle) = 0;
00297 
00298     // Register a new 
00299     // Register a new context
00308     virtual bool RegisterMenuBarContext(MenuContextId contextId, const MCHAR* pName) = 0;
00317     virtual bool RegisterQuadMenuContext(MenuContextId contextId, const MCHAR* pName) = 0;
00318 
00320     virtual int NumContexts() = 0;
00326     virtual IMenuContext* GetContextByIndex(int index) = 0;
00333     virtual IMenuContext* GetContext(MenuContextId contextId) = 0;
00334 
00335     // Update MAX's main menu bar after adding sub-menus or menu items
00338     virtual void UpdateMenuBar() = 0;
00339 
00340     // Load a menu file and update everything.  
00347     virtual BOOL LoadMenuFile(const MCHAR* pMenuFile) = 0;
00348 
00349     // Save a menu file.
00355     virtual BOOL SaveMenuFile(const MCHAR* pMenuFile) = 0;
00356 
00357     // Get the name of the current menu file.
00360     virtual const MCHAR* GetMenuFile() = 0;
00361 
00362      // Set the given menu to be used as the main menu bar
00368     virtual BOOL SetMainMenuBar(IMenu* pMenu) = 0;
00369 
00370     // Set the the viewport right-click menu to be the given quad menu
00379     virtual BOOL SetViewportRightClickMenu(IQuadMenuContext::RightClickContext context,
00380                                            IQuadMenu* pQuadMenu) = 0;
00381 
00382     // Get the the current viewport right-click menu 
00388     virtual IQuadMenu* GetViewportRightClickMenu(IQuadMenuContext::RightClickContext context) = 0;
00389 
00390     // Set the the given viewport right-click menu to be the named quad menu
00392     virtual IMenu* GetMainMenuBar() = 0;
00393 
00394     // Get/Set the show all wuad flags on a quad menu
00401     virtual bool GetShowAllQuads(IQuadMenu* pQuadMenu) = 0;
00408     virtual void SetShowAllQuads(IQuadMenu* pQuadMenu, bool showAll) = 0;
00409 
00410     // Get/Set the name of a quad menu
00415     virtual const MCHAR* GetQuadMenuName(IQuadMenu* pQuadMenu) = 0;
00422     virtual void SetQuadMenuName(IQuadMenu* pQuadMenu, const MCHAR* pName) = 0;
00423 
00424     // Function Publishing IDs
00425     enum { 
00426 #ifndef NO_CUI  // russom - 02/12/02
00427            loadMenuFile,
00428            saveMenuFile,
00429            getMenuFile,
00430 #endif // NO_CUI
00431            unRegisterMenu,
00432            unRegisterQuadMenu,
00433            registerMenuContext,
00434            findMenu,
00435            findQuadMenu,
00436            updateMenuBar,
00437            createQuadMenu,
00438            createMenu,
00439            createSubMenuItem,
00440            createSeparatorItem,
00441            createActionItem,
00442            setViewportRightClickMenu,
00443            getViewportRightClickMenu,
00444            getMainMenuBar,
00445            setMainMenuBar,
00446            getShowAllQuads,
00447            setShowAllQuads,
00448            numMenus,
00449            getMenu,
00450            numQuadMenus,
00451            getQuadMenu,
00452            getQuadMenuName,
00453            setQuadMenuName,
00454            createMenuItemFromAction,
00455     };
00456 
00457     // enumeration IDs
00458     enum { rightClickContext, };
00459 };
00460