WidgetMenuExtended Class Template Reference
[Widgets]

Extended Menu class. More...

Inherits WidgetMenuExtendedPlatformImplementation.

List of all members.

Public Types

typedef bool(*) boolDrawItemFunction (EventHandlerClass *, ObjectType, int, const DRAWITEMSTRUCT &)
 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 bool(*) boolMeasureItemFunction (EventHandlerClass *, ObjectType, MEASUREITEMSTRUCT *)
 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 void(*) menuExtendedVoidFunctionTakingUInt (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 WidgetMenuExtendedPlatformImplementation<
EventHandlerClass, MessageMapPolicy,
CurrentPlatform >::WidgetMenuExtendedPtr 
ObjectType
 Object type.
typedef WidgetMenuExtended<
EventHandlerClass, MessageMapPolicy > 
ThisType
 Type of object.

Public Member Functions

void appendItem (unsigned itemID, const SmartUtil::tstring &text, MenuItemDataPtr itemData, itsVoidMenuExtendedFunctionTakingUInt eventHandler)
 Appends a Menu Item.
void appendSeparatorItem ()
 Appends a separator item to the menu.
void checkItem (unsigned itemID, bool setChecked, bool radioMark)
 Set item state to checked/unchecked.
void clearTitle (bool clearSidebar=false)
 Removes menu title.
void enableItem (unsigned itemID, bool setEnabled)
 Enables or disables menu item.
MenuColorInfo getColorInfo ()
 Returns menu color information.
MenuItemDataPtr getItemData (int itemIndex)
 Returns item data.
SmartUtil::tstring getItemText (unsigned itemID)
 Returns item text.
bool isItemChecked (unsigned itemID)
 Returns true if item is checked.
bool isItemEnabled (unsigned itemID)
 Returns true if item is checked.
void onDrawItem (boolDrawItemFunction eventHandler)
 Setting event handler for Draw Item Event.
void onMeasureItem (boolMeasureItemFunction eventHandler)
 Setting event handler for Draw Item Event.
void removeItem (unsigned itemIndex)
 Removes specified item from this menu.
void setColorInfo (const MenuColorInfo &info)
 Sets color information for the menu.
void setTitle (const SmartUtil::tstring &title, bool drawSidebar=false)
 Sets menu title.
void setTitleFont (FontPtr font)
 Sets title font.
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

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

Classes

class  Seed
 Creational info. More...


Detailed Description

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

Extended 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.

menuextended.png
Class for creating an Extended Menu Control which then can be attached to e.g. a WidgetWindow.
Note for Desktop version 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.
Do not be fooled, a WidgetMenuExtended is a much more advanced menu type then the "normal" WidgetMenu and contains support for visualizations far beyond the capabilities of the WidgetMenu.
If you need those truly awesome visual menu effects use this menu control instead of the WidgetMenu.


Member Function Documentation

void appendItem ( unsigned  itemID,
const SmartUtil::tstring &  text,
MenuItemDataPtr  itemData,
itsVoidMenuExtendedFunctionTakingUInt  eventHandler 
)

Appends a Menu Item.

eventHandler is the function that will receive the "click" event from the menu item.
Event handler's signature must be "void foo( WidgetMenuExtendedPtr, unsigned int )" and it must be contained as a member
of the class that is defined as the EventHandlerClass, normally either the WidgetWindow derived class or the class derived from WidgetMenu.
See e.g. WidgetMenu for an example.
The reason to why we have this "id" is because the same event handler can be defined for several menu items even in fact across menu objects, therefore this number should be unique across the application.

void appendSeparatorItem (  ) 

Appends a separator item to the menu.

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

void checkItem ( unsigned  itemID,
bool  setChecked,
bool  radioMark 
)

Set item state to checked/unchecked.

If second parameter is true the menu item will be checked, otherwise it'll be unchecked

void clearTitle ( bool  clearSidebar = false  ) 

Removes menu title.

If clearSidebar is true, sidebar is removed

void enableItem ( unsigned  itemID,
bool  setEnabled 
)

Enables or disables menu item.

If the second argument is true the menu item will be enabled, otherwise it'll be disabled

void onDrawItem ( boolDrawItemFunction  eventHandler  ) 

Setting event handler for Draw Item Event.

The Draw Item Event will be raised when the menu needs to draw itself, if you wish to truly be creative and be 100% in control you must handle this Event and do the actualy drawing of the Menu yourself, but for most people it will be enough to just manipulate the background colors etc of the MenuItemData given to the menu in the appendItem or to call the setColorInfo function
Note!
If this event is handled you also MUST handle the Measure Item Event!!

void onMeasureItem ( boolMeasureItemFunction  eventHandler  ) 

Setting event handler for Draw Item Event.

The Measure Item Event is nessecary to handle if you want to draw the menu yourself since it is inside this Event Handler you're telling the system how much space you need to actually do the drawing
Note!
If this event is handled you also MUST handle the Draw Item Event!!

void removeItem ( unsigned  itemIndex  ) 

Removes specified item from this menu.

Call this function to actually DELETE a menu item from the menu hierarchy

void setColorInfo ( const MenuColorInfo info  ) 

Sets color information for the menu.

The MenuColorInfo declares which colors will be used for drawing the menu ( items )
Have no effect if you override the onDrawItem/onMeasureItem

void setTitle ( const SmartUtil::tstring &  title,
bool  drawSidebar = false 
)

Sets menu title.

A WidgetMenuExtended can have a title, this function sets that title

void setTitleFont ( FontPtr  font  ) 

Sets title font.

Create a font through e.g. createFont in WidgetFactory or similar and set the title font to the menu title through using this function

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 coordinate is - 1 ( default ) it'll show the context menu on the position the mouse was at when the system last recieved 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 do the menu command. < 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