X11workbench Toolkit  1.0
Menu Bar window - functions and structures

Data Structures

struct  tagWBMenuBarWindow
 structure for defining a menu bar window More...
 

Typedefs

typedef struct tagWBMenuBarWindow WBMenuBarWindow
 structure for defining a menu bar window More...
 

Functions

int MBInitGlobal (void)
 Initialize global resources for Menu Bar windows. More...
 
WB_FONTC MBGetDefaultMenuFont (void)
 Get a pointer to the default 'Menu Bar' font structure. More...
 
static __inline__ WBMenuBarWindowMBGetMenuBarWindowStruct (Window wID)
 Obtain a pointer to the WBMenuBarWindow structure from a Window ID of a Menu Bar window. More...
 
WBMenuBarWindowMBCreateMenuBarWindow (Window wIDParent, const char *pszResource, int iFlags)
 Create a Menu Bar windows and its associated WBMenuBarWindow structure. More...
 
WBMenuBarWindowMBFindMenuBarWindow (WBMenu *pMenu)
 Locate the first WBMenuBarWindow that is using a WBMenu structure. More...
 
void MBReCalcMenuBarWindow (WBMenuBarWindow *pMenuBar)
 Cause a 'layout recalculation' for a Menu Bar window. More...
 
void MBDestroyMenuBarWindow (WBMenuBarWindow *pMenuBar)
 Destroy a 'Menu Bar' window. More...
 
static __inline__ WBMenuMBGetMenuBarMenu (WBMenuBarWindow *pMenuBar)
 Get the current WBMenu for a Menu Bar window. More...
 
static __inline__ WBMenuMBSetMenuBarMenu (WBMenuBarWindow *pMenuBar, WBMenu *pMenu)
 Assign a new WBMenu for a Menu Bar window. More...
 
void MBSetMenuBarMenuResource (WBMenuBarWindow *pMenuBar, const char *pszMenuResource)
 Assign a new WBMenu for a Menu Bar window. More...
 

Variables

Atom aMENU_RESIZE
 Internal Client Message Atom for 'RESIZE' notification (tells menu bar to resize itself) More...
 
Atom aMENU_ACTIVATE
 Internal Client Message Atom for 'ACTIVATE' notification. More...
 
Atom aMENU_DISPLAY_POPUP
 Internal Client Message Atom for 'DISPLAY POPUP' action. More...
 
XColor clrMenuFG
 menu foreground color
 
XColor clrMenuBG
 menu background color
 
XColor clrMenuActiveFG
 menu 'active' foreground color
 
XColor clrMenuActiveBG
 menu 'active' background color
 
XColor clrMenuBorder1
 menu border color 1
 
XColor clrMenuBorder2
 menu border color 2
 
XColor clrMenuBorder3
 menu border color 3
 
XColor clrMenuDisabledFG
 menu 'disabled' foreground color
 
XColor clrMenuActiveDisabledFG
 menu 'disabled but active' foreground color
 

Detailed Description

Structures and API functions for managing and working with menu bar windows. A menu bar is a window that contains one or more text menu items, usually displaying a popup menu whenever a text menu item is activated. The popup menu is displayed as needed (normally hidden).
Normally a menu bar will be part of a frame window, and will appear at the top.

Typedef Documentation

◆ WBMenuBarWindow

structure for defining a menu bar window

Definition for the structure that defines a menu bar window

typedef struct tagWBMenuBarWindow
{
unsigned int ulTag; // tag indicating I'm a 'Menu Bar' window
Window wSelf; // The window ID of the menu bar window
Window wOwner; // The window ID of the owning window
WBMenu *pMenu; // a pointer to the associated WBMenu structure
int iX; // menu bar 'X' position within the owner's client area
int iY; // menu bar 'Y' position within the owner's client area
int iWidth; // menu bar width
int iHeight; // menu bar height
int iSelected; // currently selected menu (for internal-only menu UI purposes)
int iPrevSel; // previously selected menu item (for internal-only menu UI purposes)
int iFlags; // flags that determine behavior (reserved)
See also
WBMenu

Function Documentation

◆ MBCreateMenuBarWindow()

WBMenuBarWindow* MBCreateMenuBarWindow ( Window  wIDParent,
const char *  pszResource,
int  iFlags 
)

Create a Menu Bar windows and its associated WBMenuBarWindow structure.

Parameters
wIDParentThe Window ID for the owning window
pszResourcea 0-byte terminated string resource that defines the menu
iFlagsAdditional binary flags
Returns
A pointer to the associated WBMenuBarWindow structure, or NULL on error

Use this function to create a Menu Bar windows and its associated WBMenuBarWindow structure. You must call MBDestroyMenuBarWindow() for any non-NULL return value.

Header File: menu_bar.h

Definition at line 343 of file menu_bar.c.

◆ MBDestroyMenuBarWindow()

void MBDestroyMenuBarWindow ( WBMenuBarWindow pMenuBar)

Destroy a 'Menu Bar' window.

Parameters
pMenuBarA pointer to the WBMenuBarWindow structure associated with a Menu Bar window
Returns
void

Use this function to destroy a WBMenuBarWindow structure and the associated Menu Bar window, as created using WBCreateMenBarWindow()

Header File: menu_bar.h

Definition at line 511 of file menu_bar.c.

◆ MBFindMenuBarWindow()

WBMenuBarWindow* MBFindMenuBarWindow ( WBMenu pMenu)

Locate the first WBMenuBarWindow that is using a WBMenu structure.

Parameters
pMenuA pointer to a WBMenu structure
Returns
A pointer to the first WBMenuBarWindow structure that is using 'pMenu'

Use this function to locate the first 'Menu Bar' window that is using a specific WBMenu structure

Header File: menu_bar.h

Definition at line 492 of file menu_bar.c.

◆ MBGetDefaultMenuFont()

WB_FONTC MBGetDefaultMenuFont ( void  )

Get a pointer to the default 'Menu Bar' font structure.

Returns
A pointer to the default WB_FONTC for 'Menu Bar' windows

Use this function to obtain a pointer to the default 'Menu Bar' font structure

Header File: menu_bar.h

Definition at line 338 of file menu_bar.c.

◆ MBGetMenuBarMenu()

static __inline__ WBMenu* MBGetMenuBarMenu ( WBMenuBarWindow pMenuBar)
static

Get the current WBMenu for a Menu Bar window.

Parameters
pMenuBarA pointer to the WBMenuBarWindow structure associated with a Menu Bar window
Returns
A pointer to the WBMenu associated with this Menu Bar window

Use this function to safely obtain the current WBMenu for a specified Menu Bar window.

Header File: menu_bar.h

Definition at line 269 of file menu_bar.h.

◆ MBGetMenuBarWindowStruct()

static __inline__ WBMenuBarWindow* MBGetMenuBarWindowStruct ( Window  wID)
static

Obtain a pointer to the WBMenuBarWindow structure from a Window ID of a Menu Bar window.

Parameters
wIDThe Window ID for a 'Menu Bar' window
Returns
A pointer to the associated WBMenuBarWindow structure, or NULL on error

Use this function to obtain the WBMenuBarWindow struct pointer for a 'Menu Bar' window.

Header File: menu_bar.h

Definition at line 191 of file menu_bar.h.

◆ MBInitGlobal()

int MBInitGlobal ( void  )

Initialize global resources for Menu Bar windows.

Returns
non-zero on success, zero on error

Use this function to initialize the 'Menu Bar' support.

Header File: menu_bar.h

Definition at line 177 of file menu_bar.c.

◆ MBReCalcMenuBarWindow()

void MBReCalcMenuBarWindow ( WBMenuBarWindow pMenuBar)

Cause a 'layout recalculation' for a Menu Bar window.

Parameters
pMenuBarA pointer to the WBMenuBarWindow structure associated with a Menu Bar window
Returns
void

Use this function to re-calculate the layout of a Menu Bar window. Typically this will be done as a result of a re-size on the owning window, or as a result of re-assigning a new WBMenu.

Header File: menu_bar.h

Definition at line 504 of file menu_bar.c.

◆ MBSetMenuBarMenu()

static __inline__ WBMenu* MBSetMenuBarMenu ( WBMenuBarWindow pMenuBar,
WBMenu pMenu 
)
static

Assign a new WBMenu for a Menu Bar window.

Parameters
pMenuBarA pointer to the WBMenuBarWindow structure associated with a Menu Bar window
pMenuA pointer to a new WBMenu to be assigned to the Menu Bar window. Can be NULL.
Returns
previously assigned WBMenu

Use this function to safely assign a new WBMenu to a Menu Bar window. This resource will be destroyed when the Menu Bar window is destroyed, so if you keep a cached copy and maintain it outside of the Menu Bar, be sure and assign a WBMenu of 'NULL' before destroying the menu bar.

Header File: menu_bar.h

Definition at line 292 of file menu_bar.h.

◆ MBSetMenuBarMenuResource()

void MBSetMenuBarMenuResource ( WBMenuBarWindow pMenuBar,
const char *  pszMenuResource 
)

Assign a new WBMenu for a Menu Bar window.

Parameters
pMenuBarA pointer to the WBMenuBarWindow structure associated with a Menu Bar window
pszMenuResourceA pionter to a 'menu resource' (const) character string that will be used to replace the current menu

Use this function to safely replace the menu resource for a Menu Bar window. The existing WBMenu will be destroyed. If you want to preserve the existing WBMenu, use MBSetMenuBarMenu() instead, after constructing the replacement WBMenu from the resource.

Header File: menu_bar.h

Definition at line 530 of file menu_bar.c.

Variable Documentation

◆ aMENU_ACTIVATE

Atom aMENU_ACTIVATE

Internal Client Message Atom for 'ACTIVATE' notification.

Atom for 'ACTIVATE' client event.

XClientMessageEvent members: window = menu bar window ID message_type = aMENU_ACTIVATE format = 32

To activate a specific menu item: data.l[0] = Hashed pointer to WBMenuItem - see WBGetPointerFromHash() data.l[1] = the index for menu item

To move to the previous or next menu item in the list: data.l[0] = 0 data.l[1] = 1 or -1; 1 moves 'next', -1 'previous', 0 'first'. others undefined.

Definition at line 150 of file menu_bar.c.

◆ aMENU_DISPLAY_POPUP

Atom aMENU_DISPLAY_POPUP

Internal Client Message Atom for 'DISPLAY POPUP' action.

Atom for 'DISPLAY POPUP' client event.

XClientMessageEvent members: window = menu bar window ID message_type = aMENU_DISPLAY_POPUP format = 32 data.l[0] = popup menu identifier data.l[1] = X coordinate for popup 'left' side data.l[2] = X coordinate for popup 'right' side (left side plus text extent)

Definition at line 165 of file menu_bar.c.

◆ aMENU_RESIZE

Atom aMENU_RESIZE

Internal Client Message Atom for 'RESIZE' notification (tells menu bar to resize itself)

Atom for 'RESIZE' client event.

XCLientMessageEvent members: window = menu bar window ID message_type = aMENU_RESIZE format = 32

(no data members)

Definition at line 130 of file menu_bar.c.