1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/toolbar.h
3 // Purpose: wxToolBar declaration
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_TOOLBAR_H_
13 #define _WX_UNIV_TOOLBAR_H_
16 #pragma interface "univtoolbar.h"
19 #include "wx/button.h" // for wxStdButtonInputHandler
21 class WXDLLEXPORT wxToolBarTool
;
23 // ----------------------------------------------------------------------------
24 // the actions supported by this control
25 // ----------------------------------------------------------------------------
27 #define wxACTION_TOOLBAR_TOGGLE wxACTION_BUTTON_TOGGLE
28 #define wxACTION_TOOLBAR_PRESS wxACTION_BUTTON_PRESS
29 #define wxACTION_TOOLBAR_RELEASE wxACTION_BUTTON_RELEASE
30 #define wxACTION_TOOLBAR_CLICK wxACTION_BUTTON_CLICK
31 #define wxACTION_TOOLBAR_ENTER _T("enter") // highlight the tool
32 #define wxACTION_TOOLBAR_LEAVE _T("leave") // unhighlight the tool
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxToolBar
: public wxToolBarBase
41 // construction/destruction
42 wxToolBar() { Init(); }
43 wxToolBar(wxWindow
*parent
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
48 const wxString
& name
= wxToolBarNameStr
)
52 Create(parent
, id
, pos
, size
, style
, name
);
55 bool Create( wxWindow
*parent
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
60 const wxString
& name
= wxToolBarNameStr
);
64 virtual bool Realize();
66 virtual wxToolBarToolBase
*FindToolForPosition(wxCoord x
, wxCoord y
) const;
68 virtual void SetToolShortHelp(int id
, const wxString
& helpString
);
71 // common part of all ctors
74 // implement base class pure virtuals
75 virtual bool DoInsertTool(size_t pos
, wxToolBarToolBase
*tool
);
76 virtual bool DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
);
78 virtual void DoEnableTool(wxToolBarToolBase
*tool
, bool enable
);
79 virtual void DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
);
80 virtual void DoSetToggle(wxToolBarToolBase
*tool
, bool toggle
);
82 virtual wxToolBarToolBase
*CreateTool(int id
,
83 const wxString
& label
,
84 const wxBitmap
& bmpNormal
,
85 const wxBitmap
& bmpDisabled
,
88 const wxString
& shortHelp
,
89 const wxString
& longHelp
);
90 virtual wxToolBarToolBase
*CreateTool(wxControl
*control
);
92 // implement wxUniversal methods
93 virtual bool PerformAction(const wxControlAction
& action
,
95 const wxString
& strArg
= wxEmptyString
);
96 virtual wxSize
DoGetBestClientSize() const;
97 virtual void DoDraw(wxControlRenderer
*renderer
);
99 // get the bounding rect for the given tool
100 wxRect
GetToolRect(wxToolBarToolBase
*tool
) const;
102 // redraw the given tool
103 void RefreshTool(wxToolBarToolBase
*tool
);
105 // (re)calculate the tool positions, should only be called if it is
106 // necessary to do it, i.e. m_needsLayout == TRUE
109 // get the rect limits depending on the orientation: top/bottom for a
110 // vertical toolbar, left/right for a horizontal one
111 void GetRectLimits(const wxRect
& rect
, wxCoord
*start
, wxCoord
*end
) const;
113 // wxButton actions: all these use m_toolPressed and can only be called if
119 // this one used m_toolCurrent
123 // have we calculated the positions of our tools?
126 // the width of a separator
127 wxCoord m_widthSeparator
;
129 // the total size of all toolbar elements
133 // the tool over which the mouse currently is or NULL
134 wxToolBarToolBase
*m_toolCurrent
;
136 // the tool which currently has the mouse capture (i.e. the one user is
138 wxToolBarTool
*m_toolPressed
;
140 DECLARE_DYNAMIC_CLASS(wxToolBar
)
143 // ----------------------------------------------------------------------------
144 // wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
145 // click into button press/release actions
146 // ----------------------------------------------------------------------------
148 class WXDLLEXPORT wxStdToolbarInputHandler
: public wxStdButtonInputHandler
151 wxStdToolbarInputHandler(wxInputHandler
*inphand
);
153 virtual bool HandleKey(wxInputConsumer
*consumer
,
154 const wxKeyEvent
& event
,
156 virtual bool HandleMouse(wxInputConsumer
*consumer
,
157 const wxMouseEvent
& event
);
158 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
159 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
160 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
163 #endif // _WX_UNIV_TOOLBAR_H_