]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/ribbon/toolbar.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbon/toolbar.h
3 // Purpose: interface of wxRibbonToolBar
4 // Author: Peter Cawley
5 // Licence: wxWindows licence
6 ///////////////////////////////////////////////////////////////////////////////
11 A ribbon tool bar is similar to a traditional toolbar which has no labels.
12 It contains one or more tool groups, each of which contains one or more
13 tools. Each tool is represented by a (generally small, i.e. 16x15) bitmap.
15 @beginEventEmissionTable{wxRibbonToolBarEvent}
16 @event{EVT_RIBBONTOOLBAR_CLICKED(id, func)}
17 Triggered when the normal (non-dropdown) region of a tool on the tool
19 @event{EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(id, func)}
20 Triggered when the dropdown region of a tool on the tool bar is
21 clicked. wxRibbonToolBarEvent::PopupMenu() should be called by the
22 event handler if it wants to display a popup menu (which is what most
23 dropdown tools should be doing).
29 class wxRibbonToolBar
: public wxRibbonControl
34 With this constructor, Create() should be called in order to create
40 Construct a ribbon tool bar with the given parameters.
43 Parent window for the tool bar (typically a wxRibbonPanel).
45 An identifier for the toolbar. @c wxID_ANY is taken to mean a default.
47 Initial position of the tool bar.
49 Initial size of the tool bar.
51 Tool bar style, currently unused.
53 wxRibbonToolBar(wxWindow
* parent
,
54 wxWindowID id
= wxID_ANY
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
62 virtual ~wxRibbonToolBar();
65 Create a tool bar in two-step tool bar construction.
66 Should only be called when the default constructor is used, and
67 arguments have the same meaning as in the full constructor.
69 bool Create(wxWindow
* parent
,
70 wxWindowID id
= wxID_ANY
,
71 const wxPoint
& pos
= wxDefaultPosition
,
72 const wxSize
& size
= wxDefaultSize
,
76 Add a tool to the tool bar (simple version).
78 virtual wxRibbonToolBarToolBase
* AddTool(
80 const wxBitmap
& bitmap
,
81 const wxString
& help_string
,
82 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
85 Add a dropdown tool to the tool bar (simple version).
89 virtual wxRibbonToolBarToolBase
* AddDropdownTool(
91 const wxBitmap
& bitmap
,
92 const wxString
& help_string
= wxEmptyString
);
95 Add a hybrid tool to the tool bar (simple version).
99 virtual wxRibbonToolBarToolBase
* AddHybridTool(
101 const wxBitmap
& bitmap
,
102 const wxString
& help_string
= wxEmptyString
);
105 Add a toggle tool to the tool bar (simple version).
111 virtual wxRibbonToolBarToolBase
* AddToggleTool(
113 const wxBitmap
& bitmap
,
114 const wxString
& help_string
);
117 Add a tool to the tool bar.
120 ID of the new tool (used for event callbacks).
122 Bitmap to use as the foreground for the new tool. Does not have
123 to be the same size as other tool bitmaps, but should be similar
124 as otherwise it will look visually odd.
125 @param bitmap_disabled
126 Bitmap to use when the tool is disabled. If left as wxNullBitmap,
127 then a bitmap will be automatically generated from @a bitmap.
129 The UI help string to associate with the new tool.
131 The kind of tool to add.
133 Client data to associate with the new tool.
135 @return An opaque pointer which can be used only with other tool bar
138 @see AddDropdownTool(), AddHybridTool(), AddSeparator(), InsertTool()
140 virtual wxRibbonToolBarToolBase
* AddTool(
142 const wxBitmap
& bitmap
,
143 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
144 const wxString
& help_string
= wxEmptyString
,
145 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
146 wxObject
* client_data
= NULL
);
149 Add a separator to the tool bar.
151 Separators are used to separate tools into groups. As such, a separator
152 is not explicitly drawn, but is visually seen as the gap between tool
155 virtual wxRibbonToolBarToolBase
* AddSeparator();
158 Insert a tool to the tool bar (simple version) as the specified
165 virtual wxRibbonToolBarToolBase
* InsertTool(
168 const wxBitmap
& bitmap
,
169 const wxString
& help_string
,
170 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
174 Insert a dropdown tool to the tool bar (simple version) as the specified
179 @see AddDropdownTool(), InsertTool()
181 virtual wxRibbonToolBarToolBase
* InsertDropdownTool(
184 const wxBitmap
& bitmap
,
185 const wxString
& help_string
= wxEmptyString
);
188 Insert a hybrid tool to the tool bar (simple version) as the specified
193 @see AddHybridTool(), InsertTool()
195 virtual wxRibbonToolBarToolBase
* InsertHybridTool(
198 const wxBitmap
& bitmap
,
199 const wxString
& help_string
= wxEmptyString
);
202 Insert a toggle tool to the tool bar (simple version) as the specified
207 @see AddToggleTool(), InsertTool()
209 virtual wxRibbonToolBarToolBase
* InsertToggleTool(
212 const wxBitmap
& bitmap
,
213 const wxString
& help_string
= wxEmptyString
);
216 Insert a tool to the tool bar at the specified position.
219 Position of the new tool (number of tools and separators from the
220 beginning of the toolbar).
222 ID of the new tool (used for event callbacks).
224 Bitmap to use as the foreground for the new tool. Does not have
225 to be the same size as other tool bitmaps, but should be similar
226 as otherwise it will look visually odd.
227 @param bitmap_disabled
228 Bitmap to use when the tool is disabled. If left as wxNullBitmap,
229 then a bitmap will be automatically generated from @a bitmap.
231 The UI help string to associate with the new tool.
233 The kind of tool to add.
235 Client data to associate with the new tool.
237 @return An opaque pointer which can be used only with other tool bar
242 @see InsertDropdownTool(), InsertHybridTool(), InsertSeparator()
244 virtual wxRibbonToolBarToolBase
* InsertTool(
247 const wxBitmap
& bitmap
,
248 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
249 const wxString
& help_string
= wxEmptyString
,
250 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
251 wxObject
* client_data
= NULL
);
254 Insert a separator to the tool bar at the specified position.
258 @see AddSeparator(), InsertTool()
260 virtual wxRibbonToolBarToolBase
* InsertSeparator(size_t pos
);
263 Deletes all the tools in the toolbar.
267 virtual void ClearTools();
270 Removes the specified tool from the toolbar and deletes it.
273 ID of the tool to delete.
275 @returns @true if the tool was deleted, @false otherwise.
279 @see DeleteToolByPos()
281 virtual bool DeleteTool(int tool_id
);
284 This function behaves like DeleteTool() but it deletes the tool at the
285 specified position and not the one with the given id.
286 Useful to delete separators.
290 virtual bool DeleteToolByPos(size_t pos
);
293 Returns a pointer to the tool opaque structure by @a id or @NULL if no
294 corresponding tool is found.
298 virtual wxRibbonToolBarToolBase
* FindById(int tool_id
)const;
301 Return the opaque pointer corresponding to the given tool.
303 @return an opaque pointer, NULL if is a separator or not found.
307 wxRibbonToolBarToolBase
* GetToolByPos(size_t pos
)const
310 Returns the number of tools in the toolbar.
314 virtual size_t GetToolCount() const;
317 Return the id assciated to the tool opaque structure.
319 The structure pointer must not be @NULL.
323 virtual int GetToolId(const wxRibbonToolBarToolBase
* tool
)const;
326 Get any client data associated with the tool.
329 ID of the tool in question, as passed to AddTool().
331 @return Client data, or @NULL if there is none.
335 virtual wxObject
* GetToolClientData(int tool_id
)const;
338 Called to determine whether a tool is enabled (responds to user input).
341 ID of the tool in question, as passed to AddTool().
343 @return @true if the tool is enabled, @false otherwise.
349 virtual bool GetToolEnabled(int tool_id
)const;
352 Returns the help string for the given tool.
355 ID of the tool in question, as passed to AddTool().
359 virtual wxString
GetToolHelpString(int tool_id
)const;
362 Return the kind of the given tool.
365 ID of the tool in question, as passed to AddTool().
369 virtual wxRibbonButtonKind
GetToolKind(int tool_id
)const;
372 Returns the tool position in the toolbar, or @c wxNOT_FOUND if the tool
376 ID of the tool in question, as passed to AddTool().
380 virtual int GetToolPos(int tool_id
)const;
383 Gets the on/off state of a toggle tool.
386 ID of the tool in question, as passed to AddTool().
388 @return @true if the tool is toggled on, @false otherwise.
394 virtual bool GetToolState(int tool_id
)const;
397 Calculate tool layouts and positions.
399 Must be called after tools are added to the tool bar, as otherwise
400 the newly added tools will not be displayed.
402 virtual bool Realize();
405 Set the number of rows to distribute tool groups over.
407 Tool groups can be distributed over a variable number of rows. The way
408 in which groups are assigned to rows is not specified, and the order
409 of groups may change, but they will be distributed in such a way as to
410 minimise the overall size of the tool bar.
413 The minimum number of rows to use.
415 The maximum number of rows to use (defaults to nMin).
417 virtual void SetRows(int nMin
, int nMax
= -1);
420 Sets the client data associated with the tool.
423 ID of the tool in question, as passed to AddTool().
427 virtual void SetToolClientData(int tool_id
, wxObject
* clientData
);
430 Sets the bitmap to be used by the tool with the given ID when the tool
431 is in a disabled state.
434 ID of the tool in question, as passed to AddTool().
438 virtual void SetToolDisabledBitmap(int tool_id
, const wxBitmap
&bitmap
);
441 Sets the help string shown in tooltip for the given tool.
444 ID of the tool in question, as passed to AddTool().
446 A string for the help.
448 @see GetToolHelpString()
452 virtual void SetToolHelpString(int tool_id
, const wxString
& helpString
);
455 Sets the bitmap to be used by the tool with the given ID.
458 ID of the tool in question, as passed to AddTool().
462 virtual void SetToolNormalBitmap(int tool_id
, const wxBitmap
&bitmap
);
465 Enable or disable a single tool on the bar.
468 ID of the tool to enable or disable.
470 @true to enable the tool, @false to disable it.
474 virtual void EnableTool(int tool_id
, bool enable
= true);
477 Set a toggle tool to the checked or unchecked state.
480 ID of the toggle tool to manipulate.
482 @true to set the tool to the toggled/pressed/checked state,
483 @false to set it to the untoggled/unpressed/unchecked state.
487 virtual void ToggleTool(int tool_id
, bool checked
);