Pyro higlevel API
Classes | Public Member Functions | Friends | List of all members

The menuing system for Syllable. More...

Inheritance diagram for os::Menu:
os::View os::Handler os::RadioMenu

Classes

class  Private
 

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. More...
 
 ~Menu ()
 internal More...
 
int Lock (void) const
 Locks the Menu... More...
 
void Unlock (void) const
 Unlocks the Menu... More...
 
virtual void TimerTick (int nID)
 Timer dispatch member. More...
 
void AttachedToWindow (void)
 
void DetachedFromWindow (void)
 
void WindowActivated (bool bIsActive)
 Hook called when the window hosting this view gain or loose focus. More...
 
Point GetPreferredSize (bool bLargest) const
 Returns the exact size of the Menu. More...
 
virtual void MouseDown (const Point &cPosition, uint32 nButtons)
 Hook called by the system when a mouse button is pressed. More...
 
virtual void MouseUp (const Point &cPosition, uint32 nButtons, Message *pcData)
 Hook called by the system when a mouse button is release. More...
 
virtual void MouseMove (const Point &cNewPos, int nCode, uint32 nButtons, Message *pcData)
 Hook called by the system when the mouse is moved. More...
 
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. More...
 
virtual void FrameSized (const Point &cDelta)
 Virtual hook called by the system when the view is resized. More...
 
virtual void Paint (const Rect &cUpdateRect)
 Called by the system update "damaged" areas of the view. More...
 
String GetLabel () const
 Gets the label of the Menu... More...
 
void SetLabel (const os::String &cLabel)
 Sets the label of the Menu... More...
 
MenuLayout_e GetLayout () const
 Gets the layout of the Menu... More...
 
bool AddItem (const String &cLabel, Message *pcMessage, const String &cShortcut="", Image *pcImage=NULL)
 Adds a MenuItem. More...
 
bool AddItem (MenuItem *pcItem)
 Adds a MenuItem. More...
 
bool AddItem (MenuItem *pcItem, int nIndex)
 Adds a MenuItem. More...
 
bool AddItem (Menu *pcItem)
 Adds a MenuItem. More...
 
bool AddItem (Menu *pcItem, int nIndex)
 Adds a MenuItem. More...
 
MenuItemRemoveItem (int nIndex)
 Removes an MenuItem. More...
 
bool RemoveItem (MenuItem *pcItem)
 Removes an MenuItem. More...
 
bool RemoveItem (Menu *pcMenu)
 Removes an MenuItem. More...
 
MenuItemGetItemAt (int nIndex) const
 Gets the MenuItem at a certain index number. More...
 
MenuItemGetItemAt (Point cPos) const
 Gets the MenuItem at a certain point. More...
 
MenuGetSubMenuAt (int nIndex) const
 Gets the SubMenu determined by the passing index number. More...
 
int GetItemCount (void) const
 Returns the number of items in the Menu. More...
 
int GetIndexOf (MenuItem *pcItem) const
 Returns the number of the MenuItem's position. More...
 
int GetIndexOf (Menu *pcMenu) const
 Returns the number of the Menu's position. More...
 
MenuItemFindItem (int nCode) const
 Method that finds an item by a certain Message code. More...
 
MenuItemFindItem (const String &cName) const
 Method that finds an item by a certain name. More...
 
MenuItemFindMarked () const
 Gets the MenuItem that is Hightlighted. More...
 
virtual status_t SetTargetForItems (Handler *pcTarget)
 Sets the object that the MenuItems will send messages to. More...
 
virtual status_t SetTargetForItems (Messenger cMessenger)
 Sets the object that the MenuItems will send messages to. More...
 
MenuGetSuperMenu () const
 Gets the Menu that the Menu is attached to. More...
 
MenuItemGetSuperItem ()
 Gets the MenuItem that the Menu is attached to. More...
 
void InvalidateLayout ()
 Refreshes the layout of the Menu... More...
 
void SetCloseMessage (const Message &cMsg)
 Sets the message. More...
 
void SetCloseMsgTarget (const Messenger &cTarget)
 Sets Target for Menu. More...
 
MenuItemTrack (const Point &cScreenPos)
 Go to a certain MenuItem by screen position... More...
 
void Open (Point cScrPos)
 Opens the Menu at a specific position. More...
 
void SetEnable (bool)
 Tells the system to disable or enable this element... More...
 
bool IsEnabled ()
 Tells the programmer whether this element is enabled or disabled... More...
 
- Public Member Functions inherited from os::View
 View (const Rect &cFrame, const String &cTitle, uint32 nResizeMask=CF_FOLLOW_LEFT|CF_FOLLOW_TOP, uint32 nFlags=WID_WILL_DRAW|WID_CLEAR_BACKGROUND)
 View constructor. More...
 
virtual ~View ()
 View destructor. More...
 
virtual void AllAttached ()
 
virtual void AllDetached ()
 
virtual void Activated (bool bIsActive)
 Hook called when the view gain or loose focus. More...
 
virtual void KeyUp (const char *pzString, const char *pzRawString, uint32 nQualifiers)
 Hook called by the system when a key is released while the view has focus. More...
 
virtual void FrameMoved (const Point &cDelta)
 Virtual hook called by the system when the view is moved within it's parent. More...
 
virtual void ViewScrolled (const Point &cDelta)
 Virtual hook called by the system when the view content is scrolled. More...
 
virtual void FontChanged (Font *pcNewFont)
 Called to notify the view that the font has changed. More...
 
virtual Point GetContentSize () const
 
virtual void WheelMoved (const Point &cDelta)
 Hook called by the system when the scroll-wheel is rotated. More...
 
virtual void AddChild (View *pcView, bool bAssignTabOrder=false)
 
void RemoveChild (View *pcChild)
 
void RemoveThis ()
 
ViewGetChildAt (const Point &cPos) const
 
ViewGetChildAt (int nIndex) const
 
ViewGetParent () const
 
ScrollBarGetVScrollBar () const
 
ScrollBarGetHScrollBar () const
 
WindowGetWindow () const
 
String GetTitle () const
 
virtual int GetTabOrder () const
 Get the keybord manouvering order. More...
 
virtual void SetTabOrder (int nOrder=NEXT_TAB_ORDER)
 Set the keyboard manouvering sorting order. More...
 
virtual const ShortcutKeyGetShortcut () const
 
virtual void SetShortcut (const ShortcutKey &cShortcut)
 Set keyboard shortcut. More...
 
virtual void SetShortcutFromLabel (const String &cLabel)
 Set keyboard shortcut from Label. More...
 
void SetContextMenu (Menu *pcMenu)
 Set popup menu for a View. More...
 
MenuGetContextMenu () const
 Get popup menu. More...
 
uint32 GetQualifiers () const
 
void GetMouse (Point *pcPosition, uint32 *pnButtons) const
 
void SetMousePos (const Point &cPosition)
 
void BeginDrag (Message *pcData, const Point &cOffset, const Bitmap *pcBitmap, Handler *pcReplyTarget=NULL)
 Start a drag and drop operation. More...
 
void BeginDrag (Message *pcData, const Point &cOffset, const Rect &cBounds, Handler *pcReplyTarget=NULL)
 Start a drag and drop operation. More...
 
void SetFlags (uint32 nFlags)
 
uint32 GetFlags (uint32 nMask=~0L) const
 
void SetResizeMask (uint32 nFlags)
 
uint32 GetResizeMask () const
 
void Show (bool bVisible=true)
 Show/hide a view and all it's children. More...
 
void Hide ()
 
bool IsVisible () const
 
virtual void MakeFocus (bool bFocus=true)
 
virtual bool HasFocus () const
 
Rect GetFrame () const
 
Rect GetBounds () const
 
Rect GetNormalizedBounds () const
 
float Width () const
 
float Height () const
 
Point GetLeftTop () const
 
virtual void SetFrame (const Rect &cRect, bool bNotifyServer=true)
 Set the size and position relative to the parent view. More...
 
virtual void MoveBy (const Point &cDelta)
 Move the view within the parent coordinate system. More...
 
virtual void MoveBy (float vDeltaX, float vDeltaY)
 
virtual void MoveTo (const Point &cPos)
 Set the views position within the parent coordinate system. More...
 
virtual void MoveTo (float x, float y)
 
virtual void ResizeBy (const Point &cDelta)
 
virtual void ResizeBy (float vDeltaW, float vDeltaH)
 
virtual void ResizeTo (const Point &cSize)
 Set a new absolute size for the view. More...
 
virtual void ResizeTo (float W, float H)
 Set a new absolute size for the view. More...
 
void SetDrawingRegion (const Region &cReg)
 Restrict rendering using a clipping region. More...
 
void ClearDrawingRegion ()
 Remove any previously assigned drawing region. More...
 
void SetShapeRegion (const Region &cReg)
 Define a non-square shape for the view. More...
 
void ClearShapeRegion ()
 Remove any previously assigned shape region. More...
 
virtual int ToggleDepth ()
 
Point ConvertFromParent (const Point &cPoint) const
 
void ConvertFromParent (Point *cPoint) const
 
Rect ConvertFromParent (const Rect &cRect) const
 
void ConvertFromParent (Rect *cRect) const
 
Point ConvertToWindow (const Point &cPoint) const
 
void ConvertToWindow (Point *cPoint) const
 
Rect ConvertToWindow (const Rect &cRect) const
 
void ConvertToWindow (Rect *cRect) const
 
Point ConvertFromWindow (const Point &cPoint) const
 
void ConvertFromWindow (Point *cPoint) const
 
Rect ConvertFromWindow (const Rect &cRect) const
 
void ConvertFromWindow (Rect *cRect) const
 
Point ConvertToScreen (const Point &cPoint) const
 
void ConvertToScreen (Point *cPoint) const
 
Rect ConvertToScreen (const Rect &cRect) const
 
void ConvertToScreen (Rect *cRect) const
 
Point ConvertFromScreen (const Point &cPoint) const
 
void ConvertFromScreen (Point *cPoint) const
 
Rect ConvertFromScreen (const Rect &cRect) const
 
void ConvertFromScreen (Rect *cRect) const
 
void Invalidate (const Rect &cRect, bool bRecurse=false)
 Add a rectangle to the damage list. More...
 
void Invalidate (bool bRecurse=false)
 Invalidate the whole view. More...
 
void Flush ()
 Flush the render queue. More...
 
void Sync ()
 Flush the render queue. More...
 
void SetDrawingMode (drawing_mode nMode)
 
drawing_mode GetDrawingMode () const
 
void SetFont (Font *pcFont)
 Change the views text font. More...
 
FontGetFont () const
 
void SetFgColor (int nRed, int nGreen, int nBlue, int nAlpha=255)
 
void SetFgColor (Color32_s sColor)
 
Color32_s GetFgColor () const
 
void SetBgColor (int nRed, int nGreen, int nBlue, int nAlpha=255)
 
void SetBgColor (Color32_s sColor)
 
Color32_s GetBgColor () const
 
void SetEraseColor (int nRed, int nGreen, int nBlue, int nAlpha=255)
 
void SetEraseColor (Color32_s sColor)
 
Color32_s GetEraseColor () const
 
void MovePenTo (const Point &cPos)
 
void MovePenTo (float x, float y)
 
void MovePenBy (const Point &cPos)
 
void MovePenBy (float x, float y)
 
Point GetPenPosition () const
 Get the current pen position. More...
 
void DrawLine (const Point &cToPoint)
 
void DrawLine (const Point &cFromPnt, const Point &cToPnt)
 
virtual void ScrollBy (const Point &cDelta)
 
virtual void ScrollBy (float vDeltaX, float vDeltaY)
 
virtual void ScrollTo (Point cTopLeft)
 
virtual void ScrollTo (float x, float y)
 
Point GetScrollOffset () const
 
void ScrollRect (const Rect &cSrcRect, const Rect &cDstRect)
 Copy a rectangle from one location to another within the view. More...
 
void FillRect (const Rect &cRect)
 
void FillRect (const Rect &cRect, Color32_s sColor)
 
void DrawBitmap (const Bitmap *pcBitmap, const Rect &cSrcRect, const Rect &cDstRect)
 Render a bitmap into the view. More...
 
void EraseRect (const Rect &cRect)
 
void DrawFrame (const Rect &cRect, uint32 nFlags)
 
void DrawRoundedFrame (const os::Rect &cReizeFrame=os::Rect(1, 4,-1,-4), const os::Color32_s &cColor=get_default_color(COL_SHADOW))
 
void DrawRoundedFrame (const os::Rect &cFrame, const os::Rect &cReizeFrame=os::Rect(1, 4,-1,-4), const os::Color32_s &cColor=get_default_color(COL_SHADOW))
 
void DrawString (const Point &cPos, const String &cString)
 
void DrawString (const String &cString)
 Render a text-string at the current pen position. More...
 
void DrawString (const char *pzStr, int Len=-1)
 
void DrawText (const Rect &cPos, const String &cString, uint32 nFlags=0)
 Render a text-string in a specified rectangle. More...
 
void DrawSelectedText (const Rect &cPos, const String &cString, const IPoint &cSel1, const IPoint &cSel2, uint32 nMode=SEL_CHAR, uint32 nFlags=0)
 
void GetSelection (const String &cClipboard="__system_clipboard__")
 
void GetTruncatedStrings (const char **pazStringArray, int nStringCount, uint32 nMode, float nWidth, char **pazResultArray) const
 
float GetStringWidth (const String &cString) const
 
float GetStringWidth (const char *pzString, int nLen=-1) const
 
void GetStringWidths (const char **apzStringArray, const int *anLengthArray, int nStringCount, float *avWidthArray) const
 
Point GetTextExtent (const String &cString, uint32 nFlags=0, int nTargetWidth=-1) const
 
int GetStringLength (const String &cString, float vWidth, bool bIncludeLast=false) const
 
int GetStringLength (const char *pzString, int nLen, float vWidth, bool bIncludeLast=false) const
 
void GetStringLengths (const char **apzStringArray, const int *anLengthArray, int nStringCount, float vWidth, int *anMaxLengthArray, bool bIncludeLast=false) const
 
void GetFontHeight (font_height *psHeight) const
 
void Ping (int nSize=0) const
 
void SetToolTip (const os::String &t)
 
os::String GetToolTip () const
 
Point ConvertToParent (const Point &cPoint) const
 Translate a os::Point into our parents coordinate system. More...
 
void ConvertToParent (Point *cPoint) const
 Translate a os::Point into our parents coordinate system. More...
 
Rect ConvertToParent (const Rect &cRect) const
 
void ConvertToParent (Rect *cRect) const
 
- Public Member Functions inherited from os::Handler
 Handler (const String &cName)
 Construct a handler. More...
 
virtual ~Handler ()
 Destructor. More...
 
virtual void HandleMessage (Message *pcMessage)
 Handle a message targeted at this handler. More...
 
String GetName () const
 Get the handlers name. More...
 
void SetName (const String &cName)
 Rename the handler. More...
 
LooperGetLooper () const
 Get a pointer to the looper this handler belongs to. More...
 
void SetNextHandler (Handler *pcNextHandler)
 Set a handler that should handle messages this handler is not interrested in. More...
 
HandlerGetNextHandler () const
 Get the next handler in a handler chain. More...
 
void AddFilter (MessageFilter *pcFilter)
 
void RemoveFilter (MessageFilter *pcFilter)
 
const MsgFilterListGetFilterList () const
 
const uint32 GetToken ()
 Get the handlers token. More...
 

Friends

class MenuItem
 

Detailed Description

Description:
The menuing system for Syllable.
See Also
os::MenuItem, os::MenuSeparator()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx) 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)
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).

References os::Menu::Private::m_cTitle, os::Menu::Private::m_eLayout, and os::Menu::Private::m_pcRoot.

Menu::~Menu ( )

Member Function Documentation

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.

References MenuItem.

Referenced by os::RadioMenu::AddItem(), AddItem(), and os::IconDirectoryView::OpenContextMenu().

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.

References AddItem(), and os::Menu::Private::m_nItemCount.

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.

References os::MenuItem::GetSubMenu(), InvalidateLayout(), os::Menu::Private::m_nItemCount, os::Menu::Private::m_pcFirstItem, and os::Menu::Private::m_pcRoot.

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.

References AddItem(), os::Menu::Private::m_nItemCount, and os::Menu::Private::m_pcRoot.

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.

References AddItem(), os::Menu::Private::m_pcRoot, and MenuItem.

void Menu::AttachedToWindow ( void  )
virtual
void Menu::DetachedFromWindow ( void  )
virtual
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.

References FindItem(), os::Message::GetCode(), os::Invoker::GetMessage(), os::MenuItem::GetSubMenu(), and os::Menu::Private::m_pcFirstItem.

Referenced by FindItem().

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.

References FindItem(), os::MenuItem::GetLabel(), os::MenuItem::GetSubMenu(), and os::Menu::Private::m_pcFirstItem.

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 (sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::MenuItem::IsHighlighted(), and os::Menu::Private::m_pcFirstItem.

Referenced by KeyDown(), os::RadioMenu::MouseUp(), and MouseUp().

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
cDeltaThe distance the bottom/right corner was moved relative to the upper/left corner.
See Also
FrameMoved(), SetFrame, ResizeBy(), ResizeTo()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References os::View::Flush(), os::View::GetBounds(), os::View::Invalidate(), os::Rect::left, os::Rect::right, and os::Point::x.

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.

References os::Menu::Private::m_pcFirstItem.

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.

References os::MenuItem::GetSubMenu(), and os::Menu::Private::m_pcFirstItem.

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.

References os::Menu::Private::m_pcFirstItem.

Referenced by GetSubMenuAt(), MouseDown(), MouseMove(), os::RadioMenu::MouseUp(), MouseUp(), os::IconDirectoryView::OpenContextMenu(), and SetEnable().

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.

References os::Rect::DoIntersect(), os::MenuItem::GetFrame(), and os::Menu::Private::m_pcFirstItem.

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.

References os::Menu::Private::m_nItemCount.

Referenced by os::RadioMenu::AddItem(), os::RadioMenu::MouseUp(), Open(), and SetEnable().

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

References os::Menu::Private::m_cTitle.

Referenced by os::MenuItem::MenuItem().

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)

References os::Menu::Private::m_eLayout.

Referenced by os::MenuItem::Draw(), os::MenuSeparator::Draw(), os::MenuItem::GetContentSize(), and os::MenuSeparator::GetContentSize().

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.

References os::Menu::Private::m_cSize, and os::Point::y.

Referenced by Open(), and Track().

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.

References GetItemAt(), and os::MenuItem::GetSubMenu().

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.
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 (sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::MenuItem::GetSuperMenu().

Referenced by KeyDown(), MouseDown(), and MouseMove().

void Menu::InvalidateLayout ( )
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 (sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::Menu::Private::m_bEnabled.

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
pzStringString 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.
pzRawStringSame 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'.
nQualifiersBitmask describing which qualifiers that was active when the key was pressed.
See Also
KeyUp(), os::Looper::GetCurrentMessage()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References FindMarked(), os::View::Flush(), os::MenuItem::GetSubMenu(), GetSuperMenu(), os::Invoker::Invoke(), os::ITEMS_IN_COLUMN, os::ITEMS_IN_ROW, os::View::KeyDown(), os::Menu::Private::m_cMutex, os::Menu::Private::m_eLayout, os::Menu::Private::m_pcRoot, VK_DOWN_ARROW, VK_ENTER, VK_LEFT_ARROW, VK_RIGHT_ARROW, and VK_UP_ARROW.

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)

References os::Locker::Lock(), os::Menu::Private::m_cMutex, and os::Menu::Private::m_pcRoot.

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
cPositionMouse position in the views coordinate system at the time the mouse was pressed.
nButtonsIndex 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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References os::View::ConvertFromScreen(), os::View::ConvertToScreen(), os::View::Flush(), os::View::GetBounds(), GetItemAt(), GetSuperMenu(), os::ITEMS_IN_ROW, os::Menu::Private::m_bHasOpenChilds, os::Menu::Private::m_bIsTracking, os::Menu::Private::m_cMouseHitPos, os::Menu::Private::m_cMutex, os::Menu::Private::m_eLayout, os::Menu::Private::m_hTrackPort, os::Menu::Private::m_pcRoot, os::View::MakeFocus(), and MouseDown().

Referenced by MouseDown().

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
cNewPosNew mouse position given in the views coordinate system.
nCodeEnter/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).
nButtonsBitmask 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.
pcDataPointer 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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References os::View::ConvertFromScreen(), os::View::ConvertToScreen(), os::View::Flush(), os::View::GetBounds(), GetItemAt(), GetSuperMenu(), os::ITEMS_IN_ROW, os::Menu::Private::m_bCloseOnMouseUp, os::Menu::Private::m_bIsTracking, os::Menu::Private::m_cMouseHitPos, os::Menu::Private::m_cMutex, os::Menu::Private::m_eLayout, os::Menu::Private::m_pcRoot, MouseMove(), STICKY_THRESHOLD, os::Point::x, and os::Point::y.

Referenced by MouseMove().

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
cPositionMouse position in the views coordinate system at the time the mouse was pressed.
nButtonsIndex 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.
pcDataPointer 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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

Reimplemented in os::RadioMenu.

References FindMarked(), os::View::GetBounds(), GetItemAt(), os::MenuItem::GetSubMenu(), os::Invoker::Invoke(), os::MenuItem::IsEnabled(), os::Menu::Private::m_bCloseOnMouseUp, os::Menu::Private::m_cMutex, os::Menu::Private::m_hTrackPort, and os::Menu::Private::m_pcRoot.

Referenced by os::RadioMenu::MouseUp().

void Menu::Open ( Point  cScrPos)
void Menu::Paint ( const Rect cUpdateRect)
virtual
Description:
Note:
Warning:
Parameters
cUpdateRectA 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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References os::COL_MENU_BACKGROUND, os::MenuItem::Draw(), os::View::DrawFrame(), os::View::FillRect(), os::FRAME_RAISED, os::FRAME_THIN, os::FRAME_TRANSPARENT, os::get_default_color(), os::View::GetBounds(), os::Menu::Private::m_cMutex, os::Menu::Private::m_pcFirstItem, os::Menu::Private::m_pcRoot, and os::View::SetFgColor().

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.

References os::MenuItem::GetSubMenu(), InvalidateLayout(), os::Menu::Private::m_nItemCount, and os::Menu::Private::m_pcFirstItem.

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.

References os::MenuItem::GetSubMenu(), InvalidateLayout(), os::Menu::Private::m_nItemCount, and os::Menu::Private::m_pcFirstItem.

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.

References os::MenuItem::GetSubMenu(), InvalidateLayout(), os::Menu::Private::m_nItemCount, and os::Menu::Private::m_pcFirstItem.

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.

References os::Menu::Private::m_cCloseMsg.

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.

References os::Menu::Private::m_cCloseMsgTarget.

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 (sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References os::View::Flush(), GetItemAt(), GetItemCount(), os::MenuItem::GetSubMenu(), os::Menu::Private::m_bEnabled, os::MenuItem::SetEnable(), and SetEnable().

Referenced by SetEnable().

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

References os::Menu::Private::m_cTitle.

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.

References os::MenuItem::GetSubMenu(), os::Menu::Private::m_pcFirstItem, os::Invoker::SetTarget(), and SetTargetForItems().

Referenced by os::IconDirectoryView::OpenContextMenu(), and SetTargetForItems().

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.

References os::MenuItem::GetSubMenu(), os::Menu::Private::m_pcFirstItem, os::Invoker::SetTarget(), and SetTargetForItems().

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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::Handler.

References os::Menu::Private::m_cMutex, and os::Menu::Private::m_pcRoot.

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 (sylla.nosp@m.ble_.nosp@m.deskt.nosp@m.op@h.nosp@m.otpop.nosp@m..com)

References GetPreferredSize(), os::Locker::Lock(), os::Menu::Private::m_bIsTracking, os::Menu::Private::m_cMutex, os::Menu::Private::m_hTrackPort, os::Menu::Private::m_pcRoot, os::Menu::Private::m_pcWindow, os::View::MakeFocus(), os::View::SetFrame(), os::Looper::SetMutex(), os::Window::Show(), os::Point::x, and os::Point::y.

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)

References os::Menu::Private::m_cMutex, os::Menu::Private::m_pcRoot, and os::Locker::Unlock().

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 (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::View.

References os::Menu::Private::m_bHasOpenChilds, os::Menu::Private::m_cMutex, os::Menu::Private::m_hTrackPort, and os::Menu::Private::m_pcRoot.

Friends And Related Function Documentation

friend class MenuItem
friend

Referenced by AddItem().