1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/toolbar.h
3 // Purpose: Documentation of wxAuiToolBar and related classes.
5 // Copyright: (c) 2011 wxWidgets development team
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
10 wxAuiToolBarStyle is part of the wxAUI class framework, used to define the appearance of a wxAuiToolBar.
12 See also @ref overview_aui.
17 enum wxAuiToolBarStyle
20 Shows the text in the toolbar buttons; by default only icons are shown.
22 wxAUI_TB_TEXT
= 1 << 0,
25 Don't show tooltips on wxAuiToolBar items.
27 wxAUI_TB_NO_TOOLTIPS
= 1 << 1,
30 Do not auto-resize the wxAuiToolBar.
32 wxAUI_TB_NO_AUTORESIZE
= 1 << 2,
35 Shows a gripper on the wxAuiToolBar.
37 wxAUI_TB_GRIPPER
= 1 << 3,
40 The wxAuiToolBar can contain overflow items.
42 wxAUI_TB_OVERFLOW
= 1 << 4,
45 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.
47 wxAUI_TB_VERTICAL
= 1 << 5,
50 Shows the text and the icons alongside, not vertically stacked. This style must be used with wxAUI_TB_TEXT
52 wxAUI_TB_HORZ_LAYOUT
= 1 << 6,
55 Analogous to wxAUI_TB_VERTICAL, but forces the toolbar to be horizontal, docking to the top or bottom of the window.
57 wxAUI_TB_HORIZONTAL
= 1 << 7,
61 Draw a plain background (based on parent) instead of the default gradient background.
65 wxAUI_TB_PLAIN_BACKGROUND
= 1 << 8,
68 Shows the text alongside the icons, not vertically stacked.
70 wxAUI_TB_HORZ_TEXT
= (wxAUI_TB_HORZ_LAYOUT
| wxAUI_TB_TEXT
),
73 Shows the text in the toolbar buttons; by default only icons are shown.
75 wxAUI_ORIENTATION_MASK
= (wxAUI_TB_VERTICAL
| wxAUI_TB_HORIZONTAL
),
78 By default only icons are shown.
80 wxAUI_TB_DEFAULT_STYLE
= 0
85 wxAuiToolBarArtSetting
90 enum wxAuiToolBarArtSetting
93 wxAuiToolBar seperator size.
95 wxAUI_TBART_SEPARATOR_SIZE
= 0,
98 wxAuiToolBar gripper size.
100 wxAUI_TBART_GRIPPER_SIZE
= 1,
103 Overflow button size in wxAuiToolBar.
105 wxAUI_TBART_OVERFLOW_SIZE
= 2
110 wxAuiToolBarToolTextOrientation
115 enum wxAuiToolBarToolTextOrientation
118 Text in wxAuiToolBar items is left aligned, currently unused/unimplemented.
120 wxAUI_TBTOOL_TEXT_LEFT
= 0,
123 Text in wxAuiToolBar items is right aligned.
125 wxAUI_TBTOOL_TEXT_RIGHT
= 1,
128 Text in wxAuiToolBar items is top aligned, currently unused/unimplemented.
130 wxAUI_TBTOOL_TEXT_TOP
= 2,
133 Text in wxAuiToolBar items is bottom aligned.
135 wxAUI_TBTOOL_TEXT_BOTTOM
= 3
141 @class wxAuiToolBarEvent
143 wxAuiToolBarEvent is used for the events generated by @ref wxAuiToolBar.
148 class wxAuiToolBarEvent
: public wxNotifyEvent
152 Returns whether the drop down menu has been clicked.
154 bool IsDropDownClicked() const;
157 Returns the point where the user clicked with the mouse.
159 wxPoint
GetClickPoint() const;
162 Returns the wxAuiToolBarItem rectangle bounding the mouse click point.
164 wxRect
GetItemRect() const;
167 Returns the wxAuiToolBarItem identifier.
169 int GetToolId() const;
174 @class wxAuiToolBarItem
176 wxAuiToolBarItem is part of the wxAUI class framework, representing a toolbar element.
178 See also @ref wxAuiToolBar and @ref overview_aui.
180 It has a unique id (except for the separators which always have id = -1), the
181 style (telling whether it is a normal button, separator or a control), the
182 state (toggled or not, enabled or not) and short and long help strings. The
183 default implementations use the short help string for the tooltip text which
184 is popped up when the mouse pointer enters the tool and the long help string
185 for the applications status bar (currently not implemented).
190 class wxAuiToolBarItem
200 Assigns the properties of the wxAuiToolBarItem "c" to this.
202 wxAuiToolBarItem(const wxAuiToolBarItem
& c
);
205 Assigns the properties of the wxAuiToolBarItem "c" to this, returning a pointer to this.
207 wxAuiToolBarItem
& operator=(const wxAuiToolBarItem
& c
);
210 Assigns the properties of the wxAuiToolBarItem "c" to this.
212 void Assign(const wxAuiToolBarItem
& c
);
215 Assigns a window to the toolbar item.
217 void SetWindow(wxWindow
* w
);
219 Returns the wxWindow* associated to the toolbar item.
221 wxWindow
* GetWindow();
224 Sets the toolbar item identifier.
226 void SetId(int new_id
);
228 Returns the toolbar item identifier.
233 Sets the wxAuiToolBarItem kind.
235 void SetKind(int new_kind
);
238 Returns the toolbar item kind.
245 void SetState(int new_state
);
249 int GetState() const;
254 void SetSizerItem(wxSizerItem
* s
);
258 wxSizerItem
* GetSizerItem() const;
263 void SetLabel(const wxString
& s
);
267 const wxString
& GetLabel() const;
272 void SetBitmap(const wxBitmap
& bmp
);
276 const wxBitmap
& GetBitmap() const;
281 void SetDisabledBitmap(const wxBitmap
& bmp
);
285 const wxBitmap
& GetDisabledBitmap() const;
290 void SetHoverBitmap(const wxBitmap
& bmp
);
294 const wxBitmap
& GetHoverBitmap() const;
299 void SetShortHelp(const wxString
& s
);
303 const wxString
& GetShortHelp() const;
308 void SetLongHelp(const wxString
& s
);
312 const wxString
& GetLongHelp() const;
317 void SetMinSize(const wxSize
& s
);
321 const wxSize
& GetMinSize() const;
326 void SetSpacerPixels(int s
);
330 int GetSpacerPixels() const;
335 void SetProportion(int p
);
339 int GetProportion() const;
344 void SetActive(bool b
);
348 bool IsActive() const;
351 Set whether this tool has a drop down button.
353 This is only valid for wxITEM_NORMAL tools.
355 void SetHasDropDown(bool b
);
357 Returns whether the toolbar item has an associated drop down button.
359 bool HasDropDown() const;
364 void SetSticky(bool b
);
368 bool IsSticky() const;
373 void SetUserData(long l
);
377 long GetUserData() const;
382 void SetAlignment(int l
);
386 int GetAlignment() const;
390 @class wxAuiToolBarArt
392 wxAuiToolBarArt is part of the wxAUI class framework.
393 See also @ref wxAuiToolBar and @ref overview_aui.
398 class wxAuiToolBarArt
403 virtual wxAuiToolBarArt
* Clone() = 0;
404 virtual void SetFlags(unsigned int flags
) = 0;
405 virtual unsigned int GetFlags() = 0;
406 virtual void SetFont(const wxFont
& font
) = 0;
407 virtual wxFont
GetFont() = 0;
408 virtual void SetTextOrientation(int orientation
) = 0;
409 virtual int GetTextOrientation() = 0;
411 virtual void DrawBackground(
414 const wxRect
& rect
) = 0;
416 virtual void DrawPlainBackground(
419 const wxRect
& rect
) = 0;
421 virtual void DrawLabel(
424 const wxAuiToolBarItem
& item
,
425 const wxRect
& rect
) = 0;
427 virtual void DrawButton(
430 const wxAuiToolBarItem
& item
,
431 const wxRect
& rect
) = 0;
433 virtual void DrawDropDownButton(
436 const wxAuiToolBarItem
& item
,
437 const wxRect
& rect
) = 0;
439 virtual void DrawControlLabel(
442 const wxAuiToolBarItem
& item
,
443 const wxRect
& rect
) = 0;
445 virtual void DrawSeparator(
448 const wxRect
& rect
) = 0;
450 virtual void DrawGripper(
453 const wxRect
& rect
) = 0;
455 virtual void DrawOverflowButton(
461 virtual wxSize
GetLabelSize(
464 const wxAuiToolBarItem
& item
) = 0;
466 virtual wxSize
GetToolSize(
469 const wxAuiToolBarItem
& item
) = 0;
471 virtual int GetElementSize(int element_id
) = 0;
472 virtual void SetElementSize(int element_id
, int size
) = 0;
474 virtual int ShowDropDown(
476 const wxAuiToolBarItemArray
& items
) = 0;
481 @class wxAuiDefaultToolBarArt
483 wxAuiDefaultToolBarArt is part of the wxAUI class framework.
484 See also @ref wxAuiToolBarArt , @ref wxAuiToolBar and @ref overview_aui.
489 class wxAuiDefaultToolBarArt
: public wxAuiToolBarArt
492 wxAuiDefaultToolBarArt();
493 virtual ~wxAuiDefaultToolBarArt();
495 virtual wxAuiToolBarArt
* Clone();
496 virtual void SetFlags(unsigned int flags
);
497 virtual unsigned int GetFlags();
498 virtual void SetFont(const wxFont
& font
);
499 virtual wxFont
GetFont();
500 virtual void SetTextOrientation(int orientation
);
501 virtual int GetTextOrientation();
503 virtual void DrawBackground(
508 virtual void DrawPlainBackground(wxDC
& dc
,
512 virtual void DrawLabel(
515 const wxAuiToolBarItem
& item
,
518 virtual void DrawButton(
521 const wxAuiToolBarItem
& item
,
524 virtual void DrawDropDownButton(
527 const wxAuiToolBarItem
& item
,
530 virtual void DrawControlLabel(
533 const wxAuiToolBarItem
& item
,
536 virtual void DrawSeparator(
541 virtual void DrawGripper(
546 virtual void DrawOverflowButton(
552 virtual wxSize
GetLabelSize(
555 const wxAuiToolBarItem
& item
);
557 virtual wxSize
GetToolSize(
560 const wxAuiToolBarItem
& item
);
562 virtual int GetElementSize(int element
);
563 virtual void SetElementSize(int element_id
, int size
);
565 virtual int ShowDropDown(wxWindow
* wnd
,
566 const wxAuiToolBarItemArray
& items
);
574 wxAuiToolBar is a dockable toolbar, part of the wxAUI class framework.
575 See also @ref overview_aui.
578 @style{wxAUI_TB_TEXT}
579 @style{wxAUI_TB_NO_TOOLTIPS}
580 @style{wxAUI_TB_NO_AUTORESIZE}
581 @style{wxAUI_TB_GRIPPER}
582 @style{wxAUI_TB_OVERFLOW}
583 @style{wxAUI_TB_VERTICAL}
584 using this style forces the toolbar to be vertical and
585 be only dockable to the left or right sides of the window
586 whereas by default it can be horizontal or vertical and
588 @style{wxAUI_TB_HORZ_LAYOUT}
589 @style{wxAUI_TB_HORIZONTAL}
590 analogous to wxAUI_TB_VERTICAL, but forces the toolbar
592 @style{wxAUI_TB_PLAIN_BACKGROUND}
593 Draw a plain background (based on parent) instead of the
594 default gradient background.
595 @style{wxAUI_TB_HORZ_TEXT}
596 Equivalent to wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT
597 @style{wxAUI_TB_DEFAULT_STYLE}
598 The default is to have no styles
601 @beginEventEmissionTable{wxAuiToolBarEvent}
602 @event{EVT_AUITOOLBAR_TOOL_DROPDOWN(id, func)}
603 Process a wxEVT_AUITOOLBAR_TOOL_DROPDOWN event
604 @event{EVT_AUITOOLBAR_OVERFLOW_CLICK(id, func)}
605 Process a wxEVT_AUITOOLBAR_OVERFLOW_CLICK event
606 @event{EVT_AUITOOLBAR_RIGHT_CLICK(id, func)}
607 Process a wxEVT_AUITOOLBAR_RIGHT_CLICK event
608 @event{EVT_AUITOOLBAR_MIDDLE_CLICK(id, func)}
609 Process a wxEVT_AUITOOLBAR_MIDDLE_CLICK event
610 @event{EVT_AUITOOLBAR_BEGIN_DRAG(id, func)}
611 Process a wxEVT_AUITOOLBAR_BEGIN_DRAG event
617 class wxAuiToolBar
: public wxControl
621 Default constructor, use Create() later.
628 Constructor creating and initializing the object.
630 wxAuiToolBar(wxWindow
* parent
,
631 wxWindowID id
= wxID_ANY
,
632 const wxPoint
& position
= wxDefaultPosition
,
633 const wxSize
& size
= wxDefaultSize
,
634 long style
= wxAUI_TB_DEFAULT_STYLE
);
637 Really create wxAuiToolBar created using default constructor.
641 bool Create(wxWindow
* parent
,
642 wxWindowID id
= wxID_ANY
,
643 const wxPoint
& pos
= wxDefaultPosition
,
644 const wxSize
& size
= wxDefaultSize
,
645 long style
= wxAUI_TB_DEFAULT_STYLE
);
646 virtual ~wxAuiToolBar();
648 void SetWindowStyleFlag(long style
);
649 long GetWindowStyleFlag() const;
651 void SetArtProvider(wxAuiToolBarArt
* art
);
652 wxAuiToolBarArt
* GetArtProvider() const;
654 bool SetFont(const wxFont
& font
);
657 wxAuiToolBarItem
* AddTool(int tool_id
,
658 const wxString
& label
,
659 const wxBitmap
& bitmap
,
660 const wxString
& short_help_string
= wxEmptyString
,
661 wxItemKind kind
= wxITEM_NORMAL
);
663 wxAuiToolBarItem
* AddTool(int tool_id
,
664 const wxString
& label
,
665 const wxBitmap
& bitmap
,
666 const wxBitmap
& disabled_bitmap
,
668 const wxString
& short_help_string
,
669 const wxString
& long_help_string
,
670 wxObject
* client_data
);
672 wxAuiToolBarItem
* AddTool(int tool_id
,
673 const wxBitmap
& bitmap
,
674 const wxBitmap
& disabled_bitmap
,
676 wxObject
* client_data
= NULL
,
677 const wxString
& short_help_string
= wxEmptyString
,
678 const wxString
& long_help_string
= wxEmptyString
);
680 wxAuiToolBarItem
* AddLabel(int tool_id
,
681 const wxString
& label
= wxEmptyString
,
682 const int width
= -1);
683 wxAuiToolBarItem
* AddControl(wxControl
* control
,
684 const wxString
& label
= wxEmptyString
);
685 wxAuiToolBarItem
* AddSeparator();
686 wxAuiToolBarItem
* AddSpacer(int pixels
);
687 wxAuiToolBarItem
* AddStretchSpacer(int proportion
= 1);
691 wxControl
* FindControl(int window_id
);
692 wxAuiToolBarItem
* FindToolByPosition(wxCoord x
, wxCoord y
) const;
693 wxAuiToolBarItem
* FindToolByIndex(int idx
) const;
694 wxAuiToolBarItem
* FindTool(int tool_id
) const;
698 bool DeleteTool(int tool_id
);
699 bool DeleteByIndex(int tool_id
);
701 size_t GetToolCount() const;
702 int GetToolPos(int tool_id
) const;
703 int GetToolIndex(int tool_id
) const;
704 bool GetToolFits(int tool_id
) const;
705 wxRect
GetToolRect(int tool_id
) const;
706 bool GetToolFitsByIndex(int tool_id
) const;
707 bool GetToolBarFits() const;
709 void SetMargins(const wxSize
& size
);
710 void SetMargins(int x
, int y
);
711 void SetMargins(int left
, int right
, int top
, int bottom
);
713 void SetToolBitmapSize(const wxSize
& size
);
714 wxSize
GetToolBitmapSize() const;
716 bool GetOverflowVisible() const;
717 void SetOverflowVisible(bool visible
);
719 bool GetGripperVisible() const;
720 void SetGripperVisible(bool visible
);
722 void ToggleTool(int tool_id
, bool state
);
723 bool GetToolToggled(int tool_id
) const;
725 void EnableTool(int tool_id
, bool state
);
726 bool GetToolEnabled(int tool_id
) const;
729 Set whether the specified toolbar item has a drop down button.
731 This is only valid for wxITEM_NORMAL tools.
733 @see wxAuiToolBarItem::SetHasDropDown()
735 void SetToolDropDown(int tool_id
, bool dropdown
);
738 Returns whether the specified toolbar item has an associated drop down
741 @see wxAuiToolBarItem::HasDropDown()
743 bool GetToolDropDown(int tool_id
) const;
745 void SetToolBorderPadding(int padding
);
746 int GetToolBorderPadding() const;
748 void SetToolTextOrientation(int orientation
);
749 int GetToolTextOrientation() const;
751 void SetToolPacking(int packing
);
752 int GetToolPacking() const;
754 void SetToolProportion(int tool_id
, int proportion
);
755 int GetToolProportion(int tool_id
) const;
757 void SetToolSeparation(int separation
);
758 int GetToolSeparation() const;
760 void SetToolSticky(int tool_id
, bool sticky
);
761 bool GetToolSticky(int tool_id
) const;
763 wxString
GetToolLabel(int tool_id
) const;
764 void SetToolLabel(int tool_id
, const wxString
& label
);
766 wxBitmap
GetToolBitmap(int tool_id
) const;
767 void SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
);
769 wxString
GetToolShortHelp(int tool_id
) const;
770 void SetToolShortHelp(int tool_id
, const wxString
& help_string
);
772 wxString
GetToolLongHelp(int tool_id
) const;
773 void SetToolLongHelp(int tool_id
, const wxString
& help_string
);
775 void SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
776 const wxAuiToolBarItemArray
& append
);
778 /** get size of hint rectangle for a particular dock location */
779 wxSize
GetHintSize(int dock_direction
) const;
780 bool IsPaneValid(const wxAuiPaneInfo
& pane
) const;