#include <contmenu.h>
Inheritance diagram for ContextMenu:
Public Member Functions | |
ContextMenu () | |
virtual | ~ContextMenu () |
BOOL | Show () |
BOOL | ShowOverView (Spread *pSpread, DocCoord ClickPos, ClickModifiers ClickMods) |
This function does the same job as ShowMenu but unfortunately needs some parameters to pass on to the menu builders. Not very neat, I know... | |
BOOL | Hide () |
Close and delete any context menu that may be open. | |
virtual BOOL | Build () |
Base class implementation of menu builder. This function builds a menu statically by creating the appropriate objects. It does NOT call teh menu script interpreter because I am unhappy about the reliability of repeatedly calling that code. | |
virtual BOOL | BuildOverView (Spread *pSpread, DocCoord ClickPos, ClickModifiers ClickMods) |
Base class function which, when overridden in derived classes, will build a pop-up menu according to a given position in a view. | |
BOOL | BuildTransferCommands (BOOL NodeCommands) |
Append the standard "transfer command" menu items to the input root menu This function adds: Cut Copy Paste (Paste link When we implement OLE...) And if NodeCommands is TRUE: ----- Delete Duplicate Clone -----. | |
BOOL | BuildEffectCommands () |
Append the "effect" menu items to the input root menu. | |
BOOL | BuildCommand (TCHAR *pOpToken, BOOL Separator=FALSE, MenuItem *pRootMenu=NULL, const String &strNewText=String(_T("")), OpMenuParam *pParam=NULL) |
Append a new menu item to this menu. Passing pRootMenu as NULL (leaving it defaulted) causes the new item to be added to the first level of the pop-up menu. Passing pRootMenu non-NULL allows you to build a submenu. | |
MenuItem * | GetLastItem () |
Get pointer to item last previously created. | |
Static Public Member Functions | |
static BOOL | HideCurrent () |
Close and delete the current context menu if it's open. | |
Protected Attributes | |
MenuItem * | pRootItem |
MenuItem * | pLastItem |
UINT32 | AutoIDStash |
Static Protected Attributes | |
static ContextMenu * | pCurrentMenu = NULL |
Private Member Functions | |
CC_DECLARE_MEMDUMP (ContextMenu) |
Note: There are guidelines about how to construct a pop-up menu and when to open it. The menu should be formed something like this: Clicked object's primary commands Clicked object's transfer commands (e.g. cut, copy, etc...) "Properties..." command The menu should be opened in response to a BUTTON UP event!!!
Definition at line 139 of file contmenu.h.
|
Definition at line 145 of file contmenu.cpp. 00146 { 00147 pRootItem = NULL; 00148 pLastItem = NULL; 00149 AutoIDStash = 0; 00150 }
|
|
Definition at line 170 of file contmenu.cpp.
|
|
Base class implementation of menu builder. This function builds a menu statically by creating the appropriate objects. It does NOT call teh menu script interpreter because I am unhappy about the reliability of repeatedly calling that code.
Note also that by building the menu programmatically it can change depending on the context within which it is opened... The standard layout for pop-up menus is: Clicked object's primary commands Transfer commands Other commands supported by the clicked object The "What's this?" command The Properties... command These are only guidelines and you can omit any sections you don't need. To implement an overriden version of this function you simply need to make it add new menu items to the root menu. There are helper functions to make this easier: BuildTransferCommands will add Cut,Copy,Paste,etc. BuildCommand will take any OPTOKEN you give it and build an item linked to that OPTOKEN.
Reimplemented in BfxPlugInContextMenu, ColEditContextMenu, PaletteContextMenu, PlugInsContextMenu, PreviewContextMenu, RulerContextMenu, OriginContextMenu, and GalleryContextMenu. Definition at line 373 of file contmenu.cpp. 00374 { 00375 ERROR2(FALSE,"ContextMenu::Build called in base class - should be overridden!"); 00376 }
|
|
Append a new menu item to this menu. Passing pRootMenu as NULL (leaving it defaulted) causes the new item to be added to the first level of the pop-up menu. Passing pRootMenu non-NULL allows you to build a submenu.
Definition at line 504 of file contmenu.cpp. 00505 { 00506 MenuItem* pNewItem; 00507 00508 // If caller hasn't specified a root menu use the root of the whole thing... 00509 if (pRootMenu == NULL) 00510 pRootMenu = pRootItem; 00511 00512 // Create a new kernel menu item... 00513 pNewItem = CreateMenuItem(pOpToken, pRootMenu->GetMenuId(), Separator); 00514 00515 // If that worked, add it to the root menu. Else flag failure. 00516 if (pNewItem) 00517 { 00518 pLastItem = pNewItem; 00519 00520 if (!strNewText.IsEmpty()) 00521 pNewItem->SetMenuText(strNewText); 00522 00523 if (pParam) 00524 pNewItem->SetMenuParam(pParam); 00525 00526 pRootMenu->AddMenuItem(pNewItem); 00527 00528 return TRUE; 00529 } 00530 else 00531 return FALSE; 00532 }
|
|
Append the "effect" menu items to the input root menu.
Definition at line 467 of file contmenu.cpp. 00468 { 00469 EffectsStack* pStack = GetApplication()->FindSelection()->GetEffectsStack(); // Cached copy 00470 if (pStack->IsEmpty() || !pStack->bConsistent) 00471 return TRUE; 00472 00473 BuildCommand( TOOL_OPTOKEN_LIVEEFFECT ); // Go to Effects tool 00474 00475 pStack->BuildEffectMenu(this); // <List of effects> 00476 00477 BuildCommand(OPTOKEN_DELETEALL_LIVEEFFECT, TRUE); // Remove all Effects 00478 00479 return TRUE; 00480 }
|
|
Base class function which, when overridden in derived classes, will build a pop-up menu according to a given position in a view.
Reimplemented in ViewContextMenu. Definition at line 397 of file contmenu.cpp. 00398 { 00399 ERROR2(FALSE,"ContextMenu::BuildOverView called in base class - should be overridden!"); 00400 }
|
|
Append the standard "transfer command" menu items to the input root menu This function adds: Cut Copy Paste (Paste link When we implement OLE...) And if NodeCommands is TRUE: ----- Delete Duplicate Clone -----.
Definition at line 431 of file contmenu.cpp. 00432 { 00433 // Build the standard transfer command menu items... 00434 BuildCommand(OPTOKEN_CUT); 00435 BuildCommand(OPTOKEN_COPY); 00436 BuildCommand(OPTOKEN_PASTE, TRUE); 00437 // BuildCommand(OPTOKEN_PASTELINK); 00438 00439 // If caller wants transfer commands for Nodes in the document build them... 00440 if (NodeCommands) 00441 { 00442 BuildCommand(OPTOKEN_DELETE); 00443 BuildCommand(OPTOKEN_DUPLICATE); 00444 BuildCommand(OPTOKEN_CLONE, TRUE); 00445 } 00446 00447 return TRUE; 00448 }
|
|
|
|
Get pointer to item last previously created.
Definition at line 551 of file contmenu.cpp. 00552 { 00553 return pLastItem; 00554 }
|
|
Close and delete any context menu that may be open.
Definition at line 291 of file contmenu.cpp. 00292 { 00293 DestroyContextMenu(); 00294 00295 // Restore ID generator state 00296 MenuItem::SetAutomaticIDState(AutoIDStash); 00297 AutoIDStash = 0; 00298 00299 if (pCurrentMenu==this) 00300 pCurrentMenu = NULL; 00301 00302 delete this; 00303 return TRUE; 00304 }
|
|
Close and delete the current context menu if it's open.
Definition at line 324 of file contmenu.cpp. 00325 { 00326 if (pCurrentMenu) 00327 pCurrentMenu->Hide(); 00328 return TRUE; 00329 }
|
|
Definition at line 192 of file contmenu.cpp. 00193 { 00194 // If there's a menu still around for some reason, get rid of it. 00195 if (pCurrentMenu) 00196 { 00197 pCurrentMenu->Hide(); 00198 } 00199 00200 // Preserve current ID generator state 00201 AutoIDStash = MenuItem::GetAutomaticIDState(); 00202 00203 // Make a new root item 00204 pRootItem = new MenuItem("CONTEXT"); 00205 if (pRootItem) 00206 { 00207 // OK, make this menu current and try to build it's contents 00208 pCurrentMenu=this; 00209 if (Build()) 00210 { 00211 // Kernel menu built OK so create the OILy part of it... 00212 CreateContextMenu(pRootItem); 00213 return TRUE; 00214 } 00215 } 00216 00217 // Failed to completely build Kernel menu structure so delete anything 00218 // that might have been built... 00219 Hide(); 00220 return FALSE; 00221 }
|
|
This function does the same job as ShowMenu but unfortunately needs some parameters to pass on to the menu builders. Not very neat, I know...
Definition at line 242 of file contmenu.cpp. 00243 { 00244 // If there's a menu still around for some reason, get rid of it. 00245 if (pCurrentMenu) 00246 { 00247 pCurrentMenu->Hide(); 00248 } 00249 00250 // Preserve current ID generator state 00251 AutoIDStash = MenuItem::GetAutomaticIDState(); 00252 00253 // Make a new root item 00254 pRootItem = new MenuItem("CONTEXT"); 00255 if (pRootItem) 00256 { 00257 // OK, make this menu current and try to build it's contents 00258 pCurrentMenu=this; 00259 if (BuildOverView(pSpread, ClickPos, ClickMods)) 00260 { 00261 // Kernel menu built OK so create the OILy part of it... 00262 CreateContextMenu(pRootItem); 00263 return TRUE; 00264 } 00265 } 00266 00267 // Failed to completely build Kernel menu structure so delete anything 00268 // that might have been built... 00269 Hide(); 00270 return FALSE; 00271 }
|
|
Definition at line 175 of file contmenu.h. |
|
Definition at line 177 of file contmenu.h. |
|
Definition at line 174 of file contmenu.h. |
|
Definition at line 173 of file contmenu.h. |