Template class to implement the generic field implementation. More...
#include <field.hpp>


Public Member Functions | |
| tfield (const std::string &id, const bool mandatory, T(*callback_load_value)(), void(*callback_save_value)(CT value)) | |
| Constructor. | |
| tfield (const std::string &id, const bool mandatory, T &linked_variable) | |
| Constructor. | |
| tfield (const std::string &id, const bool mandatory, const T &value) | |
| Constructor. | |
| void | widget_restore (twindow &window) |
| Inherited from tfield_. | |
| void | set_widget_value (twindow &window, CT value) |
| Sets the value of the field. | |
| void | set_cache_value (CT value) |
| Sets the value of the field. | |
| void | widget_save (twindow &window) |
| Inherited from tfield_. | |
| T | get_widget_value (twindow &window) |
| Gets the value of the field. | |
Private Member Functions | |
| void | init_generic (twindow &window) |
| Inherited from tfield_. | |
| void | finalize_generic (twindow &window) |
| Inherited from tfield_. | |
| void | validate_widget (twindow &window) |
| Test whether the widget exists if the widget is mandatory. | |
| void | save (twindow &window, const bool must_be_active) |
| Stores the value in the widget in the interval value_. | |
| void | restore (twindow &window) |
| Stores the internal value_ in the widget. | |
| template<> | |
| void | save (twindow &window, const bool must_be_active) |
| template<> | |
| void | restore (twindow &window) |
Private Attributes | |
| T | value_ |
| The value_ of the widget, this value is also available once the widget is destroyed. | |
| T & | link_ |
| The variable linked to the field. | |
| T(* | callback_load_value_ )() |
| The callback function to load the value. | |
| void(* | callback_save_value_ )(CT value) |
| The callback function to save the value. | |
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 behaviour 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 254 of file field.hpp.
| gui2::tfield< T, W, CT >::tfield | ( | const std::string & | id, | |
| const bool | mandatory, | |||
| T(*)() | callback_load_value, | |||
| void(*)(CT value) | callback_save_value | |||
| ) | [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. |
| gui2::tfield< T, W, CT >::tfield | ( | const std::string & | id, | |
| const bool | mandatory, | |||
| T & | linked_variable | |||
| ) | [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. * Upon loading its value is used as initial value of the widget. * Upon closing: * with OK its value is set to the value of the widget. * else, its value is undefined. |
| gui2::tfield< T, W, CT >::tfield | ( | const std::string & | id, | |
| const bool | mandatory, | |||
| const T & | value | |||
| ) | [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. |
| void gui2::tfield< T, W, CT >::finalize_generic | ( | twindow & | window | ) | [inline, private, virtual] |
| T gui2::tfield< T, W, CT >::get_widget_value | ( | twindow & | window | ) | [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.
| window | The window containing the widget. |
Definition at line 396 of file field.hpp.
Referenced by gui2::teditor_settings::pre_show(), gui2::teditor_resize_map::update_expand_direction(), and gui2::teditor_settings::update_tod_display().

| void gui2::tfield< T, W, CT >::init_generic | ( | twindow & | window | ) | [inline, private, virtual] |
| void gui2::tfield< T, W, CT >::restore | ( | twindow & | window | ) | [private] |
Stores the internal value_ in the widget.
| window | The window containing the widget. |
Definition at line 514 of file field.hpp.
References gui2::tfield_::id(), gui2::tfield< T, W, CT >::value_, and gui2::tfield_::widget().
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::init_generic(), gui2::tfield< std::string, ttext_, const std::string & >::set_widget_value(), and gui2::tfield< std::string, ttext_, const std::string & >::widget_restore().


| void gui2::tfield< std::string, tcontrol, const std::string & >::restore | ( | twindow & | window | ) | [inline, private] |
Definition at line 524 of file field.hpp.
References gui2::id, and gui2::tcontrol::set_label().

| void gui2::tfield< T, W, CT >::save | ( | twindow & | window, | |
| const bool | must_be_active | |||
| ) | [private] |
Stores the value in the widget in the interval value_.
| window | The window containing the widget. | |
| must_be_active | If true only active widgets will store their value. |
Definition at line 490 of file field.hpp.
References gui2::tfield_::id(), gui2::tfield< T, W, CT >::value_, and gui2::tfield_::widget().
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::finalize_generic(), gui2::tfield< std::string, ttext_, const std::string & >::get_widget_value(), and gui2::tfield< std::string, ttext_, const std::string & >::widget_save().


| void gui2::tfield< std::string, tcontrol, const std::string & >::save | ( | twindow & | window, | |
| const bool | must_be_active | |||
| ) | [inline, private] |
Definition at line 501 of file field.hpp.
References gui2::id, and gui2::tcontrol::label().

| void gui2::tfield< T, W, CT >::set_cache_value | ( | CT | value | ) | [inline] |
| void gui2::tfield< T, W, CT >::set_widget_value | ( | twindow & | window, | |
| CT | value | |||
| ) | [inline] |
Sets the value of the field.
This sets the value in both the internal cache value and in the widget itself.
| window | The window containing the widget. | |
| value | The new value. |
Definition at line 359 of file field.hpp.
Referenced by gui2::teditor_settings::update_selected_tod_info().

| void gui2::tfield< T, W, CT >::validate_widget | ( | twindow & | window | ) | [inline, private] |
Test whether the widget exists if the widget is mandatory.
| window | The window containing the widget. |
Definition at line 464 of file field.hpp.
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::init_generic(), and gui2::tfield< std::string, ttext_, const std::string & >::widget_restore().

| void gui2::tfield< T, W, CT >::widget_restore | ( | twindow & | window | ) | [inline, virtual] |
| void gui2::tfield< T, W, CT >::widget_save | ( | twindow & | window | ) | [inline, virtual] |
T(* gui2::tfield< T, W, CT >::callback_load_value_)() [private] |
The callback function to load the value.
This is used to load the initial value of the widget, if defined.
Definition at line 423 of file field.hpp.
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::init_generic().
void(* gui2::tfield< T, W, CT >::callback_save_value_)(CT value) [private] |
The callback function to save the value.
Once the dialog has been successful this function is used to store the result of this widget.
Definition at line 457 of file field.hpp.
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::finalize_generic().
T& gui2::tfield< T, W, CT >::link_ [private] |
The variable linked to the field.
When set determines the initial value and the final value is stored here in the finallizer.
Definition at line 416 of file field.hpp.
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::finalize_generic(), and gui2::tfield< std::string, ttext_, const std::string & >::init_generic().
T gui2::tfield< T, W, CT >::value_ [private] |
The value_ of the widget, this value is also available once the widget is destroyed.
Definition at line 408 of file field.hpp.
Referenced by gui2::tfield< std::string, ttext_, const std::string & >::finalize_generic(), gui2::tfield< std::string, ttext_, const std::string & >::get_widget_value(), gui2::tfield< std::string, ttext_, const std::string & >::init_generic(), gui2::tfield< T, W, CT >::restore(), gui2::tfield< T, W, CT >::save(), gui2::tfield< std::string, ttext_, const std::string & >::set_cache_value(), and gui2::tfield< std::string, ttext_, const std::string & >::set_widget_value().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:22:09 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |