OpendTect
6.6
|
Public Member Functions | |
MenuHandler (int id) | |
virtual bool | executeMenu ()=0 |
bool | isHandled () const |
int | menuID () const |
int | queueID () const |
void | setIsHandled (bool) |
void | setMenuID (int newid) |
Public Member Functions inherited from MenuItemHolder | |
MenuItemHolder () | |
virtual | ~MenuItemHolder () |
virtual void | addItem (MenuItem *, bool manage=false) |
MenuItem * | findItem (const char *) |
Seaches for untranslated text. More... | |
const MenuItem * | findItem (const char *) const |
Seaches for untranslated text. More... | |
MenuItem * | findItem (int id) |
const MenuItem * | findItem (int id) const |
MenuItem * | getItem (int idx) |
const MenuItem * | getItem (int idx) const |
const ObjectSet< MenuItem > & | getItems () const |
int | itemIndex (const MenuItem *) const |
int | itemIndex (int id) const |
int | nrItems () const |
void | removeItems () |
Public Member Functions inherited from CallBacker | |
CallBacker () | |
CallBacker (const CallBacker &) | |
virtual | ~CallBacker () |
bool | attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const |
bool | attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const |
void | detachAllNotifiers () const |
Call from the destructor of your inherited object. More... | |
void | detachCB (const NotifierAccess &, const CallBack &) const |
void | detachCB (const NotifierAccess *notif, const CallBack &cb) const |
virtual bool | isCapsule () const |
bool | isNotifierAttached (const NotifierAccess *) const |
Only for debugging purposes, don't use. More... | |
void | stopReceivingNotifications () const |
Public Attributes | |
Notifier< MenuHandler > | createnotifier |
CNotifier< MenuHandler, int > | handlenotifier |
Notifier< MenuHandler > | initnotifier |
Public Attributes inherited from MenuItemHolder | |
Notifier< MenuItemHolder > | removal |
Protected Member Functions | |
void | assignItemID (MenuItem &) |
void | executeQueue () |
Protected Member Functions inherited from MenuItemHolder | |
void | itemIsDeletedCB (CallBacker *) |
Protected Attributes | |
int | id_ |
bool | ishandled_ |
int | queueid_ |
Protected Attributes inherited from MenuItemHolder | |
MenuItemHolder * | parent_ |
Additional Inherited Members | |
Static Public Member Functions inherited from CallBacker | |
static void | createReceiverForCurrentThread () |
static void | removeReceiverForCurrentThread () |
A generic representation of a menu. It allows anyone to add their own custom menuitems to it. The principle is that the menu triggers it's createnotifier just before the menu should be displayed, and the application adds the items it wants into the menu. When the user has clicked on something in the menu, the handlenotifier is triggered and the application checks what should be done.
Usage:
\code menu->createnotifier.notify( mCB(this,myclass,createMenuCB) ); menu->handlenotifier.notify( mCB(this,myclass,handleMenuCB) ); \endcode Upon a create notification, your class might do something like this: \code void myclass::createMenuCB( CallBacker* callback ) { mDynamicCastGet( MenuHandler*, menu, callback ); mAddMenuItem( menu, &mymenuitem, true, false ); mAddMenuItem( menu, &mysubmenu, true, false ); mAddMenuItem( &mysubmenu, &mysubmenuitem1, true, false ); mAddMenuItem( &mysubmenu, &mysubmenuitem2, true, false ); } \endcode
The code will make a menu with two items, and the second item will have a submenu with two items. The first boolean says whether the item should be enabled, the second one says where there should be a check before it.
The menuitems are instantiations of MenuItem and should be stored in your class. They hold information about the item itself (like text, enabled or not enabled, checked or not checked, information on where in the menu it should be placed. In addition, it has an unique id that is set when the item is inserted into the menu.
Upon a handle notification, your class might do something like this: \code void myclass::handleMenuCB(CallBacker* callback ) { mCBCapsuleUnpackWithCaller( int, mnuid, caller, callback ); mDynamicCastGet( MenuHandler*, menu, caller ); if ( mnuid==-1 || menu->isHandled() ) return; bool ishandled = true; if ( mnuid==mymenuitem.id ) do_something(); else if ( mnuid==mysubmenuitem1.id ) do_something_else(); else if ( mnuid==mymenusubitem2.id ) do_something_else(); else ishandled = false; menu->setIsHandled(ishandled); } \endcode
<>
MenuHandler::MenuHandler | ( | int | id | ) |
|
protectedvirtual |
Get a unique id for this item.
Reimplemented from MenuItemHolder.
|
pure virtual |
Implemented in uiTreeItemTBHandler, and uiMenuHandler.
|
protected |
bool MenuHandler::isHandled | ( | ) | const |
Should be called as the first thing from callbacks that is triggered from uiMenuHandler::handlenotifier. If isHandled() returns true, the callback should return immediately.
|
inline |
|
inline |
After a menu is executed, it will execute a queue, identified by this id.
void MenuHandler::setIsHandled | ( | bool | ) |
Should be called from callbacks that are triggered from uiMenuHandler::handlenotifier if they have found the menu id they are looking for.
|
inline |
Notifier<MenuHandler> MenuHandler::createnotifier |
CNotifier<MenuHandler,int> MenuHandler::handlenotifier |
|
protected |
Notifier<MenuHandler> MenuHandler::initnotifier |
|
protected |
|
protected |
Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2022