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 ///////////////////////////////////////////////////////////////////////////////
11 wxAuiToolBarStyle is part of the wxAUI class framework, used to define the appearance of a wxAuiToolBar.
13 See also @ref overview_aui.
18 enum wxAuiToolBarStyle
21 Shows the text in the toolbar buttons; by default only icons are shown.
23 wxAUI_TB_TEXT
= 1 << 0,
26 Don't show tooltips on wxAuiToolBar items.
28 wxAUI_TB_NO_TOOLTIPS
= 1 << 1,
31 Do not auto-resize the wxAuiToolBar.
33 wxAUI_TB_NO_AUTORESIZE
= 1 << 2,
36 Shows a gripper on the wxAuiToolBar.
38 wxAUI_TB_GRIPPER
= 1 << 3,
41 The wxAuiToolBar can contain overflow items.
43 wxAUI_TB_OVERFLOW
= 1 << 4,
46 Using this style forces the toolbar to be vertical and be only dockable to the left or right sides of the window whereas by default it can be horizontal or vertical and be docked anywhere.
48 wxAUI_TB_VERTICAL
= 1 << 5,
51 Shows the text and the icons alongside, not vertically stacked. This style must be used with wxAUI_TB_TEXT
53 wxAUI_TB_HORZ_LAYOUT
= 1 << 6,
56 Analogous to wxAUI_TB_VERTICAL, but forces the toolbar to be horizontal, docking to the top or bottom of the window.
58 wxAUI_TB_HORIZONTAL
= 1 << 7,
61 Shows the text alongside the icons, not vertically stacked.
63 wxAUI_TB_HORZ_TEXT
= (wxAUI_TB_HORZ_LAYOUT
| wxAUI_TB_TEXT
),
66 Shows the text in the toolbar buttons; by default only icons are shown.
68 wxAUI_ORIENTATION_MASK
= (wxAUI_TB_VERTICAL
| wxAUI_TB_HORIZONTAL
),
71 By default only icons are shown.
73 wxAUI_TB_DEFAULT_STYLE
= 0
78 wxAuiToolBarArtSetting
83 enum wxAuiToolBarArtSetting
86 wxAuiToolBar seperator size.
88 wxAUI_TBART_SEPARATOR_SIZE
= 0,
91 wxAuiToolBar gripper size.
93 wxAUI_TBART_GRIPPER_SIZE
= 1,
96 Overflow button size in wxAuiToolBar.
98 wxAUI_TBART_OVERFLOW_SIZE
= 2
103 wxAuiToolBarToolTextOrientation
108 enum wxAuiToolBarToolTextOrientation
111 Text in wxAuiToolBar items is left aligned, currently unused/unimplemented.
113 wxAUI_TBTOOL_TEXT_LEFT
= 0,
116 Text in wxAuiToolBar items is right aligned.
118 wxAUI_TBTOOL_TEXT_RIGHT
= 1,
121 Text in wxAuiToolBar items is top aligned, currently unused/unimplemented.
123 wxAUI_TBTOOL_TEXT_TOP
= 2,
126 Text in wxAuiToolBar items is bottom aligned.
128 wxAUI_TBTOOL_TEXT_BOTTOM
= 3
134 @class wxAuiToolBarEvent
136 wxAuiToolBarEvent is used for the events generated by @ref wxAuiToolBar.
141 class wxAuiToolBarEvent
: public wxNotifyEvent
145 Returns whether the drop down menu has been clicked.
147 bool IsDropDownClicked() const;
150 Returns the point where the user clicked with the mouse.
152 wxPoint
GetClickPoint() const;
155 Returns the wxAuiToolBarItem rectangle bounding the mouse click point.
157 wxRect
GetItemRect() const;
160 Returns the wxAuiToolBarItem identifier.
162 int GetToolId() const;
167 @class wxAuiToolBarItem
169 wxAuiToolBarItem is part of the wxAUI class framework, representing a toolbar element.
171 See also @ref wxAuiToolBar and @ref overview_aui.
173 It has a unique id (except for the separators which always have id = -1), the
174 style (telling whether it is a normal button, separator or a control), the
175 state (toggled or not, enabled or not) and short and long help strings. The
176 default implementations use the short help string for the tooltip text which
177 is popped up when the mouse pointer enters the tool and the long help string
178 for the applications status bar (currently not implemented).
183 class wxAuiToolBarItem
193 Assigns the properties of the wxAuiToolBarItem "c" to this.
195 wxAuiToolBarItem(const wxAuiToolBarItem
& c
);
198 Assigns the properties of the wxAuiToolBarItem "c" to this, returning a pointer to this.
200 wxAuiToolBarItem
& operator=(const wxAuiToolBarItem
& c
);
203 Assigns the properties of the wxAuiToolBarItem "c" to this.
205 void Assign(const wxAuiToolBarItem
& c
);
208 Assigns a window to the toolbar item.
210 void SetWindow(wxWindow
* w
);
212 Returns the wxWindow* associated to the toolbar item.
214 wxWindow
* GetWindow();
217 Sets the toolbar item identifier.
219 void SetId(int new_id
);
221 Returns the toolbar item identifier.
226 Sets the wxAuiToolBarItem kind.
228 void SetKind(int new_kind
);
231 Returns the toolbar item kind.
238 void SetState(int new_state
);
242 int GetState() const;
247 void SetSizerItem(wxSizerItem
* s
);
251 wxSizerItem
* GetSizerItem() const;
256 void SetLabel(const wxString
& s
);
260 const wxString
& GetLabel() const;
265 void SetBitmap(const wxBitmap
& bmp
);
269 const wxBitmap
& GetBitmap() const;
274 void SetDisabledBitmap(const wxBitmap
& bmp
);
278 const wxBitmap
& GetDisabledBitmap() const;
283 void SetHoverBitmap(const wxBitmap
& bmp
);
287 const wxBitmap
& GetHoverBitmap() const;
292 void SetShortHelp(const wxString
& s
);
296 const wxString
& GetShortHelp() const;
301 void SetLongHelp(const wxString
& s
);
305 const wxString
& GetLongHelp() const;
310 void SetMinSize(const wxSize
& s
);
314 const wxSize
& GetMinSize() const;
319 void SetSpacerPixels(int s
);
323 int GetSpacerPixels() const;
328 void SetProportion(int p
);
332 int GetProportion() const;
337 void SetActive(bool b
);
341 bool IsActive() const;
346 void SetHasDropDown(bool b
);
350 bool HasDropDown() const;
355 void SetSticky(bool b
);
359 bool IsSticky() const;
364 void SetUserData(long l
);
368 long GetUserData() const;
373 void SetAlignment(int l
);
377 int GetAlignment() const;
381 @class wxAuiToolBarArt
383 wxAuiToolBarArt is part of the wxAUI class framework.
384 See also @ref wxAuiToolBar and @ref overview_aui.
389 class wxAuiToolBarArt
394 virtual wxAuiToolBarArt
* Clone() = 0;
395 virtual void SetFlags(unsigned int flags
) = 0;
396 virtual unsigned int GetFlags() = 0;
397 virtual void SetFont(const wxFont
& font
) = 0;
398 virtual wxFont
GetFont() = 0;
399 virtual void SetTextOrientation(int orientation
) = 0;
400 virtual int GetTextOrientation() = 0;
402 virtual void DrawBackground(
405 const wxRect
& rect
) = 0;
407 virtual void DrawLabel(
410 const wxAuiToolBarItem
& item
,
411 const wxRect
& rect
) = 0;
413 virtual void DrawButton(
416 const wxAuiToolBarItem
& item
,
417 const wxRect
& rect
) = 0;
419 virtual void DrawDropDownButton(
422 const wxAuiToolBarItem
& item
,
423 const wxRect
& rect
) = 0;
425 virtual void DrawControlLabel(
428 const wxAuiToolBarItem
& item
,
429 const wxRect
& rect
) = 0;
431 virtual void DrawSeparator(
434 const wxRect
& rect
) = 0;
436 virtual void DrawGripper(
439 const wxRect
& rect
) = 0;
441 virtual void DrawOverflowButton(
447 virtual wxSize
GetLabelSize(
450 const wxAuiToolBarItem
& item
) = 0;
452 virtual wxSize
GetToolSize(
455 const wxAuiToolBarItem
& item
) = 0;
457 virtual int GetElementSize(int element_id
) = 0;
458 virtual void SetElementSize(int element_id
, int size
) = 0;
460 virtual int ShowDropDown(
462 const wxAuiToolBarItemArray
& items
) = 0;
467 @class wxAuiDefaultToolBarArt
469 wxAuiDefaultToolBarArt is part of the wxAUI class framework.
470 See also @ref wxAuiToolBarArt , @ref wxAuiToolBar and @ref overview_aui.
475 class wxAuiDefaultToolBarArt
: public wxAuiToolBarArt
478 wxAuiDefaultToolBarArt();
479 virtual ~wxAuiDefaultToolBarArt();
481 virtual wxAuiToolBarArt
* Clone();
482 virtual void SetFlags(unsigned int flags
);
483 virtual unsigned int GetFlags();
484 virtual void SetFont(const wxFont
& font
);
485 virtual wxFont
GetFont();
486 virtual void SetTextOrientation(int orientation
);
487 virtual int GetTextOrientation();
489 virtual void DrawBackground(
494 virtual void DrawLabel(
497 const wxAuiToolBarItem
& item
,
500 virtual void DrawButton(
503 const wxAuiToolBarItem
& item
,
506 virtual void DrawDropDownButton(
509 const wxAuiToolBarItem
& item
,
512 virtual void DrawControlLabel(
515 const wxAuiToolBarItem
& item
,
518 virtual void DrawSeparator(
523 virtual void DrawGripper(
528 virtual void DrawOverflowButton(
534 virtual wxSize
GetLabelSize(
537 const wxAuiToolBarItem
& item
);
539 virtual wxSize
GetToolSize(
542 const wxAuiToolBarItem
& item
);
544 virtual int GetElementSize(int element
);
545 virtual void SetElementSize(int element_id
, int size
);
547 virtual int ShowDropDown(wxWindow
* wnd
,
548 const wxAuiToolBarItemArray
& items
);
556 wxAuiToolBar is a dockable toolbar, part of the wxAUI class framework.
557 See also @ref overview_aui.
560 @style{wxAUI_TB_TEXT}
561 @style{wxAUI_TB_NO_TOOLTIPS}
562 @style{wxAUI_TB_NO_AUTORESIZE}
563 @style{wxAUI_TB_GRIPPER}
564 @style{wxAUI_TB_OVERFLOW}
565 @style{wxAUI_TB_VERTICAL}
566 using this style forces the toolbar to be vertical and
567 be only dockable to the left or right sides of the window
568 whereas by default it can be horizontal or vertical and
570 @style{wxAUI_TB_HORZ_LAYOUT}
571 @style{wxAUI_TB_HORIZONTAL}
572 analogous to wxAUI_TB_VERTICAL, but forces the toolbar
574 @style{wxAUI_TB_HORZ_TEXT}
575 Equivalent to wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT
576 @style{wxAUI_TB_DEFAULT_STYLE}
577 The default is to have no styles
580 @beginEventEmissionTable{wxAuiToolBarEvent}
581 @event{EVT_AUITOOLBAR_TOOL_DROPDOWN(id, func)}
582 Process a wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN event
583 @event{EVT_AUITOOLBAR_OVERFLOW_CLICK(id, func)}
584 Process a wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK event
585 @event{EVT_AUITOOLBAR_RIGHT_CLICK(id, func)}
586 Process a wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK event
587 @event{EVT_AUITOOLBAR_MIDDLE_CLICK(id, func)}
588 Process a wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK event
589 @event{EVT_AUITOOLBAR_BEGIN_DRAG(id, func)}
590 Process a wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG event
596 class wxAuiToolBar
: public wxControl
600 Default constructor, use Create() later.
607 Constructor creating and initializing the object.
609 wxAuiToolBar(wxWindow
* parent
,
610 wxWindowID id
= wxID_ANY
,
611 const wxPoint
& position
= wxDefaultPosition
,
612 const wxSize
& size
= wxDefaultSize
,
613 long style
= wxAUI_TB_DEFAULT_STYLE
);
616 Really create wxAuiToolBar created using default constructor.
620 bool Create(wxWindow
* parent
,
621 wxWindowID id
= wxID_ANY
,
622 const wxPoint
& pos
= wxDefaultPosition
,
623 const wxSize
& size
= wxDefaultSize
,
624 long style
= wxAUI_TB_DEFAULT_STYLE
);
625 virtual ~wxAuiToolBar();
627 void SetWindowStyleFlag(long style
);
628 long GetWindowStyleFlag() const;
630 void SetArtProvider(wxAuiToolBarArt
* art
);
631 wxAuiToolBarArt
* GetArtProvider() const;
633 bool SetFont(const wxFont
& font
);
636 wxAuiToolBarItem
* AddTool(int tool_id
,
637 const wxString
& label
,
638 const wxBitmap
& bitmap
,
639 const wxString
& short_help_string
= wxEmptyString
,
640 wxItemKind kind
= wxITEM_NORMAL
);
642 wxAuiToolBarItem
* AddTool(int tool_id
,
643 const wxString
& label
,
644 const wxBitmap
& bitmap
,
645 const wxBitmap
& disabled_bitmap
,
647 const wxString
& short_help_string
,
648 const wxString
& long_help_string
,
649 wxObject
* client_data
);
651 wxAuiToolBarItem
* AddTool(int tool_id
,
652 const wxBitmap
& bitmap
,
653 const wxBitmap
& disabled_bitmap
,
655 wxObject
* client_data
= NULL
,
656 const wxString
& short_help_string
= wxEmptyString
,
657 const wxString
& long_help_string
= wxEmptyString
);
659 wxAuiToolBarItem
* AddLabel(int tool_id
,
660 const wxString
& label
= wxEmptyString
,
661 const int width
= -1);
662 wxAuiToolBarItem
* AddControl(wxControl
* control
,
663 const wxString
& label
= wxEmptyString
);
664 wxAuiToolBarItem
* AddSeparator();
665 wxAuiToolBarItem
* AddSpacer(int pixels
);
666 wxAuiToolBarItem
* AddStretchSpacer(int proportion
= 1);
670 wxControl
* FindControl(int window_id
);
671 wxAuiToolBarItem
* FindToolByPosition(wxCoord x
, wxCoord y
) const;
672 wxAuiToolBarItem
* FindToolByIndex(int idx
) const;
673 wxAuiToolBarItem
* FindTool(int tool_id
) const;
677 bool DeleteTool(int tool_id
);
678 bool DeleteByIndex(int tool_id
);
680 size_t GetToolCount() const;
681 int GetToolPos(int tool_id
) const;
682 int GetToolIndex(int tool_id
) const;
683 bool GetToolFits(int tool_id
) const;
684 wxRect
GetToolRect(int tool_id
) const;
685 bool GetToolFitsByIndex(int tool_id
) const;
686 bool GetToolBarFits() const;
688 void SetMargins(const wxSize
& size
);
689 void SetMargins(int x
, int y
);
690 void SetMargins(int left
, int right
, int top
, int bottom
);
692 void SetToolBitmapSize(const wxSize
& size
);
693 wxSize
GetToolBitmapSize() const;
695 bool GetOverflowVisible() const;
696 void SetOverflowVisible(bool visible
);
698 bool GetGripperVisible() const;
699 void SetGripperVisible(bool visible
);
701 void ToggleTool(int tool_id
, bool state
);
702 bool GetToolToggled(int tool_id
) const;
704 void EnableTool(int tool_id
, bool state
);
705 bool GetToolEnabled(int tool_id
) const;
707 void SetToolDropDown(int tool_id
, bool dropdown
);
708 bool GetToolDropDown(int tool_id
) const;
710 void SetToolBorderPadding(int padding
);
711 int GetToolBorderPadding() const;
713 void SetToolTextOrientation(int orientation
);
714 int GetToolTextOrientation() const;
716 void SetToolPacking(int packing
);
717 int GetToolPacking() const;
719 void SetToolProportion(int tool_id
, int proportion
);
720 int GetToolProportion(int tool_id
) const;
722 void SetToolSeparation(int separation
);
723 int GetToolSeparation() const;
725 void SetToolSticky(int tool_id
, bool sticky
);
726 bool GetToolSticky(int tool_id
) const;
728 wxString
GetToolLabel(int tool_id
) const;
729 void SetToolLabel(int tool_id
, const wxString
& label
);
731 wxBitmap
GetToolBitmap(int tool_id
) const;
732 void SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
);
734 wxString
GetToolShortHelp(int tool_id
) const;
735 void SetToolShortHelp(int tool_id
, const wxString
& help_string
);
737 wxString
GetToolLongHelp(int tool_id
) const;
738 void SetToolLongHelp(int tool_id
, const wxString
& help_string
);
740 void SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
741 const wxAuiToolBarItemArray
& append
);
743 /** get size of hint rectangle for a particular dock location */
744 wxSize
GetHintSize(int dock_direction
) const;
745 bool IsPaneValid(const wxAuiPaneInfo
& pane
) const;