]>
Commit | Line | Data |
---|---|---|
1154f91b BW |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/aui/toolbar.h | |
3 | // Purpose: wxaui: wx advanced user interface - docking window manager | |
4 | // Author: Benjamin I. Williams | |
5 | // Modified by: | |
6 | // Created: 2008-08-04 | |
054f177b | 7 | // RCS-ID: $Id$ |
1154f91b BW |
8 | // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved. |
9 | // Licence: wxWindows Library Licence, Version 3.1 | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
1154f91b BW |
12 | #ifndef _WX_AUIBAR_H_ |
13 | #define _WX_AUIBAR_H_ | |
14 | ||
1154f91b BW |
15 | #include "wx/defs.h" |
16 | ||
17 | #if wxUSE_AUI | |
18 | ||
9da38912 | 19 | #include "wx/control.h" |
8e190381 FM |
20 | #include "wx/sizer.h" |
21 | #include "wx/pen.h" | |
22 | ||
f3cf14a9 VZ |
23 | class WXDLLIMPEXP_FWD_CORE wxClientDC; |
24 | class WXDLLIMPEXP_FWD_AUI wxAuiPaneInfo; | |
1154f91b BW |
25 | |
26 | enum wxAuiToolBarStyle | |
27 | { | |
28 | wxAUI_TB_TEXT = 1 << 0, | |
29 | wxAUI_TB_NO_TOOLTIPS = 1 << 1, | |
30 | wxAUI_TB_NO_AUTORESIZE = 1 << 2, | |
31 | wxAUI_TB_GRIPPER = 1 << 3, | |
32 | wxAUI_TB_OVERFLOW = 1 << 4, | |
e5dcae09 VZ |
33 | // using this style forces the toolbar to be vertical and |
34 | // be only dockable to the left or right sides of the window | |
35 | // whereas by default it can be horizontal or vertical and | |
36 | // be docked anywhere | |
1154f91b | 37 | wxAUI_TB_VERTICAL = 1 << 5, |
9578058d | 38 | wxAUI_TB_HORZ_LAYOUT = 1 << 6, |
e5dcae09 VZ |
39 | // analogous to wxAUI_TB_VERTICAL, but forces the toolbar |
40 | // to be horizontal | |
41 | wxAUI_TB_HORIZONTAL = 1 << 7, | |
9578058d | 42 | wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT), |
e5dcae09 | 43 | wxAUI_ORIENTATION_MASK = (wxAUI_TB_VERTICAL | wxAUI_TB_HORIZONTAL), |
1154f91b BW |
44 | wxAUI_TB_DEFAULT_STYLE = 0 |
45 | }; | |
46 | ||
47 | enum wxAuiToolBarArtSetting | |
48 | { | |
49 | wxAUI_TBART_SEPARATOR_SIZE = 0, | |
50 | wxAUI_TBART_GRIPPER_SIZE = 1, | |
51 | wxAUI_TBART_OVERFLOW_SIZE = 2 | |
52 | }; | |
53 | ||
54 | enum wxAuiToolBarToolTextOrientation | |
55 | { | |
56 | wxAUI_TBTOOL_TEXT_LEFT = 0, // unused/unimplemented | |
57 | wxAUI_TBTOOL_TEXT_RIGHT = 1, | |
58 | wxAUI_TBTOOL_TEXT_TOP = 2, // unused/unimplemented | |
59 | wxAUI_TBTOOL_TEXT_BOTTOM = 3 | |
60 | }; | |
61 | ||
62 | ||
63 | // aui toolbar event class | |
64 | ||
65 | class WXDLLIMPEXP_AUI wxAuiToolBarEvent : public wxNotifyEvent | |
66 | { | |
67 | public: | |
9a29fe70 VZ |
68 | wxAuiToolBarEvent(wxEventType commandType = wxEVT_NULL, |
69 | int winId = 0) | |
70 | : wxNotifyEvent(commandType, winId) | |
1154f91b | 71 | { |
9a29fe70 VZ |
72 | m_isDropdownClicked = false; |
73 | m_clickPt = wxPoint(-1, -1); | |
74 | m_rect = wxRect(-1,-1, 0, 0); | |
75 | m_toolId = -1; | |
1154f91b BW |
76 | } |
77 | #ifndef SWIG | |
78 | wxAuiToolBarEvent(const wxAuiToolBarEvent& c) : wxNotifyEvent(c) | |
79 | { | |
9a29fe70 VZ |
80 | m_isDropdownClicked = c.m_isDropdownClicked; |
81 | m_clickPt = c.m_clickPt; | |
82 | m_rect = c.m_rect; | |
83 | m_toolId = c.m_toolId; | |
1154f91b BW |
84 | } |
85 | #endif | |
86 | wxEvent *Clone() const { return new wxAuiToolBarEvent(*this); } | |
87 | ||
9a29fe70 VZ |
88 | bool IsDropDownClicked() const { return m_isDropdownClicked; } |
89 | void SetDropDownClicked(bool c) { m_isDropdownClicked = c; } | |
9da38912 | 90 | |
9a29fe70 VZ |
91 | wxPoint GetClickPoint() const { return m_clickPt; } |
92 | void SetClickPoint(const wxPoint& p) { m_clickPt = p; } | |
9da38912 | 93 | |
9a29fe70 VZ |
94 | wxRect GetItemRect() const { return m_rect; } |
95 | void SetItemRect(const wxRect& r) { m_rect = r; } | |
9da38912 | 96 | |
9a29fe70 VZ |
97 | int GetToolId() const { return m_toolId; } |
98 | void SetToolId(int toolId) { m_toolId = toolId; } | |
9da38912 | 99 | |
e42f2c16 BW |
100 | private: |
101 | ||
9a29fe70 VZ |
102 | bool m_isDropdownClicked; |
103 | wxPoint m_clickPt; | |
104 | wxRect m_rect; | |
105 | int m_toolId; | |
9da38912 | 106 | |
1154f91b BW |
107 | private: |
108 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiToolBarEvent) | |
1154f91b BW |
109 | }; |
110 | ||
111 | ||
112 | class WXDLLIMPEXP_AUI wxAuiToolBarItem | |
113 | { | |
e42f2c16 | 114 | friend class wxAuiToolBar; |
8e190381 | 115 | |
1154f91b BW |
116 | public: |
117 | ||
118 | wxAuiToolBarItem() | |
119 | { | |
9a29fe70 VZ |
120 | m_window = NULL; |
121 | m_sizerItem = NULL; | |
122 | m_spacerPixels = 0; | |
123 | m_toolId = 0; | |
124 | m_kind = wxITEM_NORMAL; | |
125 | m_state = 0; // normal, enabled | |
126 | m_proportion = 0; | |
127 | m_active = true; | |
128 | m_dropDown = true; | |
129 | m_sticky = true; | |
130 | m_userData = 0; | |
131 | m_alignment = wxALIGN_CENTER; | |
1154f91b | 132 | } |
9da38912 | 133 | |
1154f91b BW |
134 | wxAuiToolBarItem(const wxAuiToolBarItem& c) |
135 | { | |
136 | Assign(c); | |
137 | } | |
9da38912 | 138 | |
1154f91b BW |
139 | wxAuiToolBarItem& operator=(const wxAuiToolBarItem& c) |
140 | { | |
141 | Assign(c); | |
142 | return *this; | |
143 | } | |
9da38912 | 144 | |
1154f91b BW |
145 | void Assign(const wxAuiToolBarItem& c) |
146 | { | |
9a29fe70 VZ |
147 | m_window = c.m_window; |
148 | m_label = c.m_label; | |
149 | m_bitmap = c.m_bitmap; | |
150 | m_disabledBitmap = c.m_disabledBitmap; | |
151 | m_hoverBitmap = c.m_hoverBitmap; | |
152 | m_shortHelp = c.m_shortHelp; | |
153 | m_longHelp = c.m_longHelp; | |
154 | m_sizerItem = c.m_sizerItem; | |
155 | m_minSize = c.m_minSize; | |
156 | m_spacerPixels = c.m_spacerPixels; | |
157 | m_toolId = c.m_toolId; | |
158 | m_kind = c.m_kind; | |
159 | m_state = c.m_state; | |
160 | m_proportion = c.m_proportion; | |
161 | m_active = c.m_active; | |
162 | m_dropDown = c.m_dropDown; | |
163 | m_sticky = c.m_sticky; | |
164 | m_userData = c.m_userData; | |
165 | m_alignment = c.m_alignment; | |
1154f91b | 166 | } |
8e190381 FM |
167 | |
168 | ||
9a29fe70 VZ |
169 | void SetWindow(wxWindow* w) { m_window = w; } |
170 | wxWindow* GetWindow() { return m_window; } | |
8e190381 | 171 | |
9a29fe70 VZ |
172 | void SetId(int newId) { m_toolId = newId; } |
173 | int GetId() const { return m_toolId; } | |
8e190381 | 174 | |
9a29fe70 VZ |
175 | void SetKind(int newKind) { m_kind = newKind; } |
176 | int GetKind() const { return m_kind; } | |
8e190381 | 177 | |
9a29fe70 VZ |
178 | void SetState(int newState) { m_state = newState; } |
179 | int GetState() const { return m_state; } | |
8e190381 | 180 | |
9a29fe70 VZ |
181 | void SetSizerItem(wxSizerItem* s) { m_sizerItem = s; } |
182 | wxSizerItem* GetSizerItem() const { return m_sizerItem; } | |
8e190381 | 183 | |
9a29fe70 VZ |
184 | void SetLabel(const wxString& s) { m_label = s; } |
185 | const wxString& GetLabel() const { return m_label; } | |
8e190381 | 186 | |
9a29fe70 VZ |
187 | void SetBitmap(const wxBitmap& bmp) { m_bitmap = bmp; } |
188 | const wxBitmap& GetBitmap() const { return m_bitmap; } | |
8e190381 | 189 | |
9a29fe70 VZ |
190 | void SetDisabledBitmap(const wxBitmap& bmp) { m_disabledBitmap = bmp; } |
191 | const wxBitmap& GetDisabledBitmap() const { return m_disabledBitmap; } | |
8e190381 | 192 | |
9a29fe70 VZ |
193 | void SetHoverBitmap(const wxBitmap& bmp) { m_hoverBitmap = bmp; } |
194 | const wxBitmap& GetHoverBitmap() const { return m_hoverBitmap; } | |
8e190381 | 195 | |
9a29fe70 VZ |
196 | void SetShortHelp(const wxString& s) { m_shortHelp = s; } |
197 | const wxString& GetShortHelp() const { return m_shortHelp; } | |
8e190381 | 198 | |
9a29fe70 VZ |
199 | void SetLongHelp(const wxString& s) { m_longHelp = s; } |
200 | const wxString& GetLongHelp() const { return m_longHelp; } | |
8e190381 | 201 | |
9a29fe70 VZ |
202 | void SetMinSize(const wxSize& s) { m_minSize = s; } |
203 | const wxSize& GetMinSize() const { return m_minSize; } | |
8e190381 | 204 | |
9a29fe70 VZ |
205 | void SetSpacerPixels(int s) { m_spacerPixels = s; } |
206 | int GetSpacerPixels() const { return m_spacerPixels; } | |
8e190381 | 207 | |
9a29fe70 VZ |
208 | void SetProportion(int p) { m_proportion = p; } |
209 | int GetProportion() const { return m_proportion; } | |
8e190381 | 210 | |
9a29fe70 VZ |
211 | void SetActive(bool b) { m_active = b; } |
212 | bool IsActive() const { return m_active; } | |
8e190381 | 213 | |
9a29fe70 VZ |
214 | void SetHasDropDown(bool b) { m_dropDown = b; } |
215 | bool HasDropDown() const { return m_dropDown; } | |
8e190381 | 216 | |
9a29fe70 VZ |
217 | void SetSticky(bool b) { m_sticky = b; } |
218 | bool IsSticky() const { return m_sticky; } | |
8e190381 | 219 | |
9a29fe70 VZ |
220 | void SetUserData(long l) { m_userData = l; } |
221 | long GetUserData() const { return m_userData; } | |
9da38912 | 222 | |
9a29fe70 VZ |
223 | void SetAlignment(int l) { m_alignment = l; } |
224 | int GetAlignment() const { return m_alignment; } | |
0eefa659 | 225 | |
e42f2c16 | 226 | private: |
9da38912 | 227 | |
9a29fe70 VZ |
228 | wxWindow* m_window; // item's associated window |
229 | wxString m_label; // label displayed on the item | |
230 | wxBitmap m_bitmap; // item's bitmap | |
231 | wxBitmap m_disabledBitmap; // item's disabled bitmap | |
232 | wxBitmap m_hoverBitmap; // item's hover bitmap | |
233 | wxString m_shortHelp; // short help (for tooltip) | |
234 | wxString m_longHelp; // long help (for status bar) | |
235 | wxSizerItem* m_sizerItem; // sizer item | |
236 | wxSize m_minSize; // item's minimum size | |
237 | int m_spacerPixels; // size of a spacer | |
238 | int m_toolId; // item's id | |
239 | int m_kind; // item's kind | |
240 | int m_state; // state | |
241 | int m_proportion; // proportion | |
242 | bool m_active; // true if the item is currently active | |
243 | bool m_dropDown; // true if the item has a dropdown button | |
244 | bool m_sticky; // overrides button states if true (always active) | |
245 | long m_userData; // user-specified data | |
246 | int m_alignment; // sizer alignment flag, defaults to wxCENTER, may be wxEXPAND or any other | |
1154f91b BW |
247 | }; |
248 | ||
249 | #ifndef SWIG | |
250 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiToolBarItem, wxAuiToolBarItemArray, WXDLLIMPEXP_AUI); | |
251 | #endif | |
252 | ||
253 | ||
254 | ||
255 | ||
256 | // tab art class | |
257 | ||
258 | class WXDLLIMPEXP_AUI wxAuiToolBarArt | |
259 | { | |
260 | public: | |
261 | ||
262 | wxAuiToolBarArt() { } | |
263 | virtual ~wxAuiToolBarArt() { } | |
9da38912 | 264 | |
1154f91b | 265 | virtual wxAuiToolBarArt* Clone() = 0; |
9da38912 | 266 | virtual void SetFlags(unsigned int flags) = 0; |
8bc10f32 | 267 | virtual unsigned int GetFlags() = 0; |
1154f91b | 268 | virtual void SetFont(const wxFont& font) = 0; |
8bc10f32 | 269 | virtual wxFont GetFont() = 0; |
1154f91b | 270 | virtual void SetTextOrientation(int orientation) = 0; |
8bc10f32 | 271 | virtual int GetTextOrientation() = 0; |
1154f91b BW |
272 | |
273 | virtual void DrawBackground( | |
274 | wxDC& dc, | |
275 | wxWindow* wnd, | |
9da38912 VZ |
276 | const wxRect& rect) = 0; |
277 | ||
1154f91b BW |
278 | virtual void DrawLabel( |
279 | wxDC& dc, | |
280 | wxWindow* wnd, | |
281 | const wxAuiToolBarItem& item, | |
282 | const wxRect& rect) = 0; | |
9da38912 | 283 | |
1154f91b BW |
284 | virtual void DrawButton( |
285 | wxDC& dc, | |
286 | wxWindow* wnd, | |
287 | const wxAuiToolBarItem& item, | |
288 | const wxRect& rect) = 0; | |
9da38912 | 289 | |
1154f91b BW |
290 | virtual void DrawDropDownButton( |
291 | wxDC& dc, | |
292 | wxWindow* wnd, | |
293 | const wxAuiToolBarItem& item, | |
294 | const wxRect& rect) = 0; | |
9da38912 | 295 | |
1154f91b BW |
296 | virtual void DrawControlLabel( |
297 | wxDC& dc, | |
298 | wxWindow* wnd, | |
299 | const wxAuiToolBarItem& item, | |
300 | const wxRect& rect) = 0; | |
9da38912 | 301 | |
1154f91b BW |
302 | virtual void DrawSeparator( |
303 | wxDC& dc, | |
304 | wxWindow* wnd, | |
305 | const wxRect& rect) = 0; | |
9da38912 | 306 | |
1154f91b BW |
307 | virtual void DrawGripper( |
308 | wxDC& dc, | |
309 | wxWindow* wnd, | |
310 | const wxRect& rect) = 0; | |
311 | ||
312 | virtual void DrawOverflowButton( | |
313 | wxDC& dc, | |
314 | wxWindow* wnd, | |
315 | const wxRect& rect, | |
316 | int state) = 0; | |
9da38912 | 317 | |
1154f91b BW |
318 | virtual wxSize GetLabelSize( |
319 | wxDC& dc, | |
320 | wxWindow* wnd, | |
321 | const wxAuiToolBarItem& item) = 0; | |
9da38912 | 322 | |
1154f91b BW |
323 | virtual wxSize GetToolSize( |
324 | wxDC& dc, | |
325 | wxWindow* wnd, | |
326 | const wxAuiToolBarItem& item) = 0; | |
9da38912 | 327 | |
9a29fe70 VZ |
328 | virtual int GetElementSize(int elementId) = 0; |
329 | virtual void SetElementSize(int elementId, int size) = 0; | |
9da38912 | 330 | |
1154f91b BW |
331 | virtual int ShowDropDown( |
332 | wxWindow* wnd, | |
333 | const wxAuiToolBarItemArray& items) = 0; | |
334 | }; | |
335 | ||
336 | ||
337 | ||
338 | class WXDLLIMPEXP_AUI wxAuiDefaultToolBarArt : public wxAuiToolBarArt | |
339 | { | |
340 | ||
341 | public: | |
342 | ||
343 | wxAuiDefaultToolBarArt(); | |
344 | virtual ~wxAuiDefaultToolBarArt(); | |
9da38912 | 345 | |
1154f91b BW |
346 | virtual wxAuiToolBarArt* Clone(); |
347 | virtual void SetFlags(unsigned int flags); | |
8bc10f32 | 348 | virtual unsigned int GetFlags(); |
1154f91b | 349 | virtual void SetFont(const wxFont& font); |
8bc10f32 | 350 | virtual wxFont GetFont(); |
1154f91b | 351 | virtual void SetTextOrientation(int orientation); |
8bc10f32 | 352 | virtual int GetTextOrientation(); |
1154f91b BW |
353 | |
354 | virtual void DrawBackground( | |
355 | wxDC& dc, | |
356 | wxWindow* wnd, | |
9da38912 VZ |
357 | const wxRect& rect); |
358 | ||
1154f91b BW |
359 | virtual void DrawLabel( |
360 | wxDC& dc, | |
361 | wxWindow* wnd, | |
362 | const wxAuiToolBarItem& item, | |
363 | const wxRect& rect); | |
9da38912 | 364 | |
1154f91b BW |
365 | virtual void DrawButton( |
366 | wxDC& dc, | |
367 | wxWindow* wnd, | |
368 | const wxAuiToolBarItem& item, | |
369 | const wxRect& rect); | |
9da38912 | 370 | |
1154f91b BW |
371 | virtual void DrawDropDownButton( |
372 | wxDC& dc, | |
373 | wxWindow* wnd, | |
374 | const wxAuiToolBarItem& item, | |
375 | const wxRect& rect); | |
9da38912 | 376 | |
1154f91b BW |
377 | virtual void DrawControlLabel( |
378 | wxDC& dc, | |
379 | wxWindow* wnd, | |
380 | const wxAuiToolBarItem& item, | |
381 | const wxRect& rect); | |
9da38912 | 382 | |
1154f91b BW |
383 | virtual void DrawSeparator( |
384 | wxDC& dc, | |
385 | wxWindow* wnd, | |
386 | const wxRect& rect); | |
9da38912 | 387 | |
1154f91b BW |
388 | virtual void DrawGripper( |
389 | wxDC& dc, | |
390 | wxWindow* wnd, | |
391 | const wxRect& rect); | |
9da38912 | 392 | |
1154f91b BW |
393 | virtual void DrawOverflowButton( |
394 | wxDC& dc, | |
395 | wxWindow* wnd, | |
396 | const wxRect& rect, | |
397 | int state); | |
9da38912 | 398 | |
1154f91b BW |
399 | virtual wxSize GetLabelSize( |
400 | wxDC& dc, | |
401 | wxWindow* wnd, | |
402 | const wxAuiToolBarItem& item); | |
9da38912 | 403 | |
1154f91b BW |
404 | virtual wxSize GetToolSize( |
405 | wxDC& dc, | |
406 | wxWindow* wnd, | |
407 | const wxAuiToolBarItem& item); | |
9da38912 | 408 | |
1154f91b | 409 | virtual int GetElementSize(int element); |
9a29fe70 | 410 | virtual void SetElementSize(int elementId, int size); |
1154f91b BW |
411 | |
412 | virtual int ShowDropDown(wxWindow* wnd, | |
413 | const wxAuiToolBarItemArray& items); | |
414 | ||
415 | protected: | |
416 | ||
9a29fe70 VZ |
417 | wxBitmap m_buttonDropDownBmp; |
418 | wxBitmap m_disabledButtonDropDownBmp; | |
419 | wxBitmap m_overflowBmp; | |
420 | wxBitmap m_disabledOverflowBmp; | |
421 | wxColour m_baseColour; | |
422 | wxColour m_highlightColour; | |
1154f91b BW |
423 | wxFont m_font; |
424 | unsigned int m_flags; | |
9a29fe70 | 425 | int m_textOrientation; |
9da38912 | 426 | |
9a29fe70 VZ |
427 | wxPen m_gripperPen1; |
428 | wxPen m_gripperPen2; | |
429 | wxPen m_gripperPen3; | |
9da38912 | 430 | |
9a29fe70 VZ |
431 | int m_separatorSize; |
432 | int m_gripperSize; | |
433 | int m_overflowSize; | |
1154f91b BW |
434 | }; |
435 | ||
436 | ||
437 | ||
438 | ||
439 | class WXDLLIMPEXP_AUI wxAuiToolBar : public wxControl | |
440 | { | |
441 | public: | |
46e67202 | 442 | wxAuiToolBar() { Init(); } |
1154f91b BW |
443 | |
444 | wxAuiToolBar(wxWindow* parent, | |
46e67202 VZ |
445 | wxWindowID id = wxID_ANY, |
446 | const wxPoint& pos = wxDefaultPosition, | |
1154f91b | 447 | const wxSize& size = wxDefaultSize, |
46e67202 VZ |
448 | long style = wxAUI_TB_DEFAULT_STYLE) |
449 | { | |
450 | Init(); | |
451 | Create(parent, id, pos, size, style); | |
452 | } | |
453 | ||
7bce8439 | 454 | virtual ~wxAuiToolBar(); |
9da38912 | 455 | |
46e67202 VZ |
456 | bool Create(wxWindow* parent, |
457 | wxWindowID id = wxID_ANY, | |
458 | const wxPoint& pos = wxDefaultPosition, | |
459 | const wxSize& size = wxDefaultSize, | |
460 | long style = 0); | |
461 | ||
1154f91b | 462 | void SetWindowStyleFlag(long style); |
e7b8af65 | 463 | long GetWindowStyleFlag() const; |
9da38912 | 464 | |
1154f91b BW |
465 | void SetArtProvider(wxAuiToolBarArt* art); |
466 | wxAuiToolBarArt* GetArtProvider() const; | |
467 | ||
468 | bool SetFont(const wxFont& font); | |
9da38912 | 469 | |
1154f91b | 470 | |
9a29fe70 | 471 | wxAuiToolBarItem* AddTool(int toolId, |
1154f91b BW |
472 | const wxString& label, |
473 | const wxBitmap& bitmap, | |
9a29fe70 | 474 | const wxString& shortHelpString = wxEmptyString, |
1154f91b | 475 | wxItemKind kind = wxITEM_NORMAL); |
9da38912 | 476 | |
9a29fe70 | 477 | wxAuiToolBarItem* AddTool(int toolId, |
1154f91b BW |
478 | const wxString& label, |
479 | const wxBitmap& bitmap, | |
9a29fe70 | 480 | const wxBitmap& disabledBitmap, |
1154f91b | 481 | wxItemKind kind, |
9a29fe70 VZ |
482 | const wxString& shortHelpString, |
483 | const wxString& longHelpString, | |
484 | wxObject* clientData); | |
9da38912 | 485 | |
9a29fe70 | 486 | wxAuiToolBarItem* AddTool(int toolId, |
1154f91b | 487 | const wxBitmap& bitmap, |
9a29fe70 | 488 | const wxBitmap& disabledBitmap, |
1154f91b | 489 | bool toggle = false, |
9a29fe70 VZ |
490 | wxObject* clientData = NULL, |
491 | const wxString& shortHelpString = wxEmptyString, | |
492 | const wxString& longHelpString = wxEmptyString) | |
1154f91b | 493 | { |
9a29fe70 | 494 | return AddTool(toolId, |
1154f91b BW |
495 | wxEmptyString, |
496 | bitmap, | |
9a29fe70 | 497 | disabledBitmap, |
1154f91b | 498 | toggle ? wxITEM_CHECK : wxITEM_NORMAL, |
9a29fe70 VZ |
499 | shortHelpString, |
500 | longHelpString, | |
501 | clientData); | |
1154f91b | 502 | } |
9da38912 | 503 | |
9a29fe70 | 504 | wxAuiToolBarItem* AddLabel(int toolId, |
1154f91b BW |
505 | const wxString& label = wxEmptyString, |
506 | const int width = -1); | |
7bce8439 | 507 | wxAuiToolBarItem* AddControl(wxControl* control, |
1154f91b | 508 | const wxString& label = wxEmptyString); |
7bce8439 BW |
509 | wxAuiToolBarItem* AddSeparator(); |
510 | wxAuiToolBarItem* AddSpacer(int pixels); | |
511 | wxAuiToolBarItem* AddStretchSpacer(int proportion = 1); | |
9da38912 | 512 | |
1154f91b BW |
513 | bool Realize(); |
514 | ||
9a29fe70 | 515 | wxControl* FindControl(int windowId); |
1154f91b BW |
516 | wxAuiToolBarItem* FindToolByPosition(wxCoord x, wxCoord y) const; |
517 | wxAuiToolBarItem* FindToolByIndex(int idx) const; | |
9a29fe70 | 518 | wxAuiToolBarItem* FindTool(int toolId) const; |
9da38912 | 519 | |
1154f91b BW |
520 | void ClearTools() { Clear() ; } |
521 | void Clear(); | |
9a29fe70 VZ |
522 | bool DeleteTool(int toolId); |
523 | bool DeleteByIndex(int toolId); | |
9da38912 | 524 | |
1154f91b | 525 | size_t GetToolCount() const; |
9a29fe70 VZ |
526 | int GetToolPos(int toolId) const { return GetToolIndex(toolId); } |
527 | int GetToolIndex(int toolId) const; | |
528 | bool GetToolFits(int toolId) const; | |
529 | wxRect GetToolRect(int toolId) const; | |
530 | bool GetToolFitsByIndex(int toolId) const; | |
1154f91b | 531 | bool GetToolBarFits() const; |
9da38912 | 532 | |
1154f91b BW |
533 | void SetMargins(const wxSize& size) { SetMargins(size.x, size.x, size.y, size.y); } |
534 | void SetMargins(int x, int y) { SetMargins(x, x, y, y); } | |
535 | void SetMargins(int left, int right, int top, int bottom); | |
9da38912 | 536 | |
1154f91b BW |
537 | void SetToolBitmapSize(const wxSize& size); |
538 | wxSize GetToolBitmapSize() const; | |
539 | ||
540 | bool GetOverflowVisible() const; | |
541 | void SetOverflowVisible(bool visible); | |
9da38912 | 542 | |
1154f91b BW |
543 | bool GetGripperVisible() const; |
544 | void SetGripperVisible(bool visible); | |
9da38912 | 545 | |
9a29fe70 VZ |
546 | void ToggleTool(int toolId, bool state); |
547 | bool GetToolToggled(int toolId) const; | |
9da38912 | 548 | |
9a29fe70 VZ |
549 | void EnableTool(int toolId, bool state); |
550 | bool GetToolEnabled(int toolId) const; | |
9da38912 | 551 | |
9a29fe70 VZ |
552 | void SetToolDropDown(int toolId, bool dropdown); |
553 | bool GetToolDropDown(int toolId) const; | |
1154f91b BW |
554 | |
555 | void SetToolBorderPadding(int padding); | |
556 | int GetToolBorderPadding() const; | |
9da38912 | 557 | |
1154f91b BW |
558 | void SetToolTextOrientation(int orientation); |
559 | int GetToolTextOrientation() const; | |
9da38912 | 560 | |
1154f91b BW |
561 | void SetToolPacking(int packing); |
562 | int GetToolPacking() const; | |
9da38912 | 563 | |
9a29fe70 VZ |
564 | void SetToolProportion(int toolId, int proportion); |
565 | int GetToolProportion(int toolId) const; | |
9da38912 | 566 | |
1154f91b BW |
567 | void SetToolSeparation(int separation); |
568 | int GetToolSeparation() const; | |
9da38912 | 569 | |
9a29fe70 VZ |
570 | void SetToolSticky(int toolId, bool sticky); |
571 | bool GetToolSticky(int toolId) const; | |
9da38912 | 572 | |
9a29fe70 VZ |
573 | wxString GetToolLabel(int toolId) const; |
574 | void SetToolLabel(int toolId, const wxString& label); | |
9da38912 | 575 | |
9a29fe70 VZ |
576 | wxBitmap GetToolBitmap(int toolId) const; |
577 | void SetToolBitmap(int toolId, const wxBitmap& bitmap); | |
9da38912 | 578 | |
9a29fe70 VZ |
579 | wxString GetToolShortHelp(int toolId) const; |
580 | void SetToolShortHelp(int toolId, const wxString& helpString); | |
9da38912 | 581 | |
9a29fe70 VZ |
582 | wxString GetToolLongHelp(int toolId) const; |
583 | void SetToolLongHelp(int toolId, const wxString& helpString); | |
9da38912 | 584 | |
1154f91b BW |
585 | void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend, |
586 | const wxAuiToolBarItemArray& append); | |
9da38912 | 587 | |
e5dcae09 | 588 | // get size of hint rectangle for a particular dock location |
9a29fe70 | 589 | wxSize GetHintSize(int dockDirection) const; |
e5dcae09 VZ |
590 | bool IsPaneValid(const wxAuiPaneInfo& pane) const; |
591 | ||
3ac17397 VZ |
592 | // Override to call DoIdleUpdate(). |
593 | virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE); | |
594 | ||
1154f91b | 595 | protected: |
46e67202 | 596 | void Init(); |
1154f91b BW |
597 | |
598 | virtual void OnCustomRender(wxDC& WXUNUSED(dc), | |
599 | const wxAuiToolBarItem& WXUNUSED(item), | |
600 | const wxRect& WXUNUSED(rect)) { } | |
601 | ||
602 | protected: | |
603 | ||
604 | void DoIdleUpdate(); | |
605 | void SetOrientation(int orientation); | |
606 | void SetHoverItem(wxAuiToolBarItem* item); | |
607 | void SetPressedItem(wxAuiToolBarItem* item); | |
608 | void RefreshOverflowState(); | |
9da38912 | 609 | |
1154f91b BW |
610 | int GetOverflowState() const; |
611 | wxRect GetOverflowRect() const; | |
612 | wxSize GetLabelSize(const wxString& label); | |
613 | wxAuiToolBarItem* FindToolByPositionWithPacking(wxCoord x, wxCoord y) const; | |
614 | ||
615 | void DoSetSize(int x, | |
616 | int y, | |
617 | int width, | |
618 | int height, | |
619 | int sizeFlags = wxSIZE_AUTO); | |
9da38912 | 620 | |
1154f91b BW |
621 | protected: // handlers |
622 | ||
623 | void OnSize(wxSizeEvent& evt); | |
624 | void OnIdle(wxIdleEvent& evt); | |
625 | void OnPaint(wxPaintEvent& evt); | |
626 | void OnEraseBackground(wxEraseEvent& evt); | |
627 | void OnLeftDown(wxMouseEvent& evt); | |
628 | void OnLeftUp(wxMouseEvent& evt); | |
629 | void OnRightDown(wxMouseEvent& evt); | |
630 | void OnRightUp(wxMouseEvent& evt); | |
631 | void OnMiddleDown(wxMouseEvent& evt); | |
632 | void OnMiddleUp(wxMouseEvent& evt); | |
633 | void OnMotion(wxMouseEvent& evt); | |
634 | void OnLeaveWindow(wxMouseEvent& evt); | |
4a21ea9d | 635 | void OnCaptureLost(wxMouseCaptureLostEvent& evt); |
1154f91b | 636 | void OnSetCursor(wxSetCursorEvent& evt); |
9da38912 | 637 | |
1154f91b BW |
638 | protected: |
639 | ||
640 | wxAuiToolBarItemArray m_items; // array of toolbar items | |
641 | wxAuiToolBarArt* m_art; // art provider | |
642 | wxBoxSizer* m_sizer; // main sizer for toolbar | |
9a29fe70 VZ |
643 | wxAuiToolBarItem* m_actionItem; // item that's being acted upon (pressed) |
644 | wxAuiToolBarItem* m_tipItem; // item that has its tooltip shown | |
1154f91b | 645 | wxBitmap m_bitmap; // double-buffer bitmap |
9a29fe70 VZ |
646 | wxSizerItem* m_gripperSizerItem; |
647 | wxSizerItem* m_overflowSizerItem; | |
648 | wxSize m_absoluteMinSize; | |
649 | wxPoint m_actionPos; // position of left-mouse down | |
650 | wxAuiToolBarItemArray m_customOverflowPrepend; | |
651 | wxAuiToolBarItemArray m_customOverflowAppend; | |
652 | ||
653 | int m_buttonWidth; | |
654 | int m_buttonHeight; | |
655 | int m_sizerElementCount; | |
656 | int m_leftPadding; | |
657 | int m_rightPadding; | |
658 | int m_topPadding; | |
659 | int m_bottomPadding; | |
660 | int m_toolPacking; | |
661 | int m_toolBorderPadding; | |
662 | int m_toolTextOrientation; | |
663 | int m_overflowState; | |
1154f91b | 664 | bool m_dragging; |
9a29fe70 VZ |
665 | bool m_gripperVisible; |
666 | bool m_overflowVisible; | |
1154f91b | 667 | long m_style; |
9da38912 | 668 | |
e5dcae09 VZ |
669 | bool RealizeHelper(wxClientDC& dc, bool horizontal); |
670 | static bool IsPaneValid(long style, const wxAuiPaneInfo& pane); | |
671 | bool IsPaneValid(long style) const; | |
672 | void SetArtFlags() const; | |
673 | wxOrientation m_orientation; | |
674 | wxSize m_horzHintSize; | |
675 | wxSize m_vertHintSize; | |
676 | ||
4a21ea9d VZ |
677 | private: |
678 | // Common part of OnLeaveWindow() and OnCaptureLost(). | |
679 | void DoResetMouseState(); | |
680 | ||
1154f91b BW |
681 | DECLARE_EVENT_TABLE() |
682 | DECLARE_CLASS(wxAuiToolBar) | |
683 | }; | |
684 | ||
685 | ||
686 | ||
687 | ||
688 | // wx event machinery | |
689 | ||
690 | #ifndef SWIG | |
691 | ||
9b11752c VZ |
692 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEvent ); |
693 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, wxAuiToolBarEvent ); | |
694 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEvent ); | |
695 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, wxAuiToolBarEvent ); | |
696 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEvent ); | |
1154f91b BW |
697 | |
698 | typedef void (wxEvtHandler::*wxAuiToolBarEventFunction)(wxAuiToolBarEvent&); | |
699 | ||
700 | #define wxAuiToolBarEventHandler(func) \ | |
3c778901 | 701 | wxEVENT_HANDLER_CAST(wxAuiToolBarEventFunction, func) |
9da38912 | 702 | |
1154f91b BW |
703 | #define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \ |
704 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn)) | |
705 | #define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \ | |
706 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
707 | #define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \ | |
708 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
709 | #define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \ | |
710 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
711 | #define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \ | |
712 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn)) | |
713 | ||
714 | #else | |
715 | ||
716 | // wxpython/swig event work | |
717 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN; | |
718 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK; | |
719 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK; | |
720 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK; | |
721 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG; | |
722 | ||
723 | %pythoncode { | |
724 | EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, 1 ) | |
725 | EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, 1 ) | |
726 | EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, 1 ) | |
727 | EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, 1 ) | |
728 | EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, 1 ) | |
729 | } | |
730 | #endif // SWIG | |
731 | ||
732 | #endif // wxUSE_AUI | |
733 | #endif // _WX_AUIBAR_H_ | |
734 |