WidgetMenu Class Template Reference
[Widgets]

Menu class. More...

Inherits WidgetMenuPlatformImplementation.

List of all members.

Public Types

typedef void(*) menuVoidFunctionTakingUInt (EventHandlerClass *, ObjectType, unsigned)
 Typedef of a static/global function taking a pointer to the original class, a pointer to the this Widget class and an unsigned int returning void.
typedef WidgetMenuPlatformImplementation<
EventHandlerClass, MessageMapPolicy,
CurrentPlatform >::WidgetMenuPtr 
ObjectType
 Object type.
typedef WidgetMenu< EventHandlerClass,
MessageMapPolicy > 
ThisType
 Class type.

Public Member Functions

void appendCheckedItem (unsigned id, const SmartUtil::tstring &name, itsVoidMenuFunctionTakingUInt eventHandler)
 Appends a checked menu item.
void appendItem (unsigned int id, const SmartUtil::tstring &name, itsVoidMenuFunctionTakingUInt eventHandler)
 Appends a "normal" menu item.
void appendSeparatorItem ()
 Appends a separator item to the menu.
void checkItem (unsigned id, bool value=true)
 Checks (or uncheck) a specific menu item.
bool getCheckedState (unsigned id)
 Returns a boolean indicating if a specific menu item is checked or not.
bool getItemEnabled (unsigned id)
 Returns a boolean indicating if a specific menu item is enabled or not.
SmartUtil::tstring getText (unsigned id)
 Returns the text of a specific menu item.
void setItemEnabled (unsigned id, bool value=true)
 Enables (or disables) a specific menu item.
unsigned trackPopupMenu (EventHandlerClass *mainWindow, int x=-1, int y=-1, unsigned flags=0)
 Displays and handles a menu which can appear anywhere in the window.

Protected Member Functions

 WidgetMenu (SmartWin::Widget *parent)
 Constructor Taking pointer to parent.

Classes

class  Seed
 Creational info. More...


Detailed Description

template<class EventHandlerClass, class MessageMapPolicy>
class SmartWin::WidgetMenu< EventHandlerClass, MessageMapPolicy >

Menu class.

You can either inherit from this class or add an instance of this class into your WidgetWindow inherited class.
If you inherit from the class you should explicitly call create e.g. in the CTOR of you class.
If you instantiate it directly (through the class Widget) you should create it by calling WidgetFactory::createxxx where xxx equals the name of the class WITHOUT the Widget part.

menu.PNG
Class for creating a Menu Control which then can be attached to a WidgetWindow.
Note for Desktop applications only!
After you have created a menu you must call WidgetMenu::attach() to make it "attach" to the WidgetWindow you want it to belong to.
Related class :
WidgetMenuExtended


Member Function Documentation

void appendSeparatorItem (  ) 

Appends a separator item to the menu.

A menu separator is basically just "air" between menu items.
A separator cannot be "clicked" or "chosen".

void checkItem ( unsigned  id,
bool  value = true 
)

Checks (or uncheck) a specific menu item.

Which menu item you wish to check ( or uncheck ) is passed in as the "id" parameter.
If the "value" parameter is true the item will be checked, otherwise it will be unchecked

bool getCheckedState ( unsigned  id  ) 

Returns a boolean indicating if a specific menu item is checked or not.

Which menu item you wish to check must be passed as the "id" parameter of the function

bool getItemEnabled ( unsigned  id  ) 

Returns a boolean indicating if a specific menu item is enabled or not.

Which menu item you wish to check must be passed as the "id" parameter to the function.

SmartUtil::tstring getText ( unsigned  id  ) 

Returns the text of a specific menu item.

Which menu item you wish to retrieve the text for is defined by the "id" parameter of the function.

void setItemEnabled ( unsigned  id,
bool  value = true 
)

Enables (or disables) a specific menu item.

Which menu item you wish to enable ( or disable ) is passed in as the "id" parameter.
If the "value" parameter is true the item becomes enabled, otherwise disabled

unsigned trackPopupMenu ( EventHandlerClass *  mainWindow,
int  x = -1,
int  y = -1,
unsigned  flags = 0 
)

Displays and handles a menu which can appear anywhere in the window.

Typically called by a Right Mouse click. If both the x and the y coordinates are - 1 ( default ), it'll show the context menu at the mouse position when the system last received a message, basically the "right" place. Depending on the flags it might return the id of the menu item selected, or 0 if none was chosen. Flags with TPM_RETURNCMD will return the menu - item, but not call the Event Handler. < ul > < li >TPM_CENTERALIGN : Centers the shortcut menu horizontally relative to the coordinate specified by the x parameter< /li > < li >TPM_LEFTALIGN : Function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter< /li > < li >TPM_RIGHTALIGN : Opposite of LEFTALIGN< /li > < li >TPM_BOTTOMALIGN : Aligns menu bottoms to the coordinate specified by the y parameter< /li > < li >TPM_TOPALIGN : Opposite of BOTTOMALIGN< /li > < li >TPM_VCENTERALIGN : Centers vertically relative to the y parameter< /li > < li >TPM_NONOTIFY : Restricts the menu from sending notifications when user clicks item< /li > < li >TPM_RETURNCMD : returns the menu item identifier of the user's selection in the return value but DOES NOT carry out the event handler< /li > < li >TPM_LEFTBUTTON : Restricts users to selecting menu items with only left mouse button< /li > < li >TPM_RIGHTBUTTON : User can choose menu item with both mouse buttons< /li > < /ul > None of the following are used by default but can be manually chosen if you manually call SystemParametersInfo < ul > < li >TPM_HORNEGANIMATION : Animates the menu from right to left< /li > < li >TPM_HORPOSANIMATION : Animates the menu from left to right< /li > < li >TPM_NOANIMATION : Displays menu without animation< /li > < li >TPM_VERNEGANIMATION : Animates the menu from bottom to top< /li > < li >TPM_VERPOSANIMATION : Animates the menu from top to bottom< /li > < /ul >

Back to SmartWin website
SourceForge.net Logo