]>
Commit | Line | Data |
---|---|---|
3c3ead1d PC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/ribbon/toolbar.h | |
3 | // Purpose: Ribbon-style tool bar | |
4 | // Author: Peter Cawley | |
5 | // Modified by: | |
6 | // Created: 2009-07-06 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (C) Peter Cawley | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | #ifndef _WX_RIBBON_TOOLBAR_H_ | |
12 | #define _WX_RIBBON_TOOLBAR_H_ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_RIBBON | |
17 | ||
18 | #include "wx/ribbon/control.h" | |
19 | #include "wx/ribbon/art.h" | |
20 | ||
21 | class wxRibbonToolBarToolBase; | |
22 | class wxRibbonToolBarToolGroup; | |
c155b9b5 | 23 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxRibbonToolBarToolGroup*, wxArrayRibbonToolBarToolGroup, class WXDLLIMPEXP_RIBBON); |
3c3ead1d PC |
24 | |
25 | enum wxRibbonToolBarToolState | |
26 | { | |
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, | |
30 | ||
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, | |
d1bf0be0 VZ |
38 | wxRIBBON_TOOLBAR_TOOL_TOGGLED = 1 << 8, |
39 | wxRIBBON_TOOLBAR_TOOL_STATE_MASK = 0x1F8 | |
3c3ead1d PC |
40 | }; |
41 | ||
42 | ||
43 | class WXDLLIMPEXP_RIBBON wxRibbonToolBar : public wxRibbonControl | |
44 | { | |
45 | public: | |
46 | wxRibbonToolBar(); | |
47 | ||
48 | wxRibbonToolBar(wxWindow* parent, | |
49 | wxWindowID id = wxID_ANY, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0); | |
53 | ||
54 | virtual ~wxRibbonToolBar(); | |
55 | ||
56 | bool Create(wxWindow* parent, | |
57 | wxWindowID id = wxID_ANY, | |
58 | const wxPoint& pos = wxDefaultPosition, | |
59 | const wxSize& size = wxDefaultSize, | |
60 | long style = 0); | |
61 | ||
62 | virtual wxRibbonToolBarToolBase* AddTool( | |
63 | int tool_id, | |
64 | const wxBitmap& bitmap, | |
65 | const wxString& help_string, | |
66 | wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL); | |
67 | ||
68 | virtual wxRibbonToolBarToolBase* AddDropdownTool( | |
69 | int tool_id, | |
70 | const wxBitmap& bitmap, | |
71 | const wxString& help_string = wxEmptyString); | |
72 | ||
73 | virtual wxRibbonToolBarToolBase* AddHybridTool( | |
74 | int tool_id, | |
75 | const wxBitmap& bitmap, | |
76 | const wxString& help_string = wxEmptyString); | |
77 | ||
d1bf0be0 VZ |
78 | virtual wxRibbonToolBarToolBase* AddToggleTool( |
79 | int tool_id, | |
80 | const wxBitmap& bitmap, | |
81 | const wxString& help_string = wxEmptyString); | |
82 | ||
3c3ead1d PC |
83 | virtual wxRibbonToolBarToolBase* AddTool( |
84 | int tool_id, | |
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); | |
90 | ||
91 | virtual wxRibbonToolBarToolBase* AddSeparator(); | |
92 | ||
d1bf0be0 VZ |
93 | virtual wxRibbonToolBarToolBase* InsertTool( |
94 | size_t pos, | |
95 | int tool_id, | |
96 | const wxBitmap& bitmap, | |
97 | const wxString& help_string, | |
98 | wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL); | |
99 | ||
100 | virtual wxRibbonToolBarToolBase* InsertDropdownTool( | |
101 | size_t pos, | |
102 | int tool_id, | |
103 | const wxBitmap& bitmap, | |
104 | const wxString& help_string = wxEmptyString); | |
105 | ||
106 | virtual wxRibbonToolBarToolBase* InsertHybridTool( | |
107 | size_t pos, | |
108 | int tool_id, | |
109 | const wxBitmap& bitmap, | |
110 | const wxString& help_string = wxEmptyString); | |
111 | ||
112 | virtual wxRibbonToolBarToolBase* InsertToggleTool( | |
113 | size_t pos, | |
114 | int tool_id, | |
115 | const wxBitmap& bitmap, | |
116 | const wxString& help_string = wxEmptyString); | |
117 | ||
118 | virtual wxRibbonToolBarToolBase* InsertTool( | |
119 | size_t pos, | |
120 | int tool_id, | |
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); | |
126 | ||
127 | virtual wxRibbonToolBarToolBase* InsertSeparator(size_t pos); | |
128 | ||
129 | virtual void ClearTools(); | |
130 | virtual bool DeleteTool(int tool_id); | |
131 | virtual bool DeleteToolByPos(size_t pos); | |
132 | ||
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; | |
137 | ||
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; | |
144 | ||
3c3ead1d PC |
145 | virtual bool Realize(); |
146 | virtual void SetRows(int nMin, int nMax = -1); | |
147 | ||
d1bf0be0 VZ |
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); | |
152 | ||
3c3ead1d | 153 | virtual bool IsSizingContinuous() const; |
3c3ead1d | 154 | |
d1bf0be0 VZ |
155 | virtual void EnableTool(int tool_id, bool enable = true); |
156 | virtual void ToggleTool(int tool_id, bool checked); | |
157 | ||
3c3ead1d PC |
158 | protected: |
159 | friend class wxRibbonToolBarEvent; | |
cff9681b | 160 | virtual wxSize DoGetBestSize() const; |
3c3ead1d PC |
161 | wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } |
162 | ||
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); | |
171 | ||
172 | virtual wxSize DoGetNextSmallerSize(wxOrientation direction, | |
173 | wxSize relative_to) const; | |
174 | virtual wxSize DoGetNextLargerSize(wxOrientation direction, | |
175 | wxSize relative_to) const; | |
176 | ||
177 | void CommonInit(long style); | |
178 | void AppendGroup(); | |
d1bf0be0 VZ |
179 | wxRibbonToolBarToolGroup* InsertGroup(size_t pos); |
180 | virtual void UpdateWindowUI(long flags); | |
3c3ead1d PC |
181 | |
182 | static wxBitmap MakeDisabledBitmap(const wxBitmap& original); | |
183 | ||
184 | wxArrayRibbonToolBarToolGroup m_groups; | |
185 | wxRibbonToolBarToolBase* m_hover_tool; | |
186 | wxRibbonToolBarToolBase* m_active_tool; | |
187 | wxSize* m_sizes; | |
188 | int m_nrows_min; | |
189 | int m_nrows_max; | |
190 | ||
191 | #ifndef SWIG | |
192 | DECLARE_CLASS(wxRibbonToolBar) | |
193 | DECLARE_EVENT_TABLE() | |
194 | #endif | |
195 | }; | |
196 | ||
197 | ||
198 | class WXDLLIMPEXP_RIBBON wxRibbonToolBarEvent : public wxCommandEvent | |
199 | { | |
200 | public: | |
201 | wxRibbonToolBarEvent(wxEventType command_type = wxEVT_NULL, | |
202 | int win_id = 0, | |
203 | wxRibbonToolBar* bar = NULL) | |
204 | : wxCommandEvent(command_type, win_id) | |
205 | , m_bar(bar) | |
206 | { | |
207 | } | |
208 | #ifndef SWIG | |
209 | wxRibbonToolBarEvent(const wxRibbonToolBarEvent& e) : wxCommandEvent(e) | |
210 | { | |
211 | m_bar = e.m_bar; | |
212 | } | |
213 | #endif | |
214 | wxEvent *Clone() const { return new wxRibbonToolBarEvent(*this); } | |
215 | ||
216 | wxRibbonToolBar* GetBar() {return m_bar;} | |
217 | void SetBar(wxRibbonToolBar* bar) {m_bar = bar;} | |
218 | bool PopupMenu(wxMenu* menu); | |
219 | ||
220 | protected: | |
221 | wxRibbonToolBar* m_bar; | |
222 | ||
223 | #ifndef SWIG | |
224 | private: | |
225 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRibbonToolBarEvent) | |
226 | #endif | |
227 | }; | |
228 | ||
229 | #ifndef SWIG | |
230 | ||
231 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_CLICKED, wxRibbonToolBarEvent); | |
232 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_RIBBON, wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, wxRibbonToolBarEvent); | |
233 | ||
234 | typedef void (wxEvtHandler::*wxRibbonToolBarEventFunction)(wxRibbonToolBarEvent&); | |
235 | ||
236 | #define wxRibbonToolBarEventHandler(func) \ | |
237 | wxEVENT_HANDLER_CAST(wxRibbonToolBarEventFunction, func) | |
238 | ||
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)) | |
243 | #else | |
244 | ||
245 | // wxpython/swig event work | |
246 | %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_CLICKED; | |
247 | %constant wxEventType wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED; | |
248 | ||
249 | %pythoncode { | |
250 | EVT_RIBBONTOOLBAR_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_CLICKED, 1 ) | |
251 | EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED = wx.PyEventBinder( wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED, 1 ) | |
252 | } | |
253 | #endif | |
254 | ||
255 | #endif // wxUSE_RIBBON | |
256 | ||
257 | #endif // _WX_RIBBON_TOOLBAR_H_ |