#include <GMenu.h>
Public Member Functions | |
GMenu () | |
Constructor. | |
virtual | ~GMenu () |
Destructor. | |
GViewI * | WindowHandle () |
Returns the top level window that this menu is attached to. | |
bool | Attach (GViewI *p) |
Attach the menu to a window. | |
bool | Detach () |
Detact the menu from the window. | |
bool | Load (GView *p, const char *Res, const char *Tags=0) |
Load the menu from a resource file. | |
bool | OnKey (GView *v, GKey &k) |
See if any of the accelerators match the key event. | |
Static Public Member Functions | |
static GFont * | GetFont () |
Returns the font used by the menu items. | |
Protected Attributes | |
List< GAccelerator > | Accel |
List of keyboard shortcuts in the menu items attached. | |
Friends | |
class | GSubMenu |
class | GMenuItem |
class | GWindow |
This class contains GMenuItem's and GSubMenu's.
A basic menu can be constructed inside a GWindow like this:
Menu = new GMenu; if (Menu) { Menu->Attach(this); GSubMenu *File = Menu->AppendSub("&File"); if (File) { File->AppendItem("&Open\tCtrl+O", IDM_OPEN, true); File->AppendItem("&Save All\tCtrl+S", IDM_SAVE_ALL, true); File->AppendItem("Save &As", IDM_SAVEAS, true); File->AppendSeparator(); File->AppendItem("&Options", IDM_OPTIONS, true); File->AppendSeparator(); File->AppendItem("E&xit", IDM_EXIT, true); } GSubMenu *Help = Menu->AppendSub("&Help"); if (Help) { Help->AppendItem("&Help", IDM_HELP, true); Help->AppendItem("&About", IDM_ABOUT, true); } }
Or you can load a menu from a resource like this:
bool GMenu::Load | ( | GView * | p, | |
const char * | Res, | |||
const char * | Tags = 0 | |||
) |
Load the menu from a resource file.
p | The parent view for any error message boxes |
Res | The resource to load. Will probably change to an int sometime. |
Tags | Optional list of comma or space separated tags |
Referenced by GDocApp< OptionsFmt >::_LoadMenu().
See if any of the accelerators match the key event.
v | The view that will eventually receive the key event |
k | The keyboard event details |
References Accel, GUiEvent::Alt(), GKey::c16, GUiEvent::Down(), List< Type >::First(), List< Type >::Next(), and GSubMenu::Window.