wex v24.10.0
|
Container class for using with item_dialog. More...
#include <wex/ui/item.h>
Public Types | |
enum | type_t { BUTTON , CHECKBOX , CHECKLISTBOX_BIT , CHECKLISTBOX_BOOL , COLOURPICKERWIDGET , COMBOBOX , COMBOBOX_DIR , COMBOBOX_FILE , COMMANDLINKBUTTON , DIRPICKERCTRL , EMPTY , FILEPICKERCTRL , FONTPICKERCTRL , GRID , GROUP , HYPERLINKCTRL , LISTVIEW , NOTEBOOK , NOTEBOOK_AUI , NOTEBOOK_CHOICE , NOTEBOOK_LIST , NOTEBOOK_SIMPLE , NOTEBOOK_TOOL , NOTEBOOK_TREE , NOTEBOOK_WEX , RADIOBOX , SLIDER , SPACER , SPINCTRL , SPINCTRLDOUBLE , STATICBOX , STATICLINE , STATICTEXT , TEXTCTRL , TEXTCTRL_FLOAT , TEXTCTRL_INT , TOGGLEBUTTON , USER } |
The item types supported. More... | |
typedef std::unordered_map< long, const std::string > | choices_t |
Choices for radioboxes. | |
typedef std::unordered_set< std::string > | choices_bool_t |
Choices for listboxes with toggle options. | |
typedef std::pair< std::string, std::vector< item > > | group_t |
A group is a pair of text with a vector of items. | |
typedef std::vector< group_t > | notebook_t |
A notebook is a vector of groups. | |
Public Member Functions | |
item () | |
Default constructor for an EMPTY item. | |
item (int size) | |
Constructor for a SPACER item. | |
item (wxOrientation orientation) | |
Constructor for a STATICLINE item. | |
item (const std::string &label, type_t type, const data::item &data) | |
Constructor from data::item. | |
item (const std::string &label, const std::string &value=std::string(), type_t type=TEXTCTRL, const data::item &data=data::item()) | |
Constructor for several items. | |
item (const std::string &label, int min, int max, const std::any &value=std::any(), type_t type=SPINCTRL, const data::item &data=data::item()) | |
Constructor for a SPINCTRL or a SLIDER item. | |
item (const std::string &label, double min, double max, const std::any &value=std::any(), const data::item &data=data::item().window(data::window().style(wxSP_ARROW_KEYS))) | |
Constructor for a SPINCTRLDOUBLE item. | |
item (const choices_bool_t &choices, const data::item &data=data::item().label_type(data::item::LABEL_NONE)) | |
Constructor for a CHECKLISTBOX_BOOL item. | |
item (const std::string &label, const notebook_t &v, type_t type=NOTEBOOK_LIST, const data::item &data=data::item().label_type(data::item::LABEL_NONE)) | |
Constructor for a NOTEBOOK item, being a vector of a pair of pages with a vector of items. | |
item (const group_t &g, const data::item &data=data::item().label_type(data::item::LABEL_NONE)) | |
Constructor for a STATICBOX or GROUP item. | |
item (const std::string &label, const choices_t &choices, bool use_radiobox=true, const data::item &data=data::item()) | |
Constructor for a RADIOBOX, or a CHECKLISTBOX_BIT item. | |
item (const std::string &label, wxWindow *window, const data::item &data) | |
Constructor for a USER item. | |
item (const std::string &label, const data::listview &data, const std::any &value=std::any(), const data::item &d=data::item().label_type(data::item::LABEL_NONE)) | |
Constructor a LISTVIEW item. | |
item (const std::string &label, type_t type, const std::any &value=std::any(), const data::item &data=data::item()) | |
Constructor several items. | |
bool | apply (bool save=true) const |
If apply callback has been provided calls apply. | |
const auto & | data () const |
Returns item data. | |
const auto & | data_listview () const |
Returns item listview data. | |
bool | empty () const |
Returns true if this item is empty. | |
const std::any | get_value () const |
Returns actual value, or empty object if this item has no (or not yet) associated window, or conversion is not implemented. | |
bool | is_notebook () const |
Returns true if this item is a notebook. | |
auto | is_row_growable () const |
Is this item allowed to be expanded on a row. | |
const auto & | label () const |
Returns the label. | |
const auto & | label_window () const |
Returns the label window. | |
data::layout::sizer_t * | layout (data::layout &layout) |
layouts this item (creates the window) using the specified layout. | |
std::stringstream | log () const |
Logs info about this item. | |
const auto & | page () const |
Returns the page. | |
void | set_row_growable (bool value) |
Sets this item to be growable. | |
bool | set_value (const std::any &value) const |
Sets actual value for the associated window. | |
bool | to_config (bool save) const |
Loads or saves this item to the config. | |
auto | type () const |
Returns the type. | |
bool | validate () const |
If validate callback has been provided calls validate. | |
bool | validate (const std::string ®ex) const |
Validates current value against supplied regex. | |
auto * | window () const |
Returns the window (first call layout, to create it, otherwise it is nullptr). | |
Static Public Member Functions | |
static void | set_dialog (item_template_dialog< item > *dlg) |
Sets dialog to parent, to allow subitems to be added to the template dialog. | |
static void | use_config (bool use) |
Use config for getting and retrieving values. | |
Container class for using with item_dialog.
The next items can be set using specified data::control:
For corresponding window (such as wxFLP_DEFAULT_STYLE for FILEPICKERCTRL) the style for the control used (e.g. wxTE_MULTILINE or wxTE_PASSWORD). If the window supports it you can use a markup label.
typedef std::pair<std::string, std::vector<item> > wex::item::group_t |
A group is a pair of text with a vector of items.
If the text is empty, a group is used, otherwise a static box, if used by a notebook, the text is the page text.
enum wex::item::type_t |
The item types supported.
Enumerator | |
---|---|
BUTTON | wxButton item |
CHECKBOX | wxCheckBox item |
CHECKLISTBOX_BIT | wxCheckListBox item to set individual bits in a long |
CHECKLISTBOX_BOOL | wxCheckListBox item using boolean choices |
COLOURPICKERWIDGET | wxColourPickerWidget item |
COMBOBOX | wxComboBox item |
COMBOBOX_DIR | wxComboBox item with a browse button for a directory |
COMBOBOX_FILE | wxComboBox item with a browse button for a file |
COMMANDLINKBUTTON | wxCommandLinkButton button |
DIRPICKERCTRL | wxDirPickerCtrl item |
EMPTY | empty item |
FILEPICKERCTRL | wxFilePickerCtrl item |
FONTPICKERCTRL | wxFontPickerCtrl item |
GRID | wex::grid item |
GROUP | group item, containing vector of subitems |
HYPERLINKCTRL | wxHyperlinkCtrl item |
LISTVIEW | wex::listview item |
NOTEBOOK | wxNotebook item |
NOTEBOOK_AUI | wxAuiNotebook item |
NOTEBOOK_CHOICE | wxChoicebook item |
NOTEBOOK_LIST | wxListbook item |
NOTEBOOK_SIMPLE | wxSimpleNotebook item |
NOTEBOOK_TOOL | wxToolbook item |
NOTEBOOK_TREE | wxTreebook item |
NOTEBOOK_WEX | wex::notebook item |
RADIOBOX | wxRadioBox item |
SLIDER | wxSlider item |
SPACER | spacer item |
SPINCTRL | wxSpinCtrl item |
SPINCTRLDOUBLE | wxSpinCtrlDouble item |
STATICBOX | wxStaticBox item |
STATICLINE | wxStaticLine item |
STATICTEXT | wxStaticText item |
TEXTCTRL | wxTextCtrl item |
TEXTCTRL_FLOAT | wxTextCtrl item that only accepts a float (double) |
TEXTCTRL_INT | wxTextCtrl item that only accepts an integer (long) |
TOGGLEBUTTON | wxToggleButton item |
USER | provide your own window |
wex::item::item | ( | int | size | ) |
Constructor for a SPACER item.
The size is the size for the spacer used.
wex::item::item | ( | wxOrientation | orientation | ) |
Constructor for a STATICLINE item.
The orientation is wxHORIZONTAL or wxVERTICAL.
wex::item::item | ( | const std::string & | label, |
type_t | type, | ||
const data::item & | data ) |
Constructor from data::item.
label | label for the window as on the dialog, |
type | type of this item |
data | item data |
wex::item::item | ( | const std::string & | label, |
const std::string & | value = std::string(), | ||
type_t | type = TEXTCTRL, | ||
const data::item & | data = data::item() ) |
Constructor for several items.
label | label for the window as on the dialog, might also contain the note after a tab for a command link button you can use a parent child config item by using a dot in the label, the prefix is not shown on the window |
value | initial value, also used as default for a hyperlink ctrl, or as lexer for STC |
type | type of this item:
|
data | item data |
wex::item::item | ( | const std::string & | label, |
int | min, | ||
int | max, | ||
const std::any & | value = std::any(), | ||
type_t | type = SPINCTRL, | ||
const data::item & | data = data::item() ) |
Constructor for a SPINCTRL or a SLIDER item.
label | label for this item |
min | min value |
max | max value |
value | default value |
type | type of item:
|
data | item data |
wex::item::item | ( | const std::string & | label, |
double | min, | ||
double | max, | ||
const std::any & | value = std::any(), | ||
const data::item & | data = data::item().window(data::window().style(wxSP_ARROW_KEYS)) ) |
Constructor for a SPINCTRLDOUBLE item.
label | label for this item |
min | min value |
max | max value |
value | default value |
data | item data |
wex::item::item | ( | const choices_bool_t & | choices, |
const data::item & | data = data::item().label_type(data::item::LABEL_NONE) ) |
Constructor for a CHECKLISTBOX_BOOL item.
This checklistbox can be used to get/set several boolean values.
choices | the set with names of boolean items the default value is false, but can be changed by adding a ',1' postfix to the name |
data | item data |
wex::item::item | ( | const std::string & | label, |
const notebook_t & | v, | ||
type_t | type = NOTEBOOK_LIST, | ||
const data::item & | data = data::item().label_type(data::item::LABEL_NONE) ) |
Constructor for a NOTEBOOK item, being a vector of a pair of pages with a vector of items.
e.g.:
label | label for this item |
v | notebook items |
type | type of this item (kind of notebook):
|
data | item data |
wex::item::item | ( | const group_t & | g, |
const data::item & | data = data::item().label_type(data::item::LABEL_NONE) ) |
Constructor for a STATICBOX or GROUP item.
If the group text is empty, a GROUP item is created, otherwise a STATIXBOX item.
g | group items |
data | item data |
wex::item::item | ( | const std::string & | label, |
const choices_t & | choices, | ||
bool | use_radiobox = true, | ||
const data::item & | data = data::item() ) |
Constructor for a RADIOBOX, or a CHECKLISTBOX_BIT item.
This checklistbox (not mutually exclusive choices) can be used to get/set individual bits in a long. A radiobox (mutually exclusive choices) should be used when a long value can have a short set of possible individual values.
label | label for this item |
choices | the map with values and text |
use_radiobox | indicates whether to use a radiobox or a checklistbox. |
data | item data |
wex::item::item | ( | const std::string & | label, |
wxWindow * | window, | ||
const data::item & | data ) |
Constructor for a USER item.
label | label for this item |
window | the window (use default constructor for it) |
data | remember to set callback for window creation |
wex::item::item | ( | const std::string & | label, |
const data::listview & | data, | ||
const std::any & | value = std::any(), | ||
const data::item & | d = data::item().label_type(data::item::LABEL_NONE) ) |
Constructor a LISTVIEW item.
label | label for this item |
data | listview data |
value | initial value expects std::list< std::string> |
d | item data |
wex::item::item | ( | const std::string & | label, |
type_t | type, | ||
const std::any & | value = std::any(), | ||
const data::item & | data = data::item() ) |
Constructor several items.
label | label for this item if type is BUTTON then markup is allowed in the label text |
type | type of item:
|
value | initial value for the control, if appropriate:
|
data | item data |
data::layout::sizer_t * wex::item::layout | ( | data::layout & | layout | ) |
layouts this item (creates the window) using the specified layout.
It returns the flex grid sizer that was used for creating the item sizer. Or it returns nullptr if no flex grid sizer was used.
|
inline |
Sets this item to be growable.
Default whether the item row is growable is determined by the kind of item. You can override this using SetRowGrowable.
bool wex::item::set_value | ( | const std::any & | value | ) | const |
Sets actual value for the associated window.
Returns false if window is nullptr, or value was not set.
bool wex::item::to_config | ( | bool | save | ) | const |
Loads or saves this item to the config.
Returns true if the config was accessed, as not all config items associate with the config.
|
inlinestatic |
Use config for getting and retrieving values.
Default the config is used. The label is used as entry in the config.