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