| Methods Index |
CNotifierSubclasses: None
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.
CMenubar *aMenubar = new CMenuBar(aCWindow,-OR-
MENU_BAR_RID);
CSubmenu aSubmenu("Window, WINDOW_TAG, 'W',
CMenu::ENABLED);
aMenubar->AppendSubmenu(aSubmenu);
aMenuBar->DoUpdate();
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);
...
}
}
}
CMenuBar(CWindow *theWindow, MENU_TAG theMenu,
BOOLEAN isImport = TRUE);
theWindow. If the flag isImport is TRUE, the menubar is loaded from the URL resource file. If isImport is FALSE, this constructor creates an empty menubar that you need to fill. The MENU_TAG cannot be equal to zero.
CMenuBar(const CMenuBar &theMenubar);
const CMenuBar &operator= (const CMenuBar &theMenuBar);
virtual ~CMenuBar();
MENU_TAG GetTag(void) const;
CWindow* GetWindow(void) const;
void DoPopup(
const CPoint& theGlobalLoc,
MENU_TAG theSubmenuPopup,
XVT_POPUP_ALIGNMENT theAlign = XVT_POPUP_LEFT_ALIGN);
theAlign attribute.
void DoPopup(
const CPoint& theGlobalLoc,
MENU_TAG theSubmenuPopup,
MENU_TAG theOverMenuItem);
theOverMenuItem menu element.
FindSubmenu method.
BOOLEAN AppendSubmenu(const CSubmenu &theSubmenu);
theSubmenu at the end of the list of submenus in the menubar. The physical menubar is not updated until DoUpdate is called.
BOOLEAN InsertSubmenu(MENU_TAG theInFrontOfTag,
const CSubmenu &theSubmenu);
theSubmenu in the list of submenus in front of the submenu tagged theInFrontOfTag. The physical menubar is not updated until DoUpdate is called.
BOOLEAN RemoveSubmenu(MENU_TAG theTag);
theTag from the menubar. The physical menubar is not updated until DoUpdate is called.
BOOLEAN ReplaceSubmenu(MENU_TAG theTag, const CSubmenu &theSubmenu);
theTag with the submenu theSubmenu. The physical menubar is not updated until DoUpdate is called.
CSubmenu* FindSubmenu(MENU_TAG theTag);
theTag, returns the existing data structure associated with the CSubmenu object. The returned pointer should not be deleted but can be modified.
const RWOrdered* GetSubmenus(void) const;
void DoUpdate(void);
DoUpdate is called. Therefore, you can call several collection methods on a menubar, then call DoUpdate once.
void SetTitle(MENU_TAG theTag,
const CStringRW &theText);
theTag's submenu to the string theText.
const CStringRW& GetTitle(MENU_TAG theTag) const;
theTag.
void SetEnabled(MENU_TAG theTag, BOOLEAN isEnabled);
isEnabled = TRUE) or disables (isEnabled = FALSE) the submenu tagged theTag.
BOOLEAN IsEnabled(MENU_TAG theTag) const;
theTag.
void SetChecked(MENU_TAG theTag, BOOLEAN isChecked);
isChecked = TRUE) or unchecks (isChecked = FALSE) the submenu tagged theTag.
BOOLEAN IsChecked(MENU_TAG theTag) const;
theTag.
BOOLEAN IsCheckable(MENU_TAG theTag) const;
TRUE if theTag both exists in the menubar or submenu and is checkable.
BOOLEAN IsInMenu(MENU_TAG theTag) const;
TRUE if theTag exists in the menubar.
static BOOLEAN IsReferenceCounted(void);
CMenuBar objects. When reference counting is on, objects are copied using the "copy-on-write" policy.
static void SetReferenceCounting(BOOLEAN isRefCounted);
CMenuBar objects. When reference counting is on, objects are copied using the "copy-on-write" policy.
CMenuBar(void);
void DestructiveHandle(void);
CMenu *FindMenu(MENU_TAG theTag);
theTag, finds the associated CMenu object.
const CMenu* FindMenu(MENU_TAG theTag) const;
const version of the above FindMenu, so you can call it from a const method.
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 );