Public Member Functions | Private Member Functions | Private Attributes

gui2::tfield_ Class Reference

Abstract base class for the fields. More...

#include <field.hpp>

Inheritance diagram for gui2::tfield_:
Inheritance graph
[legend]
Collaboration diagram for gui2::tfield_:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tfield_ (const std::string &id, const bool mandatory)
 Constructor.
virtual ~tfield_ ()
void attach_to_window (twindow &window)
 Attaches the field to a window.
void widget_init (twindow &window)
 Initializes the widget.
void widget_finalize (twindow &window)
 Finalizes the widget.
void detach_from_window ()
 Detaches the field from a window.
virtual void widget_save (twindow &window)=0
 Saves a widget.
virtual void widget_restore (twindow &window)=0
 Restores a widget.
void widget_set_enabled (twindow &window, const bool enable, const bool sync)
 Enables a widget.
const std::string & id () const
bool is_mandatory () const
tcontrolwidget ()
const tcontrolwidget () const

Private Member Functions

virtual void init_generic (twindow &window)=0
 See widget_init.
virtual void init_specialized (twindow &)
 See widget_init.
virtual void finalize_generic (twindow &window)=0
 See widget_finalize.
virtual void finalize_specialized (twindow &)
 See widget_finalize.

Private Attributes

const std::string id_
 The id field of the widget, should be unique in a window.
const bool mandatory_
 Is the widget optional or mandatory in this window.
tcontrolwidget_
 The widget attached to the field.

Detailed Description

Abstract base class for the fields.

Note:
In this context a widget is a gui2::tcontrol and not a gui2::twidget. This name widget is a generic name and fits, however some functions used are first declared in a control.

Definition at line 45 of file field.hpp.


Constructor & Destructor Documentation

gui2::tfield_::tfield_ ( const std::string &  id,
const bool  mandatory 
) [inline]

Constructor.

Parameters:
id The id of the widget to connect to the window. A widget can only be connected once.
mandatory Is the widget mandatory

Definition at line 56 of file field.hpp.

virtual gui2::tfield_::~tfield_ (  )  [inline, virtual]

Definition at line 63 of file field.hpp.


Member Function Documentation

void gui2::tfield_::attach_to_window ( twindow window  )  [inline]

Attaches the field to a window.

When attached the widget which we're a wrapper around is stored linked in here.

Warning:
After attaching the window must remain a valid. Before the window is destroyed the detach_from_window function must be called.
Todo:
Most functions that have a window parameter only use it to get the widget. Evaluate and remove the window parameter where applicable.
Precondition:
widget_ == NULL
Parameters:
window The window to be attached to.

Definition at line 81 of file field.hpp.

References id(), mandatory_, and widget_.

Referenced by gui2::tdialog::init_fields().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::tfield_::detach_from_window (  )  [inline]

Detaches the field from a window.

Precondition:
widget_ != NULL || !mandatory_
Parameters:
window The window to be attached to.

Definition at line 137 of file field.hpp.

References mandatory_, and widget_.

Referenced by gui2::tdialog::finalize_fields().

Here is the caller graph for this function:

virtual void gui2::tfield_::finalize_generic ( twindow window  )  [private, pure virtual]
virtual void gui2::tfield_::finalize_specialized ( twindow  )  [inline, private, virtual]

See widget_finalize.

Reimplemented in gui2::tfield_text.

Definition at line 237 of file field.hpp.

Referenced by widget_finalize().

Here is the caller graph for this function:

const std::string& gui2::tfield_::id (  )  const [inline]
virtual void gui2::tfield_::init_generic ( twindow window  )  [private, pure virtual]
virtual void gui2::tfield_::init_specialized ( twindow  )  [inline, private, virtual]

See widget_init.

Reimplemented in gui2::tfield_bool, and gui2::tfield_label.

Definition at line 230 of file field.hpp.

Referenced by widget_init().

Here is the caller graph for this function:

bool gui2::tfield_::is_mandatory (  )  const [inline]

Definition at line 204 of file field.hpp.

References mandatory_.

Referenced by gui2::tfield< std::string, ttext_, const std::string & >::validate_widget().

Here is the caller graph for this function:

const tcontrol* gui2::tfield_::widget (  )  const [inline]

Definition at line 211 of file field.hpp.

References widget_.

tcontrol* gui2::tfield_::widget (  )  [inline]
void gui2::tfield_::widget_finalize ( twindow window  )  [inline]

Finalizes the widget.

This routine is called after the dialog is closed with OK. It's called before post_show(). This routine does the following:

  • if no active widget available exit.
  • if a setter is defined the widget value is saved in the setter.
  • The widget value is saved in value_.

Like widget_init it calls two functions with the same purpose.

Parameters:
window The window containing the widget.

Definition at line 124 of file field.hpp.

References finalize_generic(), and finalize_specialized().

Referenced by gui2::tdialog::finalize_fields().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::tfield_::widget_init ( twindow window  )  [inline]

Initializes the widget.

This routine is called before the dialog is shown and the pre_show() is called. So the user can override the values set. This routine does the following:

  • If no widget available exit gives feedback it the widget must exist.
  • If a getter is defined we use to set value_ and the widget.
  • If no setter is defined we use the widget value to set value_.

The function calls two functions

  • init_generic which is to be used in the template subclass.
  • init_specialized which is to be used in subclasses of the template class. This way they can override this function without to use their signature to inherit.
Parameters:
window The window containing the widget.

Definition at line 105 of file field.hpp.

References init_generic(), and init_specialized().

Referenced by gui2::tdialog::init_fields().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void gui2::tfield_::widget_restore ( twindow window  )  [pure virtual]

Restores a widget.

See widget_save for more info.

Parameters:
window The window containing the widget.

Implemented in gui2::tfield< T, W, CT >, gui2::tfield< bool, tselectable_ >, gui2::tfield< std::string, tcontrol, const std::string & >, and gui2::tfield< std::string, ttext_, const std::string & >.

Referenced by widget_set_enabled().

Here is the caller graph for this function:

virtual void gui2::tfield_::widget_save ( twindow window  )  [pure virtual]

Saves a widget.

It can be a window must be recreated, in that case the state needs to be saved and restored. This routine does the following:

  • if no widget available exit (doesn't look at the active state).
  • The widget value is saved in value_.
Parameters:
window The window containing the widget.

Implemented in gui2::tfield< T, W, CT >, gui2::tfield< bool, tselectable_ >, gui2::tfield< std::string, tcontrol, const std::string & >, and gui2::tfield< std::string, ttext_, const std::string & >.

Referenced by widget_set_enabled().

Here is the caller graph for this function:

void gui2::tfield_::widget_set_enabled ( twindow window,
const bool  enable,
const bool  sync 
) [inline]

Enables a widget.

Parameters:
window The window containing the widget.
enable If true enables the widget, disables otherwise.
sync If the state is changed do we need to synchronize. Upon disabling, write the value of the widget in the variable value_. Upon enabling write the value of value_ in the widget.

Definition at line 175 of file field.hpp.

References gui2::twindow::find(), gui2::tcontrol::get_active(), gui2::tcontrol::set_active(), widget(), widget_restore(), and widget_save().

Here is the call graph for this function:


Member Data Documentation

const std::string gui2::tfield_::id_ [private]

The id field of the widget, should be unique in a window.

Definition at line 218 of file field.hpp.

Referenced by id().

const bool gui2::tfield_::mandatory_ [private]

Is the widget optional or mandatory in this window.

Definition at line 221 of file field.hpp.

Referenced by attach_to_window(), detach_from_window(), and is_mandatory().

The widget attached to the field.

Definition at line 224 of file field.hpp.

Referenced by attach_to_window(), detach_from_window(), and widget().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:22:08 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs