]>
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 | ||
23 | //class WXDLLIMPEXP_FWD_CORE wxSizerItem; | |
1154f91b BW |
24 | |
25 | enum wxAuiToolBarStyle | |
26 | { | |
27 | wxAUI_TB_TEXT = 1 << 0, | |
28 | wxAUI_TB_NO_TOOLTIPS = 1 << 1, | |
29 | wxAUI_TB_NO_AUTORESIZE = 1 << 2, | |
30 | wxAUI_TB_GRIPPER = 1 << 3, | |
31 | wxAUI_TB_OVERFLOW = 1 << 4, | |
32 | wxAUI_TB_VERTICAL = 1 << 5, | |
9578058d BW |
33 | wxAUI_TB_HORZ_LAYOUT = 1 << 6, |
34 | wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT), | |
1154f91b BW |
35 | wxAUI_TB_DEFAULT_STYLE = 0 |
36 | }; | |
37 | ||
38 | enum wxAuiToolBarArtSetting | |
39 | { | |
40 | wxAUI_TBART_SEPARATOR_SIZE = 0, | |
41 | wxAUI_TBART_GRIPPER_SIZE = 1, | |
42 | wxAUI_TBART_OVERFLOW_SIZE = 2 | |
43 | }; | |
44 | ||
45 | enum wxAuiToolBarToolTextOrientation | |
46 | { | |
47 | wxAUI_TBTOOL_TEXT_LEFT = 0, // unused/unimplemented | |
48 | wxAUI_TBTOOL_TEXT_RIGHT = 1, | |
49 | wxAUI_TBTOOL_TEXT_TOP = 2, // unused/unimplemented | |
50 | wxAUI_TBTOOL_TEXT_BOTTOM = 3 | |
51 | }; | |
52 | ||
53 | ||
54 | // aui toolbar event class | |
55 | ||
56 | class WXDLLIMPEXP_AUI wxAuiToolBarEvent : public wxNotifyEvent | |
57 | { | |
58 | public: | |
59 | wxAuiToolBarEvent(wxEventType command_type = wxEVT_NULL, | |
60 | int win_id = 0) | |
61 | : wxNotifyEvent(command_type, win_id) | |
62 | { | |
63 | is_dropdown_clicked = false; | |
64 | click_pt = wxPoint(-1, -1); | |
65 | rect = wxRect(-1,-1, 0, 0); | |
66 | tool_id = -1; | |
67 | } | |
68 | #ifndef SWIG | |
69 | wxAuiToolBarEvent(const wxAuiToolBarEvent& c) : wxNotifyEvent(c) | |
70 | { | |
71 | is_dropdown_clicked = c.is_dropdown_clicked; | |
72 | click_pt = c.click_pt; | |
73 | rect = c.rect; | |
74 | tool_id = c.tool_id; | |
75 | } | |
76 | #endif | |
77 | wxEvent *Clone() const { return new wxAuiToolBarEvent(*this); } | |
78 | ||
79 | bool IsDropDownClicked() const { return is_dropdown_clicked; } | |
80 | void SetDropDownClicked(bool c) { is_dropdown_clicked = c; } | |
9da38912 | 81 | |
1154f91b BW |
82 | wxPoint GetClickPoint() const { return click_pt; } |
83 | void SetClickPoint(const wxPoint& p) { click_pt = p; } | |
9da38912 | 84 | |
1154f91b BW |
85 | wxRect GetItemRect() const { return rect; } |
86 | void SetItemRect(const wxRect& r) { rect = r; } | |
9da38912 | 87 | |
1154f91b BW |
88 | int GetToolId() const { return tool_id; } |
89 | void SetToolId(int id) { tool_id = id; } | |
9da38912 | 90 | |
e42f2c16 BW |
91 | private: |
92 | ||
1154f91b BW |
93 | bool is_dropdown_clicked; |
94 | wxPoint click_pt; | |
95 | wxRect rect; | |
96 | int tool_id; | |
9da38912 | 97 | |
1154f91b BW |
98 | private: |
99 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiToolBarEvent) | |
1154f91b BW |
100 | }; |
101 | ||
102 | ||
103 | class WXDLLIMPEXP_AUI wxAuiToolBarItem | |
104 | { | |
e42f2c16 | 105 | friend class wxAuiToolBar; |
8e190381 | 106 | |
1154f91b BW |
107 | public: |
108 | ||
109 | wxAuiToolBarItem() | |
110 | { | |
111 | window = NULL; | |
112 | sizer_item = NULL; | |
e42f2c16 | 113 | spacer_pixels = 0; |
1154f91b BW |
114 | id = 0; |
115 | kind = wxITEM_NORMAL; | |
116 | state = 0; // normal, enabled | |
117 | proportion = 0; | |
118 | active = true; | |
119 | dropdown = true; | |
120 | sticky = true; | |
121 | user_data = 0; | |
122 | } | |
9da38912 | 123 | |
1154f91b BW |
124 | wxAuiToolBarItem(const wxAuiToolBarItem& c) |
125 | { | |
126 | Assign(c); | |
127 | } | |
9da38912 | 128 | |
1154f91b BW |
129 | wxAuiToolBarItem& operator=(const wxAuiToolBarItem& c) |
130 | { | |
131 | Assign(c); | |
132 | return *this; | |
133 | } | |
9da38912 | 134 | |
1154f91b BW |
135 | void Assign(const wxAuiToolBarItem& c) |
136 | { | |
137 | window = c.window; | |
138 | label = c.label; | |
139 | bitmap = c.bitmap; | |
140 | disabled_bitmap = c.disabled_bitmap; | |
141 | hover_bitmap = c.hover_bitmap; | |
142 | short_help = c.short_help; | |
143 | long_help = c.long_help; | |
144 | sizer_item = c.sizer_item; | |
145 | min_size = c.min_size; | |
e42f2c16 | 146 | spacer_pixels = c.spacer_pixels; |
1154f91b BW |
147 | id = c.id; |
148 | kind = c.kind; | |
149 | state = c.state; | |
150 | proportion = c.proportion; | |
151 | active = c.active; | |
152 | dropdown = c.dropdown; | |
153 | sticky = c.sticky; | |
154 | user_data = c.user_data; | |
155 | } | |
8e190381 FM |
156 | |
157 | ||
0766faa3 | 158 | void SetWindow(wxWindow* w) { window = w; } |
e42f2c16 | 159 | wxWindow* GetWindow() { return window; } |
8e190381 | 160 | |
0766faa3 | 161 | void SetId(int new_id) { id = new_id; } |
e42f2c16 | 162 | int GetId() const { return id; } |
8e190381 | 163 | |
0766faa3 | 164 | void SetKind(int new_kind) { kind = new_kind; } |
e42f2c16 | 165 | int GetKind() const { return kind; } |
8e190381 | 166 | |
0766faa3 | 167 | void SetState(int new_state) { state = new_state; } |
e42f2c16 | 168 | int GetState() const { return state; } |
8e190381 | 169 | |
0766faa3 | 170 | void SetSizerItem(wxSizerItem* s) { sizer_item = s; } |
e42f2c16 | 171 | wxSizerItem* GetSizerItem() const { return sizer_item; } |
8e190381 | 172 | |
e42f2c16 BW |
173 | void SetLabel(const wxString& s) { label = s; } |
174 | const wxString& GetLabel() const { return label; } | |
8e190381 | 175 | |
e42f2c16 BW |
176 | void SetBitmap(const wxBitmap& bmp) { bitmap = bmp; } |
177 | const wxBitmap& GetBitmap() const { return bitmap; } | |
8e190381 | 178 | |
e42f2c16 BW |
179 | void SetDisabledBitmap(const wxBitmap& bmp) { disabled_bitmap = bmp; } |
180 | const wxBitmap& GetDisabledBitmap() const { return disabled_bitmap; } | |
8e190381 | 181 | |
e42f2c16 BW |
182 | void SetHoverBitmap(const wxBitmap& bmp) { hover_bitmap = bmp; } |
183 | const wxBitmap& GetHoverBitmap() const { return hover_bitmap; } | |
8e190381 | 184 | |
e42f2c16 BW |
185 | void SetShortHelp(const wxString& s) { short_help = s; } |
186 | const wxString& GetShortHelp() const { return short_help; } | |
8e190381 | 187 | |
e42f2c16 BW |
188 | void SetLongHelp(const wxString& s) { long_help = s; } |
189 | const wxString& GetLongHelp() const { return long_help; } | |
8e190381 | 190 | |
e42f2c16 BW |
191 | void SetMinSize(const wxSize& s) { min_size = s; } |
192 | const wxSize& GetMinSize() const { return min_size; } | |
8e190381 | 193 | |
e42f2c16 BW |
194 | void SetSpacerPixels(int s) { spacer_pixels = s; } |
195 | int GetSpacerPixels() const { return spacer_pixels; } | |
8e190381 | 196 | |
e42f2c16 BW |
197 | void SetProportion(int p) { proportion = p; } |
198 | int GetProportion() const { return proportion; } | |
8e190381 | 199 | |
e42f2c16 BW |
200 | void SetActive(bool b) { active = b; } |
201 | bool IsActive() const { return active; } | |
8e190381 | 202 | |
e42f2c16 BW |
203 | void SetHasDropDown(bool b) { dropdown = b; } |
204 | bool HasDropDown() const { return dropdown; } | |
8e190381 | 205 | |
e42f2c16 BW |
206 | void SetSticky(bool b) { sticky = b; } |
207 | bool IsSticky() const { return sticky; } | |
8e190381 | 208 | |
e42f2c16 BW |
209 | void SetUserData(long l) { user_data = l; } |
210 | long GetUserData() const { return user_data; } | |
9da38912 | 211 | |
e42f2c16 | 212 | private: |
9da38912 | 213 | |
1154f91b BW |
214 | wxWindow* window; // item's associated window |
215 | wxString label; // label displayed on the item | |
216 | wxBitmap bitmap; // item's bitmap | |
217 | wxBitmap disabled_bitmap; // item's disabled bitmap | |
218 | wxBitmap hover_bitmap; // item's hover bitmap | |
219 | wxString short_help; // short help (for tooltip) | |
220 | wxString long_help; // long help (for status bar) | |
221 | wxSizerItem* sizer_item; // sizer item | |
222 | wxSize min_size; // item's minimum size | |
e42f2c16 | 223 | int spacer_pixels; // size of a spacer |
1154f91b BW |
224 | int id; // item's id |
225 | int kind; // item's kind | |
226 | int state; // state | |
227 | int proportion; // proportion | |
228 | bool active; // true if the item is currently active | |
229 | bool dropdown; // true if the item has a dropdown button | |
230 | bool sticky; // overrides button states if true (always active) | |
231 | long user_data; // user-specified data | |
232 | }; | |
233 | ||
234 | #ifndef SWIG | |
235 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiToolBarItem, wxAuiToolBarItemArray, WXDLLIMPEXP_AUI); | |
236 | #endif | |
237 | ||
238 | ||
239 | ||
240 | ||
241 | // tab art class | |
242 | ||
243 | class WXDLLIMPEXP_AUI wxAuiToolBarArt | |
244 | { | |
245 | public: | |
246 | ||
247 | wxAuiToolBarArt() { } | |
248 | virtual ~wxAuiToolBarArt() { } | |
9da38912 | 249 | |
1154f91b | 250 | virtual wxAuiToolBarArt* Clone() = 0; |
9da38912 | 251 | virtual void SetFlags(unsigned int flags) = 0; |
1154f91b BW |
252 | virtual void SetFont(const wxFont& font) = 0; |
253 | virtual void SetTextOrientation(int orientation) = 0; | |
254 | ||
255 | virtual void DrawBackground( | |
256 | wxDC& dc, | |
257 | wxWindow* wnd, | |
9da38912 VZ |
258 | const wxRect& rect) = 0; |
259 | ||
1154f91b BW |
260 | virtual void DrawLabel( |
261 | wxDC& dc, | |
262 | wxWindow* wnd, | |
263 | const wxAuiToolBarItem& item, | |
264 | const wxRect& rect) = 0; | |
9da38912 | 265 | |
1154f91b BW |
266 | virtual void DrawButton( |
267 | wxDC& dc, | |
268 | wxWindow* wnd, | |
269 | const wxAuiToolBarItem& item, | |
270 | const wxRect& rect) = 0; | |
9da38912 | 271 | |
1154f91b BW |
272 | virtual void DrawDropDownButton( |
273 | wxDC& dc, | |
274 | wxWindow* wnd, | |
275 | const wxAuiToolBarItem& item, | |
276 | const wxRect& rect) = 0; | |
9da38912 | 277 | |
1154f91b BW |
278 | virtual void DrawControlLabel( |
279 | wxDC& dc, | |
280 | wxWindow* wnd, | |
281 | const wxAuiToolBarItem& item, | |
282 | const wxRect& rect) = 0; | |
9da38912 | 283 | |
1154f91b BW |
284 | virtual void DrawSeparator( |
285 | wxDC& dc, | |
286 | wxWindow* wnd, | |
287 | const wxRect& rect) = 0; | |
9da38912 | 288 | |
1154f91b BW |
289 | virtual void DrawGripper( |
290 | wxDC& dc, | |
291 | wxWindow* wnd, | |
292 | const wxRect& rect) = 0; | |
293 | ||
294 | virtual void DrawOverflowButton( | |
295 | wxDC& dc, | |
296 | wxWindow* wnd, | |
297 | const wxRect& rect, | |
298 | int state) = 0; | |
9da38912 | 299 | |
1154f91b BW |
300 | virtual wxSize GetLabelSize( |
301 | wxDC& dc, | |
302 | wxWindow* wnd, | |
303 | const wxAuiToolBarItem& item) = 0; | |
9da38912 | 304 | |
1154f91b BW |
305 | virtual wxSize GetToolSize( |
306 | wxDC& dc, | |
307 | wxWindow* wnd, | |
308 | const wxAuiToolBarItem& item) = 0; | |
9da38912 | 309 | |
1154f91b BW |
310 | virtual int GetElementSize(int element_id) = 0; |
311 | virtual void SetElementSize(int element_id, int size) = 0; | |
9da38912 | 312 | |
1154f91b BW |
313 | virtual int ShowDropDown( |
314 | wxWindow* wnd, | |
315 | const wxAuiToolBarItemArray& items) = 0; | |
316 | }; | |
317 | ||
318 | ||
319 | ||
320 | class WXDLLIMPEXP_AUI wxAuiDefaultToolBarArt : public wxAuiToolBarArt | |
321 | { | |
322 | ||
323 | public: | |
324 | ||
325 | wxAuiDefaultToolBarArt(); | |
326 | virtual ~wxAuiDefaultToolBarArt(); | |
9da38912 | 327 | |
1154f91b BW |
328 | virtual wxAuiToolBarArt* Clone(); |
329 | virtual void SetFlags(unsigned int flags); | |
330 | virtual void SetFont(const wxFont& font); | |
331 | virtual void SetTextOrientation(int orientation); | |
332 | ||
333 | virtual void DrawBackground( | |
334 | wxDC& dc, | |
335 | wxWindow* wnd, | |
9da38912 VZ |
336 | const wxRect& rect); |
337 | ||
1154f91b BW |
338 | virtual void DrawLabel( |
339 | wxDC& dc, | |
340 | wxWindow* wnd, | |
341 | const wxAuiToolBarItem& item, | |
342 | const wxRect& rect); | |
9da38912 | 343 | |
1154f91b BW |
344 | virtual void DrawButton( |
345 | wxDC& dc, | |
346 | wxWindow* wnd, | |
347 | const wxAuiToolBarItem& item, | |
348 | const wxRect& rect); | |
9da38912 | 349 | |
1154f91b BW |
350 | virtual void DrawDropDownButton( |
351 | wxDC& dc, | |
352 | wxWindow* wnd, | |
353 | const wxAuiToolBarItem& item, | |
354 | const wxRect& rect); | |
9da38912 | 355 | |
1154f91b BW |
356 | virtual void DrawControlLabel( |
357 | wxDC& dc, | |
358 | wxWindow* wnd, | |
359 | const wxAuiToolBarItem& item, | |
360 | const wxRect& rect); | |
9da38912 | 361 | |
1154f91b BW |
362 | virtual void DrawSeparator( |
363 | wxDC& dc, | |
364 | wxWindow* wnd, | |
365 | const wxRect& rect); | |
9da38912 | 366 | |
1154f91b BW |
367 | virtual void DrawGripper( |
368 | wxDC& dc, | |
369 | wxWindow* wnd, | |
370 | const wxRect& rect); | |
9da38912 | 371 | |
1154f91b BW |
372 | virtual void DrawOverflowButton( |
373 | wxDC& dc, | |
374 | wxWindow* wnd, | |
375 | const wxRect& rect, | |
376 | int state); | |
9da38912 | 377 | |
1154f91b BW |
378 | virtual wxSize GetLabelSize( |
379 | wxDC& dc, | |
380 | wxWindow* wnd, | |
381 | const wxAuiToolBarItem& item); | |
9da38912 | 382 | |
1154f91b BW |
383 | virtual wxSize GetToolSize( |
384 | wxDC& dc, | |
385 | wxWindow* wnd, | |
386 | const wxAuiToolBarItem& item); | |
9da38912 | 387 | |
1154f91b BW |
388 | virtual int GetElementSize(int element); |
389 | virtual void SetElementSize(int element_id, int size); | |
390 | ||
391 | virtual int ShowDropDown(wxWindow* wnd, | |
392 | const wxAuiToolBarItemArray& items); | |
393 | ||
394 | protected: | |
395 | ||
396 | wxBitmap m_button_dropdown_bmp; | |
397 | wxBitmap m_disabled_button_dropdown_bmp; | |
398 | wxBitmap m_overflow_bmp; | |
399 | wxBitmap m_disabled_overflow_bmp; | |
400 | wxColour m_base_colour; | |
401 | wxColour m_highlight_colour; | |
402 | wxFont m_font; | |
403 | unsigned int m_flags; | |
404 | int m_text_orientation; | |
9da38912 | 405 | |
1154f91b BW |
406 | wxPen m_gripper_pen1; |
407 | wxPen m_gripper_pen2; | |
408 | wxPen m_gripper_pen3; | |
9da38912 | 409 | |
1154f91b BW |
410 | int m_separator_size; |
411 | int m_gripper_size; | |
412 | int m_overflow_size; | |
413 | }; | |
414 | ||
415 | ||
416 | ||
417 | ||
418 | class WXDLLIMPEXP_AUI wxAuiToolBar : public wxControl | |
419 | { | |
420 | public: | |
421 | ||
422 | wxAuiToolBar(wxWindow* parent, | |
423 | wxWindowID id = -1, | |
424 | const wxPoint& position = wxDefaultPosition, | |
425 | const wxSize& size = wxDefaultSize, | |
426 | long style = wxAUI_TB_DEFAULT_STYLE); | |
7bce8439 | 427 | virtual ~wxAuiToolBar(); |
9da38912 | 428 | |
1154f91b | 429 | void SetWindowStyleFlag(long style); |
9da38912 | 430 | |
1154f91b BW |
431 | void SetArtProvider(wxAuiToolBarArt* art); |
432 | wxAuiToolBarArt* GetArtProvider() const; | |
433 | ||
434 | bool SetFont(const wxFont& font); | |
9da38912 | 435 | |
1154f91b | 436 | |
7bce8439 | 437 | wxAuiToolBarItem* AddTool(int tool_id, |
1154f91b BW |
438 | const wxString& label, |
439 | const wxBitmap& bitmap, | |
440 | const wxString& short_help_string = wxEmptyString, | |
441 | wxItemKind kind = wxITEM_NORMAL); | |
9da38912 | 442 | |
7bce8439 | 443 | wxAuiToolBarItem* AddTool(int tool_id, |
1154f91b BW |
444 | const wxString& label, |
445 | const wxBitmap& bitmap, | |
446 | const wxBitmap& disabled_bitmap, | |
447 | wxItemKind kind, | |
448 | const wxString& short_help_string, | |
449 | const wxString& long_help_string, | |
450 | wxObject* client_data); | |
9da38912 | 451 | |
7bce8439 | 452 | wxAuiToolBarItem* AddTool(int tool_id, |
1154f91b BW |
453 | const wxBitmap& bitmap, |
454 | const wxBitmap& disabled_bitmap, | |
455 | bool toggle = false, | |
456 | wxObject* client_data = NULL, | |
457 | const wxString& short_help_string = wxEmptyString, | |
458 | const wxString& long_help_string = wxEmptyString) | |
459 | { | |
7bce8439 | 460 | return AddTool(tool_id, |
1154f91b BW |
461 | wxEmptyString, |
462 | bitmap, | |
463 | disabled_bitmap, | |
464 | toggle ? wxITEM_CHECK : wxITEM_NORMAL, | |
465 | short_help_string, | |
466 | long_help_string, | |
467 | client_data); | |
468 | } | |
9da38912 | 469 | |
7bce8439 | 470 | wxAuiToolBarItem* AddLabel(int tool_id, |
1154f91b BW |
471 | const wxString& label = wxEmptyString, |
472 | const int width = -1); | |
7bce8439 | 473 | wxAuiToolBarItem* AddControl(wxControl* control, |
1154f91b | 474 | const wxString& label = wxEmptyString); |
7bce8439 BW |
475 | wxAuiToolBarItem* AddSeparator(); |
476 | wxAuiToolBarItem* AddSpacer(int pixels); | |
477 | wxAuiToolBarItem* AddStretchSpacer(int proportion = 1); | |
9da38912 | 478 | |
1154f91b BW |
479 | bool Realize(); |
480 | ||
481 | wxControl* FindControl(int window_id); | |
482 | wxAuiToolBarItem* FindToolByPosition(wxCoord x, wxCoord y) const; | |
483 | wxAuiToolBarItem* FindToolByIndex(int idx) const; | |
484 | wxAuiToolBarItem* FindTool(int tool_id) const; | |
9da38912 | 485 | |
1154f91b BW |
486 | void ClearTools() { Clear() ; } |
487 | void Clear(); | |
488 | bool DeleteTool(int tool_id); | |
489 | bool DeleteByIndex(int tool_id); | |
9da38912 | 490 | |
1154f91b BW |
491 | size_t GetToolCount() const; |
492 | int GetToolPos(int tool_id) const { return GetToolIndex(tool_id); } | |
493 | int GetToolIndex(int tool_id) const; | |
494 | bool GetToolFits(int tool_id) const; | |
495 | wxRect GetToolRect(int tool_id) const; | |
9da38912 | 496 | bool GetToolFitsByIndex(int tool_id) const; |
1154f91b | 497 | bool GetToolBarFits() const; |
9da38912 | 498 | |
1154f91b BW |
499 | void SetMargins(const wxSize& size) { SetMargins(size.x, size.x, size.y, size.y); } |
500 | void SetMargins(int x, int y) { SetMargins(x, x, y, y); } | |
501 | void SetMargins(int left, int right, int top, int bottom); | |
9da38912 | 502 | |
1154f91b BW |
503 | void SetToolBitmapSize(const wxSize& size); |
504 | wxSize GetToolBitmapSize() const; | |
505 | ||
506 | bool GetOverflowVisible() const; | |
507 | void SetOverflowVisible(bool visible); | |
9da38912 | 508 | |
1154f91b BW |
509 | bool GetGripperVisible() const; |
510 | void SetGripperVisible(bool visible); | |
9da38912 | 511 | |
1154f91b BW |
512 | void ToggleTool(int tool_id, bool state); |
513 | bool GetToolToggled(int tool_id) const; | |
9da38912 | 514 | |
1154f91b BW |
515 | void EnableTool(int tool_id, bool state); |
516 | bool GetToolEnabled(int tool_id) const; | |
9da38912 | 517 | |
1154f91b BW |
518 | void SetToolDropDown(int tool_id, bool dropdown); |
519 | bool GetToolDropDown(int tool_id) const; | |
520 | ||
521 | void SetToolBorderPadding(int padding); | |
522 | int GetToolBorderPadding() const; | |
9da38912 | 523 | |
1154f91b BW |
524 | void SetToolTextOrientation(int orientation); |
525 | int GetToolTextOrientation() const; | |
9da38912 | 526 | |
1154f91b BW |
527 | void SetToolPacking(int packing); |
528 | int GetToolPacking() const; | |
9da38912 | 529 | |
1154f91b BW |
530 | void SetToolProportion(int tool_id, int proportion); |
531 | int GetToolProportion(int tool_id) const; | |
9da38912 | 532 | |
1154f91b BW |
533 | void SetToolSeparation(int separation); |
534 | int GetToolSeparation() const; | |
9da38912 | 535 | |
1154f91b BW |
536 | void SetToolSticky(int tool_id, bool sticky); |
537 | bool GetToolSticky(int tool_id) const; | |
9da38912 | 538 | |
1154f91b BW |
539 | wxString GetToolLabel(int tool_id) const; |
540 | void SetToolLabel(int tool_id, const wxString& label); | |
9da38912 | 541 | |
1154f91b BW |
542 | wxBitmap GetToolBitmap(int tool_id) const; |
543 | void SetToolBitmap(int tool_id, const wxBitmap& bitmap); | |
9da38912 | 544 | |
1154f91b BW |
545 | wxString GetToolShortHelp(int tool_id) const; |
546 | void SetToolShortHelp(int tool_id, const wxString& help_string); | |
9da38912 | 547 | |
1154f91b BW |
548 | wxString GetToolLongHelp(int tool_id) const; |
549 | void SetToolLongHelp(int tool_id, const wxString& help_string); | |
9da38912 | 550 | |
1154f91b BW |
551 | void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend, |
552 | const wxAuiToolBarItemArray& append); | |
9da38912 | 553 | |
1154f91b BW |
554 | protected: |
555 | ||
556 | virtual void OnCustomRender(wxDC& WXUNUSED(dc), | |
557 | const wxAuiToolBarItem& WXUNUSED(item), | |
558 | const wxRect& WXUNUSED(rect)) { } | |
559 | ||
560 | protected: | |
561 | ||
562 | void DoIdleUpdate(); | |
563 | void SetOrientation(int orientation); | |
564 | void SetHoverItem(wxAuiToolBarItem* item); | |
565 | void SetPressedItem(wxAuiToolBarItem* item); | |
566 | void RefreshOverflowState(); | |
9da38912 | 567 | |
1154f91b BW |
568 | int GetOverflowState() const; |
569 | wxRect GetOverflowRect() const; | |
570 | wxSize GetLabelSize(const wxString& label); | |
571 | wxAuiToolBarItem* FindToolByPositionWithPacking(wxCoord x, wxCoord y) const; | |
572 | ||
573 | void DoSetSize(int x, | |
574 | int y, | |
575 | int width, | |
576 | int height, | |
577 | int sizeFlags = wxSIZE_AUTO); | |
9da38912 | 578 | |
1154f91b BW |
579 | protected: // handlers |
580 | ||
581 | void OnSize(wxSizeEvent& evt); | |
582 | void OnIdle(wxIdleEvent& evt); | |
583 | void OnPaint(wxPaintEvent& evt); | |
584 | void OnEraseBackground(wxEraseEvent& evt); | |
585 | void OnLeftDown(wxMouseEvent& evt); | |
586 | void OnLeftUp(wxMouseEvent& evt); | |
587 | void OnRightDown(wxMouseEvent& evt); | |
588 | void OnRightUp(wxMouseEvent& evt); | |
589 | void OnMiddleDown(wxMouseEvent& evt); | |
590 | void OnMiddleUp(wxMouseEvent& evt); | |
591 | void OnMotion(wxMouseEvent& evt); | |
592 | void OnLeaveWindow(wxMouseEvent& evt); | |
593 | void OnSetCursor(wxSetCursorEvent& evt); | |
9da38912 | 594 | |
1154f91b BW |
595 | protected: |
596 | ||
597 | wxAuiToolBarItemArray m_items; // array of toolbar items | |
598 | wxAuiToolBarArt* m_art; // art provider | |
599 | wxBoxSizer* m_sizer; // main sizer for toolbar | |
600 | wxAuiToolBarItem* m_action_item; // item that's being acted upon (pressed) | |
601 | wxAuiToolBarItem* m_tip_item; // item that has its tooltip shown | |
602 | wxBitmap m_bitmap; // double-buffer bitmap | |
603 | wxSizerItem* m_gripper_sizer_item; | |
604 | wxSizerItem* m_overflow_sizer_item; | |
605 | wxSize m_absolute_min_size; | |
606 | wxPoint m_action_pos; // position of left-mouse down | |
607 | wxAuiToolBarItemArray m_custom_overflow_prepend; | |
608 | wxAuiToolBarItemArray m_custom_overflow_append; | |
9da38912 | 609 | |
1154f91b BW |
610 | int m_button_width; |
611 | int m_button_height; | |
612 | int m_sizer_element_count; | |
613 | int m_left_padding; | |
614 | int m_right_padding; | |
615 | int m_top_padding; | |
616 | int m_bottom_padding; | |
617 | int m_tool_packing; | |
618 | int m_tool_border_padding; | |
619 | int m_tool_text_orientation; | |
620 | int m_overflow_state; | |
621 | bool m_dragging; | |
622 | bool m_gripper_visible; | |
623 | bool m_overflow_visible; | |
624 | long m_style; | |
9da38912 | 625 | |
1154f91b BW |
626 | DECLARE_EVENT_TABLE() |
627 | DECLARE_CLASS(wxAuiToolBar) | |
628 | }; | |
629 | ||
630 | ||
631 | ||
632 | ||
633 | // wx event machinery | |
634 | ||
635 | #ifndef SWIG | |
636 | ||
9b11752c VZ |
637 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEvent ); |
638 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, wxAuiToolBarEvent ); | |
639 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEvent ); | |
640 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, wxAuiToolBarEvent ); | |
641 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEvent ); | |
1154f91b BW |
642 | |
643 | typedef void (wxEvtHandler::*wxAuiToolBarEventFunction)(wxAuiToolBarEvent&); | |
644 | ||
645 | #define wxAuiToolBarEventHandler(func) \ | |
3c778901 | 646 | wxEVENT_HANDLER_CAST(wxAuiToolBarEventFunction, func) |
9da38912 | 647 | |
1154f91b BW |
648 | #define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \ |
649 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn)) | |
650 | #define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \ | |
651 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
652 | #define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \ | |
653 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
654 | #define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \ | |
655 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn)) | |
656 | #define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \ | |
657 | wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn)) | |
658 | ||
659 | #else | |
660 | ||
661 | // wxpython/swig event work | |
662 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN; | |
663 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK; | |
664 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK; | |
665 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK; | |
666 | %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG; | |
667 | ||
668 | %pythoncode { | |
669 | EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, 1 ) | |
670 | EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, 1 ) | |
671 | EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, 1 ) | |
672 | EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, 1 ) | |
673 | EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, 1 ) | |
674 | } | |
675 | #endif // SWIG | |
676 | ||
677 | #endif // wxUSE_AUI | |
678 | #endif // _WX_AUIBAR_H_ | |
679 |