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,
62 Draw a plain background (based on parent) instead of the default gradient background.
66 wxAUI_TB_PLAIN_BACKGROUND
= 1 << 8,
69 Shows the text alongside the icons, not vertically stacked.
71 wxAUI_TB_HORZ_TEXT
= (wxAUI_TB_HORZ_LAYOUT
| wxAUI_TB_TEXT
),
74 Shows the text in the toolbar buttons; by default only icons are shown.
76 wxAUI_ORIENTATION_MASK
= (wxAUI_TB_VERTICAL
| wxAUI_TB_HORIZONTAL
),
79 By default only icons are shown.
81 wxAUI_TB_DEFAULT_STYLE
= 0
86 wxAuiToolBarArtSetting
91 enum wxAuiToolBarArtSetting
94 wxAuiToolBar seperator size.
96 wxAUI_TBART_SEPARATOR_SIZE
= 0,
99 wxAuiToolBar gripper size.
101 wxAUI_TBART_GRIPPER_SIZE
= 1,
104 Overflow button size in wxAuiToolBar.
106 wxAUI_TBART_OVERFLOW_SIZE
= 2
111 wxAuiToolBarToolTextOrientation
116 enum wxAuiToolBarToolTextOrientation
119 Text in wxAuiToolBar items is left aligned, currently unused/unimplemented.
121 wxAUI_TBTOOL_TEXT_LEFT
= 0,
124 Text in wxAuiToolBar items is right aligned.
126 wxAUI_TBTOOL_TEXT_RIGHT
= 1,
129 Text in wxAuiToolBar items is top aligned, currently unused/unimplemented.
131 wxAUI_TBTOOL_TEXT_TOP
= 2,
134 Text in wxAuiToolBar items is bottom aligned.
136 wxAUI_TBTOOL_TEXT_BOTTOM
= 3
142 @class wxAuiToolBarEvent
144 wxAuiToolBarEvent is used for the events generated by @ref wxAuiToolBar.
149 class wxAuiToolBarEvent
: public wxNotifyEvent
153 Returns whether the drop down menu has been clicked.
155 bool IsDropDownClicked() const;
158 Returns the point where the user clicked with the mouse.
160 wxPoint
GetClickPoint() const;
163 Returns the wxAuiToolBarItem rectangle bounding the mouse click point.
165 wxRect
GetItemRect() const;
168 Returns the wxAuiToolBarItem identifier.
170 int GetToolId() const;
175 @class wxAuiToolBarItem
177 wxAuiToolBarItem is part of the wxAUI class framework, representing a toolbar element.
179 See also @ref wxAuiToolBar and @ref overview_aui.
181 It has a unique id (except for the separators which always have id = -1), the
182 style (telling whether it is a normal button, separator or a control), the
183 state (toggled or not, enabled or not) and short and long help strings. The
184 default implementations use the short help string for the tooltip text which
185 is popped up when the mouse pointer enters the tool and the long help string
186 for the applications status bar (currently not implemented).
191 class wxAuiToolBarItem
201 Assigns the properties of the wxAuiToolBarItem "c" to this.
203 wxAuiToolBarItem(const wxAuiToolBarItem
& c
);
206 Assigns the properties of the wxAuiToolBarItem "c" to this, returning a pointer to this.
208 wxAuiToolBarItem
& operator=(const wxAuiToolBarItem
& c
);
211 Assigns the properties of the wxAuiToolBarItem "c" to this.
213 void Assign(const wxAuiToolBarItem
& c
);
216 Assigns a window to the toolbar item.
218 void SetWindow(wxWindow
* w
);
220 Returns the wxWindow* associated to the toolbar item.
222 wxWindow
* GetWindow();
225 Sets the toolbar item identifier.
227 void SetId(int new_id
);
229 Returns the toolbar item identifier.
234 Sets the wxAuiToolBarItem kind.
236 void SetKind(int new_kind
);
239 Returns the toolbar item kind.
246 void SetState(int new_state
);
250 int GetState() const;
255 void SetSizerItem(wxSizerItem
* s
);
259 wxSizerItem
* GetSizerItem() const;
264 void SetLabel(const wxString
& s
);
268 const wxString
& GetLabel() const;
273 void SetBitmap(const wxBitmap
& bmp
);
277 const wxBitmap
& GetBitmap() const;
282 void SetDisabledBitmap(const wxBitmap
& bmp
);
286 const wxBitmap
& GetDisabledBitmap() const;
291 void SetHoverBitmap(const wxBitmap
& bmp
);
295 const wxBitmap
& GetHoverBitmap() const;
300 void SetShortHelp(const wxString
& s
);
304 const wxString
& GetShortHelp() const;
309 void SetLongHelp(const wxString
& s
);
313 const wxString
& GetLongHelp() const;
318 void SetMinSize(const wxSize
& s
);
322 const wxSize
& GetMinSize() const;
327 void SetSpacerPixels(int s
);
331 int GetSpacerPixels() const;
336 void SetProportion(int p
);
340 int GetProportion() const;
345 void SetActive(bool b
);
349 bool IsActive() const;
352 Set whether this tool has a drop down button.
354 This is only valid for wxITEM_NORMAL tools.
356 void SetHasDropDown(bool b
);
358 Returns whether the toolbar item has an associated drop down button.
360 bool HasDropDown() const;
365 void SetSticky(bool b
);
369 bool IsSticky() const;
374 void SetUserData(long l
);
378 long GetUserData() const;
383 void SetAlignment(int l
);
387 int GetAlignment() const;
391 @class wxAuiToolBarArt
393 wxAuiToolBarArt is part of the wxAUI class framework.
394 See also @ref wxAuiToolBar and @ref overview_aui.
399 class wxAuiToolBarArt
404 virtual wxAuiToolBarArt
* Clone() = 0;
405 virtual void SetFlags(unsigned int flags
) = 0;
406 virtual unsigned int GetFlags() = 0;
407 virtual void SetFont(const wxFont
& font
) = 0;
408 virtual wxFont
GetFont() = 0;
409 virtual void SetTextOrientation(int orientation
) = 0;
410 virtual int GetTextOrientation() = 0;
412 virtual void DrawBackground(
415 const wxRect
& rect
) = 0;
417 virtual void DrawPlainBackground(
420 const wxRect
& rect
) = 0;
422 virtual void DrawLabel(
425 const wxAuiToolBarItem
& item
,
426 const wxRect
& rect
) = 0;
428 virtual void DrawButton(
431 const wxAuiToolBarItem
& item
,
432 const wxRect
& rect
) = 0;
434 virtual void DrawDropDownButton(
437 const wxAuiToolBarItem
& item
,
438 const wxRect
& rect
) = 0;
440 virtual void DrawControlLabel(
443 const wxAuiToolBarItem
& item
,
444 const wxRect
& rect
) = 0;
446 virtual void DrawSeparator(
449 const wxRect
& rect
) = 0;
451 virtual void DrawGripper(
454 const wxRect
& rect
) = 0;
456 virtual void DrawOverflowButton(
462 virtual wxSize
GetLabelSize(
465 const wxAuiToolBarItem
& item
) = 0;
467 virtual wxSize
GetToolSize(
470 const wxAuiToolBarItem
& item
) = 0;
472 virtual int GetElementSize(int element_id
) = 0;
473 virtual void SetElementSize(int element_id
, int size
) = 0;
475 virtual int ShowDropDown(
477 const wxAuiToolBarItemArray
& items
) = 0;
482 @class wxAuiDefaultToolBarArt
484 wxAuiDefaultToolBarArt is part of the wxAUI class framework.
485 See also @ref wxAuiToolBarArt , @ref wxAuiToolBar and @ref overview_aui.
490 class wxAuiDefaultToolBarArt
: public wxAuiToolBarArt
493 wxAuiDefaultToolBarArt();
494 virtual ~wxAuiDefaultToolBarArt();
496 virtual wxAuiToolBarArt
* Clone();
497 virtual void SetFlags(unsigned int flags
);
498 virtual unsigned int GetFlags();
499 virtual void SetFont(const wxFont
& font
);
500 virtual wxFont
GetFont();
501 virtual void SetTextOrientation(int orientation
);
502 virtual int GetTextOrientation();
504 virtual void DrawBackground(
509 virtual void DrawPlainBackground(wxDC
& dc
,
513 virtual void DrawLabel(
516 const wxAuiToolBarItem
& item
,
519 virtual void DrawButton(
522 const wxAuiToolBarItem
& item
,
525 virtual void DrawDropDownButton(
528 const wxAuiToolBarItem
& item
,
531 virtual void DrawControlLabel(
534 const wxAuiToolBarItem
& item
,
537 virtual void DrawSeparator(
542 virtual void DrawGripper(
547 virtual void DrawOverflowButton(
553 virtual wxSize
GetLabelSize(
556 const wxAuiToolBarItem
& item
);
558 virtual wxSize
GetToolSize(
561 const wxAuiToolBarItem
& item
);
563 virtual int GetElementSize(int element
);
564 virtual void SetElementSize(int element_id
, int size
);
566 virtual int ShowDropDown(wxWindow
* wnd
,
567 const wxAuiToolBarItemArray
& items
);
575 wxAuiToolBar is a dockable toolbar, part of the wxAUI class framework.
576 See also @ref overview_aui.
579 @style{wxAUI_TB_TEXT}
580 @style{wxAUI_TB_NO_TOOLTIPS}
581 @style{wxAUI_TB_NO_AUTORESIZE}
582 @style{wxAUI_TB_GRIPPER}
583 @style{wxAUI_TB_OVERFLOW}
584 @style{wxAUI_TB_VERTICAL}
585 using this style forces the toolbar to be vertical and
586 be only dockable to the left or right sides of the window
587 whereas by default it can be horizontal or vertical and
589 @style{wxAUI_TB_HORZ_LAYOUT}
590 @style{wxAUI_TB_HORIZONTAL}
591 analogous to wxAUI_TB_VERTICAL, but forces the toolbar
593 @style{wxAUI_TB_PLAIN_BACKGROUND}
594 Draw a plain background (based on parent) instead of the
595 default gradient background.
596 @style{wxAUI_TB_HORZ_TEXT}
597 Equivalent to wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT
598 @style{wxAUI_TB_DEFAULT_STYLE}
599 The default is to have no styles
602 @beginEventEmissionTable{wxAuiToolBarEvent}
603 @event{EVT_AUITOOLBAR_TOOL_DROPDOWN(id, func)}
604 Process a wxEVT_AUITOOLBAR_TOOL_DROPDOWN event
605 @event{EVT_AUITOOLBAR_OVERFLOW_CLICK(id, func)}
606 Process a wxEVT_AUITOOLBAR_OVERFLOW_CLICK event
607 @event{EVT_AUITOOLBAR_RIGHT_CLICK(id, func)}
608 Process a wxEVT_AUITOOLBAR_RIGHT_CLICK event
609 @event{EVT_AUITOOLBAR_MIDDLE_CLICK(id, func)}
610 Process a wxEVT_AUITOOLBAR_MIDDLE_CLICK event
611 @event{EVT_AUITOOLBAR_BEGIN_DRAG(id, func)}
612 Process a wxEVT_AUITOOLBAR_BEGIN_DRAG event
618 class wxAuiToolBar
: public wxControl
622 Default constructor, use Create() later.
629 Constructor creating and initializing the object.
631 wxAuiToolBar(wxWindow
* parent
,
632 wxWindowID id
= wxID_ANY
,
633 const wxPoint
& position
= wxDefaultPosition
,
634 const wxSize
& size
= wxDefaultSize
,
635 long style
= wxAUI_TB_DEFAULT_STYLE
);
638 Really create wxAuiToolBar created using default constructor.
642 bool Create(wxWindow
* parent
,
643 wxWindowID id
= wxID_ANY
,
644 const wxPoint
& pos
= wxDefaultPosition
,
645 const wxSize
& size
= wxDefaultSize
,
646 long style
= wxAUI_TB_DEFAULT_STYLE
);
647 virtual ~wxAuiToolBar();
649 void SetWindowStyleFlag(long style
);
650 long GetWindowStyleFlag() const;
652 void SetArtProvider(wxAuiToolBarArt
* art
);
653 wxAuiToolBarArt
* GetArtProvider() const;
655 bool SetFont(const wxFont
& font
);
658 wxAuiToolBarItem
* AddTool(int tool_id
,
659 const wxString
& label
,
660 const wxBitmap
& bitmap
,
661 const wxString
& short_help_string
= wxEmptyString
,
662 wxItemKind kind
= wxITEM_NORMAL
);
664 wxAuiToolBarItem
* AddTool(int tool_id
,
665 const wxString
& label
,
666 const wxBitmap
& bitmap
,
667 const wxBitmap
& disabled_bitmap
,
669 const wxString
& short_help_string
,
670 const wxString
& long_help_string
,
671 wxObject
* client_data
);
673 wxAuiToolBarItem
* AddTool(int tool_id
,
674 const wxBitmap
& bitmap
,
675 const wxBitmap
& disabled_bitmap
,
677 wxObject
* client_data
= NULL
,
678 const wxString
& short_help_string
= wxEmptyString
,
679 const wxString
& long_help_string
= wxEmptyString
);
681 wxAuiToolBarItem
* AddLabel(int tool_id
,
682 const wxString
& label
= wxEmptyString
,
683 const int width
= -1);
684 wxAuiToolBarItem
* AddControl(wxControl
* control
,
685 const wxString
& label
= wxEmptyString
);
686 wxAuiToolBarItem
* AddSeparator();
687 wxAuiToolBarItem
* AddSpacer(int pixels
);
688 wxAuiToolBarItem
* AddStretchSpacer(int proportion
= 1);
692 wxControl
* FindControl(int window_id
);
693 wxAuiToolBarItem
* FindToolByPosition(wxCoord x
, wxCoord y
) const;
694 wxAuiToolBarItem
* FindToolByIndex(int idx
) const;
695 wxAuiToolBarItem
* FindTool(int tool_id
) const;
699 bool DeleteTool(int tool_id
);
700 bool DeleteByIndex(int tool_id
);
702 size_t GetToolCount() const;
703 int GetToolPos(int tool_id
) const;
704 int GetToolIndex(int tool_id
) const;
705 bool GetToolFits(int tool_id
) const;
706 wxRect
GetToolRect(int tool_id
) const;
707 bool GetToolFitsByIndex(int tool_id
) const;
708 bool GetToolBarFits() const;
710 void SetMargins(const wxSize
& size
);
711 void SetMargins(int x
, int y
);
712 void SetMargins(int left
, int right
, int top
, int bottom
);
714 void SetToolBitmapSize(const wxSize
& size
);
715 wxSize
GetToolBitmapSize() const;
717 bool GetOverflowVisible() const;
718 void SetOverflowVisible(bool visible
);
720 bool GetGripperVisible() const;
721 void SetGripperVisible(bool visible
);
723 void ToggleTool(int tool_id
, bool state
);
724 bool GetToolToggled(int tool_id
) const;
726 void EnableTool(int tool_id
, bool state
);
727 bool GetToolEnabled(int tool_id
) const;
730 Set whether the specified toolbar item has a drop down button.
732 This is only valid for wxITEM_NORMAL tools.
734 @see wxAuiToolBarItem::SetHasDropDown()
736 void SetToolDropDown(int tool_id
, bool dropdown
);
739 Returns whether the specified toolbar item has an associated drop down
742 @see wxAuiToolBarItem::HasDropDown()
744 bool GetToolDropDown(int tool_id
) const;
746 void SetToolBorderPadding(int padding
);
747 int GetToolBorderPadding() const;
749 void SetToolTextOrientation(int orientation
);
750 int GetToolTextOrientation() const;
752 void SetToolPacking(int packing
);
753 int GetToolPacking() const;
755 void SetToolProportion(int tool_id
, int proportion
);
756 int GetToolProportion(int tool_id
) const;
758 void SetToolSeparation(int separation
);
759 int GetToolSeparation() const;
761 void SetToolSticky(int tool_id
, bool sticky
);
762 bool GetToolSticky(int tool_id
) const;
764 wxString
GetToolLabel(int tool_id
) const;
765 void SetToolLabel(int tool_id
, const wxString
& label
);
767 wxBitmap
GetToolBitmap(int tool_id
) const;
768 void SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
);
770 wxString
GetToolShortHelp(int tool_id
) const;
771 void SetToolShortHelp(int tool_id
, const wxString
& help_string
);
773 wxString
GetToolLongHelp(int tool_id
) const;
774 void SetToolLongHelp(int tool_id
, const wxString
& help_string
);
776 void SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
777 const wxAuiToolBarItemArray
& append
);
779 /** get size of hint rectangle for a particular dock location */
780 wxSize
GetHintSize(int dock_direction
) const;
781 bool IsPaneValid(const wxAuiPaneInfo
& pane
) const;