Class for text input history. More...
#include <text_box.hpp>

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. | |
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.
| 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.
| 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.
| text | The text to push in 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().


| 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().

| ttext_history gui2::ttext_history::get_history | ( | const std::string & | id, | |
| const bool | enabled | |||
| ) | [static] |
Gets history that matches id.
| id | The id of the history to look for. | |
| enabled | The enabled state of the history. |
Definition at line 38 of file text_box.cpp.
References preferences::get_history().

| std::string gui2::ttext_history::get_value | ( | ) | const |
| 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.
| 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().

| 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.
| text | The text to push in 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().


bool gui2::ttext_history::enabled_ [private] |
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().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:23:28 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |