Provide shorter synonyms for wxEVT_XXX constants.
[wxWidgets.git] / interface / wx / aui / auibar.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/toolbar.h
3 // Purpose: Documentation of wxAuiToolBar and related classes.
4 // Created: 2011-01-17
5 // RCS-ID: $Id$
6 // Copyright: (c) 2011 wxWidgets development team
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 /**
11 wxAuiToolBarStyle is part of the wxAUI class framework, used to define the appearance of a wxAuiToolBar.
12
13 See also @ref overview_aui.
14
15 @library{wxaui}
16 @category{aui}
17 */
18 enum wxAuiToolBarStyle
19 {
20 /**
21 Shows the text in the toolbar buttons; by default only icons are shown.
22 */
23 wxAUI_TB_TEXT = 1 << 0,
24
25 /**
26 Don't show tooltips on wxAuiToolBar items.
27 */
28 wxAUI_TB_NO_TOOLTIPS = 1 << 1,
29
30 /**
31 Do not auto-resize the wxAuiToolBar.
32 */
33 wxAUI_TB_NO_AUTORESIZE = 1 << 2,
34
35 /**
36 Shows a gripper on the wxAuiToolBar.
37 */
38 wxAUI_TB_GRIPPER = 1 << 3,
39
40 /**
41 The wxAuiToolBar can contain overflow items.
42 */
43 wxAUI_TB_OVERFLOW = 1 << 4,
44
45 /**
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.
47 */
48 wxAUI_TB_VERTICAL = 1 << 5,
49
50 /**
51 Shows the text and the icons alongside, not vertically stacked. This style must be used with wxAUI_TB_TEXT
52 */
53 wxAUI_TB_HORZ_LAYOUT = 1 << 6,
54
55 /**
56 Analogous to wxAUI_TB_VERTICAL, but forces the toolbar to be horizontal, docking to the top or bottom of the window.
57 */
58 wxAUI_TB_HORIZONTAL = 1 << 7,
59
60
61 /**
62 Draw a plain background (based on parent) instead of the default gradient background.
63
64 @since 2.9.5
65 */
66 wxAUI_TB_PLAIN_BACKGROUND = 1 << 8,
67
68 /**
69 Shows the text alongside the icons, not vertically stacked.
70 */
71 wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT),
72
73 /**
74 Shows the text in the toolbar buttons; by default only icons are shown.
75 */
76 wxAUI_ORIENTATION_MASK = (wxAUI_TB_VERTICAL | wxAUI_TB_HORIZONTAL),
77
78 /**
79 By default only icons are shown.
80 */
81 wxAUI_TB_DEFAULT_STYLE = 0
82
83 };
84
85 /**
86 wxAuiToolBarArtSetting
87
88 @library{wxaui}
89 @category{aui}
90 */
91 enum wxAuiToolBarArtSetting
92 {
93 /**
94 wxAuiToolBar seperator size.
95 */
96 wxAUI_TBART_SEPARATOR_SIZE = 0,
97
98 /**
99 wxAuiToolBar gripper size.
100 */
101 wxAUI_TBART_GRIPPER_SIZE = 1,
102
103 /**
104 Overflow button size in wxAuiToolBar.
105 */
106 wxAUI_TBART_OVERFLOW_SIZE = 2
107
108 };
109
110 /**
111 wxAuiToolBarToolTextOrientation
112
113 @library{wxaui}
114 @category{aui}
115 */
116 enum wxAuiToolBarToolTextOrientation
117 {
118 /**
119 Text in wxAuiToolBar items is left aligned, currently unused/unimplemented.
120 */
121 wxAUI_TBTOOL_TEXT_LEFT = 0,
122
123 /**
124 Text in wxAuiToolBar items is right aligned.
125 */
126 wxAUI_TBTOOL_TEXT_RIGHT = 1,
127
128 /**
129 Text in wxAuiToolBar items is top aligned, currently unused/unimplemented.
130 */
131 wxAUI_TBTOOL_TEXT_TOP = 2,
132
133 /**
134 Text in wxAuiToolBar items is bottom aligned.
135 */
136 wxAUI_TBTOOL_TEXT_BOTTOM = 3
137
138 };
139
140
141 /**
142 @class wxAuiToolBarEvent
143
144 wxAuiToolBarEvent is used for the events generated by @ref wxAuiToolBar.
145
146 @library{wxaui}
147 @category{aui}
148 */
149 class wxAuiToolBarEvent : public wxNotifyEvent
150 {
151 public:
152 /**
153 Returns whether the drop down menu has been clicked.
154 */
155 bool IsDropDownClicked() const;
156
157 /**
158 Returns the point where the user clicked with the mouse.
159 */
160 wxPoint GetClickPoint() const;
161
162 /**
163 Returns the wxAuiToolBarItem rectangle bounding the mouse click point.
164 */
165 wxRect GetItemRect() const;
166
167 /**
168 Returns the wxAuiToolBarItem identifier.
169 */
170 int GetToolId() const;
171 };
172
173
174 /**
175 @class wxAuiToolBarItem
176
177 wxAuiToolBarItem is part of the wxAUI class framework, representing a toolbar element.
178
179 See also @ref wxAuiToolBar and @ref overview_aui.
180
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).
187
188 @library{wxaui}
189 @category{aui}
190 */
191 class wxAuiToolBarItem
192 {
193 public:
194
195 /**
196 Default Constructor
197 */
198 wxAuiToolBarItem();
199
200 /**
201 Assigns the properties of the wxAuiToolBarItem "c" to this.
202 */
203 wxAuiToolBarItem(const wxAuiToolBarItem& c);
204
205 /**
206 Assigns the properties of the wxAuiToolBarItem "c" to this, returning a pointer to this.
207 */
208 wxAuiToolBarItem& operator=(const wxAuiToolBarItem& c);
209
210 /**
211 Assigns the properties of the wxAuiToolBarItem "c" to this.
212 */
213 void Assign(const wxAuiToolBarItem& c);
214
215 /**
216 Assigns a window to the toolbar item.
217 */
218 void SetWindow(wxWindow* w);
219 /**
220 Returns the wxWindow* associated to the toolbar item.
221 */
222 wxWindow* GetWindow();
223
224 /**
225 Sets the toolbar item identifier.
226 */
227 void SetId(int new_id);
228 /**
229 Returns the toolbar item identifier.
230 */
231 int GetId() const;
232
233 /**
234 Sets the wxAuiToolBarItem kind.
235 */
236 void SetKind(int new_kind);
237
238 /**
239 Returns the toolbar item kind.
240 */
241 int GetKind() const;
242
243 /**
244
245 */
246 void SetState(int new_state);
247 /**
248
249 */
250 int GetState() const;
251
252 /**
253
254 */
255 void SetSizerItem(wxSizerItem* s);
256 /**
257
258 */
259 wxSizerItem* GetSizerItem() const;
260
261 /**
262
263 */
264 void SetLabel(const wxString& s);
265 /**
266
267 */
268 const wxString& GetLabel() const;
269
270 /**
271
272 */
273 void SetBitmap(const wxBitmap& bmp);
274 /**
275
276 */
277 const wxBitmap& GetBitmap() const;
278
279 /**
280
281 */
282 void SetDisabledBitmap(const wxBitmap& bmp);
283 /**
284
285 */
286 const wxBitmap& GetDisabledBitmap() const;
287
288 /**
289
290 */
291 void SetHoverBitmap(const wxBitmap& bmp);
292 /**
293
294 */
295 const wxBitmap& GetHoverBitmap() const;
296
297 /**
298
299 */
300 void SetShortHelp(const wxString& s);
301 /**
302
303 */
304 const wxString& GetShortHelp() const;
305
306 /**
307
308 */
309 void SetLongHelp(const wxString& s);
310 /**
311
312 */
313 const wxString& GetLongHelp() const;
314
315 /**
316
317 */
318 void SetMinSize(const wxSize& s);
319 /**
320
321 */
322 const wxSize& GetMinSize() const;
323
324 /**
325
326 */
327 void SetSpacerPixels(int s);
328 /**
329
330 */
331 int GetSpacerPixels() const;
332
333 /**
334
335 */
336 void SetProportion(int p);
337 /**
338
339 */
340 int GetProportion() const;
341
342 /**
343
344 */
345 void SetActive(bool b);
346 /**
347
348 */
349 bool IsActive() const;
350
351 /**
352 Set whether this tool has a drop down button.
353
354 This is only valid for wxITEM_NORMAL tools.
355 */
356 void SetHasDropDown(bool b);
357 /**
358 Returns whether the toolbar item has an associated drop down button.
359 */
360 bool HasDropDown() const;
361
362 /**
363
364 */
365 void SetSticky(bool b);
366 /**
367
368 */
369 bool IsSticky() const;
370
371 /**
372
373 */
374 void SetUserData(long l);
375 /**
376
377 */
378 long GetUserData() const;
379
380 /**
381
382 */
383 void SetAlignment(int l);
384 /**
385
386 */
387 int GetAlignment() const;
388 };
389
390 /**
391 @class wxAuiToolBarArt
392
393 wxAuiToolBarArt is part of the wxAUI class framework.
394 See also @ref wxAuiToolBar and @ref overview_aui.
395
396 @library{wxaui}
397 @category{aui}
398 */
399 class wxAuiToolBarArt
400 {
401 public:
402 wxAuiToolBarArt();
403
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;
411
412 virtual void DrawBackground(
413 wxDC& dc,
414 wxWindow* wnd,
415 const wxRect& rect) = 0;
416
417 virtual void DrawPlainBackground(
418 wxDC& dc,
419 wxWindow* wnd,
420 const wxRect& rect) = 0;
421
422 virtual void DrawLabel(
423 wxDC& dc,
424 wxWindow* wnd,
425 const wxAuiToolBarItem& item,
426 const wxRect& rect) = 0;
427
428 virtual void DrawButton(
429 wxDC& dc,
430 wxWindow* wnd,
431 const wxAuiToolBarItem& item,
432 const wxRect& rect) = 0;
433
434 virtual void DrawDropDownButton(
435 wxDC& dc,
436 wxWindow* wnd,
437 const wxAuiToolBarItem& item,
438 const wxRect& rect) = 0;
439
440 virtual void DrawControlLabel(
441 wxDC& dc,
442 wxWindow* wnd,
443 const wxAuiToolBarItem& item,
444 const wxRect& rect) = 0;
445
446 virtual void DrawSeparator(
447 wxDC& dc,
448 wxWindow* wnd,
449 const wxRect& rect) = 0;
450
451 virtual void DrawGripper(
452 wxDC& dc,
453 wxWindow* wnd,
454 const wxRect& rect) = 0;
455
456 virtual void DrawOverflowButton(
457 wxDC& dc,
458 wxWindow* wnd,
459 const wxRect& rect,
460 int state) = 0;
461
462 virtual wxSize GetLabelSize(
463 wxDC& dc,
464 wxWindow* wnd,
465 const wxAuiToolBarItem& item) = 0;
466
467 virtual wxSize GetToolSize(
468 wxDC& dc,
469 wxWindow* wnd,
470 const wxAuiToolBarItem& item) = 0;
471
472 virtual int GetElementSize(int element_id) = 0;
473 virtual void SetElementSize(int element_id, int size) = 0;
474
475 virtual int ShowDropDown(
476 wxWindow* wnd,
477 const wxAuiToolBarItemArray& items) = 0;
478 };
479
480
481 /**
482 @class wxAuiDefaultToolBarArt
483
484 wxAuiDefaultToolBarArt is part of the wxAUI class framework.
485 See also @ref wxAuiToolBarArt , @ref wxAuiToolBar and @ref overview_aui.
486
487 @library{wxaui}
488 @category{aui}
489 */
490 class wxAuiDefaultToolBarArt : public wxAuiToolBarArt
491 {
492 public:
493 wxAuiDefaultToolBarArt();
494 virtual ~wxAuiDefaultToolBarArt();
495
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();
503
504 virtual void DrawBackground(
505 wxDC& dc,
506 wxWindow* wnd,
507 const wxRect& rect);
508
509 virtual void DrawPlainBackground(wxDC& dc,
510 wxWindow* wnd,
511 const wxRect& rect);
512
513 virtual void DrawLabel(
514 wxDC& dc,
515 wxWindow* wnd,
516 const wxAuiToolBarItem& item,
517 const wxRect& rect);
518
519 virtual void DrawButton(
520 wxDC& dc,
521 wxWindow* wnd,
522 const wxAuiToolBarItem& item,
523 const wxRect& rect);
524
525 virtual void DrawDropDownButton(
526 wxDC& dc,
527 wxWindow* wnd,
528 const wxAuiToolBarItem& item,
529 const wxRect& rect);
530
531 virtual void DrawControlLabel(
532 wxDC& dc,
533 wxWindow* wnd,
534 const wxAuiToolBarItem& item,
535 const wxRect& rect);
536
537 virtual void DrawSeparator(
538 wxDC& dc,
539 wxWindow* wnd,
540 const wxRect& rect);
541
542 virtual void DrawGripper(
543 wxDC& dc,
544 wxWindow* wnd,
545 const wxRect& rect);
546
547 virtual void DrawOverflowButton(
548 wxDC& dc,
549 wxWindow* wnd,
550 const wxRect& rect,
551 int state);
552
553 virtual wxSize GetLabelSize(
554 wxDC& dc,
555 wxWindow* wnd,
556 const wxAuiToolBarItem& item);
557
558 virtual wxSize GetToolSize(
559 wxDC& dc,
560 wxWindow* wnd,
561 const wxAuiToolBarItem& item);
562
563 virtual int GetElementSize(int element);
564 virtual void SetElementSize(int element_id, int size);
565
566 virtual int ShowDropDown(wxWindow* wnd,
567 const wxAuiToolBarItemArray& items);
568 };
569
570
571
572 /**
573 @class wxAuiToolBar
574
575 wxAuiToolBar is a dockable toolbar, part of the wxAUI class framework.
576 See also @ref overview_aui.
577
578 @beginStyleTable
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
588 be docked anywhere
589 @style{wxAUI_TB_HORZ_LAYOUT}
590 @style{wxAUI_TB_HORIZONTAL}
591 analogous to wxAUI_TB_VERTICAL, but forces the toolbar
592 to be horizontal
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
600 @endStyleTable
601
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
613 @endEventTable
614
615 @library{wxaui}
616 @category{aui}
617 */
618 class wxAuiToolBar : public wxControl
619 {
620 public:
621 /**
622 Default constructor, use Create() later.
623
624 @since 2.9.5
625 */
626 wxAuiToolBar();
627
628 /**
629 Constructor creating and initializing the object.
630 */
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);
636
637 /**
638 Really create wxAuiToolBar created using default constructor.
639
640 @since 2.9.5
641 */
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();
648
649 void SetWindowStyleFlag(long style);
650 long GetWindowStyleFlag() const;
651
652 void SetArtProvider(wxAuiToolBarArt* art);
653 wxAuiToolBarArt* GetArtProvider() const;
654
655 bool SetFont(const wxFont& font);
656
657
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);
663
664 wxAuiToolBarItem* AddTool(int tool_id,
665 const wxString& label,
666 const wxBitmap& bitmap,
667 const wxBitmap& disabled_bitmap,
668 wxItemKind kind,
669 const wxString& short_help_string,
670 const wxString& long_help_string,
671 wxObject* client_data);
672
673 wxAuiToolBarItem* AddTool(int tool_id,
674 const wxBitmap& bitmap,
675 const wxBitmap& disabled_bitmap,
676 bool toggle = false,
677 wxObject* client_data = NULL,
678 const wxString& short_help_string = wxEmptyString,
679 const wxString& long_help_string = wxEmptyString);
680
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);
689
690 bool Realize();
691
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;
696
697 void ClearTools();
698 void Clear();
699 bool DeleteTool(int tool_id);
700 bool DeleteByIndex(int tool_id);
701
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;
709
710 void SetMargins(const wxSize& size);
711 void SetMargins(int x, int y);
712 void SetMargins(int left, int right, int top, int bottom);
713
714 void SetToolBitmapSize(const wxSize& size);
715 wxSize GetToolBitmapSize() const;
716
717 bool GetOverflowVisible() const;
718 void SetOverflowVisible(bool visible);
719
720 bool GetGripperVisible() const;
721 void SetGripperVisible(bool visible);
722
723 void ToggleTool(int tool_id, bool state);
724 bool GetToolToggled(int tool_id) const;
725
726 void EnableTool(int tool_id, bool state);
727 bool GetToolEnabled(int tool_id) const;
728
729 /**
730 Set whether the specified toolbar item has a drop down button.
731
732 This is only valid for wxITEM_NORMAL tools.
733
734 @see wxAuiToolBarItem::SetHasDropDown()
735 */
736 void SetToolDropDown(int tool_id, bool dropdown);
737
738 /**
739 Returns whether the specified toolbar item has an associated drop down
740 button.
741
742 @see wxAuiToolBarItem::HasDropDown()
743 */
744 bool GetToolDropDown(int tool_id) const;
745
746 void SetToolBorderPadding(int padding);
747 int GetToolBorderPadding() const;
748
749 void SetToolTextOrientation(int orientation);
750 int GetToolTextOrientation() const;
751
752 void SetToolPacking(int packing);
753 int GetToolPacking() const;
754
755 void SetToolProportion(int tool_id, int proportion);
756 int GetToolProportion(int tool_id) const;
757
758 void SetToolSeparation(int separation);
759 int GetToolSeparation() const;
760
761 void SetToolSticky(int tool_id, bool sticky);
762 bool GetToolSticky(int tool_id) const;
763
764 wxString GetToolLabel(int tool_id) const;
765 void SetToolLabel(int tool_id, const wxString& label);
766
767 wxBitmap GetToolBitmap(int tool_id) const;
768 void SetToolBitmap(int tool_id, const wxBitmap& bitmap);
769
770 wxString GetToolShortHelp(int tool_id) const;
771 void SetToolShortHelp(int tool_id, const wxString& help_string);
772
773 wxString GetToolLongHelp(int tool_id) const;
774 void SetToolLongHelp(int tool_id, const wxString& help_string);
775
776 void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend,
777 const wxAuiToolBarItemArray& append);
778
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;
782 };
783