1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ribbon/buttonbar.h
3 // Purpose: interface of wxRibbonButtonBar
4 // Author: Peter Cawley
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
10 Flags for button bar button size and state.
12 Buttons on a ribbon button bar can each come in three sizes: small, medium,
13 and large. In some places this is called the size class, and the term size
14 used for the pixel width and height associated with a particular size
17 A button can also be in zero or more hovered or active states, or in the
20 enum wxRibbonButtonBarButtonState
23 Button is small (the interpretation of small is dependent upon the art
24 provider, but it will be smaller than medium).
26 wxRIBBON_BUTTONBAR_BUTTON_SMALL
= 0 << 0,
29 Button is medium sized (the interpretation of medium is dependent upon
30 the art provider, but it will be between small and large).
32 wxRIBBON_BUTTONBAR_BUTTON_MEDIUM
= 1 << 0,
35 Button is large (the interpretation of large is dependent upon the art
36 provider, but it will be larger than medium).
38 wxRIBBON_BUTTONBAR_BUTTON_LARGE
= 2 << 0,
41 A mask to extract button size from a combination of flags.
43 wxRIBBON_BUTTONBAR_BUTTON_SIZE_MASK
= 3 << 0,
46 The normal (non-dropdown) region of the button is being hovered over by
47 the mouse cursor. Only applicable to normal and hybrid buttons.
49 wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
= 1 << 3,
52 The dropdown region of the button is being hovered over by the mouse
53 cursor. Only applicable to dropdown and hybrid buttons.
55 wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED
= 1 << 4,
58 A mask to extract button hover state from a combination of flags.
60 wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK
= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED
| wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED
,
63 The normal (non-dropdown) region of the button is being pressed.
64 Only applicable to normal and hybrid buttons.
66 wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE
= 1 << 5,
69 The dropdown region of the button is being pressed.
70 Only applicable to dropdown and hybrid buttons.
72 wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE
= 1 << 6,
75 The button is disabled. Hover flags may still be set when a button
76 is disabled, but should be ignored during drawing if the button is
79 wxRIBBON_BUTTONBAR_BUTTON_DISABLED
= 1 << 7,
82 The button is a toggle button which is currently in the toggled state.
84 wxRIBBON_BUTTONBAR_BUTTON_TOGGLED
= 1 << 8,
87 A mask to extract button state from a combination of flags.
89 wxRIBBON_BUTTONBAR_BUTTON_STATE_MASK
= 0x1F8,
93 @class wxRibbonButtonBar
95 A ribbon button bar is similar to a traditional toolbar. It contains one or
96 more buttons (button bar buttons, not wxButtons), each of which has a label
97 and an icon. It differs from a wxRibbonToolBar in several ways:
98 @li Individual buttons can grow and contract.
99 @li Buttons have labels as well as bitmaps.
100 @li Bitmaps are typically larger (at least 32x32 pixels) on a button bar
101 compared to a tool bar (which typically has 16x15).
102 @li There is no grouping of buttons on a button bar
103 @li A button bar typically has a border around each individual button,
104 whereas a tool bar typically has a border around each group of buttons.
106 @beginEventEmissionTable{wxRibbonButtonBarEvent}
107 @event{EVT_RIBBONBUTTONBAR_CLICKED(id, func)}
108 Triggered when the normal (non-dropdown) region of a button on the
109 button bar is clicked.
110 @event{EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED(id, func)}
111 Triggered when the dropdown region of a button on the button bar is
112 clicked. wxRibbonButtonBarEvent::PopupMenu() should be called by the
113 event handler if it wants to display a popup menu (which is what most
114 dropdown buttons should be doing).
120 class wxRibbonButtonBar
: public wxRibbonControl
125 With this constructor, Create() should be called in order to create
131 Construct a ribbon button bar with the given parameters.
134 Parent window for the button bar (typically a wxRibbonPanel).
136 An identifier for the button bar. @c wxID_ANY is taken to mean a default.
138 Initial position of the button bar.
140 Initial size of the button bar.
142 Button bar style, currently unused.
144 wxRibbonButtonBar(wxWindow
* parent
,
145 wxWindowID id
= wxID_ANY
,
146 const wxPoint
& pos
= wxDefaultPosition
,
147 const wxSize
& size
= wxDefaultSize
,
153 virtual ~wxRibbonButtonBar();
156 Create a button bar in two-step button bar construction.
157 Should only be called when the default constructor is used, and
158 arguments have the same meaning as in the full constructor.
160 bool Create(wxWindow
* parent
,
161 wxWindowID id
= wxID_ANY
,
162 const wxPoint
& pos
= wxDefaultPosition
,
163 const wxSize
& size
= wxDefaultSize
,
167 Add a button to the button bar (simple version).
169 virtual wxRibbonButtonBarButtonBase
* AddButton(
171 const wxString
& label
,
172 const wxBitmap
& bitmap
,
173 const wxString
& help_string
,
174 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
177 Add a dropdown button to the button bar (simple version).
181 virtual wxRibbonButtonBarButtonBase
* AddDropdownButton(
183 const wxString
& label
,
184 const wxBitmap
& bitmap
,
185 const wxString
& help_string
= wxEmptyString
);
188 Add a hybrid button to the button bar (simple version).
192 virtual wxRibbonButtonBarButtonBase
* AddHybridButton(
194 const wxString
& label
,
195 const wxBitmap
& bitmap
,
196 const wxString
& help_string
= wxEmptyString
);
199 Add a toggle button to the button bar (simple version).
203 virtual wxRibbonButtonBarButtonBase
* AddToggleButton(
205 const wxString
& label
,
206 const wxBitmap
& bitmap
,
207 const wxString
& help_string
= wxEmptyString
);
210 Add a button to the button bar.
213 ID of the new button (used for event callbacks).
215 Label of the new button.
217 Large bitmap of the new button. Must be the same size as all other
218 large bitmaps used on the button bar.
220 Small bitmap of the new button. If left as null, then a small
221 bitmap will be automatically generated. Must be the same size as
222 all other small bitmaps used on the button bar.
223 @param bitmap_disabled
224 Large bitmap of the new button when it is disabled. If left as
225 null, then a bitmap will be automatically generated from @a bitmap.
226 @param bitmap_small_disabled
227 Small bitmap of the new button when it is disabled. If left as
228 null, then a bitmap will be automatically generated from @a
231 The kind of button to add.
233 The UI help string to associate with the new button.
235 Client data to associate with the new button.
237 @return An opaque pointer which can be used only with other button bar
240 @see AddDropdownButton()
241 @see AddHybridButton()
242 @see AddToggleButton()
244 virtual wxRibbonButtonBarButtonBase
* AddButton(
246 const wxString
& label
,
247 const wxBitmap
& bitmap
,
248 const wxBitmap
& bitmap_small
= wxNullBitmap
,
249 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
250 const wxBitmap
& bitmap_small_disabled
= wxNullBitmap
,
251 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
252 const wxString
& help_string
= wxEmptyString
,
253 wxObject
* client_data
= NULL
);
256 Inserts a button to the button bar (simple version) at the given position.
262 virtual wxRibbonButtonBarButtonBase
* InsertButton(
265 const wxString
& label
,
266 const wxBitmap
& bitmap
,
267 const wxString
& help_string
,
268 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
);
271 Inserts a dropdown button to the button bar (simple version) at the
275 @see AddDropdownButton()
280 virtual wxRibbonButtonBarButtonBase
* InsertDropdownButton(
283 const wxString
& label
,
284 const wxBitmap
& bitmap
,
285 const wxString
& help_string
= wxEmptyString
);
288 Inserts a hybrid button to the button bar (simple version) at the given
292 @see AddHybridButton()
297 virtual wxRibbonButtonBarButtonBase
* InsertHybridButton(
300 const wxString
& label
,
301 const wxBitmap
& bitmap
,
302 const wxString
& help_string
= wxEmptyString
);
305 Inserts a toggle button to the button bar (simple version) at the given
309 @see AddToggleButton()
314 virtual wxRibbonButtonBarButtonBase
* InsertToggleButton(
317 const wxString
& label
,
318 const wxBitmap
& bitmap
,
319 const wxString
& help_string
= wxEmptyString
);
322 Insert a button to the button bar at the given position.
325 Position of the new button in the button bar.
327 ID of the new button (used for event callbacks).
329 Label of the new button.
331 Large bitmap of the new button. Must be the same size as all other
332 large bitmaps used on the button bar.
334 Small bitmap of the new button. If left as null, then a small
335 bitmap will be automatically generated. Must be the same size as
336 all other small bitmaps used on the button bar.
337 @param bitmap_disabled
338 Large bitmap of the new button when it is disabled. If left as
339 null, then a bitmap will be automatically generated from @a bitmap.
340 @param bitmap_small_disabled
341 Small bitmap of the new button when it is disabled. If left as
342 null, then a bitmap will be automatically generated from @a
345 The kind of button to add.
347 The UI help string to associate with the new button.
349 Client data to associate with the new button.
351 @return An opaque pointer which can be used only with other button bar
354 @see InsertDropdownButton()
355 @see InsertHybridButton()
356 @see InsertToggleButton()
361 virtual wxRibbonButtonBarButtonBase
* InsertButton(
364 const wxString
& label
,
365 const wxBitmap
& bitmap
,
366 const wxBitmap
& bitmap_small
= wxNullBitmap
,
367 const wxBitmap
& bitmap_disabled
= wxNullBitmap
,
368 const wxBitmap
& bitmap_small_disabled
= wxNullBitmap
,
369 wxRibbonButtonKind kind
= wxRIBBON_BUTTON_NORMAL
,
370 const wxString
& help_string
= wxEmptyString
,
371 wxObject
* client_data
= NULL
);
374 Returns the number of buttons in this button bar.
378 virtual size_t GetButtonCount() const;
381 Calculate button layouts and positions.
383 Must be called after buttons are added to the button bar, as otherwise
384 the newly added buttons will not be displayed. In normal situations, it
385 will be called automatically when wxRibbonBar::Realize() is called.
387 virtual bool Realize();
390 Delete all buttons from the button bar.
394 virtual void ClearButtons();
397 Delete a single button from the button bar.
401 virtual bool DeleteButton(int button_id
);
404 Enable or disable a single button on the bar.
407 ID of the button to enable or disable.
409 @true to enable the button, @false to disable it.
411 virtual void EnableButton(int button_id
, bool enable
= true);
414 Set a toggle button to the checked or unchecked state.
417 ID of the toggle button to manipulate.
419 @true to set the button to the toggled/pressed/checked state,
420 @false to set it to the untoggled/unpressed/unchecked state.
422 virtual void ToggleButton(int button_id
, bool checked
);
426 @class wxRibbonButtonBarEvent
428 Event used to indicate various actions relating to a button on a
429 wxRibbonButtonBar. For toggle buttons, IsChecked() can be used to test
430 the state of the button.
432 See wxRibbonButtonBar for available event types.
435 @category{events,ribbon}
439 class wxRibbonButtonBarEvent
: public wxCommandEvent
445 wxRibbonButtonBarEvent(wxEventType command_type
= wxEVT_NULL
,
447 wxRibbonButtonBar
* bar
= NULL
);
450 Returns the bar which contains the button which the event relates to.
452 wxRibbonButtonBar
* GetBar();
455 Sets the button bar relating to this event.
457 void SetBar(wxRibbonButtonBar
* bar
);
460 Display a popup menu as a result of this (dropdown clicked) event.
462 bool PopupMenu(wxMenu
* menu
);