1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ribbon/toolbar.h
3 // Purpose: Ribbon-style tool bar
4 // Author: Peter Cawley
8 // Copyright: (C) Peter Cawley
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RIBBON_TOOLBAR_H_
12 #define _WX_RIBBON_TOOLBAR_H_
18 #include "wx/ribbon/control.h"
19 #include "wx/ribbon/art.h"
21 class wxRibbonToolBarToolBase
;
22 class wxRibbonToolBarToolGroup
;
23 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonToolBarToolGroup
*, wxArrayRibbonToolBarToolGroup
, class WXDLLIMPEXP_RIBBON
);
25 enum wxRibbonToolBarToolState
27 wxRIBBON_TOOLBAR_TOOL_FIRST
= 1 << 0,
28 wxRIBBON_TOOLBAR_TOOL_LAST
= 1 << 1,
29 wxRIBBON_TOOLBAR_TOOL_POSITION_MASK
= wxRIBBON_TOOLBAR_TOOL_FIRST
| wxRIBBON_TOOLBAR_TOOL_LAST
,
31 wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED
= 1 << 3,
32 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
= 1 << 4,
33 wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
= wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED
| wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED
,
34 wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE
= 1 << 5,
35 wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
= 1 << 6,
36 wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK
= wxRIBBON_TOOLBAR_TOOL_NORMAL_ACTIVE
| wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE
,
37 wxRIBBON_TOOLBAR_TOOL_DISABLED
= 1 << 7,
38 wxRIBBON_TOOLBAR_TOOL_TOGGLED
= 1 << 8,
39 wxRIBBON_TOOLBAR_TOOL_STATE_MASK
= 0x1F8
43 class WXDLLIMPEXP_RIBBON wxRibbonToolBar
: public wxRibbonControl
48 wxRibbonToolBar(wxWindow
* parent
,
49 wxWindowID id
= wxID_ANY
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
54 virtual ~wxRibbonToolBar();
56 bool Create(wxWindow
* parent
,
57 wxWindowID id
= wxID_ANY
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
62 virtual wxRibbonToolBarToolBase
* AddTool(
64 const wxBitmap
& bitmap
,
65 const wxString
& help_string
,
66 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
68 virtual wxRibbonToolBarToolBase
* AddDropdownTool(
70 const wxBitmap
& bitmap
,
71 const wxString
& help_string
= wxEmptyString
);
73 virtual wxRibbonToolBarToolBase
* AddHybridTool(
75 const wxBitmap
& bitmap
,
76 const wxString
& help_string
= wxEmptyString
);
78 virtual wxRibbonToolBarToolBase
* AddToggleTool(
80 const wxBitmap
& bitmap
,
81 const wxString
& help_string
= wxEmptyString
);
83 virtual wxRibbonToolBarToolBase
* AddTool(
85 const wxBitmap
& bitmap
,
86 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
87 const wxString
& help_string
= wxEmptyString
,
88 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
89 wxObject
* client_data
= NULL
);
91 virtual wxRibbonToolBarToolBase
* AddSeparator();
93 virtual wxRibbonToolBarToolBase
* InsertTool(
96 const wxBitmap
& bitmap
,
97 const wxString
& help_string
,
98 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
100 virtual wxRibbonToolBarToolBase
* InsertDropdownTool(
103 const wxBitmap
& bitmap
,
104 const wxString
& help_string
= wxEmptyString
);
106 virtual wxRibbonToolBarToolBase
* InsertHybridTool(
109 const wxBitmap
& bitmap
,
110 const wxString
& help_string
= wxEmptyString
);
112 virtual wxRibbonToolBarToolBase
* InsertToggleTool(
115 const wxBitmap
& bitmap
,
116 const wxString
& help_string
= wxEmptyString
);
118 virtual wxRibbonToolBarToolBase
* InsertTool(
121 const wxBitmap
& bitmap
,
122 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
123 const wxString
& help_string
= wxEmptyString
,
124 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
125 wxObject
* client_data
= NULL
);
127 virtual wxRibbonToolBarToolBase
* InsertSeparator(size_t pos
);
129 virtual void ClearTools();
130 virtual bool DeleteTool(int tool_id
);
131 virtual bool DeleteToolByPos(size_t pos
);
133 virtual wxRibbonToolBarToolBase
* FindById(int tool_id
)const;
134 virtual wxRibbonToolBarToolBase
* GetToolByPos(size_t pos
)const;
135 virtual size_t GetToolCount() const;
136 virtual int GetToolId(const wxRibbonToolBarToolBase
* tool
)const;
138 virtual wxObject
* GetToolClientData(int tool_id
)const;
139 virtual bool GetToolEnabled(int tool_id
)const;
140 virtual wxString
GetToolHelpString(int tool_id
)const;
141 virtual wxRibbonButtonKind
GetToolKind(int tool_id
)const;
142 virtual int GetToolPos(int tool_id
)const;
143 virtual bool GetToolState(int tool_id
)const;
145 virtual bool Realize();
146 virtual void SetRows(int nMin
, int nMax
= -1);
148 virtual void SetToolClientData(int tool_id
, wxObject
* clientData
);
149 virtual void SetToolDisabledBitmap(int tool_id
, const wxBitmap
&bitmap
);
150 virtual void SetToolHelpString(int tool_id
, const wxString
& helpString
);
151 virtual void SetToolNormalBitmap(int tool_id
, const wxBitmap
&bitmap
);
153 virtual bool IsSizingContinuous() const;
155 virtual void EnableTool(int tool_id
, bool enable
= true);
156 virtual void ToggleTool(int tool_id
, bool checked
);
159 friend class wxRibbonToolBarEvent
;
160 virtual wxSize
DoGetBestSize() const;
161 wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
163 void OnEraseBackground(wxEraseEvent
& evt
);
164 void OnMouseDown(wxMouseEvent
& evt
);
165 void OnMouseEnter(wxMouseEvent
& evt
);
166 void OnMouseLeave(wxMouseEvent
& evt
);
167 void OnMouseMove(wxMouseEvent
& evt
);
168 void OnMouseUp(wxMouseEvent
& evt
);
169 void OnPaint(wxPaintEvent
& evt
);
170 void OnSize(wxSizeEvent
& evt
);
172 virtual wxSize
DoGetNextSmallerSize(wxOrientation direction
,
173 wxSize relative_to
) const;
174 virtual wxSize
DoGetNextLargerSize(wxOrientation direction
,
175 wxSize relative_to
) const;
177 void CommonInit(long style
);
179 wxRibbonToolBarToolGroup
* InsertGroup(size_t pos
);
180 virtual void UpdateWindowUI(long flags
);
182 static wxBitmap
MakeDisabledBitmap(const wxBitmap
& original
);
184 wxArrayRibbonToolBarToolGroup m_groups
;
185 wxRibbonToolBarToolBase
* m_hover_tool
;
186 wxRibbonToolBarToolBase
* m_active_tool
;
192 DECLARE_CLASS(wxRibbonToolBar
)
193 DECLARE_EVENT_TABLE()
198 class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent
: public wxCommandEvent
201 wxRibbonToolBarEvent(wxEventType command_type
= wxEVT_NULL
,
203 wxRibbonToolBar
* bar
= NULL
)
204 : wxCommandEvent(command_type
, win_id
)
209 wxRibbonToolBarEvent(const wxRibbonToolBarEvent
& e
) : wxCommandEvent(e
)
214 wxEvent
*Clone() const { return new wxRibbonToolBarEvent(*this); }
216 wxRibbonToolBar
* GetBar() {return m_bar
;}
217 void SetBar(wxRibbonToolBar
* bar
) {m_bar
= bar
;}
218 bool PopupMenu(wxMenu
* menu
);
221 wxRibbonToolBar
* m_bar
;
225 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent
)
231 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONTOOL_CLICKED
, wxRibbonToolBarEvent
);
232 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON
, wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
, wxRibbonToolBarEvent
);
234 typedef void (wxEvtHandler::*wxRibbonToolBarEventFunction
)(wxRibbonToolBarEvent
&);
236 #define wxRibbonToolBarEventHandler(func) \
237 wxEVENT_HANDLER_CAST(wxRibbonToolBarEventFunction, func)
239 #define EVT_RIBBONTOOLBAR_CLICKED(winid, fn) \
240 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
241 #define EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(winid, fn) \
242 wx__DECLARE_EVT1(wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, winid, wxRibbonToolBarEventHandler(fn))
245 // wxpython/swig event work
246 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_CLICKED
;
247 %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
;
250 EVT_RIBBONTOOLBAR_CLICKED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_CLICKED
, 1 )
251 EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED
= wx
.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED
, 1 )
255 #endif // wxUSE_RIBBON
257 #endif // _WX_RIBBON_TOOLBAR_H_