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

The menuing system for Syllable. More...

Inheritance diagram for os::Menu:

os::View os::Handler List of all members.

Public Member Functions

 Menu (Rect cFrame, const String &cName, MenuLayout_e eLayout, uint32 nResizeMask=CF_FOLLOW_LEFT|CF_FOLLOW_RIGHT|CF_FOLLOW_TOP, uint32 nFlags=WID_WILL_DRAW|WID_CLEAR_BACKGROUND|WID_FULL_UPDATE_ON_RESIZE)
 Constructor.
 ~Menu ()
 internal
int Lock (void) const
 Locks the Menu.
void Unlock (void) const
 Unlocks the Menu.
virtual void TimerTick (int nID)
 Timer dispatch member.
void AttachedToWindow (void)
void DetachedFromWindow (void)
void WindowActivated (bool bIsActive)
 Hook called when the window hosting this view gain or loose focus.
Point GetPreferredSize (bool bLargest) const
 Returns the exact size of the Menu.
virtual void MouseDown (const Point &cPosition, uint32 nButtons)
 Hook called by the system when a mouse button is pressed.
virtual void MouseUp (const Point &cPosition, uint32 nButtons, Message *pcData)
 Hook called by the system when a mouse button is release.
virtual void MouseMove (const Point &cNewPos, int nCode, uint32 nButtons, Message *pcData)
 Hook called by the system when the mouse is moved.
virtual void KeyDown (const char *pzString, const char *pzRawString, uint32 nQualifiers)
 Hook called by the system when a key is pressed while the view has focus.
virtual void FrameSized (const Point &cDelta)
 Virtual hook called by the system when the view is resized.
virtual void Paint (const Rect &cUpdateRect)
 Called by the system update "damaged" areas of the view.
String GetLabel () const
 Gets the label of the Menu.
void SetLabel (const os::String &cLabel)
 Sets the label of the Menu.
MenuLayout_e GetLayout () const
 Gets the layout of the Menu.
bool AddItem (const String &cLabel, Message *pcMessage, const String &cShortcut="", Image *pcImage=NULL)
 Adds a MenuItem.
bool AddItem (MenuItem *pcItem)
 Adds a MenuItem.
bool AddItem (MenuItem *pcItem, int nIndex)
 Adds a MenuItem.
bool AddItem (Menu *pcItem)
 Adds a MenuItem.
bool AddItem (Menu *pcItem, int nIndex)
 Adds a MenuItem.
MenuItemRemoveItem (int nIndex)
 Removes an MenuItem.
bool RemoveItem (MenuItem *pcItem)
 Removes an MenuItem.
bool RemoveItem (Menu *pcMenu)
 Removes an MenuItem.
MenuItemGetItemAt (int nIndex) const
 Gets the MenuItem at a certain index number.
MenuItemGetItemAt (Point cPos) const
 Gets the MenuItem at a certain point.
MenuGetSubMenuAt (int nIndex) const
 Gets the SubMenu determined by the passing index number.
int GetItemCount (void) const
 Returns the number of items in the Menu.
int GetIndexOf (MenuItem *pcItem) const
 Returns the number of the MenuItem's position.
int GetIndexOf (Menu *pcMenu) const
 Returns the number of the Menu's position.
MenuItemFindItem (int nCode) const
 Method that finds an item by a certain Message code.
MenuItemFindItem (const String &cName) const
 Method that finds an item by a certain name.
MenuItemFindMarked () const
 Gets the MenuItem that is Hightlighted.
virtual status_t SetTargetForItems (Handler *pcTarget)
 Sets the object that the MenuItems will send messages to.
virtual status_t SetTargetForItems (Messenger cMessenger)
 Sets the object that the MenuItems will send messages to.
MenuGetSuperMenu () const
 Gets the Menu that the Menu is attached to.
MenuItemGetSuperItem ()
 Gets the MenuItem that the Menu is attached to.
void InvalidateLayout ()
 Refreshes the layout of the Menu.
void SetCloseMessage (const Message &cMsg)
 Sets the message.
void SetCloseMsgTarget (const Messenger &cTarget)
 Sets Target for Menu.
MenuItemTrack (const Point &cScreenPos)
 Go to a certain MenuItem by screen position.
void Open (Point cScrPos)
 Opens the Menu at a specific position.
void SetEnable (bool)
 Tells the system to disable or enable this element.
bool IsEnabled ()
 Tells the programmer whether this element is enabled or disabled.

Friends

class MenuItem

Classes

class  Private

Detailed Description

Description:
The menuing system for Syllable.
See also:
os::MenuItem, os::MenuSeparator()
Author:
Kurt Skauen ([email protected]) with modifications and improvements by the Syllable team.


Constructor & Destructor Documentation

Menu::Menu ( Rect  cFrame,
const String cTitle,
MenuLayout_e  eLayout,
uint32  nResizeMask = CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP,
uint32  nFlags = WID_WILL_DRAW | WID_CLEAR_BACKGROUND | WID_FULL_UPDATE_ON_RESIZE 
)

Description:
The Menu constructor initializes the local object.
Parameters:
cFrame - The frame that holds the size of the Menu.
cTitle - The label that will be displayed.
eLayout - The layout of the Menu. OS::ITEMS_IN_ROW for displaying items horizontally and OS::ITEMS_IN_COLUMN for displaying items vertically.
nResizeMask - The parameters of how you want the Menu to resize when resizing the Application it is attached to. Look at os::View for more documentatinon.
nFlags - The view flags that will be passed to the Menu.
Example:
        Menu* pcMenu = new Menu(Rect(),"main_menu",os::ITEMS_IN_ROW, CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP ); //creates a menu and this menu would be attached to another menu(main menu)
        Menu* pcFileMenu = new Menu(Rect(),"File",os::ITEMS_IN_COLUMN,CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP);
        pcFileMenu->AddItem("Open",new Message());
        pcMenu->AddItem(pcFileMenu); //add the file menu to the main_menu
        
        //this code will create a new frame for the menu so that the Menu will fit the Application better
        Rect cMenuFrame;
        cMenuFrame.left = 0;
        cMenuFrame.top = 0;
        cMenuFrame.right = GetBounds().Width();
        cMenuFrame.bottom = m_pcMenu->GetPreferredSize(true).y;
        pcMenu->SetFrame(cMenuFrame);
See also:
os::Menu, os::MenuSeparator
Author:
Kurt Skauen(with modifications by Rick Caudill).

Menu::~Menu (  ) 


Member Function Documentation

int Menu::Lock ( void   )  const

..

Description:
Locks the Menu and all of it items so that the user/programmer cannot modify them.
Note:
If you call the method make sure you unlock it before you try and modify the Menu or any of the items in the Menu.
See also:
Unlock
Author:
Kurt Skauen(with modifications from the Syllable team)

void Menu::Unlock ( void   )  const

..

Description:
Unlocks the Menu. Call this is you called Lock() so that you can modify the Menu again.
See also:
Lock()
Author:
Kurt Skauen(with modifications from the Syllable team)

void Menu::TimerTick ( int  nID  )  [virtual]

Description:
This member will be called by the looper thread when a timer targeting this handler expires.
When a timer created with os::Looper::AddTimer() expires the looper thread will lock the looper and call this member on the target for the expired timer. If more than one timers are created it is possible to distinguish them by the timer ID that is assigned to the timer with os::Looper::AddTimer() and that is passed to TimerTick() through the nID parameter.
Note:
Never do any lenthy operations in any hook members that are called from the looper thread if the looper is involved with the GUI (for example if the looper is a os::Window). The looper will not be able to dispatch messages until the hook returns so spending a long time in this members will make the GUI feel unresponsive.
Warning:
Parameters:
\return 
Error codes:
See also:
Author:
Kurt Skauen ([email protected])

Reimplemented from os::Handler.

void Menu::AttachedToWindow ( void   )  [virtual]

Reimplemented from os::View.

void Menu::DetachedFromWindow ( void   )  [virtual]

Reimplemented from os::View.

void Menu::WindowActivated ( bool  bIsActive  )  [virtual]

Description:
This is a callback member that can be overloaded by derived classes to learn when the window that this view is hosted by is activated and when it is deactivated. The bIsActive parameter tell whether the focus was lost or gained. This member is called whenever the window changes focus independent of whether the view is active or not.
Note:
This is a hook function that is called by the system to notify about an event. You should never call this member yourself.
The window is locked when this member is called.
Parameters:
bIsActive - true if the window gain and false if it loose focus.
See also:
MakeFocus(), Activated()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

Point Menu::GetPreferredSize ( bool  bLargest  )  const [virtual]

Description:
This method returns the exact size of the menu
Returns:
Based on bLargest. If bLargest is true then it will return the maximum size of the Menu, otherwise it will return the size of the Menu plus two more pixels high and two more pixels wide.
Author:
Kurt Skauen with modifications by the Syllable team.

Reimplemented from os::View.

void Menu::MouseDown ( const Point cPosition,
uint32  nButtons 
) [virtual]

Description:
This member is called from the window thread whenever a mouse button is clicked above the view. You can overload this member if your view need to know about mouse-down events.
A view will not automatically take focus when clicked so if you want that behaviour you must call MakeFocus() from an overloaded version of this member.
The default implementation of this member will call MouseDown() on it's parent view if one exists.
Parameters:
cPosition Mouse position in the views coordinate system at the time the mouse was pressed.
nButtons Index of the pressed button. Buttons start at 1 for the left button, 2 for the right button, 3 for the middle button. Additional buttons might be supported by the mouse driver and will then be assigned numbers from 4 and up.
See also:
MouseUp(), MouseMove(), WheelMoved()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void Menu::MouseUp ( const Point cPosition,
uint32  nButtons,
Message pcData 
) [virtual]

Description:
This member is called from the window thread whenever a mouse button is released above the view. You can overload this member if your view need to know about mouse-up events or if your view support drag and drop.
If mouse-up was the result of ending a drag and drop operation the pcData member will point to a Message containing the dragged data. Look at BeginDrag() for a more detailed description of the drag and drop system.
The default implementation of this member will call MouseDown() on it's parent view if one exists.
Parameters:
cPosition Mouse position in the views coordinate system at the time the mouse was pressed.
nButtons Index of the pressed button. Buttons start at 1 for the left button, 2 for the right button, 3 for the middle button. Additional buttons might be supported by the mouse driver and will then be assigned numbers from 4 and up.
pcData Pointer to a Message object containing the dragged data if this mouse-up was the end of a drag and drop operation. If no data was dragged it will be NULL.
See also:
MouseDown(), MouseMove(), WheelMoved()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void Menu::MouseMove ( const Point cNewPos,
int  nCode,
uint32  nButtons,
Message pcData 
) [virtual]

Description:
This member is called from the window thread whenever the mouse is moved above the view or if the view has focus.
Oveload this member if your view need to handle mouse-move events.
The default implementation of this member will call MouseMove() on it's parent view if one exists.
Parameters:
cNewPos New mouse position given in the views coordinate system.
nCode Enter/exit code. This is MOUSE_ENTERED when the mouse first enter the view, MOUSE_EXITED when the mouse leaves the view, MOUSE_INSIDE whenever the mouse move withing the boundary of the view and MOUSE_OUTSIDE when the mouse move outside the view (will only happen if the view has focus).
nButtons Bitmask telling which buttons that are currently pressed. Bit 0 is button 1 (left), bit 1 is button 2 (right), and bit 2 is button 3 (middle), and so on.
pcData Pointer to a Message object containing the dragged data if the user is in the middle of a drag and drop operation. Otherwise this pointer is NULL. Look at BeginDrag() for a more detailed description of the drag and drop system.
See also:
MouseDown(), MouseUp(), WheelMoved(), BeginDrag()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void Menu::KeyDown ( const char *  pzString,
const char *  pzRawString,
uint32  nQualifiers 
) [virtual]

Description:
Overload this member if your view need to handle keyboard input. This member is called to allow the view to handle M_KEY_DOWN messages. The most common members are exctracted from the message and passed as parameters but you might need to obtain the raw message with os::Looper::GetCurrentMessage() and find some members yourself if you the data you needed are not passed in.
For example if you need the raw key-code for the pressed key you will have to lookup the "_raw_key" member from the message.
Parameters:
pzString String containing a single UTF-8 encoded character. This is the character generated by the pressed key according to the current keymap accounting for any qualifiers that might be pressed.
pzRawString Same as pzString except that the key is converted without accounting for qualifiers. Ie. if 'A' is pressed while pressing <SHIFT> pzString will contain 'A' and pzRawString will contain 'a'.
nQualifiers Bitmask describing which qualifiers that was active when the key was pressed.
See also:
KeyUp(), os::Looper::GetCurrentMessage()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void Menu::FrameSized ( const Point cDelta  )  [virtual]

Description:
Overload this member if you need to know when the view is resized.
Note:
This member is called after the view is resized. If you need the old size you can subtract the cDelta calue from the current size.
Parameters:
cDelta The distance the bottom/right corner was moved relative to the upper/left corner.
See also:
FrameMoved(), SetFrame, ResizeBy(), ResizeTo()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

void Menu::Paint ( const Rect cUpdateRect  )  [virtual]

Description:
Note:
Warning:
Parameters:
cUpdateRect A rectangle enclosing all damaged areas. This is just a rough "worst-case", further fine-grained clipping will be performed by the Application Server to avoid updating non-damaged pixels and make the update as fast and flicker-free as possible.
See also:
Invalidate(), Flush()
Author:
Kurt Skauen ([email protected])

Reimplemented from os::View.

String Menu::GetLabel (  )  const

..

Description:
Gets the label that the Menu displays on the Appliction.
Returns:
The label as an os::String
See also:
Author:
Kurt Skauen(with modifications from the Syllable team)

void Menu::SetLabel ( const os::String cTitle  ) 

..

Description:
Sets the label that the Menu displays on the Appliction.
cLabel - The Label.
See also:
Author:
Arno Klenke

MenuLayout_e Menu::GetLayout (  )  const

..

Description:
Gets the layout of the Menu.
Returns:
It will return it as a MenuLayout_e.
See also:
Author:
Kurt Skauen(with modifications from the Syllable team)

bool Menu::AddItem ( const String cLabel,
Message pcMessage,
const String cShortcut = "",
Image pcImage = NULL 
)

Description:
Adds a MenuItem to the Menu.
Parameters:
cLabel - the label of the MenuItem.
pcMessage - the Message of that is passed when the MenuItem is clicked.
cShortcut - Keyboard shortcut.
pcImage - pointer to Image to use as icon. The image is deleted automatically by the Menu destructor!
Returns:
It returns true if MenuItem was added and false if it could not add the MenuItem.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::AddItem ( MenuItem pcItem  ) 

Description:
Adds a MenuItem to the Menu.
Parameters:
pcItem - the MenuItem to add
Returns:
It returns true if MenuItem was added and false if it could not add the MenuItem.
See also:
AddItem(MenuItem* pcItem, int nIndex)
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::AddItem ( MenuItem pcItem,
int  nIndex 
)

Description:
Adds a MenuItem to the Menu.
Parameters:
pcItem - the MenuItem to add
nIndex - the place where the MenuItem will be put.
Returns:
It returns true if MenuItem was added and false if it could not add the MenuItem.
See also:
AddItem(MenuItem* pcItem)
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::AddItem ( Menu pcMenu  ) 

Description:
Adds a MenuItem with the passing Menu* as its SubMenu.
Parameters:
pcMenu - the SubMenu that will be added to the Menu.
Returns:
It returns true if MenuItem was added and false if it could not add the MenuItem.
See also:
AddItem(Menu* pcMenu, int nIndex)
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::AddItem ( Menu pcMenu,
int  nIndex 
)

Description:
Adds a MenuItem with the passing Menu* as its SubMenu.
Parameters:
pcMenu - the SubMenu that will be added to the Menu.
nIndex - the place where the MenuItem will be put.
Returns:
It returns true if MenuItem was added and false if it could not add the MenuItem.
See also:
AddItem(Menu* pcMenu)
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::RemoveItem ( int  nIndex  ) 

Description:
Removes an MenuItem that is at the passed index.
Parameters:
nIndex - the index number of the MenuItem you wish to remove.
Returns:
It returns true if the MenuItem was found and removed and false if the MenuItem was not found and not removed.
See also:
RemoveItem(MenuItem* pcItem). RemoveItem(Menu* pcMenu)
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::RemoveItem ( MenuItem pcItem  ) 

Description:
Removes the MenuItem that is passed to the method.
Parameters:
pcItem - the MenuItem to remove.
Returns:
It returns true if the MenuItem was found and removed and false if the MenuItem was not found and not removed.
See also:
RemoveItem(Menu* pcMenu). RemoveItem(int nIndex)
Author:
Kurt Skauen with modifications by the Syllable team.

bool Menu::RemoveItem ( Menu pcMenu  ) 

Description:
Removes an MenuItem with the passing Menu* as its SubMenu.
Parameters:
pcMenu - the SubMenu that will be used to remove a certain item.
Returns:
It returns true if the MenuItem was found and removed and false if the MenuItem was not found and not removed.
See also:
RemoveItem(MenuItem* pcItem). RemoveItem(int nIndex)
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::GetItemAt ( int  nIndex  )  const

Description:
Gets the MenuItem at a certain index number.
Parameters:
nIndex - The index number you want to get the MenuItem from.
Returns:
The MenuItem that is at the certain index number. If there is no MenuItem at that number then it will return a Null MenuItem.
See also:
GetItemAt(Point cPosition)
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::GetItemAt ( Point  cPosition  )  const

Description:
Gets the MenuItem at a certain point.
Parameters:
cPosition - The position that you want get the MenuItem from
Returns:
The MenuItem that is at the certain point. If there is no MenuItem at that Point then it will return a Null MenuItem.
See also:
GetItemAt(int nIndex)
Author:
Kurt Skauen with modifications by the Syllable team.

Menu * Menu::GetSubMenuAt ( int  nIndex  )  const

Description:
Gets the SubMenu that is at the index(how many MenuItems down) number
Parameters:
nIndex - The index number you want to get the SubMenu from
Returns:
The SubMenu. If there is no SubMenu, it will return NULL
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

int Menu::GetItemCount ( void   )  const

Description:
Returns the number of items in the Menu.
Returns:
An interger giving the number of MenuItems there are attached.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

int Menu::GetIndexOf ( MenuItem pcItem  )  const

Description:
Returns the number of the MenuItems's position
Parameters:
pcItem - The MenuItem that you w you want to get the index of.
Returns:
An interger giving the number of places down the line that this MenuItem is attached.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

int Menu::GetIndexOf ( Menu pcMenu  )  const

Description:
Returns the number of the Menu's position
Parameters:
pcMenu - The Menu you want to get the index of.
Returns:
An interger giving the number of places down the line that this menu is attached.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::FindItem ( int  nCode  )  const

Description:
This method will find a MenuItem by a certain Message code.
Parameters:
nCode - Code of the MenuItem you wish to find.
See also:
FindItem(const String& cName)
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::FindItem ( const String cName  )  const

Description:
This method will find a MenuItem by a certain name.
Parameters:
cName - Name of the MenuItem you wish to find.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::FindMarked (  )  const

Description:
This method will give you the MenuItem is highlighted.
Returns:
This will return NULL if there is no item highlighted and if there is item then it will return that MenuItem.
See also:
FindItem()
Author:
Rick Caudill ([email protected])

status_t Menu::SetTargetForItems ( Handler pcTarget  )  [virtual]

Description:
This method will set the place of where your MenuItems will pass there message to.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

status_t Menu::SetTargetForItems ( Messenger  cMessenger  )  [virtual]

Description:
This method will set the place of where your MenuItems will pass there message to.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

Menu * Menu::GetSuperMenu (  )  const

Description:
This method will give you the Menu that the Menu is attached to.
Returns:
This will return NULL if there is not any Super Menu and if there is an Super Menu then it will return that Menu.
See also:
GetSuperItem()
Author:
Rick Caudill ([email protected])

MenuItem * Menu::GetSuperItem (  ) 

Description:
This method will give you the MenuItem that the Menu is attached to.
Returns:
This will return NULL if there is not any Super MenuItem and if there is an Super MenuItem then it will return that MenuItem.
See also:
GetSuperMenu()
Author:
Kurt Skauen with modifications by the Syllable team.

void Menu::InvalidateLayout (  ) 

..

Description:
This method will reset the layout of the Menu.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

void Menu::SetCloseMessage ( const Message cMsg  ) 

Description:
This method will set the message that will be passed to the target
See also:
SetCloseMsgTarget()
Author:
Kurt Skauen with modifications by the Syllable team.

void Menu::SetCloseMsgTarget ( const Messenger cTarget  ) 

Description:
This method will set target of where the message will be pushed to when you close the Menu.
See also:
SetCloseMessage()
Author:
Kurt Skauen with modifications by the Syllable team.

MenuItem * Menu::Track ( const Point cScreenPos  ) 

..

Description:
This method will open a menu by it's position.
Parameters:
cScreenPos - The screen position.
Note:
This method is not to be used outside this class and it will probably freeze the system if used.
See also:
Author:
Rick Caudill ([email protected])

void Menu::Open ( Point  cScrPos  ) 

Description:
Opens the Menu at a specific position.
Parameters:
cScrPos - The Point on the screen where you want the Menu to open
Note:
This method is mainly used for when you want to add a context menu to you application.
See also:
Author:
Kurt Skauen with modifications by the Syllable team.

void Menu::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 Menu::IsEnabled ( void   ) 

..

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


Friends And Related Function Documentation

friend class MenuItem [friend]


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