X11workbench Toolkit  1.0
Frame Window Menu Handling

Macros and functions needed to set up a frame window's menu. More...

Data Structures

struct  tagWB_FW_MENU_HANDLER
 structure for managing menu callbacks More...
 

Macros

#define FW_MENU_HANDLER_BEGIN(X)   static const WBFWMenuHandler X[] = {
 Use this macro to begin definition of a WBFWMenuHandler array. More...
 
#define FW_MENU_HANDLER_ENTRY(X, Y, Z)   { (unsigned long)X, Y, Z },
 Use this macro to define an entry for a WBFWMenuHandler array. More...
 
#define FW_MENU_HANDLER_END   {0, 0, 0} };
 Use this macro to complete the definition of a WBFWMenuHandler array.
 
#define FWGetFocusWindow(pFW)   (FWGetNumContWindows(pFW) > 0 ? FWGetContainedWindowByIndex(pFW, -1) : NULL)
 A macro to aid code readability, returning the Window ID of the contained window that has the focus. More...
 

Typedefs

typedef struct tagWB_FW_MENU_HANDLER WBFWMenuHandler
 structure for managing menu callbacks More...
 

Detailed Description

Macros and functions needed to set up a frame window's menu.

Setting up a menu event handler for a frame window using the WBFWMenuHandler structures involves the use of set of macros to create the structure, and a call to FWSetMenuHandlers() to assign them to the Frame window.

Typical sample code follows:

static int FileExitHandler(XClientMessageEvent *);
static int FileOpenHandler(XClientMessageEvent *);
static int FileSaveHandler(XClientMessageEvent *);
static char szMyMenu[]="1\n"
"_File\tpopup\t2\n"
"2\n"
"_Open File\tIDM_FILE_OPEN\tOpen File\tCtrl+O\n"
"_Save File\tIDM_FILE_SAVE\tSave File\tCtrl+S\n"
"\tseparator\n"
"\tdynamic\tIDM_RECENT_FILESn"
"\tseparator\n"
"E_xit\tIDM_FILE_EXIT\tClose Application\tAlt+F4\n"
"\n";
...
FW_MENU_HANDLER_BEGIN(main_menu_handler)
FW_MENU_HANDLER_ENTRY("IDM_FILE_EXIT",FileExitHandler,NULL)
FW_MENU_HANDLER_ENTRY("IDM_FILE_OPEN",FileOpenHandler,NULL)
FW_MENU_HANDLER_ENTRY("IDM_FILE_SAVE",FileSaveHandler,NULL)
FW_MENU_HANDLER_ENTRY("IDM_RECENT_FILES",NULL,RecentFilesUIHandler)
---
// after creating the frame window 'pFrameWindow' with menu 'szMyMenu'
FWSetMenuHandlers(pFrameWindow, main_menu_handler);
See also
Frame Window APIs and Structures

Macro Definition Documentation

◆ FW_MENU_HANDLER_BEGIN

#define FW_MENU_HANDLER_BEGIN (   X)    static const WBFWMenuHandler X[] = {

Use this macro to begin definition of a WBFWMenuHandler array.

Parameters
Xthe name of the menu handler array variable

Definition at line 893 of file frame_window.h.

◆ FW_MENU_HANDLER_ENTRY

#define FW_MENU_HANDLER_ENTRY (   X,
  Y,
 
)    { (unsigned long)X, Y, Z },

Use this macro to define an entry for a WBFWMenuHandler array.

Parameters
XA menu identifier expressed as an ASCII string or ID
YA callback function pointer, or NULL - see WBFWMenuHandler::callback
ZA UI callback functino pointer, or NULL - see WBFWMenuHandler::UIcallback

Definition at line 902 of file frame_window.h.

◆ FWGetFocusWindow

#define FWGetFocusWindow (   pFW)    (FWGetNumContWindows(pFW) > 0 ? FWGetContainedWindowByIndex(pFW, -1) : NULL)

A macro to aid code readability, returning the Window ID of the contained window that has the focus.

Parameters
pFWThe WBFrameWindow structure pointer

Definition at line 942 of file frame_window.h.

Typedef Documentation

◆ WBFWMenuHandler

structure for managing menu callbacks

The WBFWMenuHandler structure is designed to be initialized via macros, so that a set of callback functions can then be easily used to handle menu events. If no menu handler is present for a menu item, or if the menu UI handler is NOT NULL and returns a non-zero value, the menu item will be disabled and displayed accordingly. It will not be possible to use its hotkey nor select it. Otherwise, the menu will be displayed normally and be selectable, and its hotkey will be able to activate it.

typedef struct tagWB_FW_MENU_HANDLER
{
uintptr_t lMenuID; // menu ID (< 0x10000L) or const pointer to string
int (* callback)(XClientMessageEvent *); // menu callback (gets pointer to the 'XClientMessageEvent')
int (* UIcallback)(WBMenu *, WBMenuItem *); // menu 'UI' callback to handle displaying menu states
// A return value of '0' displays normally, -1 disables
// Other return values are reserved
See also
FW_MENU_HANDLER_ENTRY, FW_MENU_HANDLER_BEGIN