Template class to implement the generic field implementation. More...
#include <field-fwd.hpp>
Public Member Functions | |
field (const std::string &id, const bool mandatory, const std::function< T()> &callback_load_value, const std::function< void(CT)> &callback_save_value) | |
Constructor. More... | |
field (const std::string &id, const bool mandatory, T &linked_variable) | |
Constructor. More... | |
field (const std::string &id, const bool mandatory, const T &value) | |
Constructor. More... | |
void | widget_restore () |
Inherited from field_base. More... | |
void | set_widget_value (CT value) |
Sets the value of the field. More... | |
void | set_cache_value (CT value) |
Sets the value of the field. More... | |
void | widget_save () |
Inherited from field_base. More... | |
T | get_widget_value () |
Gets the value of the field. More... | |
![]() | |
field_base (const std::string &id, const bool mandatory) | |
Constructor. More... | |
virtual | ~field_base () |
void | attach_to_window (window &window) |
Attaches the field to a window. More... | |
void | widget_init () |
Initializes the widget. More... | |
void | widget_finalize () |
Finalizes the widget. More... | |
void | detach_from_window () |
Detaches the field from a window. More... | |
void | widget_set_enabled (const bool enable, const bool sync) |
Enables a widget. More... | |
const std::string & | id () const |
bool | is_mandatory () const |
styled_widget * | get_widget () |
const styled_widget * | get_widget () const |
Private Member Functions | |
void | init_generic () |
Inherited from field_base. More... | |
void | finalize_generic () |
Inherited from field_base. More... | |
void | validate_widget () |
Test whether the widget exists if the widget is mandatory. More... | |
void | save (const bool must_be_active) |
Stores the value in the widget in the interval value_. More... | |
void | restore () |
Stores the internal value_ in the widget. More... | |
Private Attributes | |
T | value_ |
The value_ of the widget, this value is also available once the widget is destroyed. More... | |
T & | link_ |
The variable linked to the field. More... | |
std::function< T()> | callback_load_value_ |
The callback function to load the value. More... | |
std::function< void(CT)> | callback_save_value_ |
The callback function to save the value. More... | |
Template class to implement the generic field implementation.
T | The type of the item to show in the widget. |
W | The type of widget to show, this is not a widget class but a behavior class. |
CT | The type tp be used in the callback_save_value callback. Normally this is const T but for example with strings it can be const T&. Note the const needs to be in the template otherwise compilation on GCC-4.3 fails (not sure whether compiler bug or not). |
Definition at line 36 of file field-fwd.hpp.
|
inline |
Constructor.
id | The id of the widget to connect to the window. A widget can only be connected once. |
mandatory | Is the widget mandatory? |
callback_load_value | A callback function which is called when the window is shown. This callback returns the initial value of the field. |
callback_save_value | A callback function which is called when the window closed with the OK button. The callback is executed with the new value of the field. It's meant to set the value of some variable in the engine after the window is closed with OK. |
|
inline |
Constructor.
id | The id of the widget to connect to the window. A widget can only be connected once. |
mandatory | Is the widget mandatory? |
linked_variable | The variable which is linked to the field.
|
|
inline |
Constructor.
This version is used for read only variables.
mandatory | Is the widget mandatory? |
id | The id of the widget to connect to the window. A widget can only be connected once. |
value | The value of the widget. |
|
inlineprivatevirtual |
|
inline |
Gets the value of the field.
This function gets the value of the widget and stores that in the internal cache, then that value is returned.
Definition at line 379 of file field.hpp.
Referenced by gui2::dialogs::generator_settings::adjust_minimum_size_by_players(), gui2::dialogs::custom_tod::color_slider_callback(), gui2::dialogs::mp_lobby::game_filter_init(), gui2::dialogs::mp_login::load_password(), gui2::dialogs::mp_create_game::post_show(), gui2::dialogs::mp_login::save_password(), gui2::dialogs::editor_resize_map::update_expand_direction(), and gui2::dialogs::mp_create_game::update_map_settings().
|
inlineprivatevirtual |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
Sets the value of the field.
This sets the value in both the internal cache value and in the widget itself.
value | The new value. |
Definition at line 344 of file field.hpp.
Referenced by gui2::dialogs::mp_create_game::reset_timer_settings(), gui2::dialogs::mp_create_game::update_map_settings(), and gui2::dialogs::custom_tod::update_selected_tod_info().
|
inlineprivate |
|
inlinevirtual |
|
inlinevirtual |
|
private |
|
private |
|
private |
|
private |