1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/toolbar.h
3 // Purpose: wxaui: wx advanced user interface - docking window manager
4 // Author: Benjamin I. Williams
7 // RCS-ID: $Id: framemanager.h 53135 2008-04-12 02:31:04Z VZ $
8 // Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
9 // Licence: wxWindows Library Licence, Version 3.1
10 ///////////////////////////////////////////////////////////////////////////////
23 enum wxAuiToolBarStyle
25 wxAUI_TB_TEXT
= 1 << 0,
26 wxAUI_TB_NO_TOOLTIPS
= 1 << 1,
27 wxAUI_TB_NO_AUTORESIZE
= 1 << 2,
28 wxAUI_TB_GRIPPER
= 1 << 3,
29 wxAUI_TB_OVERFLOW
= 1 << 4,
30 wxAUI_TB_VERTICAL
= 1 << 5,
31 wxAUI_TB_HORZ_TEXT
= ((1 << 6) | wxAUI_TB_TEXT
),
32 wxAUI_TB_DEFAULT_STYLE
= 0
35 enum wxAuiToolBarArtSetting
37 wxAUI_TBART_SEPARATOR_SIZE
= 0,
38 wxAUI_TBART_GRIPPER_SIZE
= 1,
39 wxAUI_TBART_OVERFLOW_SIZE
= 2
42 enum wxAuiToolBarToolTextOrientation
44 wxAUI_TBTOOL_TEXT_LEFT
= 0, // unused/unimplemented
45 wxAUI_TBTOOL_TEXT_RIGHT
= 1,
46 wxAUI_TBTOOL_TEXT_TOP
= 2, // unused/unimplemented
47 wxAUI_TBTOOL_TEXT_BOTTOM
= 3
51 // aui toolbar event class
53 class WXDLLIMPEXP_AUI wxAuiToolBarEvent
: public wxNotifyEvent
56 wxAuiToolBarEvent(wxEventType command_type
= wxEVT_NULL
,
58 : wxNotifyEvent(command_type
, win_id
)
60 is_dropdown_clicked
= false;
61 click_pt
= wxPoint(-1, -1);
62 rect
= wxRect(-1,-1, 0, 0);
66 wxAuiToolBarEvent(const wxAuiToolBarEvent
& c
) : wxNotifyEvent(c
)
68 is_dropdown_clicked
= c
.is_dropdown_clicked
;
69 click_pt
= c
.click_pt
;
74 wxEvent
*Clone() const { return new wxAuiToolBarEvent(*this); }
76 bool IsDropDownClicked() const { return is_dropdown_clicked
; }
77 void SetDropDownClicked(bool c
) { is_dropdown_clicked
= c
; }
79 wxPoint
GetClickPoint() const { return click_pt
; }
80 void SetClickPoint(const wxPoint
& p
) { click_pt
= p
; }
82 wxRect
GetItemRect() const { return rect
; }
83 void SetItemRect(const wxRect
& r
) { rect
= r
; }
85 int GetToolId() const { return tool_id
; }
86 void SetToolId(int id
) { tool_id
= id
; }
89 bool is_dropdown_clicked
;
96 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiToolBarEvent
)
101 class WXDLLIMPEXP_AUI wxAuiToolBarItem
111 kind
= wxITEM_NORMAL
;
112 state
= 0; // normal, enabled
120 wxAuiToolBarItem(const wxAuiToolBarItem
& c
)
125 wxAuiToolBarItem
& operator=(const wxAuiToolBarItem
& c
)
131 void Assign(const wxAuiToolBarItem
& c
)
136 disabled_bitmap
= c
.disabled_bitmap
;
137 hover_bitmap
= c
.hover_bitmap
;
138 short_help
= c
.short_help
;
139 long_help
= c
.long_help
;
140 sizer_item
= c
.sizer_item
;
141 min_size
= c
.min_size
;
142 space_pixels
= c
.space_pixels
;
146 proportion
= c
.proportion
;
148 dropdown
= c
.dropdown
;
150 user_data
= c
.user_data
;
155 wxWindow
* window
; // item's associated window
156 wxString label
; // label displayed on the item
157 wxBitmap bitmap
; // item's bitmap
158 wxBitmap disabled_bitmap
; // item's disabled bitmap
159 wxBitmap hover_bitmap
; // item's hover bitmap
160 wxString short_help
; // short help (for tooltip)
161 wxString long_help
; // long help (for status bar)
162 wxSizerItem
* sizer_item
; // sizer item
163 wxSize min_size
; // item's minimum size
164 int space_pixels
; // size of a spacer
166 int kind
; // item's kind
168 int proportion
; // proportion
169 bool active
; // true if the item is currently active
170 bool dropdown
; // true if the item has a dropdown button
171 bool sticky
; // overrides button states if true (always active)
172 long user_data
; // user-specified data
176 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiToolBarItem
, wxAuiToolBarItemArray
, WXDLLIMPEXP_AUI
);
184 class WXDLLIMPEXP_AUI wxAuiToolBarArt
188 wxAuiToolBarArt() { }
189 virtual ~wxAuiToolBarArt() { }
191 virtual wxAuiToolBarArt
* Clone() = 0;
192 virtual void SetFlags(unsigned int flags
) = 0;
193 virtual void SetFont(const wxFont
& font
) = 0;
194 virtual void SetTextOrientation(int orientation
) = 0;
196 virtual void DrawBackground(
199 const wxRect
& rect
) = 0;
201 virtual void DrawLabel(
204 const wxAuiToolBarItem
& item
,
205 const wxRect
& rect
) = 0;
207 virtual void DrawButton(
210 const wxAuiToolBarItem
& item
,
211 const wxRect
& rect
) = 0;
213 virtual void DrawDropDownButton(
216 const wxAuiToolBarItem
& item
,
217 const wxRect
& rect
) = 0;
219 virtual void DrawControlLabel(
222 const wxAuiToolBarItem
& item
,
223 const wxRect
& rect
) = 0;
225 virtual void DrawSeparator(
228 const wxRect
& rect
) = 0;
230 virtual void DrawGripper(
233 const wxRect
& rect
) = 0;
235 virtual void DrawOverflowButton(
241 virtual wxSize
GetLabelSize(
244 const wxAuiToolBarItem
& item
) = 0;
246 virtual wxSize
GetToolSize(
249 const wxAuiToolBarItem
& item
) = 0;
251 virtual int GetElementSize(int element_id
) = 0;
252 virtual void SetElementSize(int element_id
, int size
) = 0;
254 virtual int ShowDropDown(
256 const wxAuiToolBarItemArray
& items
) = 0;
261 class WXDLLIMPEXP_AUI wxAuiDefaultToolBarArt
: public wxAuiToolBarArt
266 wxAuiDefaultToolBarArt();
267 virtual ~wxAuiDefaultToolBarArt();
269 virtual wxAuiToolBarArt
* Clone();
270 virtual void SetFlags(unsigned int flags
);
271 virtual void SetFont(const wxFont
& font
);
272 virtual void SetTextOrientation(int orientation
);
274 virtual void DrawBackground(
279 virtual void DrawLabel(
282 const wxAuiToolBarItem
& item
,
285 virtual void DrawButton(
288 const wxAuiToolBarItem
& item
,
291 virtual void DrawDropDownButton(
294 const wxAuiToolBarItem
& item
,
297 virtual void DrawControlLabel(
300 const wxAuiToolBarItem
& item
,
303 virtual void DrawSeparator(
308 virtual void DrawGripper(
313 virtual void DrawOverflowButton(
319 virtual wxSize
GetLabelSize(
322 const wxAuiToolBarItem
& item
);
324 virtual wxSize
GetToolSize(
327 const wxAuiToolBarItem
& item
);
329 virtual int GetElementSize(int element
);
330 virtual void SetElementSize(int element_id
, int size
);
332 virtual int ShowDropDown(wxWindow
* wnd
,
333 const wxAuiToolBarItemArray
& items
);
337 wxBitmap m_button_dropdown_bmp
;
338 wxBitmap m_disabled_button_dropdown_bmp
;
339 wxBitmap m_overflow_bmp
;
340 wxBitmap m_disabled_overflow_bmp
;
341 wxColour m_base_colour
;
342 wxColour m_highlight_colour
;
344 unsigned int m_flags
;
345 int m_text_orientation
;
347 wxPen m_gripper_pen1
;
348 wxPen m_gripper_pen2
;
349 wxPen m_gripper_pen3
;
351 int m_separator_size
;
359 class WXDLLIMPEXP_AUI wxAuiToolBar
: public wxControl
363 wxAuiToolBar(wxWindow
* parent
,
365 const wxPoint
& position
= wxDefaultPosition
,
366 const wxSize
& size
= wxDefaultSize
,
367 long style
= wxAUI_TB_DEFAULT_STYLE
);
370 void SetWindowStyleFlag(long style
);
372 void SetArtProvider(wxAuiToolBarArt
* art
);
373 wxAuiToolBarArt
* GetArtProvider() const;
375 bool SetFont(const wxFont
& font
);
378 void AddTool(int tool_id
,
379 const wxString
& label
,
380 const wxBitmap
& bitmap
,
381 const wxString
& short_help_string
= wxEmptyString
,
382 wxItemKind kind
= wxITEM_NORMAL
);
384 void AddTool(int tool_id
,
385 const wxString
& label
,
386 const wxBitmap
& bitmap
,
387 const wxBitmap
& disabled_bitmap
,
389 const wxString
& short_help_string
,
390 const wxString
& long_help_string
,
391 wxObject
* client_data
);
393 void AddTool(int tool_id
,
394 const wxBitmap
& bitmap
,
395 const wxBitmap
& disabled_bitmap
,
397 wxObject
* client_data
= NULL
,
398 const wxString
& short_help_string
= wxEmptyString
,
399 const wxString
& long_help_string
= wxEmptyString
)
405 toggle ? wxITEM_CHECK
: wxITEM_NORMAL
,
411 void AddLabel(int tool_id
,
412 const wxString
& label
= wxEmptyString
,
413 const int width
= -1);
414 void AddControl(wxControl
* control
,
415 const wxString
& label
= wxEmptyString
);
417 void AddSpacer(int pixels
);
418 void AddStretchSpacer(int proportion
= 1);
422 wxControl
* FindControl(int window_id
);
423 wxAuiToolBarItem
* FindToolByPosition(wxCoord x
, wxCoord y
) const;
424 wxAuiToolBarItem
* FindToolByIndex(int idx
) const;
425 wxAuiToolBarItem
* FindTool(int tool_id
) const;
427 void ClearTools() { Clear() ; }
429 bool DeleteTool(int tool_id
);
430 bool DeleteByIndex(int tool_id
);
432 size_t GetToolCount() const;
433 int GetToolPos(int tool_id
) const { return GetToolIndex(tool_id
); }
434 int GetToolIndex(int tool_id
) const;
435 bool GetToolFits(int tool_id
) const;
436 wxRect
GetToolRect(int tool_id
) const;
437 bool GetToolFitsByIndex(int tool_id
) const;
438 bool GetToolBarFits() const;
440 void SetMargins(const wxSize
& size
) { SetMargins(size
.x
, size
.x
, size
.y
, size
.y
); }
441 void SetMargins(int x
, int y
) { SetMargins(x
, x
, y
, y
); }
442 void SetMargins(int left
, int right
, int top
, int bottom
);
444 void SetToolBitmapSize(const wxSize
& size
);
445 wxSize
GetToolBitmapSize() const;
447 bool GetOverflowVisible() const;
448 void SetOverflowVisible(bool visible
);
450 bool GetGripperVisible() const;
451 void SetGripperVisible(bool visible
);
453 void ToggleTool(int tool_id
, bool state
);
454 bool GetToolToggled(int tool_id
) const;
456 void EnableTool(int tool_id
, bool state
);
457 bool GetToolEnabled(int tool_id
) const;
459 void SetToolDropDown(int tool_id
, bool dropdown
);
460 bool GetToolDropDown(int tool_id
) const;
462 void SetToolBorderPadding(int padding
);
463 int GetToolBorderPadding() const;
465 void SetToolTextOrientation(int orientation
);
466 int GetToolTextOrientation() const;
468 void SetToolPacking(int packing
);
469 int GetToolPacking() const;
471 void SetToolProportion(int tool_id
, int proportion
);
472 int GetToolProportion(int tool_id
) const;
474 void SetToolSeparation(int separation
);
475 int GetToolSeparation() const;
477 void SetToolSticky(int tool_id
, bool sticky
);
478 bool GetToolSticky(int tool_id
) const;
480 wxString
GetToolLabel(int tool_id
) const;
481 void SetToolLabel(int tool_id
, const wxString
& label
);
483 wxBitmap
GetToolBitmap(int tool_id
) const;
484 void SetToolBitmap(int tool_id
, const wxBitmap
& bitmap
);
486 wxString
GetToolShortHelp(int tool_id
) const;
487 void SetToolShortHelp(int tool_id
, const wxString
& help_string
);
489 wxString
GetToolLongHelp(int tool_id
) const;
490 void SetToolLongHelp(int tool_id
, const wxString
& help_string
);
492 void SetCustomOverflowItems(const wxAuiToolBarItemArray
& prepend
,
493 const wxAuiToolBarItemArray
& append
);
497 virtual void OnCustomRender(wxDC
& WXUNUSED(dc
),
498 const wxAuiToolBarItem
& WXUNUSED(item
),
499 const wxRect
& WXUNUSED(rect
)) { }
504 void SetOrientation(int orientation
);
505 void SetHoverItem(wxAuiToolBarItem
* item
);
506 void SetPressedItem(wxAuiToolBarItem
* item
);
507 void RefreshOverflowState();
509 int GetOverflowState() const;
510 wxRect
GetOverflowRect() const;
511 wxSize
GetLabelSize(const wxString
& label
);
512 wxAuiToolBarItem
* FindToolByPositionWithPacking(wxCoord x
, wxCoord y
) const;
514 void DoSetSize(int x
,
518 int sizeFlags
= wxSIZE_AUTO
);
520 protected: // handlers
522 void OnSize(wxSizeEvent
& evt
);
523 void OnIdle(wxIdleEvent
& evt
);
524 void OnPaint(wxPaintEvent
& evt
);
525 void OnEraseBackground(wxEraseEvent
& evt
);
526 void OnLeftDown(wxMouseEvent
& evt
);
527 void OnLeftUp(wxMouseEvent
& evt
);
528 void OnRightDown(wxMouseEvent
& evt
);
529 void OnRightUp(wxMouseEvent
& evt
);
530 void OnMiddleDown(wxMouseEvent
& evt
);
531 void OnMiddleUp(wxMouseEvent
& evt
);
532 void OnMotion(wxMouseEvent
& evt
);
533 void OnLeaveWindow(wxMouseEvent
& evt
);
534 void OnSetCursor(wxSetCursorEvent
& evt
);
538 wxAuiToolBarItemArray m_items
; // array of toolbar items
539 wxAuiToolBarArt
* m_art
; // art provider
540 wxBoxSizer
* m_sizer
; // main sizer for toolbar
541 wxAuiToolBarItem
* m_action_item
; // item that's being acted upon (pressed)
542 wxAuiToolBarItem
* m_tip_item
; // item that has its tooltip shown
543 wxBitmap m_bitmap
; // double-buffer bitmap
544 wxSizerItem
* m_gripper_sizer_item
;
545 wxSizerItem
* m_overflow_sizer_item
;
546 wxSize m_absolute_min_size
;
547 wxPoint m_action_pos
; // position of left-mouse down
548 wxAuiToolBarItemArray m_custom_overflow_prepend
;
549 wxAuiToolBarItemArray m_custom_overflow_append
;
553 int m_sizer_element_count
;
557 int m_bottom_padding
;
559 int m_tool_border_padding
;
560 int m_tool_text_orientation
;
561 int m_overflow_state
;
563 bool m_gripper_visible
;
564 bool m_overflow_visible
;
567 DECLARE_EVENT_TABLE()
568 DECLARE_CLASS(wxAuiToolBar
)
574 // wx event machinery
578 BEGIN_DECLARE_EVENT_TYPES()
579 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN
, 0)
580 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK
, 0)
581 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
, 0)
582 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK
, 0)
583 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG
, 0)
584 END_DECLARE_EVENT_TYPES()
586 typedef void (wxEvtHandler
::*wxAuiToolBarEventFunction
)(wxAuiToolBarEvent
&);
588 #define wxAuiToolBarEventHandler(func) \
589 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiToolBarEventFunction, &func)
591 #define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \
592 wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn))
593 #define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \
594 wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn))
595 #define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \
596 wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn))
597 #define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \
598 wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn))
599 #define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \
600 wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn))
604 // wxpython/swig event work
605 %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN
;
606 %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK
;
607 %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
;
608 %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK
;
609 %constant wxEventType wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG
;
612 EVT_AUITOOLBAR_TOOL_DROPDOWN
= wx
.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN
, 1 )
613 EVT_AUITOOLBAR_OVERFLOW_CLICK
= wx
.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK
, 1 )
614 EVT_AUITOOLBAR_RIGHT_CLICK
= wx
.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK
, 1 )
615 EVT_AUITOOLBAR_MIDDLE_CLICK
= wx
.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK
, 1 )
616 EVT_AUITOOLBAR_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG
, 1 )
621 #endif // _WX_AUIBAR_H_