Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

gui2::ttext_history Class Reference

Class for text input history. More...

#include <text_box.hpp>

Collaboration diagram for gui2::ttext_history:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ttext_history ()
void push (const std::string &text)
 Push string into the history.
std::string up (const std::string &text="")
 One step up in the history.
std::string down (const std::string &text="")
 One step down in the history.
std::string get_value () const
 Gets the current history value.
void set_enabled (bool enabled=true)
bool get_enabled () const

Static Public Member Functions

static ttext_history get_history (const std::string &id, const bool enabled)
 Gets history that matches id.

Private Member Functions

 ttext_history (std::vector< std::string > *history, const bool enabled)

Private Attributes

std::vector< std::string > * history_
 The items in the history.
unsigned pos_
 The current position in the history.
bool enabled_
 Is the history enabled.

Detailed Description

Class for text input history.

The history of text items can be stored in the preferences. This class handles that. Every item needs an id by which the history is loaded and saved.

Definition at line 30 of file text_box.hpp.


Constructor & Destructor Documentation

gui2::ttext_history::ttext_history (  )  [inline]

Definition at line 43 of file text_box.hpp.

gui2::ttext_history::ttext_history ( std::vector< std::string > *  history,
const bool  enabled 
) [inline, private]

Definition at line 97 of file text_box.hpp.


Member Function Documentation

std::string gui2::ttext_history::down ( const std::string &  text = ""  ) 

One step down in the history.

Pushes text to the history if at the end.

Parameters:
text The text to push in the history.
Returns:
The current value of the history.

Definition at line 75 of file text_box.cpp.

References enabled_, get_value(), history_, pos_, and push().

Referenced by gui2::ttext_box::history_down().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui2::ttext_history::get_enabled (  )  const [inline]

Definition at line 94 of file text_box.hpp.

References enabled_.

Referenced by gui2::ttext_box::history_down(), and gui2::ttext_box::history_up().

Here is the caller graph for this function:

ttext_history gui2::ttext_history::get_history ( const std::string &  id,
const bool  enabled 
) [static]

Gets history that matches id.

Parameters:
id The id of the history to look for.
enabled The enabled state of the history.
Returns:
The history object.

Definition at line 38 of file text_box.cpp.

References preferences::get_history().

Here is the call graph for this function:

std::string gui2::ttext_history::get_value (  )  const

Gets the current history value.

Returns:
If enabled return the current history position, otherwise an empty string is returned.

Definition at line 88 of file text_box.cpp.

References enabled_, history_, and pos_.

Referenced by down(), and up().

Here is the caller graph for this function:

void gui2::ttext_history::push ( const std::string &  text  ) 

Push string into the history.

If the string is empty or the same as the last item in the history this function is a nop.

Parameters:
text The text to push in the history.

Definition at line 44 of file text_box.cpp.

References enabled_, history_, and pos_.

Referenced by down(), gui2::ttext_box::save_to_history(), and up().

Here is the caller graph for this function:

void gui2::ttext_history::set_enabled ( bool  enabled = true  )  [inline]

Definition at line 93 of file text_box.hpp.

References enabled_.

std::string gui2::ttext_history::up ( const std::string &  text = ""  ) 

One step up in the history.

Pushes text to the history if at the end.

Parameters:
text The text to push in the history.
Returns:
The current value of the history.

Definition at line 57 of file text_box.cpp.

References enabled_, get_value(), history_, pos_, and push().

Referenced by gui2::ttext_box::history_up().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Is the history enabled.

Definition at line 110 of file text_box.hpp.

Referenced by down(), get_enabled(), get_value(), push(), set_enabled(), and up().

std::vector<std::string>* gui2::ttext_history::history_ [private]

The items in the history.

Definition at line 104 of file text_box.hpp.

Referenced by down(), get_value(), push(), and up().

unsigned gui2::ttext_history::pos_ [private]

The current position in the history.

Definition at line 107 of file text_box.hpp.

Referenced by down(), get_value(), push(), and up().


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

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