A GenericMenu class.
You can use this class either to create a new menu in the menu bar (or in a menuitem in the menu bar) or you can use this class to create a pop-up menu.
#to start a pop up menu use the Execute method def mouseClick(x, y): item = menu.Execute(x, y) if item.Id == 10: [do this] else if item.Id == 100: [do that...]
There are 4 ways to insert new item in a menu. Each method needs the name of the menuitem as well as it's unique id. You can also optionnally sets a new menu for a specific item.
embeededMenu = FBGenericMenu() menu.InsertLast("new new item", 67, embeddedMenu) #A genericMenu contains a GenericMenuItem for each entry. You can iterate on the different menuitem #using GetFirstITem/GetNextItem or if you already know the id of the item you can get it with GetItem. item = menu.GetFirstItem() while item: print item.Name item = menu.GetNextItem(item)
You can also delete a Menu item: this will remove the item from the menu as well as freeing its memory.
To be notified when a menuitem is clicked, you can register using OnMenuActivate. This will send a FBEventMenu containing the name and the Id of the menu item that was clicked.
Definition at line 127 of file fbgenericmenu.h.
#include <fbgenericmenu.h>
Public Member Functions |
|
FBGenericMenu () | |
Default constructor. |
|
FBGenericMenuItem * | GetFirstItem () |
Returns the first menu item (if existing) in
this menu. |
|
FBGenericMenuItem * | GetLastItem () |
Returns the last menu item (if existing) in
this menu. |
|
FBGenericMenuItem * | GetNextItem (FBGenericMenuItem *pItem) |
Returns the menu item following an other
item. |
|
FBGenericMenuItem * | GetPrevItem (FBGenericMenuItem *pItem) |
Returns the menu item preceding an other
item. |
|
FBGenericMenuItem * | GetItem (int pItemId) |
Returns the menu item corresponding to an
id. |
|
FBGenericMenuItem * | InsertFirst (const char *pItemName, int pItemId, FBGenericMenu *pMenu=NULL) |
Inserts a new menu Item at the first
position in the menu list. |
|
FBGenericMenuItem * | InsertLast (const char *pItemName, int pItemId, FBGenericMenu *pMenu=NULL) |
Inserts a new menu Item at the last position
in the menu list. |
|
FBGenericMenuItem * | InsertAfter (FBGenericMenuItem *pBeforeItem, const char *pItemName, int pItemId, FBGenericMenu *pMenu=NULL) |
Inserts a new menu Item AFTER another item.
|
|
FBGenericMenuItem * | InsertBefore (FBGenericMenuItem *pAfterItem, const char *pItemName, int pItemId, FBGenericMenu *pMenu=NULL) |
Inserts a new menu Item BEFORE another item.
|
|
void | DeleteItem (FBGenericMenuItem *pToDelete) |
Remove a menu item from the menu and delete
it. |
|
FBGenericMenuItem * | Execute (int pX, int pY, bool pRightAlign=true) |
Starts the menu as a pop-up menu at a
specific location on screen. |
|
Public Attributes |
|
FBPropertyEvent | OnMenuActivate |
Event Property: Register on this
property to be notified when a menu item is clicked by the user.
|
|
Friends |
|
class | FBMenuManager |
class | DataFBMenuManager |
class | DataFBGenericMenu |
FBGenericMenu | ( | ) |
Default constructor.
Used to create embedded menu (inside aniother menu item) or pop-up menu.
FBGenericMenuItem* GetFirstItem | ( | ) |
Returns the first menu item (if existing) in this menu.
You can then use GetNextItem to iterate on other menu items.
FBGenericMenuItem* GetLastItem | ( | ) |
Returns the last menu item (if existing) in this menu.
You can then use GetPrevItem to reverse iterate on other menu items.
FBGenericMenuItem* GetNextItem | ( | FBGenericMenuItem * | pItem | ) |
Returns the menu item following an other item.
Returns null if this is the last item in menu.
pItem | Will return the item after pItem |
FBGenericMenuItem* GetPrevItem | ( | FBGenericMenuItem * | pItem | ) |
Returns the menu item preceding an other item.
Returns null if this is the first item in menu.
pItem | Will return the item BEFORE pItem |
FBGenericMenuItem* GetItem | ( | int | pItemId | ) |
Returns the menu item corresponding to an id.
pItemId | Id of the item we are looking for. |
FBGenericMenuItem* InsertFirst | ( | const char * | pItemName, |
int | pItemId, | ||
FBGenericMenu * | pMenu = NULL |
||
) |
Inserts a new menu Item at the first position in the menu list.
pItemName | Caption of the newly added item. |
pItemId | Unique id of this menu item. |
pMenu | Optionnal. If this Item leads to another menu (embddedd) it can be specified here. |
FBGenericMenuItem* InsertLast | ( | const char * | pItemName, |
int | pItemId, | ||
FBGenericMenu * | pMenu = NULL |
||
) |
Inserts a new menu Item at the last position in the menu list.
pItemName | Caption of the newly added item. |
pItemId | Unique id of this menu item. |
pMenu | Optionnal. If this Item leads to another menu (embddedd) it can be specified here. |
FBGenericMenuItem* InsertAfter | ( | FBGenericMenuItem * | pBeforeItem, |
const char * | pItemName, | ||
int | pItemId, | ||
FBGenericMenu * | pMenu = NULL |
||
) |
Inserts a new menu Item AFTER another item.
pBeforeItem | The reference item. We will create a new item AFTER this one. |
pItemName | Caption of the newly added item. |
pItemId | Unique id of this menu item. |
pMenu | Optionnal. If this Item leads to another menu (embddedd) it can be specified here. |
FBGenericMenuItem* InsertBefore | ( | FBGenericMenuItem * | pAfterItem, |
const char * | pItemName, | ||
int | pItemId, | ||
FBGenericMenu * | pMenu = NULL |
||
) |
Inserts a new menu Item BEFORE another item.
pAfterItem | The reference item. We will create a new item BEFORE this one. |
pItemName | Caption of the newly added item. |
pItemId | Unique id of this menu item. |
pMenu | Optionnal. If this Item leads to another menu (embddedd) it can be specified here. |
void DeleteItem | ( | FBGenericMenuItem * | pToDelete | ) |
Remove a menu item from the menu and delete it.
pToDelete | The item to remove. |
FBGenericMenuItem* Execute | ( | int | pX, |
int | pY, | ||
bool | pRightAlign =
true |
||
) |
Starts the menu as a pop-up menu at a specific location on screen.
It returns the item that was clicked by the user.
pX | X location in pixel on screen where the menu is to be popped. |
pY | Y location in pixel on screen where the menu is to be poppded. |
pRightAlign | All menu item will be align to the right justified (if true) or left justifed (if false) |
friend class FBMenuManager
[friend] |
Definition at line 215 of file fbgenericmenu.h.
friend class DataFBMenuManager
[friend] |
Definition at line 216 of file fbgenericmenu.h.
friend class DataFBGenericMenu
[friend] |
Definition at line 217 of file fbgenericmenu.h.
Event Property: Register on this property to be notified when a menu item is clicked by the user.
Definition at line 213 of file fbgenericmenu.h.