GMenu Class Reference

Top level window menu. More...

#include <GMenu.h>

Inheritance diagram for GMenu:

GSubMenu GTarget

List of all members.

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, char *Res, 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 GFontGetFont ()
 Returns the font used by the menu items.

Protected Attributes

List< GAcceleratorAccel
 List of keyboard shortcuts in the menu items attached.

Friends

class GSubMenu
class GMenuItem
class GWindow


Detailed Description

Top level window menu.

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:

Menu = new GMenu;
if (Menu)
{
    Menu->Attach(this);
    Menu->Load(this, "IDM_MENU");
}

Member Function Documentation

bool GMenu::Load ( GView p,
char *  Res,
char *  Tags = 0 
)

Load the menu from a resource file.

Parameters:
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

References GArray< Type >::Length().

Referenced by GDocApp< OptionsFmt >::_LoadMenu().

bool GMenu::OnKey ( GView v,
GKey k 
)

See if any of the accelerators match the key event.

Returns:
true if none of the accelerators match
Parameters:
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.


The documentation for this class was generated from the following files:

Generated on Wed Dec 1 15:41:03 2010 for Lgi by  doxygen 1.5.7.1