1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/toolbar.h
3 // Purpose: wxToolBar declaration
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_TOOLBAR_H_
13 #define _WX_UNIV_TOOLBAR_H_
15 #include "wx/button.h" // for wxStdButtonInputHandler
17 class WXDLLEXPORT wxToolBarTool
;
19 // ----------------------------------------------------------------------------
20 // the actions supported by this control
21 // ----------------------------------------------------------------------------
23 #define wxACTION_TOOLBAR_TOGGLE wxACTION_BUTTON_TOGGLE
24 #define wxACTION_TOOLBAR_PRESS wxACTION_BUTTON_PRESS
25 #define wxACTION_TOOLBAR_RELEASE wxACTION_BUTTON_RELEASE
26 #define wxACTION_TOOLBAR_CLICK wxACTION_BUTTON_CLICK
27 #define wxACTION_TOOLBAR_ENTER _T("enter") // highlight the tool
28 #define wxACTION_TOOLBAR_LEAVE _T("leave") // unhighlight the tool
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class WXDLLEXPORT wxToolBar
: public wxToolBarBase
37 // construction/destruction
38 wxToolBar() { Init(); }
39 wxToolBar(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxString
& name
= wxToolBarNameStr
)
48 Create(parent
, id
, pos
, size
, style
, name
);
51 bool Create( wxWindow
*parent
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
56 const wxString
& name
= wxToolBarNameStr
);
60 virtual bool Realize();
62 virtual wxToolBarToolBase
*FindToolForPosition(wxCoord x
, wxCoord y
) const;
64 virtual void SetToolShortHelp(int id
, const wxString
& helpString
);
66 virtual void SetMargins(int x
, int y
);
67 void SetMargins(const wxSize
& size
)
68 { SetMargins((int) size
.x
, (int) size
.y
); }
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 DoSetSize(int x
, int y
,
98 int width
, int height
,
99 int sizeFlags
= wxSIZE_AUTO
);
100 virtual void DoDraw(wxControlRenderer
*renderer
);
102 // get the bounding rect for the given tool
103 wxRect
GetToolRect(wxToolBarToolBase
*tool
) const;
105 // redraw the given tool
106 void RefreshTool(wxToolBarToolBase
*tool
);
108 // (re)calculate the tool positions, should only be called if it is
109 // necessary to do it, i.e. m_needsLayout == true
112 // get the rect limits depending on the orientation: top/bottom for a
113 // vertical toolbar, left/right for a horizontal one
114 void GetRectLimits(const wxRect
& rect
, wxCoord
*start
, wxCoord
*end
) const;
117 // have we calculated the positions of our tools?
120 // the width of a separator
121 wxCoord m_widthSeparator
;
123 // the total size of all toolbar elements
128 DECLARE_DYNAMIC_CLASS(wxToolBar
)
131 // ----------------------------------------------------------------------------
132 // wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
133 // click into button press/release actions
134 // ----------------------------------------------------------------------------
136 class WXDLLEXPORT wxStdToolbarInputHandler
: public wxStdInputHandler
139 wxStdToolbarInputHandler(wxInputHandler
*inphand
);
141 virtual bool HandleKey(wxInputConsumer
*consumer
,
142 const wxKeyEvent
& event
,
144 virtual bool HandleMouse(wxInputConsumer
*consumer
,
145 const wxMouseEvent
& event
);
146 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
147 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
148 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
151 wxWindow
*m_winCapture
;
152 wxToolBarToolBase
*m_toolCapture
;
153 wxToolBarToolBase
*m_toolLast
;
156 #endif // _WX_UNIV_TOOLBAR_H_