1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/toolbar.h
3 // Purpose: Documentation of wxAuiToolBar and related classes.
6 // Copyright: (c) 2011 wxWidgets development team
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
14 enum wxAuiToolBarStyle
16 wxAUI_TB_TEXT
= 1 << 0,
17 wxAUI_TB_NO_TOOLTIPS
= 1 << 1,
18 wxAUI_TB_NO_AUTORESIZE
= 1 << 2,
19 wxAUI_TB_GRIPPER
= 1 << 3,
20 wxAUI_TB_OVERFLOW
= 1 << 4,
22 Using this style forces the toolbar to be vertical and be only dockable
23 to the left or right sides of the window whereas by default it can be
24 horizontal or vertical and be docked anywhere.
26 wxAUI_TB_VERTICAL
= 1 << 5,
27 wxAUI_TB_HORZ_LAYOUT
= 1 << 6,
29 Analogous to wxAUI_TB_VERTICAL, but forces the toolbar
32 wxAUI_TB_HORIZONTAL
= 1 << 7,
33 wxAUI_TB_HORZ_TEXT
= (wxAUI_TB_HORZ_LAYOUT
| wxAUI_TB_TEXT
),
34 wxAUI_ORIENTATION_MASK
= (wxAUI_TB_VERTICAL
| wxAUI_TB_HORIZONTAL
),
35 wxAUI_TB_DEFAULT_STYLE
= 0
42 enum wxAuiToolBarArtSetting
44 wxAUI_TBART_SEPARATOR_SIZE
= 0,
45 wxAUI_TBART_GRIPPER_SIZE
= 1,
46 wxAUI_TBART_OVERFLOW_SIZE
= 2
53 enum wxAuiToolBarToolTextOrientation
55 wxAUI_TBTOOL_TEXT_LEFT
= 0, //!< unused/unimplemented
56 wxAUI_TBTOOL_TEXT_RIGHT
= 1,
57 wxAUI_TBTOOL_TEXT_TOP
= 2, //!< unused/unimplemented
58 wxAUI_TBTOOL_TEXT_BOTTOM
= 3
63 @class wxAuiToolBarEvent
65 wxAuiToolBarEvent is used for the events generated by @ref wxAuiToolBar.
70 class wxAuiToolBarEvent
: public wxNotifyEvent
73 bool IsDropDownClicked() const;
75 wxPoint
GetClickPoint() const;
77 wxRect
GetItemRect() const;
79 int GetToolId() const;
84 @class wxAuiToolBarItem
86 wxAuiToolBarItem is part of the wxAUI class framework.
87 See also @ref wxAuiToolBar and @ref overview_aui.
92 class wxAuiToolBarItem
98 wxAuiToolBarItem(const wxAuiToolBarItem
& c
);
100 wxAuiToolBarItem
& operator=(const wxAuiToolBarItem
& c
);
102 void Assign(const wxAuiToolBarItem
& c
);
104 void SetWindow(wxWindow
* w
);
105 wxWindow
* GetWindow();
107 void SetId(int new_id
);
110 void SetKind(int new_kind
);
113 void SetState(int new_state
);
114 int GetState() const;
116 void SetSizerItem(wxSizerItem
* s
);
117 wxSizerItem
* GetSizerItem() const;
119 void SetLabel(const wxString
& s
);
120 const wxString
& GetLabel() const;
122 void SetBitmap(const wxBitmap
& bmp
);
123 const wxBitmap
& GetBitmap() const;
125 void SetDisabledBitmap(const wxBitmap
& bmp
);
126 const wxBitmap
& GetDisabledBitmap() const;
128 void SetHoverBitmap(const wxBitmap
& bmp
);
129 const wxBitmap
& GetHoverBitmap() const;
131 void SetShortHelp(const wxString
& s
);
132 const wxString
& GetShortHelp() const;
134 void SetLongHelp(const wxString
& s
);
135 const wxString
& GetLongHelp() const;
137 void SetMinSize(const wxSize
& s
);
138 const wxSize
& GetMinSize() const;
140 void SetSpacerPixels(int s
);
141 int GetSpacerPixels() const;
143 void SetProportion(int p
);
144 int GetProportion() const;
146 void SetActive(bool b
);
147 bool IsActive() const;
149 void SetHasDropDown(bool b
);
150 bool HasDropDown() const;
152 void SetSticky(bool b
);
153 bool IsSticky() const;
155 void SetUserData(long l
);
156 long GetUserData() const;
158 void SetAlignment(int l
);
159 int GetAlignment() const;
163 @class wxAuiToolBarArt
165 wxAuiToolBarArt is part of the wxAUI class framework.
166 See also @ref wxAuiToolBar and @ref overview_aui.
171 class wxAuiToolBarArt
176 virtual wxAuiToolBarArt
* Clone() = 0;
177 virtual void SetFlags(unsigned int flags
) = 0;
178 virtual unsigned int GetFlags() = 0;
179 virtual void SetFont(const wxFont
& font
) = 0;
180 virtual wxFont
GetFont() = 0;
181 virtual void SetTextOrientation(int orientation
) = 0;
182 virtual int GetTextOrientation() = 0;
184 virtual void DrawBackground(
187 const wxRect
& rect
) = 0;
189 virtual void DrawLabel(
192 const wxAuiToolBarItem
& item
,
193 const wxRect
& rect
) = 0;
195 virtual void DrawButton(
198 const wxAuiToolBarItem
& item
,
199 const wxRect
& rect
) = 0;
201 virtual void DrawDropDownButton(
204 const wxAuiToolBarItem
& item
,
205 const wxRect
& rect
) = 0;
207 virtual void DrawControlLabel(
210 const wxAuiToolBarItem
& item
,
211 const wxRect
& rect
) = 0;
213 virtual void DrawSeparator(
216 const wxRect
& rect
) = 0;
218 virtual void DrawGripper(
221 const wxRect
& rect
) = 0;
223 virtual void DrawOverflowButton(
229 virtual wxSize
GetLabelSize(
232 const wxAuiToolBarItem
& item
) = 0;
234 virtual wxSize
GetToolSize(
237 const wxAuiToolBarItem
& item
) = 0;
239 virtual int GetElementSize(int element_id
) = 0;
240 virtual void SetElementSize(int element_id
, int size
) = 0;
242 virtual int ShowDropDown(
244 const wxAuiToolBarItemArray
& items
) = 0;
249 @class wxAuiDefaultToolBarArt
251 wxAuiDefaultToolBarArt is part of the wxAUI class framework.
252 See also @ref wxAuiToolBarArt , @ref wxAuiToolBar and @ref overview_aui.
257 class wxAuiDefaultToolBarArt
: public wxAuiToolBarArt
260 wxAuiDefaultToolBarArt();
261 virtual ~wxAuiDefaultToolBarArt();
263 virtual wxAuiToolBarArt
* Clone();
264 virtual void SetFlags(unsigned int flags
);
265 virtual unsigned int GetFlags();
266 virtual void SetFont(const wxFont
& font
);
267 virtual wxFont
GetFont();
268 virtual void SetTextOrientation(int orientation
);
269 virtual int GetTextOrientation();
271 virtual void DrawBackground(
276 virtual void DrawLabel(
279 const wxAuiToolBarItem
& item
,
282 virtual void DrawButton(
285 const wxAuiToolBarItem
& item
,
288 virtual void DrawDropDownButton(
291 const wxAuiToolBarItem
& item
,
294 virtual void DrawControlLabel(
297 const wxAuiToolBarItem
& item
,
300 virtual void DrawSeparator(
305 virtual void DrawGripper(
310 virtual void DrawOverflowButton(
316 virtual wxSize
GetLabelSize(
319 const wxAuiToolBarItem
& item
);
321 virtual wxSize
GetToolSize(
324 const wxAuiToolBarItem
& item
);
326 virtual int GetElementSize(int element
);
327 virtual void SetElementSize(int element_id
, int size
);
329 virtual int ShowDropDown(wxWindow
* wnd
,
330 const wxAuiToolBarItemArray
& items
);
338 wxAuiToolBar is a dockable toolbar, part of the wxAUI class framework.
339 See also @ref overview_aui.
342 @style{wxAUI_TB_TEXT}
343 @style{wxAUI_TB_NO_TOOLTIPS}
344 @style{wxAUI_TB_NO_AUTORESIZE}
345 @style{wxAUI_TB_GRIPPER}
346 @style{wxAUI_TB_OVERFLOW}
347 @style{wxAUI_TB_VERTICAL}
348 using this style forces the toolbar to be vertical and
349 be only dockable to the left or right sides of the window
350 whereas by default it can be horizontal or vertical and
352 @style{wxAUI_TB_HORZ_LAYOUT}
353 @style{wxAUI_TB_HORIZONTAL}
354 analogous to wxAUI_TB_VERTICAL, but forces the toolbar
356 @style{wxAUI_TB_HORZ_TEXT}
357 Equivalent to wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT
358 @style{wxAUI_TB_DEFAULT_STYLE}
359 The default is to have no styles
362 @beginEventEmissionTable{wxAuiToolBarEvent}
363 @event{EVT_AUITOOLBAR_TOOL_DROPDOWN(id, func)}
364 Process a wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN event
365 @event{EVT_AUITOOLBAR_OVERFLOW_CLICK(id, func)}
366 Process a wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK event
367 @event{EVT_AUITOOLBAR_RIGHT_CLICK(id, func)}
368 Process a wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK event
369 @event{EVT_AUITOOLBAR_MIDDLE_CLICK(id, func)}
370 Process a wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK event
371 @event{EVT_AUITOOLBAR_BEGIN_DRAG(id, func)}
372 Process a wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG event
378 class wxAuiToolBar
: public wxControl
381 wxAuiToolBar(wxWindow
* parent
,
383 const wxPoint
& position
= wxDefaultPosition
,
384 const wxSize
& size
= wxDefaultSize
,
385 long style
= wxAUI_TB_DEFAULT_STYLE
);
386 virtual ~wxAuiToolBar();
388 void SetWindowStyleFlag(long style
);
389 long GetWindowStyleFlag() const;
391 void SetArtProvider(wxAuiToolBarArt
* art
);
392 wxAuiToolBarArt
* GetArtProvider() const;
394 bool SetFont(const wxFont
& font
);
397 wxAuiToolBarItem
* AddTool(int tool_id
,
398 const wxString
& label
,
399 const wxBitmap
& bitmap
,
400 const wxString
& short_help_string
= wxEmptyString
,
401 wxItemKind kind
= wxITEM_NORMAL
);
403 wxAuiToolBarItem
* AddTool(int tool_id
,
404 const wxString
& label
,
405 const wxBitmap
& bitmap
,
406 const wxBitmap
& disabled_bitmap
,
408 const wxString
& short_help_string
,
409 const wxString
& long_help_string
,
410 wxObject
* client_data
);
412 wxAuiToolBarItem
* AddTool(int tool_id
,
413 const wxBitmap
& bitmap
,
414 const wxBitmap
& disabled_bitmap
,
416 wxObject
* client_data
= NULL
,
417 const wxString
& short_help_string
= wxEmptyString
,
418 const wxString
& long_help_string
= wxEmptyString
);
420 wxAuiToolBarItem
* AddLabel(int tool_id
,
421 const wxString
& label
= wxEmptyString
,
422 const int width
= -1);
423 wxAuiToolBarItem
* AddControl(wxControl
* control
,
424 const wxString
& label
= wxEmptyString
);
425 wxAuiToolBarItem
* AddSeparator();
426 wxAuiToolBarItem
* AddSpacer(int pixels
);
427 wxAuiToolBarItem
* AddStretchSpacer(int proportion
= 1);
431 wxControl
* FindControl(int window_id
);
432 wxAuiToolBarItem
* FindToolByPosition(wxCoord x
, wxCoord y
) const;
433 wxAuiToolBarItem
* FindToolByIndex(int idx
) const;
434 wxAuiToolBarItem
* FindTool(int tool_id
) const;
438 bool DeleteTool(int tool_id
);
439 bool DeleteByIndex(int tool_id
);
441 size_t GetToolCount() const;
442 int GetToolPos(int tool_id
) const;
443 int GetToolIndex(int tool_id
) const;
444 bool GetToolFits(int tool_id
) const;
445 wxRect
GetToolRect(int tool_id
) const;
446 bool GetToolFitsByIndex(int tool_id
) const;
447 bool GetToolBarFits() const;
449 void SetMargins(const wxSize
& size
);
450 void SetMargins(int x
, int y
);
451 void SetMargins(int left
, int right
, int top
, int bottom
);
453 void SetToolBitmapSize(const wxSize
& size
);
454 wxSize
GetToolBitmapSize() const;
456 bool GetOverflowVisible() const;
457 void SetOverflowVisible(bool visible
);
459 bool GetGripperVisible() const;
460 void SetGripperVisible(bool visible
);
462 void ToggleTool(int tool_id
, bool state
);
463 bool GetToolToggled(int tool_id
) const;
465 void EnableTool(int tool_id
, bool state
);
466 bool GetToolEnabled(int tool_id
) const;
468 void SetToolDropDown(int tool_id
, bool dropdown
);
469 bool GetToolDropDown(int tool_id
) const;
471 void SetToolBorderPadding(int padding
);
472 int GetToolBorderPadding() const;
474 void SetToolTextOrientation(int orientation
);
475 int GetToolTextOrientation() const;
477 void SetToolPacking(int packing
);
478 int GetToolPacking() const;
480 void SetToolProportion(int tool_id
, int proportion
);
481 int GetToolProportion(int tool_id
) const;
483 void SetToolSeparation(int separation
);
484 int GetToolSeparation() const;
486 void SetToolSticky(int tool_id
, bool sticky
);
487 bool GetToolSticky(int tool_id
) const;
489 wxString
GetToolLabel(int tool_id
) const;
490 void SetToolLabel(int tool_id
, const wxString
& label
);
492 wxBitmap
GetToolBitmap(int tool_id
) const;
493 void SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
);
495 wxString
GetToolShortHelp(int tool_id
) const;
496 void SetToolShortHelp(int tool_id
, const wxString
& help_string
);
498 wxString
GetToolLongHelp(int tool_id
) const;
499 void SetToolLongHelp(int tool_id
, const wxString
& help_string
);
501 void SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
502 const wxAuiToolBarItemArray
& append
);
504 /** get size of hint rectangle for a particular dock location */
505 wxSize
GetHintSize(int dock_direction
) const;
506 bool IsPaneValid(const wxAuiPaneInfo
& pane
) const;