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