X11workbench Toolkit
1.0
|
Data Structures | |
struct | tagWBMenuItem__ |
structure for managing menu items More... | |
struct | tagWBMenu |
structure for managing menu items More... | |
Macros | |
#define | WBMENU_TAG (*((const unsigned int *)"WBMM")) |
TAG for WBMenu structure. | |
#define | WBMENUITEM_TAG (*((const unsigned int *)"WBMI")) |
TAG for WBMenuItem structure. | |
Typedefs | |
typedef struct tagWBMenuItem__ | WBMenuItem |
structure for managing menu items More... | |
typedef struct tagWBMenu | WBMenu |
structure for managing menu items More... | |
Functions | |
WBMenu * | MBCreateMenu (int iID, int iPopup, const char *pszResource, int iReserveSpace) |
Create a WBMenu from a text menu resource. More... | |
void | MBDestroyMenu (WBMenu *pMenu) |
Destroy a WBMenu created by MBCreateMenu(), freeing up its resources. More... | |
WBMenu * | MBCopyMenu (const WBMenu *pMenu, int iReserveSpace) |
Create a copy of a WBMenu from an existing WBMenu. More... | |
int | MBIsMenuValid (const WBMenu *pMenu) |
Check whether a 'WBMenu' pointer is valid. More... | |
WBMenuItem * | MBCreateMenuItem (const char **ppszResource) |
Create a single allocated WBMenuItem structure from a text menu resource, advancing the source text pointer to the next menu item. More... | |
void | MBDestroyMenuItem (WBMenuItem *pMenuItem) |
Destroy a WBMenuItem created by MBCreateMenuItem(), freeing up its resources. More... | |
int | MBIsMenuItemValid (const WBMenuItem *pMenuItem) |
Check whether a 'WBMenuItem' pointer is valid. More... | |
int | MBAddMenuItem (WBMenu *pMenu, const WBMenuItem *pMenuItem, int iPos) |
Add a WBMenuItem menu item to an existing WBMenu. More... | |
void | MBRemoveMenuItem (WBMenu *pMenu, int iPos) |
Remove a WBMenuItem from a menu created by MBCreateMenu(), freeing up its resources. More... | |
int | MBAddPopupMenu (WBMenu *pMenu, const WBMenu *pPopupMenu) |
Add a WBMenuItem menu item to an existing WBMenu. More... | |
WBMenu * | MBFindPopupMenu (WBMenu *pMenu, int idPopup) |
Locate a WBMenu 'popup' within a menu created by MBCreateMenu() More... | |
void | MBRemovePopupMenu (WBMenu *pMenu, int idPopup) |
Remove a WBMenu 'popup' from a menu created by MBCreateMenu(), freeing up its resources. More... | |
static __inline__ int | MBMenuIsPopup (WBMenu *pMenu) |
Indicate whether a 'WBMenu' refers to a popup menu. More... | |
int | MBMenuProcessHotKey (WBMenu *pMenu, XKeyEvent *pEvent) |
Event handler for menu hotkeys. More... | |
Variables | |
Atom | aMENU_COMMAND |
commands sent by menus via ClientMessage More... | |
Atom | aMENU_UI_COMMAND |
UI notifications sent by menus to owning Frame windows via ClientMessage using 'WBWindowDispatch'. More... | |
#define | WBMENU_RESERVE_DEFAULT (256 * sizeof(void *)) |
#define | WBMENU_POPUP_HIGH_BIT 0x80000000 |
#define | WBMENU_DYNAMIC_HIGH_BIT 0x40000000 |
#define | WBMENU_POPUP_MASK 0x3fffffff |
#define | WBMENU_SEPARATOR -1 |
Structures and API functions for managing and working with menus and menu items
#define WBMENU_DYNAMIC_HIGH_BIT 0x40000000 |
marks menu item as 'dynamic' for WBMenuItem::iAction (TODO may become platform dependent)
#define WBMENU_POPUP_HIGH_BIT 0x80000000 |
#define WBMENU_POPUP_MASK 0x3fffffff |
#define WBMENU_RESERVE_DEFAULT (256 * sizeof(void *)) |
#define WBMENU_SEPARATOR -1 |
marks menu item as a 'separator' for WBMenuItem::iAction
structure for managing menu items
Definition for the structure that defines a menu. A menu is a single-level entity that can contain other "sub menus" that display as 'popup' menus when the menu item is highlighted or selected.
structure for managing menu items
Definition for the structure that defines a single menu item.
int MBAddMenuItem | ( | WBMenu * | pMenu, |
const WBMenuItem * | pMenuItem, | ||
int | iPos | ||
) |
Add a WBMenuItem menu item to an existing WBMenu.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
pMenuItem | A pointer to a (const) WBMenuItem structure, created by MBCreateMenuItem() |
iPos | The position to insert/add the menu item to, or -1 to add it to the end |
Use this function to add a WBMenuItem to the WBMenu. This function makes a copy of the specified WBMenuItem and inserts the copy (i.e. does not take ownership of the WBMenuItem).
Header File: menu.h
Add a WBMenuItem menu item to an existing WBMenu.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
pPopupMenu | A pointer to a (const) WBMenu structure, created by MBCreateMenu() |
Use this function to add a WBMenu 'popup' to the WBMenu. This function makes a copy of the specified WBMenu and inserts the copy (i.e. does not take ownership of the WBMenu). The copy operation is recursive, so that the added WBMenu 'popup' does not share memory with any other.
Header File: menu.h
Create a copy of a WBMenu from an existing WBMenu.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
iReserveSpace | The amount of space (in menu items) to reserve for use by MBAddMenuItem() and MBAddPopupMenu(). A negative value will retain the existing WBMenu's reserve space. |
Use this function to make a copy of an existing WBMenu structure.
Header File: menu.h
WBMenu* MBCreateMenu | ( | int | iID, |
int | iPopup, | ||
const char * | pszResource, | ||
int | iReserveSpace | ||
) |
Create a WBMenu from a text menu resource.
iID | The menu ID, or '-1' to read it from the resource |
iPopup | The 'popup' ID, or '-1' to read it from the resource |
pszResource | A pointer to a (const) character string, terminated by a 0 byte, defining the menu structure |
iReserveSpace | The amount of space (in menu items) to reserve for use by MBAddMenuItem() and MBAddPopupMenu() |
Use this function to create a WBMenu structure from a text resource, optionally specifying the menu's ID and/or popup ID.
Header File: menu.h
WBMenuItem* MBCreateMenuItem | ( | const char ** | ppszResource | ) |
Create a single allocated WBMenuItem structure from a text menu resource, advancing the source text pointer to the next menu item.
ppszResource | A pointer to a pointer to a (const) character string, terminated by a 0 byte, which is updated by the function call |
Use this function to create a WBMenuItem structure from a text resource, automatically advancing the source text pointer to the next menu item in the text resource. Repeated calls to this function allow you to parse a text menu resource and create all of the menu items.
Header File: menu.h
void MBDestroyMenu | ( | WBMenu * | pMenu | ) |
Destroy a WBMenu created by MBCreateMenu(), freeing up its resources.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
Use this function to destroy a WBMenu created by MBCreateMenu(), and free up its resources.
Header File: menu.h
void MBDestroyMenuItem | ( | WBMenuItem * | pMenuItem | ) |
Destroy a WBMenuItem created by MBCreateMenuItem(), freeing up its resources.
pMenuItem | A pointer to a WBMenuItem structure, created by MBCreateMenuItem() |
Use this function to destroy a WBMenuItem created by MBCreateMenuItem(), and free up its resources.
Header File: menu.h
Locate a WBMenu 'popup' within a menu created by MBCreateMenu()
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
idPopup | The 'popup menu' ID for the popup menu (this differs from WBRemoveMenuItem() which uses the index) |
Use this function to locate a 'popup' WBMenu within a WBMenu created by MBCreateMenu(), returning a pointer to the WBMenu structure, using the popup menu's ID. The returned WBMenu pointer can then be used in the functions that maintain a WBMenu, so long as the actual pointer value is not modified.
If the pointer must be re-allocated, or a new popup menu is created to replace it, you can delete the popup menu using MBRemovePopupMenu() and then re-add the new one with MBAddPopupMenu()
Header File: menu.h
int MBIsMenuItemValid | ( | const WBMenuItem * | pMenuItem | ) |
Check whether a 'WBMenuItem' pointer is valid.
pMenuItem | A (const) pointer to a WBMenuItem structure, created by MBCreateMenuItem() |
Use this function to validate a 'WBMenuItem' pointer before attempting to use it
Header File: menu.h
int MBIsMenuValid | ( | const WBMenu * | pMenu | ) |
Check whether a 'WBMenu' pointer is valid.
pMenu | A (const) pointer to a WBMenu structure, created by MBCreateMenu() |
Use this function to validate a 'WBMenu' pointer before attempting to use it
Header File: menu.h
|
static |
Indicate whether a 'WBMenu' refers to a popup menu.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenuItem() |
Use this function to indicate whether a 'WBMenu' refers to a popup menu
Header File: menu.h
int MBMenuProcessHotKey | ( | WBMenu * | pMenu, |
XKeyEvent * | pEvent | ||
) |
Event handler for menu hotkeys.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenuItem() |
pEvent | A pointer to the XKeyEvent being processed |
Use this function to process keyboard 'XKeyEvent' events, determine if they correspond to menu hot-keys, and to notify the menu owner with the hot-key action (if found).
Header File: menu.h
void MBRemoveMenuItem | ( | WBMenu * | pMenu, |
int | iPos | ||
) |
Remove a WBMenuItem from a menu created by MBCreateMenu(), freeing up its resources.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
iPos | A zero-based index for the menu item's position |
Use this function to remove a WBMenuItem from a WBMenu created by MBCreateMenu()
Header File: menu.h
void MBRemovePopupMenu | ( | WBMenu * | pMenu, |
int | idPopup | ||
) |
Remove a WBMenu 'popup' from a menu created by MBCreateMenu(), freeing up its resources.
pMenu | A pointer to a WBMenu structure, created by MBCreateMenu() |
idPopup | The 'popup menu' ID for the popup menu (this differs from WBRemoveMenuItem() which uses the index) |
Use this function to remove a popup WBMenu from a WBMenu created by MBCreateMenu()
Header File: menu.h
Atom aMENU_COMMAND |
commands sent by menus via ClientMessage
MENU_COMMAND message format (relative to XEvent.xclient)
type == ClientMessage
message_type == aMENU_COMMAND
format == 32 (always)
data.l[0] Menu command message ID (aka 'action')
data.l[1] secure hash for WBMenu object pointer - see WBCreatePointerHash()
data.l[2] Window ID of the menu bar
Whenever this message is received, you should NOT call WBDestroyPointerHash() for the WBMenu object pointer. This will be done automatically by the message framework.
Definition at line 166 of file window_helper.c.
Atom aMENU_UI_COMMAND |
UI notifications sent by menus to owning Frame windows via ClientMessage using 'WBWindowDispatch'.
MENU_COMMAND message format (relative to XEvent.xclient)
type == ClientMessage
message_type == aMENU_UI_COMMAND
format == 32 (always)
data.l[0] Menu command message ID (aka 'action')
data.l[1] secure hash for WBMenu object pointer - see WBCreatePointerHash()
data.l[2] secure hash for WBMenuItem object pointer - see WBCreatePointerHash()
data.l[3] the value '0' (reserved)
data.l[4] the value '0' (reserved)
A Frame Window returns '0' to indicate that the menu should be displayed normally (same as 'not handled')
Other return values alter the display of the menu.
For a popup menu: -1 : disables the menu 1 : enables the menu (default behavior if no UI handler present, but menu handler IS present) 0 : menu item NOT handled (menu item will be greyed)
For a dynamic menu: (preliminary) - popup menu items only (not found in top-level menus) -1 : disabled the menu 0 : 'not handled' or 'error' (no dynamic menu will be added or displayed) >0 : a 'secure internal pointer hash' representing an actual pointer value (preliminary, RESERVED) this pointer will be to a WBAlloc'd block of memory describing the menu items (as text). It will be necessary for the caller to interpret this text to create the dynamic memory items. PRELIMINARY: the text will be 'menu text\tAtom Name' - no hotkeys, no tooltip text. The menu text can include underscores which will only work when the popup is available
Whenever this message is received, you should NOT call WBDestroyPointerHash() for the WBMenu object pointer, nor for the WBMenuItem object pointer. This will be done automatically by the message framework.
Definition at line 204 of file window_helper.c.