15 #define GETTEXT_DOMAIN "wesnoth-lib"
28 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
29 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
101 , max_input_length_(0)
109 connect_signal<event::MOUSE_MOTION>(std::bind(
111 connect_signal<event::LEFT_BUTTON_DOWN>(std::bind(
113 connect_signal<event::LEFT_BUTTON_UP>(std::bind(
115 connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(std::bind(
142 PangoEllipsizeMode ellipse_mode = PANGO_ELLIPSIZE_NONE;
145 ellipse_mode = PANGO_ELLIPSIZE_START;
147 ellipse_mode = PANGO_ELLIPSIZE_END;
153 unsigned start_offset = 0;
154 unsigned end_offset = 0;
157 }
else if(length > 0) {
170 for(
auto & tmp :
canvas())
176 tmp.set_variable(
"text_maximum_width",
variant(max_width));
177 tmp.set_variable(
"text_maximum_height",
variant(max_height));
179 tmp.set_variable(
"cursor_offset",
182 tmp.set_variable(
"selection_offset",
variant(start_offset));
183 tmp.set_variable(
"selection_width",
variant(end_offset - start_offset));
184 tmp.set_variable(
"text_wrap_mode",
variant(ellipse_mode));
266 for(
auto & tmp :
canvas())
306 if(key == SDLK_TAB && (modifier & KMOD_CTRL)) {
307 if(!(modifier & KMOD_SHIFT)) {
403 DBG_GUI_P <<
"Parsing text_box " <<
id <<
'\n';
405 load_resolutions<tresolution>(cfg);
446 , text_x_offset(cfg[
"text_x_offset"])
447 , text_y_offset(cfg[
"text_y_offset"])
482 tbuilder_text_box::tbuilder_text_box(
const config& cfg)
484 , history(cfg[
"history"])
485 , max_input_length(cfg[
"max_input_length"])
504 DBG_GUI_G <<
"Window builder: placed text box '" <<
id
505 <<
"' with definition '" <<
definition <<
"'.\n";
Define the common log macros for the gui toolkit.
void set_selection_length(const int selection_length)
void handle_key_clear_line(SDLMod modifier, bool &handled)
Inherited from ttext_.
unsigned pos_
The current position in the history.
Class for text input history.
bool dragging_
Is the mouse in dragging mode, this affects selection in mouse move.
GLenum GLsizei const GLuint GLboolean enabled
void set_font_size(const unsigned font_size)
void set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
ttext_history history_
The history text for this widget.
unsigned text_y_offset_
The y offset in the widget where the text starts.
GLuint GLuint GLsizei GLenum type
unsigned text_x_offset_
The x offset in the widget where the text starts.
virtual void place(const tpoint &origin, const tpoint &size) override
See twidget::place.
void set_font_style(const unsigned font_style)
tresolution_definition_ptr config()
void set_maximum_width(const int width)
std::string up(const std::string &text="")
One step up in the history.
bool history_up()
Goes one item up in the history.
void load_config_extra()
Inherited from tcontrol.
void signal_handler_left_button_down(const event::tevent event, bool &handled)
Class for a single line text area.
unsigned text_height_
The height of the text itself.
std::string get_value() const
size_t get_selection_start() const
void select_all()
Selects all text.
void update_offsets()
Updates text_x_offset_ and text_y_offset_.
virtual void set_value(const std::string &text)
The set_value is virtual for the tpassword_box class.
virtual void update_canvas() override
See tcontrol::update_canvas.
Base class of a resolution, contains the common keys for a resolution.
tpoint get_column_line(const tpoint &position) const
GLuint GLsizei GLsizei * length
A class inherited from ttext_box that displays its input as stars.
void init_control(tcontrol *control) const
std::string definition
Parameters for the control.
std::string get_value() const
Gets the current history value.
int get_text_maximum_width() const
Returns the maximum width available for the text.
size_t get_length() const
tpoint get_mouse_position()
Returns the current mouse position.
virtual void place(const tpoint &origin, const tpoint &size) override
See twidget::place.
void push(const std::string &text)
Push string into the history.
void signal_handler_left_button_double_click(const event::tevent event, bool &handled)
tevent
The event send to the dispatcher.
void set_wants_mouse_left_double_click(const bool click=true)
int get_max_height(int size)
void handle_key_default(bool &handled, SDLKey key, SDLMod modifier, const utf8::string &unicode)
Inherited from ttext_.
Contains the state info for a resolution.
ttext_box_definition(const config &cfg)
bool enabled_
Is the history enabled.
std::vector< std::string > * get_history(const std::string &id)
Returns a pointer to the history vector associated with given id making a new one if it doesn't exist...
void handle_mouse_selection(tpoint mouse, const bool start_selection)
virtual void handle_key_default(bool &handled, SDLKey key, SDLMod modifier, const utf8::string &unicode)
Default key handler if none of the above functions is called.
size_t get_selection_length() const
void delete_selection()
Inherited from ttext_.
std::string down(const std::string &text="")
One step down in the history.
GLint GLint GLint GLint GLint x
tresolution(const config &cfg)
std::vector< tcanvas > & canvas()
void set_max_input_length(const size_t length)
void set_history(const std::string &id)
gui2::tpoint get_cursor_position(const unsigned column, const unsigned line=0) const
std::vector< tstate_definition > state
int get_text_maximum_height() const
Returns the maximum height available for the text.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void mouse_capture(const bool capture=true)
void signal_handler_mouse_motion(const event::tevent event, bool &handled, const tpoint &coordinate)
std::vector< std::string > * history_
The items in the history.
void signal_handler_left_button_up(const event::tevent event, bool &handled)
void delete_char(const bool before_cursor)
Inherited from ttext_.
void set_maximum_length(const size_t maximum_length)
void keyboard_capture(twidget *widget)
A config object defines a single node in a WML file, with access to child nodes.
size_t max_input_length_
The maximum length of the text input.
GLsizei const GLcharARB ** string
Abstract base class for text items.
Contains the implementation details for lexical_cast and shouldn't be used directly.
bool history_down()
Goes one item down in the history.
void set_cursor(const size_t offset, const bool select)
Moves the cursor at the wanted position.
utf8::string & erase(utf8::string &str, const size_t start, const size_t len)
Erases a portion of a UTF-8 string.
virtual const std::string & get_control_type() const override
See tcontrol::get_control_type.
void set_maximum_height(const int height, const bool multiline)