oilmenus.cpp File Reference

(r1785/r1667)

#include "camtypes.h"
#include "oilmenus.h"
#include "menupref.h"
#include "contmenu.h"
#include "menuops.h"
#include "plugmngr.h"
#include "camframe.h"
#include "camelot.h"

Go to the source code of this file.

Defines

#define new   CAM_DEBUG_NEW

Functions

 DECLARE_SOURCE ("$Revision: 1667 $")
MenuItem * SetupDefaultMenu ()
 Creates the default mainframe menu for an MDI type interface.
MenuItem * SetupSharedMenu ()
 Creates a MDI type shared menu.
wxCamMenuBar * ConvertToWinMenu (MenuItem *GroupSubMenu)
 Converts from a platform-independent menu system into a Windows specific one.
wxMenu * CreatePopup (MenuItem *pCamSubMenu)
 Converts from a platform-independent menu into a Windows specific one.
BOOL DestroyCamMenu (MenuItem *CamMenu)
 Destroys all dynamic objects in the menu system, freeing up memory.
BOOL DestroyWinSubMenu (wxMenu *WinSubMenu)
 Destroys all dynamic objects in the menu system, freeing up memory.
BOOL DestroyWinMenu (wxMenu *WinMenu)
 Destroys all dynamic objects in the menu system, freeing up memory.
BOOL DestroyWinSubMenuMFC (wxMenu *pWinSubMenu)
 Destroys all dynamic objects in the menu system, freeing up memory.
BOOL DestroyWinMenuMFC (wxMenu *pWinMenu)
 Destroys all dynamic objects in the menu system, freeing up memory.
BOOL InitMenuSystem ()
 Creates both the platform-independent and windows specific menu systems.
void DeinitMenuSystem ()
 Destroys both the platform-independent and windows specific menu systems.
BOOL IsMenuCommand (wxCommandEvent &event)
 To identify menu item commands.
MenuItem * FindMenuItem (UINT32 menuId, MenuItem *GroupSubMenu)
 To find a menu item in the platform independent menu system. Scope: Private To OilMenus.
MenuItem * GetMenuItem (UINT32 menuId, BOOL *pShowHotKeysFlag)
 To find a menu item in one of the platform independent menu systems.
BOOL PerformMenuCommand (wxCommandEvent &event)
 To perform menu item command.
BOOL FindMenu (MenuItem **TargetMenu, wxMenu *pMenu, BOOL *pShowHotKeysFlag)
 To find kernel menu equivalent to Windows menu that is passed in. Scope: Private to be called by UpdateMenu() only!
BOOL UpdateMenu (wxMenu *pMenu)
 To update menu.
void UpdateWinMenu (wxMenu *pMenu, MenuItem *kernelMenu)
 To update windows menu system. It is also a Friend of the MenuItem Class.
BOOL CreateContextMenu (MenuItem *pContextMenu)
 To put a popup menu on screen.
BOOL DestroyContextMenu ()
 To remove a popup menu from the screen.
MenuItem * GetCurrentContextMenu ()
 Find out whether the popup menu is open or not and what it is...
MenuItem * GetMainMDIMenu ()
 To find the menu item associated with the main kernelly MDI menu.
BOOL UpdatePlugInsWinMenu (MenuItem *pPlugInsMenu)
 This searches for the equivalent Win menu in the main MDI menu structure, destroys anything that is there already and then puts in the new structure.

Variables

MenuItem * CamelotDefMenu
MenuItem * CamelotMDIMenu
MenuItem * CamelotContextMenu
wxCamMenuBar * WinDefMenu
wxCamMenuBar * WinMDIMenu
wxMenu * WinContextMenu


Define Documentation

#define new   CAM_DEBUG_NEW
 

Definition at line 128 of file oilmenus.cpp.


Function Documentation

wxCamMenuBar* ConvertToWinMenu (  MenuItem *  GroupSubMenu  ) 
 

Converts from a platform-independent menu system into a Windows specific one.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
MenuItem - A platform-independent menu. [INPUTS]
None. [OUTPUTS]
Returns:
wxMenu - Windows MFC-type menu object.

Errors: None

See also:
OilMenus

MenuItem

CreatePopup()

Definition at line 212 of file oilmenus.cpp.

00213 {                  
00214     wxCamMenuBar*   WinMenu = new wxCamMenuBar;         // Top Level Menu - Menu Bar
00215     MenuItem*       SubMenu;                            // Sub Menu Iterator
00216                                 
00217     SubMenu = GroupSubMenu->GetFirstMenuItem();                           
00218     
00219     while (SubMenu != NULL)                         // Assumes that all MenuItems on the 
00220     {                                               // MenuBar are Group MenuItems
00221         wxMenu*     pSubMenu = CreatePopup( SubMenu );
00222         if (pSubMenu)
00223         {
00224             wxString sName((TCHAR*)SubMenu->GetMenuText());
00225             if (!WinMenu->Append( pSubMenu, sName ))
00226             {
00227                 TRACEUSER("luke", _T("Append failed\n"));
00228             }
00229         }
00230         SubMenu = GroupSubMenu->GetNextMenuItem(SubMenu);
00231     } 
00232 
00233     return WinMenu;
00234 }

BOOL CreateContextMenu (  MenuItem *  pContextMenu  ) 
 

To put a popup menu on screen.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Parameters:
pContextMenu Pointer to a context-sensitive menu [INPUTS]
- [OUTPUTS]
Returns:
TRUE if menu was created and opened on screen succesfully. FALSE otherwise

Errors: None.

Definition at line 1181 of file oilmenus.cpp.

01182 {
01183     BOOL worked = FALSE;
01184 
01185     // If the previous context menu is hanging around for some reason
01186     // get rid of it.
01187     DestroyContextMenu();
01188 
01189     // Now setup the new context menu
01190     CamelotContextMenu = pContextMenu;
01191     WinContextMenu = CreatePopup(CamelotContextMenu);
01192 
01193     if (WinContextMenu==NULL)
01194         worked = FALSE;
01195     else
01196     {
01197         // Set the menu states correctly
01198 //      CamelotContextMenu->UpdateMenuState(FALSE);
01199 //      UpdateWinMenu(WinContextMenu, CamelotContextMenu);
01200 
01201         if( CCamFrame::GetMainFrame()->PopupMenu( WinContextMenu ) )
01202             worked = TRUE;
01203         else
01204         {
01205             DestroyCamMenu(CamelotContextMenu);
01206             delete CamelotContextMenu; 
01207             CamelotContextMenu = NULL;
01208         }
01209     }
01210 
01211     return worked;
01212 }

wxMenu* CreatePopup (  MenuItem *  pCamSubMenu  ) 
 

Converts from a platform-independent menu into a Windows specific one.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
MenuItem - A platform-independent menu (popup). [INPUTS]
None. [OUTPUTS]
Returns:
wxMenu - Windows MFC-type menu object.

Errors: None Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

Definition at line 259 of file oilmenus.cpp.

00260 {                  
00261     ERROR2IF(pCamSubMenu == 0, 0, "CreatePopup: null pCamSubMenu supplied");
00262 
00263     wxMenu*         pPopupMenu = new wxMenu( /*wxString( pCamSubMenu->GetMenuText() )*/ );  // Popup Menus in Windows
00264 
00265     ERROR2IF(pPopupMenu == 0, 0, "CreatePopup failed to allocate new menu");
00266     
00267     MenuItem* pSubMenu = pCamSubMenu->GetFirstMenuItem();                      
00268 
00269     // if menu popup hasn't got any sub menu items then setup a dummy menuitem to allow 
00270     // the OnMenuPopupInit() function to work when menu is selected!
00271     
00272     if (pSubMenu == 0)
00273     {
00274         if (!pPopupMenu->Append( pCamSubMenu->GetMenuId(),      // Use the Group Menu Id
00275                                TEXT("")))                   // Give it an empty string
00276         {
00277             TRACEUSER("luke", _T("Append failed\n"));
00278         }
00279     }
00280     
00281     while (pSubMenu != 0)
00282     {
00283         bool    fIsUnimpl = *pSubMenu->GetOpToken() == OPTOKEN_DO_NOTHING;
00284         bool    fNeedSep  = pSubMenu->IsFollowedBySeparator() && 
00285                             ( 0 != pCamSubMenu->GetNextMenuItem( pSubMenu ) );
00286 
00287         if (pSubMenu->IsMenuItemGroup())                    // Distinguish between group &
00288         {                                                   // single MenuItems
00289             wxMenu* pNewMenu = CreatePopup( pSubMenu );
00290             if (pNewMenu)
00291             {
00292 #if !defined(_DEBUG)
00293                 if( !fIsUnimpl )
00294                 {
00295 #endif
00296                     wxString sName((TCHAR *)pSubMenu->GetMenuText());
00297                     if (!pPopupMenu->Append( pSubMenu->GetMenuId(), sName, pNewMenu ))
00298                     {
00299                         TRACEUSER("luke", _T("Append failed\n"));
00300                     }
00301                 }
00302 #if !defined(_DEBUG)
00303             }
00304 #endif
00305         }
00306         else
00307         {
00308             wxItemKind  ItemKind = wxITEM_NORMAL;
00309             if( pSubMenu->IsCheckable() )
00310                 ItemKind = wxITEM_CHECK;
00311 
00312 #if !defined(_DEBUG)
00313             if( !fIsUnimpl )
00314             {
00315 #endif
00316                 // Set the leaf's label ... 
00317                 if (!pPopupMenu->Append( pSubMenu->GetMenuId(), 
00318                     wxString( (TCHAR*)pSubMenu->GetMenuText() ), wxEmptyString, ItemKind ))
00319                 {
00320                     TRACEUSER("luke", _T("Append failed\n"));
00321                 }
00322 #if !defined(_DEBUG)
00323             }
00324             else
00325                 fNeedSep = false;
00326 #else
00327             if( fIsUnimpl )
00328                 pPopupMenu->Enable( pSubMenu->GetMenuId(), false );
00329 #endif
00330             
00331 /*
00332             // ... and glyph, if any.
00333             UINT32 nSelBmpID = pSubMenu->GetMenuSelectedBitmapID();
00334             UINT32 nUnselBmpID = pSubMenu->GetMenuUnselectedBitmapID();
00335             if (nSelBmpID != 0 && nUnselBmpID != 0)
00336                 pPopupMenu->SetMenuItemBitmaps(pSubMenu->GetMenuId(), 0,
00337                                                &CBitmap(nSelBmpID),
00338                                                &CBitmap(nUnselBmpID));
00339 */      }
00340 
00341         // Add a separating line if required, BUT...
00342         // Don't allow a separator to be added if this is the last item in the menu...
00343         if( fNeedSep )
00344         {
00345             if (!pPopupMenu->AppendSeparator())
00346             {
00347                 TRACEUSER("luke", _T("AppendSeparator failed\n"));
00348             }
00349         }
00350         
00351         pSubMenu = pCamSubMenu->GetNextMenuItem(pSubMenu);
00352     }
00353     
00354     return pPopupMenu;
00355 }

DECLARE_SOURCE (  "$Revision: 1667 $"   ) 
 

oilmenus.cpp - Responsibilities include menu initialisation and deinitialisation as well as updating menu states and performing menu commands.

void DeinitMenuSystem (   ) 
 

Destroys both the platform-independent and windows specific menu systems.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
None. [INPUTS]
None. [OUTPUTS]
Returns:
Nothing.

Errors: None.

See also:
OilMenus

MenuItem

DestroyCamMenu()

DestroyWinMenu()

InitMenuSystem()

Definition at line 687 of file oilmenus.cpp.

00688 {
00689     if (CamelotDefMenu)
00690     {
00691         DestroyCamMenu(CamelotDefMenu);     //Destroy Platform-Independent
00692         delete CamelotDefMenu;
00693         CamelotDefMenu = NULL;
00694     }
00695 
00696     if (CamelotMDIMenu)
00697     {
00698         DestroyCamMenu(CamelotMDIMenu);     //Menu System
00699         delete CamelotMDIMenu; 
00700         CamelotMDIMenu = NULL;
00701     }
00702 
00703 PORTNOTE("other","Removed menu destruction - temporary!")
00704 #if 0
00705     if (WinMDIMenu)
00706     {
00707         DestroyWinMenu(WinMDIMenu);         //Destroy The MDI Frame Menu
00708 
00709         WinMDIMenu->Detach();
00710         delete WinMDIMenu;
00711         WinMDIMenu = NULL;
00712     }
00713 #endif
00714     //----------------------------------------------------------
00715     // If the context-sensitive menu is left around delete it...
00716 /*  if (CamelotContextMenu)
00717     {
00718         DestroyCamMenu(CamelotContextMenu);     //Menu System
00719         delete CamelotContextMenu; 
00720         CamelotContextMenu = NULL;
00721     }
00722 
00723 
00724     if (WinContextMenu)
00725     {
00726         DestroyWinMenu(WinContextMenu);         //Destroy The MDI Frame Menu
00727 //      WinContextMenu->Detach();
00728         WinContextMenu->DestroyMenu();          // DestroyMenu releases Windows resources and calls Detach
00729         delete WinContextMenu;
00730         WinContextMenu = NULL;
00731     }
00732 */
00733     ContextMenu::HideCurrent();
00734 
00735 }

BOOL DestroyCamMenu (  MenuItem *  CamMenu  ) 
 

Destroys all dynamic objects in the menu system, freeing up memory.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
MenuItem - A platform-independent menu. [INPUTS]
None. [OUTPUTS]
Returns:
True - If all objects in menu system were destroyed successfully

Errors: None Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

DestroyWinMenu()

DeInitMenuSystem()

Definition at line 382 of file oilmenus.cpp.

00383 {               
00384     MenuItem *subMenu;
00385     MenuItem *tempMenu;
00386     
00387     subMenu = CamMenu->GetFirstMenuItem();
00388 
00389     while (subMenu != NULL)
00390     {
00391         // if MenuItem is a group then delete all MenuItems within it
00392         if (subMenu->IsMenuItemGroup())
00393             DestroyCamMenu(subMenu);
00394                            
00395         // Get Next MenuItem before the current is deleted                   
00396         tempMenu = CamMenu->GetNextMenuItem(subMenu);
00397  
00398         // Object pointed to by subMenu is deleted and memory is freed.
00399         delete CamMenu->RemoveMenuItem(subMenu);
00400         
00401         // Submenu now points to next item
00402         subMenu = tempMenu;
00403     }
00404     return TRUE;
00405 }

BOOL DestroyContextMenu (   ) 
 

To remove a popup menu from the screen.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if menu was destroyed succesfully. FALSE otherwise

Errors: None.

Definition at line 1232 of file oilmenus.cpp.

01233 {
01234     // If the previous context menu is hanging around for some reason
01235     // get rid of it.
01236     if (WinContextMenu)
01237     {
01238         DestroyWinMenu(WinContextMenu);
01239 //      WinContextMenu->Detach();
01240 //      WinContextMenu->Destroy();      // DestroyMenu releases Windows resources and calls Detach
01241         delete WinContextMenu;
01242         WinContextMenu = NULL;
01243     }
01244 
01245     if (CamelotContextMenu)
01246     {
01247         DestroyCamMenu(CamelotContextMenu);
01248         delete CamelotContextMenu; 
01249         CamelotContextMenu = NULL;
01250     }
01251 
01252     return TRUE;
01253 }

BOOL DestroyWinMenu (  wxMenu *  WinMenu  ) 
 

Destroys all dynamic objects in the menu system, freeing up memory.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
wxMenu - Windows menu object. [INPUTS]
None. [OUTPUTS]
Returns:
True - If all objects in menu system were destroyed successfully

Errors: Does not work with nested, hierarchical menus yet! Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

DestroyCamMenu()

DeInitMenuSystem()

Definition at line 436 of file oilmenus.cpp.

00437 {               
00438 PORTNOTE("other","Removed menu destruction - temporary!")
00439 #if 0
00440     wxMenu  *subMenu;
00441     INT32       position = 0;
00442     INT32       noItems = WinMenu->GetMenuItemCount();  
00443     
00444     while ((noItems > 0)  && (position < noItems))  
00445     {                                               
00446         subMenu = WinMenu->GetSubMenu(position);    
00447         if (subMenu != NULL)                        
00448         {
00449             DestroyWinSubMenu(subMenu);
00450             subMenu->Detach();
00451             delete subMenu;
00452         }
00453         position++;
00454     }
00455 #endif
00456     return TRUE;
00457 }

BOOL DestroyWinMenuMFC (  wxMenu *  pWinMenu  ) 
 

Destroys all dynamic objects in the menu system, freeing up memory.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/3/97
Parameters:
wxMenu - Windows menu object. [INPUTS]
None. [OUTPUTS]
Returns:
True - If all objects in menu system were destroyed successfully

Errors: Does not work with nested, hierarchical menus yet! Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

DestroyCamMenu()

DeInitMenuSystem()

Definition at line 540 of file oilmenus.cpp.

00541 {               
00542 PORTNOTE("other","Removed menu destruction - temporary!")
00543 #if 0
00544     ERROR2IF(pWinMenu == NULL, FALSE,"DestroyWinMenuMFC bad pWinMenu supplied");
00545     wxMenu  *pSubMenu = NULL;
00546     INT32       noItems = pWinMenu->GetMenuItemCount();  
00547     
00548     // Walk backwards through the list removing items from the end, otherwise
00549     // we would need to recalculate the position after each menu deletion as the
00550     // position will have changed.
00551     BOOL ok = TRUE;
00552     INT32   position = noItems - 1;
00553     while (position >= 0)
00554     {                                               
00555         pSubMenu = pWinMenu->GetSubMenu(position);    
00556         if (pSubMenu != NULL)                        
00557             ok = DestroyWinSubMenuMFC(pSubMenu);
00558         // now delete the menu item
00559         ok = pWinMenu->DeleteMenu( position, MF_BYPOSITION );
00560         if (pSubMenu != NULL)                        
00561         {
00562             pSubMenu->Detach();
00563             delete pSubMenu;
00564         }
00565 
00566         position--;
00567     }
00568 #endif
00569     return TRUE;
00570 }

BOOL DestroyWinSubMenu (  wxMenu *  WinSubMenu  ) 
 

Destroys all dynamic objects in the menu system, freeing up memory.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
wxMenu - Windows menu object. [INPUTS]
None. [OUTPUTS]
Returns:
True - If all objects in menu system were destroyed successfully

Errors: None! Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

DestroyWinMenu()

DeInitMenuSystem()

Definition at line 483 of file oilmenus.cpp.

00484 {               
00485 PORTNOTE("other","Removed menu destruction - temporary!")
00486 #if 0
00487     wxMenu  *subMenu;
00488     UINT32  subMenuId;
00489     INT32       position = 0;
00490     INT32       noItems = WinSubMenu->GetMenuItemCount();  
00491     
00492     while ((noItems > 0)  && (position < noItems))  
00493     {                                               
00494         subMenuId = WinSubMenu->GetMenuItemID(position); 
00495         if (subMenuId == (UINT32)-1)
00496         {
00497             subMenu = WinSubMenu->GetSubMenu(position);    
00498             if (subMenu != NULL)                        
00499             {
00500                 DestroyWinSubMenu(subMenu);
00501                 subMenu->Detach();
00502                 delete subMenu;
00503             }
00504         }
00505         position++;
00506     }
00507 #endif
00508     return TRUE;
00509 }

BOOL DestroyWinSubMenuMFC (  wxMenu *  pWinSubMenu  ) 
 

Destroys all dynamic objects in the menu system, freeing up memory.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/3/97
Parameters:
wxMenu - Windows menu object. [INPUTS]
None. [OUTPUTS]
Returns:
True - If all objects in menu system were destroyed successfully

Errors: None! Scope: Private - can only be called from within the OilMenus module

See also:
OilMenus

MenuItem

DestroyWinMenu()

DeInitMenuSystem()

Definition at line 596 of file oilmenus.cpp.

00597 {               
00598 PORTNOTE("other","Removed menu destruction - temporary!")
00599 #if 0
00600     ERROR2IF(pWinSubMenu == NULL, FALSE,"DestroyWinMenuMFC bad pWinSubMenu supplied");
00601     wxMenu  *pSubMenu = NULL;
00602     INT32       noItems = pWinSubMenu->GetMenuItemCount();  
00603     
00604     // Walk backwards through the list removing items from the end, otherwise
00605     // we would need to recalculate the position after each menu deletion as the
00606     // position will have changed.
00607     BOOL ok = TRUE;
00608     INT32   position = noItems - 1;
00609     while (position >= 0)
00610     {                                               
00611         pSubMenu = pWinSubMenu->GetSubMenu(position);    
00612         if (pSubMenu != NULL)                        
00613             ok = DestroyWinSubMenuMFC(pSubMenu);
00614         // now delete the menu item
00615         ok = pWinSubMenu->DeleteMenu( position, MF_BYPOSITION );
00616         if (pSubMenu != NULL)                        
00617         {
00618             pSubMenu->Detach();
00619             delete pSubMenu;
00620         }
00621 
00622         position--;
00623     }
00624 #endif
00625     return TRUE;
00626 }

BOOL FindMenu (  MenuItem **  TargetMenu,
wxMenu *  pMenu,
BOOL *  pShowHotKeysFlag
) 
 

To find kernel menu equivalent to Windows menu that is passed in. Scope: Private to be called by UpdateMenu() only!

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/93
Parameters:
A pointer to a Windows wxMenu [INPUTS]
A pointer to a Camelot MenuItem. [OUTPUTS]
Returns:
TRUE if found successfully FALSE otherwise

Errors: None.

See also:
CMainFrame

wxMenu

MenuItem

Definition at line 916 of file oilmenus.cpp.

00917 {
00918     UINT32  TargetMenuId = (UINT32)-1;
00919     size_t  position = 0;
00920     size_t  noItems = pMenu->GetMenuItemCount();
00921     
00922     // Get id of first non sub-menu item in Windows wxMenu
00923     // TargetMenuID is -1 if its a sub-menu item and 0 if its a separator
00924     // No separator check present, added by Neville 31/10/97
00925     TargetMenuId = pMenu->FindItemByPosition( position )->GetId(); 
00926     while (
00927             (noItems > 0) && (position < noItems) &&
00928             ((TargetMenuId == (UINT32)-1) || (TargetMenuId == 0))
00929             )
00930     {
00931         TargetMenuId = pMenu->FindItemByPosition( position )->GetId(); 
00932         position++;
00933     }
00934      
00935     if (TargetMenuId != (UINT32)-1)
00936     {                                                           
00937         //Use ID to get MenuItem object 
00938         *TargetMenu = GetMenuItem(TargetMenuId, pShowHotKeysFlag);
00939     
00940         if (*TargetMenu != NULL)                        // couldn't find it, probably
00941         {                                               // the system menu on the close box
00942             //Get Parent Id of MenuItem
00943             TargetMenuId = (*TargetMenu)->GetMenuItemParentId();
00944 
00945             //Use Parent Id to get menu we want!
00946             *TargetMenu = GetMenuItem(TargetMenuId, pShowHotKeysFlag);
00947             if (*TargetMenu)
00948                 return TRUE;
00949             else
00950                 return FALSE;
00951         }
00952     }   
00953     return FALSE;
00954 }

MenuItem* FindMenuItem (  UINT32  menuId,
MenuItem *  GroupSubMenu
) 
 

To find a menu item in the platform independent menu system. Scope: Private To OilMenus.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/7/93
Parameters:
Menu ID & Group Sub Menu [INPUTS]
None. [OUTPUTS]
Returns:
MenuItem if found NULL if menu item is not found

Errors: None.

See also:
MenuItem

Definition at line 785 of file oilmenus.cpp.

00786 {      
00787     if (GroupSubMenu==NULL)
00788         return NULL;
00789 
00790     if (GroupSubMenu->GetMenuId() == menuId)
00791         return GroupSubMenu;
00792 
00793     MenuItem* subsubMenu;
00794     MenuItem* subMenu = GroupSubMenu->GetFirstMenuItem();
00795 
00796     while (subMenu != NULL)
00797     {
00798         if (subMenu->GetMenuId() == menuId)
00799             return subMenu;
00800 
00801         if (subMenu->IsMenuItemGroup())
00802         {
00803             subsubMenu = FindMenuItem(menuId, subMenu);
00804             if (subsubMenu != NULL)
00805                 return subsubMenu;          
00806         }
00807               
00808         subMenu = GroupSubMenu->GetNextMenuItem(subMenu);
00809     }                       
00810     
00811     return NULL;
00812 }

MenuItem* GetCurrentContextMenu (   ) 
 

Find out whether the popup menu is open or not and what it is...

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the current context menu (kernel form) if it exists AND the Windows equivalent exists AND it's currently on screen.

Errors: None.

Definition at line 1273 of file oilmenus.cpp.

01274 {
01275     if (WinContextMenu!=NULL && CamelotContextMenu!=NULL)
01276         return CamelotContextMenu;
01277     else
01278         return NULL;
01279 }

MenuItem* GetMainMDIMenu (   ) 
 

To find the menu item associated with the main kernelly MDI menu.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/1/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the main MDI menu.

Errors: None.

Definition at line 1295 of file oilmenus.cpp.

01296 {
01297     return CamelotMDIMenu;
01298 }

MenuItem* GetMenuItem (  UINT32  menuId,
BOOL *  pShowHotKeysFlag
) 
 

To find a menu item in one of the platform independent menu systems.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/93
Parameters:
Menu ID [INPUTS]
None. [OUTPUTS]
Returns:
MenuItem if found NULL if menu item is not found

Errors: None.

See also:
MenuItem

FindMenuItem

Definition at line 831 of file oilmenus.cpp.

00832 {      
00833     // If There are no active child windows Then search for menu option in default menu
00834     // Else search for menu option in MDI shared menu.
00835     
00836     MenuItem* pItem = NULL;
00837     if (pShowHotKeysFlag) *pShowHotKeysFlag = TRUE;
00838 
00839 PORTNOTE( "other", "We always use MDIMenu" )
00840 /*  if( NULL == ( (wxDocMDIParentFrame *)CCamFrame::GetMainFrame() )->GetActiveChild() )
00841     {
00842         // There is no document (MDI child) window, so we want to look only in the 
00843         // current context-sensitive menu (if any), and then (if that fails), in the
00844         // default camelot menu.
00845 
00846         pItem = FindMenuItem(menuId, CamelotContextMenu);   // Look in Context sensitive menu first
00847         if (pItem == NULL)
00848             pItem = FindMenuItem(menuId, CamelotDefMenu);   // Look in default menu
00849     }
00850     else */
00851     {
00852         pItem = FindMenuItem(menuId, CamelotContextMenu);   // Look in Context sensitive menu first
00853         if (pItem == NULL)
00854             pItem = FindMenuItem(menuId, CamelotMDIMenu);
00855         else
00856             if (pShowHotKeysFlag) *pShowHotKeysFlag = FALSE;    // ContextMenu shouldn't show hot keys
00857     }
00858 
00859     return pItem;
00860 }

BOOL InitMenuSystem (   ) 
 

Creates both the platform-independent and windows specific menu systems.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
None. [INPUTS]
None. [OUTPUTS]
Returns:
TRUE if initialisation was successful

Errors: None.

See also:
OilMenus

MenuItem

SetupDefaultMenu()

SetupSharedMenu()

ConvertToWinMenu()

DeInitMenuSystem()

Definition at line 649 of file oilmenus.cpp.

00650 {
00651     CamelotDefMenu = SetupDefaultMenu();            //MainFrame Menu
00652     CamelotMDIMenu = SetupSharedMenu();             //MDI Menu
00653     CamelotContextMenu = NULL;
00654 
00655     if (CamelotDefMenu)
00656         WinDefMenu = ConvertToWinMenu(CamelotDefMenu);  //Windows MainFrame Menu        
00657     else
00658         return FALSE;
00659         
00660     if (CamelotMDIMenu)
00661         WinMDIMenu = ConvertToWinMenu(CamelotMDIMenu);  //Windows MDI Menu
00662     else
00663         return FALSE;
00664     
00665     return TRUE;
00666 }

BOOL IsMenuCommand (  wxCommandEvent &  event  ) 
 

To identify menu item commands.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/7/93
Parameters:
wParam & lParam - Windows API command parameters. [INPUTS]
None. [OUTPUTS]
Returns:
TRUE if command is a menu command FALSE otherwise

Errors: None.

See also:
CMainFrame

Definition at line 756 of file oilmenus.cpp.

00757 {
00758     return event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED;
00759 }

BOOL PerformMenuCommand (  wxCommandEvent &  event  ) 
 

To perform menu item command.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/7/93
Parameters:
wParam & lParam - Windows API command parameters. [INPUTS]
None. [OUTPUTS]
Returns:
TRUE if MenuItem found and command is performed FALSE otherwise

Errors: None.

See also:
CMainFrame

MenuItem

FindMenuItem()

MenuItem::PerformAction()

Definition at line 881 of file oilmenus.cpp.

00882 {                     
00883     MenuItem* TargetItem;
00884                            
00885     // Get appropriate menu item given the menu id
00886     TargetItem = GetMenuItem( event.GetId() );
00887 
00888     if (TargetItem)
00889     {
00890         TargetItem->PerformAction();
00891         return TRUE;
00892     }               
00893     
00894     return FALSE;
00895 }

MenuItem* SetupDefaultMenu (   ) 
 

Creates the default mainframe menu for an MDI type interface.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
None. [INPUTS]
None. [OUTPUTS]
Returns:
MenuItem - A platform independent mainframe menu.

Errors: None

See also:
OilMenus

MenuItem

SetupSharedMenu()

GetMenuPreferences()

Definition at line 156 of file oilmenus.cpp.

00157 {
00158     MenuItem* pMenu = GetMenuPreferences(_R(IDM_DEFAULT_MENU));
00159     return pMenu;
00160 }                               

MenuItem* SetupSharedMenu (   ) 
 

Creates a MDI type shared menu.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
None. [INPUTS]
None. [OUTPUTS]
Returns:
MenuItem - A platform independent MDI menu.

Errors: None

See also:
OilMenus

MenuItem

SetupDefaultMenu()

GetMenuPreferences()

Definition at line 180 of file oilmenus.cpp.

00181 {
00182     MenuItem* pMenu = GetMenuPreferences(_R(IDM_SHARED_MENU));
00183     return pMenu;
00184 }

BOOL UpdateMenu (  wxMenu *  pMenu  ) 
 

To update menu.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
A pointer to a wxMenu [INPUTS]
None. [OUTPUTS]
Returns:
FALSE if Menu is not found in the Kernel TRUE otherwize.

Errors: None.

See also:
CMainFrame

wxMenu

MenuItem

Definition at line 974 of file oilmenus.cpp.

00975 {                     
00976     MenuItem*   TargetMenu = NULL;
00977     BOOL        ShowHotKeys = TRUE;
00978     
00979     if (FindMenu(&TargetMenu, pMenu, &ShowHotKeys))
00980     {
00981         ERROR3IF(TargetMenu==NULL,"FindMenu returned TRUE but didn't fill in menu pointer");
00982 
00983 #ifdef PHOTOSHOPPLUGINS
00984 // Only add in if required - general plug-in removal at present
00985 //#ifdef NEW_NATIVE_FILTER
00986         // Must check if we are going to drop down the Plug-Ins menu item
00987         // If so then check that we have parsed the plug-ins.
00988         PlugInManager* pManager = GetApplication()->GetPlugInManager();
00989         if (pManager != NULL && !pManager->SearchedPathsYet())
00990         {
00991             MenuItem * pPlugInsMenu = pManager->FindPlugInMainMenuItem();
00992             // a pointer compare should be an adequote test
00993             if (pPlugInsMenu != NULL && TargetMenu != NULL && pPlugInsMenu == TargetMenu)
00994             {
00995                 pManager->CheckHaveDetailsOnPlugIns();
00996                 // Now done in UpdatePlugInsWinMenu
00997                 // Force the menu bar to be redrawn as we are in the middle of pulling the
00998                 // menu down and we have changed it.
00999                 //HWND hwnd = GetMainFrame()->GetSafeHwnd();
01000                 //DrawMenuBar(hwnd);
01001                 // Cannot fall through to the code below as the pMenu we have had passed in
01002                 // may now be completely false. This will cause problems in the UpdateWinMenu call.
01003                 // So return now.
01004                 return TRUE;
01005             }
01006         }
01007 //#endif
01008 #endif
01009         // Update Kernel Menu 
01010         TargetMenu->UpdateMenuState(ShowHotKeys);
01011     
01012         // Update OIL Menu 
01013         UpdateWinMenu(pMenu, TargetMenu);
01014         
01015         return TRUE;
01016     }
01017     else
01018         return FALSE;
01019 }

BOOL UpdatePlugInsWinMenu (  MenuItem *  pPlugInsMenu  ) 
 

This searches for the equivalent Win menu in the main MDI menu structure, destroys anything that is there already and then puts in the new structure.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/97
Parameters:
pPlugInsMenu Pointer to the plug-ins kernel menu structure [INPUTS]
- [OUTPUTS]
Returns:
TRUE if win menu was updated succesfully. FALSE otherwise

Errors: None.

Definition at line 1315 of file oilmenus.cpp.

01316 {
01317 #ifdef PHOTOSHOPPLUGINS
01318 // Only add in if required - general plug-in removal at present
01319     ERROR2IF(pPlugInsMenu == NULL,FALSE,"UpdatePlugInsWinMenu null plug-ins menu supplied");
01320 
01321     BOOL worked = FALSE;
01322 
01323     // Find the section in the current MDI main win menu
01324     INT32 PlugInMenuPos = -1;
01325     wxMenu * pWinMainMenu = FindSubMenu(WinMDIMenu, PlugInMenuPos, (TCHAR *) pPlugInsMenu->GetMenuText());
01326 
01327     if (pWinMainMenu == NULL)
01328         return FALSE;
01329     wxMenu * pPlugInsWinMenu = pWinMainMenu->GetSubMenu(PlugInMenuPos);
01330     if (pPlugInsWinMenu == NULL)
01331         return FALSE;
01332 
01333     // If the previous plug-ins menu is hanging around for some reason
01334     // get rid of it.
01335     // Try and destroy all the sub-menu items first
01336     BOOL ok = DestroyWinMenuMFC(pPlugInsWinMenu);
01337     ok = ok && pWinMainMenu->DeleteMenu( PlugInMenuPos, MF_BYPOSITION );
01338     pPlugInsWinMenu->Detach();
01339     delete pPlugInsWinMenu;
01340 
01341     // Now setup the new plug-ins menu inserting it at the old position
01342     // First create the new windows menu from the kernel version
01343     wxMenu * pNewWinMenu = CreatePopup(pPlugInsMenu);
01344     ERROR3IF(pNewWinMenu == NULL,"Failed to create new plug-ins main menu item");
01345     if (pNewWinMenu)
01346     {
01347         // That went ok so now add it in at the old position in the main menu
01348         pWinMainMenu->InsertMenu(PlugInMenuPos,
01349                                  MF_POPUP | MF_BYPOSITION, 
01350                                  (UINT32)(pNewWinMenu->GetSafeHmenu()), 
01351                                  pPlugInsMenu->GetMenuText()
01352                                  );                      
01353     }
01354 
01355     // Force the menu bar to be redrawn as we are in the middle of pulling the
01356     // menu down and we have changed it.
01357     HWND hwnd = GetMainFrame()->GetSafeHwnd();
01358     DrawMenuBar(hwnd);
01359 
01360     // This code should happen in the UpdateMenu after our issuing of the DrawMenuBar command
01361     // Update Kernel Menu 
01362     pPlugInsMenu->UpdateMenuState(FALSE);
01363 
01364     // Update OIL Menu 
01365     UpdateWinMenu(pNewWinMenu, pPlugInsMenu);
01366 
01367     return worked;
01368 #else
01369     return TRUE;
01370 #endif // PHOTOSHOPPLUGINS
01371 }

void UpdateWinMenu (  wxMenu *  pMenu,
MenuItem *  kernelMenu
) 
 

To update windows menu system. It is also a Friend of the MenuItem Class.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
A pointer to a wxMenu and a kernel menu object [INPUTS]
None. [OUTPUTS]
Returns:
None.

Errors: None.

See also:
CMainFrame

wxMenu

MenuItem

Definition at line 1038 of file oilmenus.cpp.

01039 {
01040     if (kernelMenu == NULL) return;
01041 
01042     MenuItem* subMenu = (kernelMenu->GetFirstMenuItem());
01043     
01044     //Read through list of Kernel MenuItems updating their state
01045     while (subMenu != NULL)
01046     {
01047         if (!subMenu->IsMenuItemGroup())
01048         {
01049             wxItemKind  ItemKind = wxITEM_NORMAL;
01050             if( subMenu->IsCheckable() )
01051                 ItemKind = wxITEM_CHECK;
01052             
01053             // Make sure the wxMenu has this menu item in it...
01054             wxMenuItem  *pItem = pMenu->FindItem( subMenu->GetMenuId() );
01055             if( NULL == pItem )
01056             {
01057                 // This menu item is missing, probably deleted by the bit of code below
01058                 // We have to put it back in again to be on the safe side
01059                 // Find out the position of the next visible menu item, so we can insert just before it
01060                 MenuItem* NextMenu = subMenu;
01061                 while( NULL != NextMenu && 
01062                     NULL == pMenu->FindItem( NextMenu->GetMenuId() ) )
01063                 {
01064                     NextMenu = (kernelMenu->GetNextMenuItem(NextMenu));
01065                 }
01066                 
01067                 // If there was a next item, insert before it, else append to the end of the menu
01068                 if (NextMenu!=NULL)
01069                 {
01070                     BOOL    MenuAdded = FALSE;
01071                     BOOL    PrevWasSeparator = FALSE;
01072                     size_t  NumMenuItems = pMenu->GetMenuItemCount();
01073                     for( size_t i=0; (!MenuAdded) && (i<NumMenuItems); i++ )
01074                     {
01075                         // loop through all the menu items to try and find our ID
01076                         wxMenuItem* pMenuItem = pMenu->FindItemByPosition( i );
01077                         UINT32 MenuID = pMenuItem->GetId();
01078                         if (MenuID == NextMenu->GetMenuId())
01079                         {
01080                             // We will be wanting to insert just before this one
01081                             size_t InsertPos = i;
01082 
01083                             // but was the previous item was a separator
01084                             if (PrevWasSeparator)
01085                                 InsertPos--;
01086                             
01087                             // Insert the menu and set the flag to say it was inserted
01088                             pMenu->Insert( InsertPos, subMenu->GetMenuId(), subMenu->GetMenuText(), 
01089                                 _T(""), ItemKind );
01090                             MenuAdded = TRUE;
01091                         }
01092 
01093                         // Unset the Prev Separator flag
01094                         PrevWasSeparator = FALSE;
01095 
01096                         // if this was a separator, then remember for the next loop
01097                         if( pMenuItem->IsSeparator() )
01098                             PrevWasSeparator = TRUE;
01099                     }
01100                 }
01101                 else
01102                     pMenu->Append( subMenu->GetMenuId(), subMenu->GetMenuText(), _T(""),
01103                         ItemKind );
01104             }
01105 
01106 PORTNOTE( "menu", "Remove Unimplemented menuitems from menu, under Release" )
01107 #if !defined(_DEBUG)
01108             if( subMenu->Description == _T("Unimplemented") )
01109                 subMenu->ControlState.RemoveFromMenu = true;
01110 #endif
01111 
01112             if( !subMenu->ControlState.RemoveFromMenu )
01113             {
01114                 //Update the Menu Text
01115                 pMenu->FindItem( subMenu->GetMenuId() )->SetText( wxString( (TCHAR *)subMenu->GetMenuText() ) );
01116 
01117                 if (subMenu->ControlState.Greyed)
01118                     //Disable and Grey Menu Item 
01119                     pMenu->Enable( subMenu->GetMenuId(), false );
01120                 else
01121                 {
01122                     //Enable Menu Item and UnGrey
01123                     pMenu->Enable( subMenu->GetMenuId(), true );
01124 
01125                     if (subMenu->ControlState.Ticked)
01126                     {
01127                         TRACE( _T("Check %s\n"), (PCTSTR)subMenu->GetMenuText() );
01128                         
01129                         //Tick Menu Item
01130                         if (pMenu->FindItem(subMenu->GetMenuId())->IsCheckable())
01131                             pMenu->Check( subMenu->GetMenuId(), true );
01132                     }
01133                     else
01134                         //UnTick Menu Item
01135                         if (pMenu->FindItem(subMenu->GetMenuId())->IsCheckable())
01136                             pMenu->Check( subMenu->GetMenuId(), false );
01137                 }
01138             }
01139             else
01140             // See if this menu item want itself removed from the menu
01141             {
01142                 // take it out of the menu
01143                 pMenu->Delete( subMenu->GetMenuId() );
01144             }
01145         }
01146         else
01147         {
01148             // It's a menu item group, so we need to recurse down
01149             wxMenuItem  *pItem = pMenu->FindItem( subMenu->GetMenuId() );
01150             if (pItem)
01151             {
01152                 wxMenu * pwxSubMenu = pItem->GetSubMenu();
01153                 if (pwxSubMenu)
01154                 {
01155                     UpdateWinMenu(pwxSubMenu,subMenu);
01156                 }
01157             }
01158         }   
01159         subMenu = (kernelMenu->GetNextMenuItem(subMenu));
01160     }
01161 }


Variable Documentation

MenuItem* CamelotContextMenu
 

Definition at line 132 of file oilmenus.cpp.

MenuItem* CamelotDefMenu
 

Definition at line 130 of file oilmenus.cpp.

MenuItem* CamelotMDIMenu
 

Definition at line 131 of file oilmenus.cpp.

wxMenu* WinContextMenu
 

Definition at line 136 of file oilmenus.cpp.

wxCamMenuBar* WinDefMenu
 

Definition at line 134 of file oilmenus.cpp.

wxCamMenuBar* WinMDIMenu
 

Definition at line 135 of file oilmenus.cpp.


Generated on Sat Nov 10 03:49:34 2007 for Camelot by  doxygen 1.4.4