[Classes] [Prev] [Next] [Methods]

CMenuBar

Methods Index

Heritage
Description
Usage
Protected Data Members
Public Methods
Constructor and Destructor Methods
Menubar State Methods
Pop-Up Menu Methods
Submenu Collection Methods
"Wide Interface" Methods
Reference Counting Methods
Protected Methods
Utility Methods
Menubar Utility Methods

CMenuBar


Heritage

Superclass: CNotifier

Subclasses: None


Description

CMenuBar defines the interface for menubars and submenus. This is the only class that can act on a window menubar directly.

In XVT Portability Toolkit terms, a menubar is a collection of submenus. A submenu is a collection of menu items, separators and/or submenus.


Usage

CMenubar *aMenubar = new CMenuBar(aCWindow,
MENU_BAR_RID);

CSubmenu aSubmenu("Window, WINDOW_TAG, 'W',
CMenu::ENABLED);
aMenubar->AppendSubmenu(aSubmenu);
aMenuBar->DoUpdate();
-OR-

CMenuItem aMenuItem("~Paste", PASTE_TAG, 'P', 
CMenu::ENABLED | CMenu::CHECKABLE);

aMenuBar->FindSubmenu(MENU_WINDOW)->
Append(aMenuItem);

CMenu *aMenu = aSubmenu.Find(PASTE_TAG);
BOOLEAN isSep = PtrCast(CMenuItem, aMenu)->
IsSeparator();
-OR-

aMenuBar->SetEnabled(PASTE_TAG);
-OR-

CSubmenu *aSubmenu;
RWOrderedIterator doTo(aMenuBar->GetSubmenus());

while (aSubmenu = (CSubmenu *)doTo.Next()) {
CMenu *aMenu;
RWOrderedIterator doTo2(aSubmenu->GetMenus());

while (aMenu = (CMenu *)doTo2.Next()) {
xvt_debug_printf("Menu: %s",
aMenu->GetTitle().GetCharPtr());
if (PtrCast(CSubmenu, aMenu) {
CSubMenu *aSubmenu = PtrCast(
CSubmenu, aMenu);
...
}
}
}

Protected Data Members

MENU_TAG itsTag; The menubar tag; a tag is a unique ID associated with a menu
CWindow* itsWindow; The window that owns the menubar
CMenuBarRep* itsMenuBarRep; The menubar implementation
static short itIsReferenceCounted Determines whether to operate under lazy copy on write scheme.


Public Methods

Constructor and Destructor Methods

CMenuBar(CWindow *theWindow, MENU_TAG theMenu, 
BOOLEAN isImport = TRUE);
CMenuBar(const CMenuBar &theMenubar);
const CMenuBar &operator= (const CMenuBar &theMenuBar);
virtual ~CMenuBar();

Menubar State Methods

MENU_TAG GetTag(void) const;

Pop-Up Menu Methods

CWindow* GetWindow(void) const;
void DoPopup(
const CPoint& theGlobalLoc,
MENU_TAG theSubmenuPopup,
XVT_POPUP_ALIGNMENT theAlign = XVT_POPUP_LEFT_ALIGN);
void DoPopup(
const CPoint& theGlobalLoc,
MENU_TAG theSubmenuPopup,
MENU_TAG theOverMenuItem);

Submenu Collection Methods

Submenu collection methods do not perform deep operation. They affect only the top-level submenus of a menubar. To work on a deeper submenu, you need to use the FindSubmenu method.

BOOLEAN AppendSubmenu(const CSubmenu &theSubmenu);
BOOLEAN InsertSubmenu(MENU_TAG theInFrontOfTag, 
const CSubmenu &theSubmenu);
BOOLEAN RemoveSubmenu(MENU_TAG theTag);
BOOLEAN ReplaceSubmenu(MENU_TAG theTag, const CSubmenu &theSubmenu);
CSubmenu* FindSubmenu(MENU_TAG theTag);
const RWOrdered* GetSubmenus(void) const;
void DoUpdate(void);

"Wide Interface" Methods

The following methods have a unique feature: they can be called on a submenu or menu located at any level in the submenu hierarchy. The burden of locating the submenu object is taken care of by XVT-Power++. In other words, these methods perform deep operations. They let you check, enable, set the title of any menu item or submenu. Similarly they let you query the enable state, the check state and the title directly from the menubar object. You do not have to traverse the hierarchical array of submenus. These "wide interface" methods perform their operation and immediately update the associated data structures (as opposed to the collection methods described above).

void SetTitle(MENU_TAG theTag, 
const CStringRW &theText);
const CStringRW& GetTitle(MENU_TAG theTag) const;
void SetEnabled(MENU_TAG theTag, BOOLEAN isEnabled);
BOOLEAN IsEnabled(MENU_TAG theTag) const;
void SetChecked(MENU_TAG theTag, BOOLEAN isChecked);
BOOLEAN IsChecked(MENU_TAG theTag) const;
BOOLEAN IsCheckable(MENU_TAG theTag) const;
BOOLEAN IsInMenu(MENU_TAG theTag) const;

Reference Counting Methods

static BOOLEAN IsReferenceCounted(void);
static void SetReferenceCounting(BOOLEAN isRefCounted);

Protected Methods

Utility Methods

CMenuBar(void);
void DestructiveHandle(void);
CMenu *FindMenu(MENU_TAG theTag);
const CMenu* FindMenu(MENU_TAG theTag) const;

Menubar Utility Methods

MENU_ITEM* BuildMenuDef(void); 
void InitMenuDefEntry(MENU_ITEM *theXVTMenu, 
CMenu *theMenu);
void InitSubmenuDefEntry(MENU_ITEM *theXVTMenu, CSubmenu *theSubmenu);
void InternalPopup(const CPoint& theGlobalLoc,
XVT_POPUP_ALIGNMENT theAlign,
MENU_TAG theSubmenuPopup,
MENU_TAG theOverMenuItem );


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.