os::MenuItem Class Reference
[The Syllable Graphical User Interface API]

Menu item class. More...

Inheritance diagram for os::MenuItem:

os::Invoker os::CheckMenu os::MenuSeparator List of all members.

Public Member Functions

 MenuItem (const String &cLabel, Message *pcMsg, const String &cShortcut="", Image *pcImage=NULL)
 Constructor.
 MenuItem (Menu *pcMenu, Message *pcMsg, const String &cShortcut="", Image *pcImage=NULL)
 Constructor.
 ~MenuItem ()
 internal
MenuGetSubMenu () const
 Gets the Sub Menu(Menu that is inside the MenuItem).
MenuGetSuperMenu () const
 Gets the Super Menu(Menu that holds the MenuItem).
Rect GetFrame () const
 Gets the frame of the MenuItem.
virtual Point GetContentSize ()
 Gets the size of the MenuItem.
virtual float GetColumnWidth (int nColumn) const
 Gets the size of a column.
virtual int GetNumColumns () const
 Get number of columns.
const StringGetLabel () const
 Gets the label of the MenuItem.
void SetLabel (const os::String &cTitle)
 Sets the label of the MenuItem.
virtual void Draw ()
 Draws the os::MenuItem.
Point GetContentLocation () const
 Returns the current location of this item.
virtual bool Invoked (Message *pcMessage)
 Intercept outgoing messages.
void SetEnable (bool bEnabled)
 Tells the system to disable or enable this element.
bool IsEnabled () const
 Tells the programmer whether this element is enabled or disabled.
virtual void SetHighlighted (bool bHighlighted)
 Tells the system to highlight or unhighlight this element.
bool IsHighlighted () const
 Tells the programmer whether this element is highlighted or not highlighted.
ImageGetImage () const
 Gets the image that is attached to the MenuItem.
void SetImage (Image *pcImage, bool bRefresh=false)
 Sets the image that you want to attach to the MenuItem.
void SetShortcut (const String &cShortcut)
 Sets the shortcut for the MenuItem.
const StringGetShortcut () const
 Gets the shortcut for the menu item.
virtual bool IsSelectable () const
 Tells the system whether or not this item can be selected.

Friends

class Menu

Classes

class  Private

Detailed Description

Description:
The MenuItem class is what you use to insert into a menu
Author:
Kurt Skauen ([email protected]) with modifications by the Syllable team


Constructor & Destructor Documentation

MenuItem::MenuItem ( const String cLabel,
Message pcMsg,
const String cShortcut = "",
Image pcImage = NULL 
)

Description:
This MenuItem constructor will create a MenuItem with and Image attached to it.
Parameters:
cLabel - The label that will be displayed.
pcMsg - The message that will be passed when invoked.
cShortcut - Keyboard shortcut.
pcImage - The image that will be attached to the MenuItem.
Example:
        Menu* pcMenu = new Menu(Rect(),"main_menu",os::ITEMS_IN_ROW, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates the main menu
        Menu* pcSubMenu = new Menu(Rect(),"File", ITEMS_IN_COLUMN, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates the file menu
        File cFile = File("./options.png"); //not the best way to do this, because then options.png will need to be in the same directory as the application at all times.
        Image* pcImage = new BitmapImage(&cFile);
        MenuItem* pcItem("Options",NULL,pcImage) // creates the menu item with the sub menu and image.
        pcSubMenu->AddItem(pcItem); //attaches the item to the file menu
        pcMenu->AddItem(pcSubMenu) //attaches the file menu to the main menu
See also:
os::Menu, os::MenuSeparator
Author:
Kurt Skauen(with modifications by the Syllable Team).

MenuItem::MenuItem ( Menu pcMenu,
Message pcMsg,
const String cShortcut = "",
Image pcImage = NULL 
)

Description:
This MenuItem constructor will create a menu item that holds a sub menu and attaches an image to the menuitem.
Parameters:
pcMenu - The menu that will be a sub menu.
pcMsg - The message that will be passed when invoked.
cShortcut - Keyboard shortcut.
pcImage - The image that will be attached to this menu item.
Example:
        Menu* pcMenu = new Menu(Rect(),"main_menu",os::ITEMS_IN_ROW, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates the main menu
        Menu* pcSubMenu = new Menu(Rect(),"File", ITEMS_IN_COLUMN, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates the file menu
        Menu* pcOptionsMenu = new Menu(Rect(),"Options", ITEMS_IN_COLUMN, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates the option menu
        File cFile = File("./options.png"); //not the best way to do this, because then options.png will need to be in the same directory as the application at all times.
        Image* pcImage = new BitmapImage(&cFile);
        MenuItem* pcItem(pcMenu,NULL,pcImage) // creates the menu item with the sub menu and image.
        pcSubMenu->AddItem(pcItem); //attaches the item to the file menu
        pcMenu->AddItem(pcSubMenu) //attaches the file menu to the main menu
See also:
os::Menu, os::MenuSeparator
Author:
Kurt Skauen(with modifications by the Syllable Team).

MenuItem::~MenuItem (  ) 


Member Function Documentation

Menu * MenuItem::GetSubMenu (  )  const

..

Description:
Gets the Sub Menu(Menu that is inside the MenuItem)...
Returns:
This method returns NULL if there is no Sub Menu and returns the Sub Menu(os::Menu) if there is a Sub Menu.
See also:
SetSubMenu()
Author:
Kurt Skauen(with modifications from the Syllable team)

Menu * MenuItem::GetSuperMenu (  )  const

..

Description:
Gets the Super Menu(Menu that holds the MenuItem)...
Returns:
This method returns NULL if there is no Super Menu and retuns the Super Menu(os::Menu) if there is a Super Menu.
See also:
SetSuperMenu()
Author:
Kurt Skauen(with modifications from the Syllable team)

Rect MenuItem::GetFrame (  )  const

..

Description:
Gets the frame of the MenuItem.
Returns:
The frame as an os::Rect
See also:
SetFrame()
Author:
Kurt Skauen(with modifications from the Syllable team)

Point MenuItem::GetContentSize (  )  [virtual]

..

Description:
Gets the size of the MenuItem.
Returns:
The size of the MenuItem as an os::Point
Author:
Kurt Skauen(with modifications from the Syllable team)

Reimplemented in os::MenuSeparator.

float MenuItem::GetColumnWidth ( int  nColumn  )  const [virtual]

Description:
Gets the size of a column. Column 0 is the space used for icons, 1 is the space for text and 2 is the space normally used for shortcuts.
Returns:
The width of the column
Author:
Henrik Isaksson ([email protected])

int MenuItem::GetNumColumns (  )  const [virtual]

Description:
Returns the number of columns. Normally there are three columns. Column 0 is the space used for icons, 1 is the space for text and 2 is the space normally used for shortcuts.
Returns:
Number of columns
Author:
Henrik Isaksson ([email protected])

const String & MenuItem::GetLabel (  )  const

..

Description:
Gets the label of the MenuItem.
Returns:
The label of the MenuItem as an os::String
Author:
Kurt Skauen(with modifications from the Syllable team)

void MenuItem::SetLabel ( const os::String cLabel  ) 

..

Description:
Sets the label of the MenuItem.
cLabel - The label of the MenuItem as an os::String
Author:
Arno Klenke

void MenuItem::Draw (  )  [virtual]

Description:
This method draws the MenuItem, make sure you call Flush() before calling this method.
See also:
os::View::Draw()
Author:
Kurt Skauen with modifications by the Syllable Team.

Reimplemented in os::CheckMenu, and os::MenuSeparator.

Point MenuItem::GetContentLocation (  )  const

..

Description:
Returns the current location of this item. It returns it as a os::Point
See also:
Author:
Kurt Shauen (with modifications from the Syllable team)

bool MenuItem::Invoked ( Message pcMessage  )  [virtual]

Description:
This member is called from Invoke() just before a message is sendt to the target.
This allow classes that inherits from os::Invoker to add data to or otherwhice modify the message before it is sendt. The message can also be canceled entirely by returning false from this member.
The message passed to Invoked() is a copy of the internal message or the message passed to Invoke() (if any) so any changes made here will not affect the internal message or the message passed to Invoke(). When this method returns the message will imidiatly be sendt to the target and then discarded (unless false is returned in which case the message is simply discarded).
The default implementation of this member does nothing and return true.
Parameters:
pcMessage Pointer to the message that is about to be sendt. You can do any modification you like to this message (but never delete it).
Returns:
Normally you should return true to indicate that the message should be sendt. You can however return false if you for some reason want to cancel the invokation.
See also:
Invoke(), SetMessage(), SetTarget()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::Invoker.

Reimplemented in os::CheckMenu.

void MenuItem::SetEnable ( bool  bEnabled  ) 

..

Description:
This method will tell the system to disable or enable this element.
Parameters:
bEnabled - To enable this element set this to true(default) and to disable set this to false.
See also:
IsEnabled()
Author:
Rick Caudill ([email protected])

bool MenuItem::IsEnabled ( void   )  const

..

Description:
This method will tell programmer whether or not this element is enabled.
Returns:
This method returns true if this MenuItem is enabled and false if it is not.
See also:
SetEnable()
Author:
Rick Caudill ([email protected])

void MenuItem::SetHighlighted ( bool  bHighlighted  )  [virtual]

..

Description:
This method will tell the system to highlight or unhighlight this element.
Parameters:
bHighlighted - To highlight this element set this to true(default) and to unhighlight set this to false.
See also:
IsHighlighted()
Author:
Rick Caudill ([email protected])

Reimplemented in os::CheckMenu, and os::MenuSeparator.

bool MenuItem::IsHighlighted (  )  const

..

Description:
This method will tell programmer whether this element is highlighted or not highlighted.
Returns:
This method returns true if the MenuItem is highlighted and false if it is not.
See also:
SetHighlighed()
Author:
Rick Caudill ([email protected])

Image * MenuItem::GetImage (  )  const

..

Description:
Gets the image that is attached to the MenuItem.
Returns:
This method will return an image pointer that is attached to the MenuItem. It will return a null Image if the Image is not set.
See also:
SetImage()
Author:
Rick Caudill ([email protected])

void MenuItem::SetImage ( Image pcImage,
bool  bRefresh = false 
)

..

Description:
Sets the image that you want to attach to the MenuItem...
Parameters:
pcImage - the image to be placed on the MenuItem.
bRefresh - tell the system whether to or not to redraw the MenuItem
See also:
GetImage()
Author:
Rick Caudill ([email protected])

void MenuItem::SetShortcut ( const String cShortcut  ) 

Description:
Sets the shortcut for the MenuItem.
See also:
GetShortcut()
Parameters:
cShortcut - The shortcut key that will invoke with this menuitem.
Author:
Rick Caudill ([email protected])

const String & MenuItem::GetShortcut (  )  const

..

Description:
Gets the shortcut for the menu item...
Returns:
Right now this will return a default shortcut(until we implement shortcuts)
See also:
SetShortcut()
Author:
Rick Caudill ([email protected])

bool MenuItem::IsSelectable (  )  const [virtual]

Description:
Tells the system whether or not this item can be selected.
Author:
Rick Caudill([email protected])

Reimplemented in os::CheckMenu, and os::MenuSeparator.


Friends And Related Function Documentation

friend class Menu [friend]


Generated on Sat May 9 22:51:36 2009 for Syllable higlevel API by  doxygen 1.5.1