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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
);
70 virtual void SetMargins(int x
, int y
);
71 void SetMargins(const wxSize
& size
)
72 { SetMargins((int) size
.x
, (int) size
.y
); }
75 // common part of all ctors
78 // implement base class pure virtuals
79 virtual bool DoInsertTool(size_t pos
, wxToolBarToolBase
*tool
);
80 virtual bool DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
);
82 virtual void DoEnableTool(wxToolBarToolBase
*tool
, bool enable
);
83 virtual void DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
);
84 virtual void DoSetToggle(wxToolBarToolBase
*tool
, bool toggle
);
86 virtual wxToolBarToolBase
*CreateTool(int id
,
87 const wxString
& label
,
88 const wxBitmap
& bmpNormal
,
89 const wxBitmap
& bmpDisabled
,
92 const wxString
& shortHelp
,
93 const wxString
& longHelp
);
94 virtual wxToolBarToolBase
*CreateTool(wxControl
*control
);
96 // implement wxUniversal methods
97 virtual bool PerformAction(const wxControlAction
& action
,
99 const wxString
& strArg
= wxEmptyString
);
100 virtual wxSize
DoGetBestClientSize() const;
101 virtual void DoSetSize(int x
, int y
,
102 int width
, int height
,
103 int sizeFlags
= wxSIZE_AUTO
);
104 virtual void DoDraw(wxControlRenderer
*renderer
);
106 // get the bounding rect for the given tool
107 wxRect
GetToolRect(wxToolBarToolBase
*tool
) const;
109 // redraw the given tool
110 void RefreshTool(wxToolBarToolBase
*tool
);
112 // (re)calculate the tool positions, should only be called if it is
113 // necessary to do it, i.e. m_needsLayout == TRUE
116 // get the rect limits depending on the orientation: top/bottom for a
117 // vertical toolbar, left/right for a horizontal one
118 void GetRectLimits(const wxRect
& rect
, wxCoord
*start
, wxCoord
*end
) const;
121 // have we calculated the positions of our tools?
124 // the width of a separator
125 wxCoord m_widthSeparator
;
127 // the total size of all toolbar elements
132 DECLARE_DYNAMIC_CLASS(wxToolBar
)
135 // ----------------------------------------------------------------------------
136 // wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
137 // click into button press/release actions
138 // ----------------------------------------------------------------------------
140 class WXDLLEXPORT wxStdToolbarInputHandler
: public wxStdInputHandler
143 wxStdToolbarInputHandler(wxInputHandler
*inphand
);
145 virtual bool HandleKey(wxInputConsumer
*consumer
,
146 const wxKeyEvent
& event
,
148 virtual bool HandleMouse(wxInputConsumer
*consumer
,
149 const wxMouseEvent
& event
);
150 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
151 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
152 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
155 wxWindow
*m_winCapture
;
156 wxToolBarToolBase
*m_toolCapture
;
157 wxToolBarToolBase
*m_toolLast
;
160 #endif // _WX_UNIV_TOOLBAR_H_