1.10 |
#include <buttongroup.h>
Public Types | |
using | CheckedCallback = std::function< void(Button &button)> |
Public Member Functions | |
ButtonGroup (bool imperative=false, bool exclusive=true) noexcept | |
ButtonGroup (ButtonGroup &&)=default | |
ButtonGroup (const ButtonGroup &)=delete | |
~ButtonGroup () noexcept | |
void | add (const std::shared_ptr< Button > &button) |
Add a button to the group. | |
EGT_NODISCARD bool | exclusive () const |
Get the exclusive property. | |
void | exclusive (bool exclusive) |
Set the exclusive property of the group. | |
void | foreach_checked (const CheckedCallback &callback) |
Run a function on each checked button. | |
EGT_NODISCARD bool | imperative () const |
Get the imperative property. | |
void | imperative (bool imperative) |
Set the imperative property of the group. | |
ButtonGroup & | operator= (ButtonGroup &&)=default |
ButtonGroup & | operator= (const ButtonGroup &)=delete |
void | remove (Button *button) |
Remove a button from the group. | |
Protected Attributes | |
ButtonArray | m_buttons |
Buttons in the group. | |
bool | m_exclusive {false} |
Only one button can be checked(). | |
bool | m_imperative {true} |
At least one button must be checked(). | |
Friends | |
class | Button |
Button group.
Several buttons can be added to a group. A button must belong to only one group.
If the group is exclusive, only one button in the group can have its checked state to true.
If the group is imperative, it ensures that at least one button is checked.
using CheckedCallback = std::function<void (Button& button)> |
|
explicitnoexcept |
imperative | When true, one button must always be checked. |
exclusive | When true, only one button can be checked at a time. |
|
delete |
|
default |
|
noexcept |
void add | ( | const std::shared_ptr< Button > & | button | ) |
Add a button to the group.
EGT_NODISCARD bool exclusive | ( | ) | const |
Get the exclusive property.
void exclusive | ( | bool | exclusive | ) |
Set the exclusive property of the group.
exclusive | When true, only one button can be checked at a time. |
void foreach_checked | ( | const CheckedCallback & | callback | ) |
Run a function on each checked button.
If the exclusive property is true, only one button will even be invoked.
callback | The callback to invoke. |
EGT_NODISCARD bool imperative | ( | ) | const |
Get the imperative property.
void imperative | ( | bool | imperative | ) |
Set the imperative property of the group.
imperative | When true, one must must always be checked. |
|
default |
|
delete |
void remove | ( | Button * | button | ) |
Remove a button from the group.
|
friend |
|
protected |
Buttons in the group.
|
protected |
Only one button can be checked().
|
protected |
At least one button must be checked().