23 #ifndef GUI_DIALOGS_FIELD_HPP_INCLUDED
24 #define GUI_DIALOGS_FIELD_HPP_INCLUDED
180 const bool widget_state = widget->
get_active();
181 if(widget_state == enable) {
260 template <
class T,
class W,
class CT>
261 class tfield :
public tfield_
281 const bool mandatory,
282 const std::function<T()>& callback_load_value,
283 const std::function<
void(CT)>& callback_save_value)
310 ,
link_(linked_variable)
431 if(callback_load_value_) {
470 find_widget<const W>(&window,
id(),
false);
480 void save(
twindow& window,
const bool must_be_active);
490 template <
class T,
class W,
class CT>
494 = find_widget<const W>(&window,
id(), must_be_active,
false);
497 value_ = widget->get_value();
503 twindow& window,
const bool must_be_active)
506 = find_widget<const tselectable_>(&window,
id(), must_be_active,
false);
515 twindow& window,
const bool must_be_active)
518 = find_widget<const tcontrol>(&window,
id(), must_be_active,
false);
521 value_ = control->
label();
525 template <
class T,
class W,
class CT>
528 W* widget = find_widget<W>(&window,
id(),
false,
false);
531 widget->set_value(value_);
539 tcontrol* control = find_widget<tcontrol>(&window,
id(),
false,
false);
551 const bool mandatory,
552 const std::function<
bool()>& callback_load_value,
553 const std::function<
void(
const bool)>& callback_save_value,
554 const std::function<
void(
twidget&)>& callback_change)
556 id, mandatory, callback_load_value, callback_save_value)
557 , callback_change_(callback_change)
562 const bool mandatory,
563 bool& linked_variable,
564 const std::function<
void(
twidget&)>& callback_change)
566 , callback_change_(callback_change)
574 if(callback_change_) {
592 const bool mandatory,
593 const std::function<
std::string()>& callback_load_value,
597 id, mandatory, callback_load_value, callback_save_value)
602 const bool mandatory,
605 id, mandatory, linked_variable)
626 const bool mandatory,
628 const bool use_markup)
630 , use_markup_(use_markup)
642 find_widget<tcontrol>(&window,
id(),
false).set_use_markup(use_markup_);
void widget_init(twindow &window)
Initializes the widget.
tfield_(const std::string &id, const bool mandatory)
Constructor.
void widget_save(twindow &window)
Inherited from tfield_.
std::function< void(CT)> callback_save_value_
The callback function to save the value.
const tcontrol * widget() const
twidget * find(const std::string &id, const bool must_be_active) override
See twidget::find.
tfield_text(const std::string &id, const bool mandatory, const std::function< std::string()> &callback_load_value, const std::function< void(const std::string &)> &callback_save_value)
tcontrol * widget_
The widget attached to the field.
bool is_mandatory() const
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
virtual void init_generic(twindow &window)=0
See widget_init.
void set_cache_value(CT value)
Sets the value of the field.
virtual void set_callback_state_change(std::function< void(twidget &)> callback)=0
When the user does something to change the widget state this event is fired.
Abstract base class for the fields.
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
Template class to implement the generic field implementation.
virtual void set_label(const t_string &label)
const std::string & id() const
void init_specialized(twindow &window)
Overridden from tfield_.
Class for a single line text area.
T get_widget_value(twindow &window)
Gets the value of the field.
void restore(twindow &window)
Stores the internal value_ in the widget.
virtual void widget_save(twindow &window)=0
Saves a widget.
virtual void widget_restore(twindow &window)=0
Restores a widget.
tfield(const std::string &id, const bool mandatory, const T &value)
Constructor.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
virtual void set_active(const bool active)=0
Sets the control's state.
void finalize_specialized(twindow &window)
Overridden from tfield_.
void widget_finalize(twindow &window)
Finalizes the widget.
void widget_restore(twindow &window)
Inherited from tfield_.
bool get_value_bool() const
GLsizei const GLfloat * value
tfield_label(const std::string &id, const bool mandatory, const std::string &text, const bool use_markup)
tfield_bool(const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(twidget &)> &callback_change)
Contains all forward declarations for field.hpp.
bool use_markup_
Whether or not the label uses markup.
const t_string & label() const
static size_t id
Ids for the timers.
virtual void finalize_specialized(twindow &)
See widget_finalize.
std::function< T()> callback_load_value_
The callback function to load the value.
void detach_from_window()
Detaches the field from a window.
void init_generic(twindow &window)
Inherited from tfield_.
Small abstract helper class.
void save_to_history()
Saves the text in the widget to the history.
void set_widget_value(twindow &window, CT value)
Sets the value of the field.
tfield_text(const std::string &id, const bool mandatory, std::string &linked_variable)
void init_specialized(twindow &window)
Overridden from tfield_.
void validate_widget(twindow &window)
Test whether the widget exists if the widget is mandatory.
static void save(LexState *ls, int c)
tfield(const std::string &id, const bool mandatory, const std::function< T()> &callback_load_value, const std::function< void(CT)> &callback_save_value)
Constructor.
tfield(const std::string &id, const bool mandatory, T &linked_variable)
Constructor.
Base class for all visible items.
T & link_
The variable linked to the field.
void finalize_generic(twindow &window)
Inherited from tfield_.
const bool mandatory_
Is the widget optional or mandatory in this window.
void save(twindow &window, const bool must_be_active)
Stores the value in the widget in the interval value_.
void widget_set_enabled(twindow &window, const bool enable, const bool sync)
Enables a widget.
T value_
The value_ of the widget, this value is also available once the widget is destroyed.
const std::string id_
The id field of the widget, should be unique in a window.
virtual void finalize_generic(twindow &window)=0
See widget_finalize.
virtual bool get_active() const =0
Gets the active state of the control.
std::function< void(twidget &)> callback_change_
Specialized field class for boolean.
GLsizei const GLcharARB ** string
virtual void init_specialized(twindow &)
See widget_init.
Abstract base class for text items.
Specialized field class for a control, used for labels and images.
Specialized field class for text.
tfield_bool(const std::string &id, const bool mandatory, const std::function< bool()> &callback_load_value, const std::function< void(const bool)> &callback_save_value, const std::function< void(twidget &)> &callback_change)
void attach_to_window(twindow &window)
Attaches the field to a window.