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