Vaca::ToolSet Class Reference

#include <ToolBar.h>

Inheritance diagram for Vaca::ToolSet:

Vaca::Widget Vaca::Component Vaca::Referenceable Vaca::NonCopyable

List of all members.


Detailed Description

A set of tool buttons.

ToolSet.png

Warning:
This is not a dockable tool bar. This is only a toolbar as Microsoft defines like "a window that contains one or more buttons". If you want a really dockable tool bar, you should use the ToolBar class.
See also:
ToolButton, ToolBar

Public Member Functions

 ToolSet (Widget *parent, Style style=ToolSetStyle)
virtual ~ToolSet ()
int getButtonCount ()
 (TB_BUTTONCOUNT).
int getRows ()
 (TB_GETROWS)
Rect setRows (int rows, bool expand)
 (TB_SETROWS)
void setImageList (ImageList &imageList)
 (TB_SETIMAGELIST)
void loadStandardImageList (int imageListId=IDB_STD_SMALL_COLOR)
void addButton (ToolButton *button)
 Adds a button to the ToolSet.
void addSeparator (int width=6)
 Adds a separator in the ToolSet.
void updateButton (ToolButton *button)
ToolButtongetButtonById (CommandId id)
ToolButtongetButtonByIndex (int index)
int hitTest (const Point &pt)
 Returns the index of the button that is above the point pt (relative to client area).
std::vector< SizegetPreferredSizes ()
void updatePreferredSizes ()
 Updates the preferred sizes of the tool-set when it has different number of rows.

Protected Member Functions

virtual void onPreferredSize (Size &sz)
 It should calculates the preferred size for this widget.
virtual void onUpdateIndicators ()
 Event called to update the state of indicators.
virtual bool onReflectedCommand (int id, int code, LRESULT &lResult)
 This method can be used to handle command notifications (WM_COMMAND(W32)) reflected from the parent.
virtual bool wndProc (UINT message, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 The customized window procedure for this particular widget.

Private Attributes

std::vector< Sizem_preferredSizes
HIMAGELIST m_loadedImageList

Constructor & Destructor Documentation

ToolSet::ToolSet ( Widget parent,
Style  style = ToolSetStyle 
)

ToolSet::~ToolSet (  )  [virtual]


Member Function Documentation

int ToolSet::getButtonCount (  ) 

(TB_BUTTONCOUNT).

int ToolSet::getRows (  ) 

(TB_GETROWS)

Rect ToolSet::setRows ( int  rows,
bool  expand 
)

(TB_SETROWS)

void ToolSet::setImageList ( ImageList imageList  ) 

(TB_SETIMAGELIST)

void ToolSet::loadStandardImageList ( int  imageListId = IDB_STD_SMALL_COLOR  ) 

Parameters:
imageListId 
  • IDB_HIST_LARGE_COLOR
  • IDB_HIST_SMALL_COLOR
  • IDB_STD_LARGE_COLOR
  • IDB_STD_SMALL_COLOR (default value).
  • IDB_VIEW_LARGE_COLOR
  • IDB_VIEW_SMALL_COLOR

void ToolSet::addButton ( ToolButton button  ) 

Adds a button to the ToolSet.

It uses Win32's TB_INSERTBUTTON with BTNS_BUTTON.

Parameters:
imageIndex The images to use for this button from the ImageList that you specified to setImageList().
id Identifier of the command. This is the identifier that will be sent to Widget::onCommand.
buttonState One of the following values:
  • TBState::Checked
  • TBState::Enabled
  • TBState::Hidden

void ToolSet::addSeparator ( int  width = 6  ) 

Adds a separator in the ToolSet.

It uses Win32's TB_INSERTBUTTON with BTNS_SEP.

void ToolSet::updateButton ( ToolButton button  ) 

ToolButton * ToolSet::getButtonById ( CommandId  id  ) 

ToolButton * ToolSet::getButtonByIndex ( int  index  ) 

int ToolSet::hitTest ( const Point pt  ) 

Returns the index of the button that is above the point pt (relative to client area).

Returns a negative index if the point is inside a (or the nearest of) a separator button.

It uses Win32's TB_HITTEST.

std::vector< Size > ToolSet::getPreferredSizes (  ) 

void ToolSet::updatePreferredSizes (  ) 

Updates the preferred sizes of the tool-set when it has different number of rows.

void ToolSet::onPreferredSize ( Size sz  )  [protected, virtual]

It should calculates the preferred size for this widget.

Parameters:
sz It's for input and output. You should put the preferred size in this value, but also you should read the input value to know if you must to fit the widget in some size. The possible values for sz are:
  • sz = Size(0, 0) to calculate the preferred size without restrictions.
  • sz = Size(width, 0) to calculate the preferred size with restricted <= width.
  • sz = Size(0, height) to calculate the preferred size with restricted <= height.

Reimplemented from Vaca::Widget.

void ToolSet::onUpdateIndicators (  )  [protected, virtual]

Event called to update the state of indicators.

See also:
Widget::updateIndicators

Reimplemented from Vaca::Widget.

bool ToolSet::onReflectedCommand ( int  id,
int  code,
LRESULT &  lResult 
) [protected, virtual]

This method can be used to handle command notifications (WM_COMMAND(W32)) reflected from the parent.

Parameters:
id Identifier of the control or menu item.
code Notification code.
lResult Result to return by the wndProc method.
Win32 Specific:
Don't confuse with onCommand: onReflectedCommand is used to handle commands that this widget by self generated, were sent to the parent, and finally were reflected to this widget again by the parent.

Reimplemented from Vaca::Widget.

bool ToolSet::wndProc ( UINT  message,
WPARAM  wParam,
LPARAM  lParam,
LRESULT &  lResult 
) [protected, virtual]

The customized window procedure for this particular widget.

Win32 Specific:
This is called from Widget::globalWndProc. It should returns true when the defWndProc doesn't need to be called.

This method is called to intercept any message after the creation of the widget, and before the destruction. To intercept messages outside that range (before creation, and after disposition), you should customize defWndProc().

This method mainly converts a message to a event:

For reflection, it does:

  • When WM_COMMAND is received, the onReflectedCommand() event of the child is called when it is a WM_COMMAND from a control, or the onCommand() event of this widget is called when the command come from a menu or an accelerator.
  • When WM_NOTIFY is received, the onReflectedNotify() event of the child is called.
  • When WM_DRAWITEM is received, the onReflectedDrawItem() event of the child is called.

How to extend widget::wndProc method?

 class MyWidget : public Widget {
   ...
 protected:
   virtual bool wndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& lResult)
   {
     if (Widget::wndProc(message, wParam, lParam, lResult))
       return true;

     // ...Your code here...

     return false;
   }
   ...
 }

Returns:
True if the message was used and lResult contains a valid value to be returned by globalWndProc.
See also:
globalWndProc, getGlobalWndProc, defWndProc

Reimplemented from Vaca::Widget.


Member Data Documentation

std::vector<Size> Vaca::ToolSet::m_preferredSizes [private]

HIMAGELIST Vaca::ToolSet::m_loadedImageList [private]