]>
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
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
10 @class wxRibbonToolBar
12 A ribbon tool bar is similar to a traditional toolbar which has no labels.
13 It contains one or more tool groups, each of which contains one or more
14 tools. Each tool is represented by a (generally small, i.e. 16x15) bitmap.
16 @beginEventEmissionTable{wxRibbonToolBarEvent}
17 @event{EVT_RIBBONTOOLBAR_CLICKED(id, func)}
18 Triggered when the normal (non-dropdown) region of a tool on the tool
20 @event{EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED(id, func)}
21 Triggered when the dropdown region of a tool on the tool bar is
22 clicked. wxRibbonToolBarEvent::PopupMenu() should be called by the
23 event handler if it wants to display a popup menu (which is what most
24 dropdown tools should be doing).
30 class wxRibbonToolBar
: public wxRibbonControl
35 With this constructor, Create() should be called in order to create
41 Construct a ribbon tool bar with the given parameters.
44 Parent window for the tool bar (typically a wxRibbonPanel).
46 An identifier for the toolbar. @c wxID_ANY is taken to mean a default.
48 Initial position of the tool bar.
50 Initial size of the tool bar.
52 Tool bar style, currently unused.
54 wxRibbonToolBar(wxWindow
* parent
,
55 wxWindowID id
= wxID_ANY
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
63 virtual ~wxRibbonToolBar();
66 Create a tool bar in two-step tool bar construction.
67 Should only be called when the default constructor is used, and
68 arguments have the same meaning as in the full constructor.
70 bool Create(wxWindow
* parent
,
71 wxWindowID id
= wxID_ANY
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
77 Add a tool to the tool bar (simple version).
79 virtual wxRibbonToolBarToolBase
* AddTool(
81 const wxBitmap
& bitmap
,
82 const wxString
& help_string
,
83 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
86 Add a dropdown tool to the tool bar (simple version).
90 virtual wxRibbonToolBarToolBase
* AddDropdownTool(
92 const wxBitmap
& bitmap
,
93 const wxString
& help_string
= wxEmptyString
);
96 Add a hybrid tool to the tool bar (simple version).
100 virtual wxRibbonToolBarToolBase
* AddHybridTool(
102 const wxBitmap
& bitmap
,
103 const wxString
& help_string
= wxEmptyString
);
106 Add a toggle tool to the tool bar (simple version).
112 virtual wxRibbonToolBarToolBase
* AddToggleTool(
114 const wxBitmap
& bitmap
,
115 const wxString
& help_string
);
118 Add a tool to the tool bar.
121 ID of the new tool (used for event callbacks).
123 Bitmap to use as the foreground for the new tool. Does not have
124 to be the same size as other tool bitmaps, but should be similar
125 as otherwise it will look visually odd.
126 @param bitmap_disabled
127 Bitmap to use when the tool is disabled. If left as wxNullBitmap,
128 then a bitmap will be automatically generated from @a bitmap.
130 The UI help string to associate with the new tool.
132 The kind of tool to add.
134 Client data to associate with the new tool.
136 @return An opaque pointer which can be used only with other tool bar
139 @see AddDropdownTool(), AddHybridTool(), AddSeparator(), InsertTool()
141 virtual wxRibbonToolBarToolBase
* AddTool(
143 const wxBitmap
& bitmap
,
144 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
145 const wxString
& help_string
= wxEmptyString
,
146 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
147 wxObject
* client_data
= NULL
);
150 Add a separator to the tool bar.
152 Separators are used to separate tools into groups. As such, a separator
153 is not explicitly drawn, but is visually seen as the gap between tool
156 virtual wxRibbonToolBarToolBase
* AddSeparator();
159 Insert a tool to the tool bar (simple version) as the specified
166 virtual wxRibbonToolBarToolBase
* InsertTool(
169 const wxBitmap
& bitmap
,
170 const wxString
& help_string
,
171 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
175 Insert a dropdown tool to the tool bar (simple version) as the specified
180 @see AddDropdownTool(), InsertTool()
182 virtual wxRibbonToolBarToolBase
* InsertDropdownTool(
185 const wxBitmap
& bitmap
,
186 const wxString
& help_string
= wxEmptyString
);
189 Insert a hybrid tool to the tool bar (simple version) as the specified
194 @see AddHybridTool(), InsertTool()
196 virtual wxRibbonToolBarToolBase
* InsertHybridTool(
199 const wxBitmap
& bitmap
,
200 const wxString
& help_string
= wxEmptyString
);
203 Insert a toggle tool to the tool bar (simple version) as the specified
208 @see AddToggleTool(), InsertTool()
210 virtual wxRibbonToolBarToolBase
* InsertToggleTool(
213 const wxBitmap
& bitmap
,
214 const wxString
& help_string
= wxEmptyString
);
217 Insert a tool to the tool bar at the specified position.
220 Position of the new tool (number of tools and separators from the
221 begining of the toolbar).
223 ID of the new tool (used for event callbacks).
225 Bitmap to use as the foreground for the new tool. Does not have
226 to be the same size as other tool bitmaps, but should be similar
227 as otherwise it will look visually odd.
228 @param bitmap_disabled
229 Bitmap to use when the tool is disabled. If left as wxNullBitmap,
230 then a bitmap will be automatically generated from @a bitmap.
232 The UI help string to associate with the new tool.
234 The kind of tool to add.
236 Client data to associate with the new tool.
238 @return An opaque pointer which can be used only with other tool bar
243 @see InsertDropdownTool(), InsertHybridTool(), InsertSeparator()
245 virtual wxRibbonToolBarToolBase
* InsertTool(
248 const wxBitmap
& bitmap
,
249 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
250 const wxString
& help_string
= wxEmptyString
,
251 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
252 wxObject
* client_data
= NULL
);
255 Insert a separator to the tool bar at the specified position.
259 @see AddSeparator(), InsertTool()
261 virtual wxRibbonToolBarToolBase
* InsertSeparator(size_t pos
);
264 Deletes all the tools in the toolbar.
268 virtual void ClearTools();
271 Removes the specified tool from the toolbar and deletes it.
274 ID of the tool to delete.
276 @returns @true if the tool was deleted, @false otherwise.
280 @see DeleteToolByPos()
282 virtual bool DeleteTool(int tool_id
);
285 This function behaves like DeleteTool() but it deletes the tool at the
286 specified position and not the one with the given id.
287 Usefull to delete separators.
291 virtual bool DeleteToolByPos(size_t pos
);
294 Returns a pointer to the tool opaque structure by @a id or @NULL if no
295 corresponding tool is found.
299 virtual wxRibbonToolBarToolBase
* FindById(int tool_id
)const;
302 Return the opaque pointer corresponding to the given tool.
304 @return an opaque pointer, NULL if is a separator or not found.
308 wxRibbonToolBarToolBase
* GetToolByPos(size_t pos
)const
311 Returns the number of tools in the toolbar.
315 virtual size_t GetToolCount() const;
318 Return the id assciated to the tool opaque structure.
320 The structure pointer must not be @NULL.
324 virtual int GetToolId(const wxRibbonToolBarToolBase
* tool
)const;
327 Get any client data associated with the tool.
330 ID of the tool in question, as passed to AddTool().
332 @return Client data, or @NULL if there is none.
336 virtual wxObject
* GetToolClientData(int tool_id
)const;
339 Called to determine whether a tool is enabled (responds to user input).
342 ID of the tool in question, as passed to AddTool().
344 @return @true if the tool is enabled, @false otherwise.
350 virtual bool GetToolEnabled(int tool_id
)const;
353 Returns the help string for the given tool.
356 ID of the tool in question, as passed to AddTool().
360 virtual wxString
GetToolHelpString(int tool_id
)const;
363 Return the kind of the given tool.
366 ID of the tool in question, as passed to AddTool().
370 virtual wxRibbonButtonKind
GetToolKind(int tool_id
)const;
373 Returns the tool position in the toolbar, or @c wxNOT_FOUND if the tool
377 ID of the tool in question, as passed to AddTool().
381 virtual int GetToolPos(int tool_id
)const;
384 Gets the on/off state of a toggle tool.
387 ID of the tool in question, as passed to AddTool().
389 @return @true if the tool is toggled on, @false otherwise.
395 virtual bool GetToolState(int tool_id
)const;
398 Calculate tool layouts and positions.
400 Must be called after tools are added to the tool bar, as otherwise
401 the newly added tools will not be displayed.
403 virtual bool Realize();
406 Set the number of rows to distribute tool groups over.
408 Tool groups can be distributed over a variable number of rows. The way
409 in which groups are assigned to rows is not specified, and the order
410 of groups may change, but they will be distributed in such a way as to
411 minimise the overall size of the tool bar.
414 The minimum number of rows to use.
416 The maximum number of rows to use (defaults to nMin).
418 virtual void SetRows(int nMin
, int nMax
= -1);
421 Sets the client data associated with the tool.
424 ID of the tool in question, as passed to AddTool().
428 virtual void SetToolClientData(int tool_id
, wxObject
* clientData
);
431 Sets the bitmap to be used by the tool with the given ID when the tool
432 is in a disabled state.
435 ID of the tool in question, as passed to AddTool().
439 virtual void SetToolDisabledBitmap(int tool_id
, const wxBitmap
&bitmap
);
442 Sets the help string shown in tooltip for the given tool.
445 ID of the tool in question, as passed to AddTool().
447 A string for the help.
449 @see GetToolHelpString()
453 virtual void SetToolHelpString(int tool_id
, const wxString
& helpString
);
456 Sets the bitmap to be used by the tool with the given ID.
459 ID of the tool in question, as passed to AddTool().
463 virtual void SetToolNormalBitmap(int tool_id
, const wxBitmap
&bitmap
);
466 Enable or disable a single tool on the bar.
469 ID of the tool to enable or disable.
471 @true to enable the tool, @false to disable it.
475 virtual void EnableTool(int tool_id
, bool enable
= true);
478 Set a toggle tool to the checked or unchecked state.
481 ID of the toggle tool to manipulate.
483 @true to set the tool to the toggled/pressed/checked state,
484 @false to set it to the untoggled/unpressed/unchecked state.
488 virtual void ToggleTool(int tool_id
, bool checked
);