gui2::ttext_ Class Reference

Base class for text items will get two base decendends More...

#include <text.hpp>

Inheritance diagram for gui2::ttext_:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ttext_ ()
void set_active (const bool)
 Sets the control in the active state, when inactive a control can't be used and doesn't react to events.
bool get_active () const
 Gets the active state of the control.
unsigned get_state () const
 Returns the id of the state, which is also the index for the canvas.
void mouse_move (tevent_handler &)
void mouse_left_button_down (tevent_handler &event)
void mouse_left_button_up (tevent_handler &)
void mouse_left_button_double_click (tevent_handler &)
void mouse_middle_button_click (tevent_handler &)
void key_press (tevent_handler &event, bool &handled, SDLKey key, SDLMod modifier, Uint16 unicode)
 Handled, if there's a keyboard focus it will get the change to handle the key first, if not done it's send to the window.
void set_text (const std::string &text)
std::string get_text () const
const std::string & text () const

Protected Member Functions

virtual void goto_end_of_line (const bool select=false)=0
void goto_end_of_data (const bool select=false)
virtual void goto_start_of_line (const bool select=false)=0
void goto_start_of_data (const bool select=false)
void select_all ()
void set_cursor (const size_t offset, const bool select)
size_t get_sel_start () const
void set_sel_start (const size_t sel_start)
size_t get_sel_len () const
void set_sel_len (const unsigned sel_len)
virtual void insert_char (Uint16 unicode)=0
 Inserts a character at the cursor.
virtual void delete_char (const bool before_cursor)=0
 Deletes the character.
virtual void delete_selection ()=0
 Deletes the current selection.
virtual void copy_selection (const bool mouse)
 Copies the current selection.
virtual void paste_selection (const bool mouse)
 Pastes the current selection.
std::string & text ()
size_t & sel_start ()
int & sel_len ()

Private Types

enum  tstate { ENABLED, DISABLED, FOCUSSED, COUNT }
 Note the order of the states must be the same as defined in settings.hpp. More...

Private Member Functions

void set_state (tstate state)
virtual void calculate_char_offset ()=0
 Calculates the offsets of all chars.
virtual void handle_key_up_arrow (SDLMod modifier, bool &handled)=0
virtual void handle_key_down_arrow (SDLMod modifier, bool &handled)=0
virtual void handle_key_clear_line (SDLMod modifier, bool &handled)=0
virtual void handle_key_left_arrow (SDLMod modifier, bool &handled)
virtual void handle_key_right_arrow (SDLMod modifier, bool &handled)
virtual void handle_key_home (SDLMod modifier, bool &handled)
virtual void handle_key_end (SDLMod modifier, bool &handled)
virtual void handle_key_backspace (SDLMod modifier, bool &handled)
virtual void handle_key_delete (SDLMod modifier, bool &handled)
virtual void handle_key_default (bool &handled, SDLKey key, SDLMod modifier, Uint16 unicode)
virtual void handle_key_page_up (SDLMod, bool &)
virtual void handle_key_page_down (SDLMod, bool &)

Private Attributes

tstate state_
std::string text_
 The text in the widget.
size_t sel_start_
int sel_len_
 positive sel_len_ means selection to the right.
size_t max_length_
bool dragging_
 Is the mouse in dragging mode, this affects selection in mouse movee.


Detailed Description

Base class for text items will get two base decendends

Definition at line 27 of file text.hpp.


Member Enumeration Documentation

enum gui2::ttext_::tstate [private]

Note the order of the states must be the same as defined in settings.hpp.

Enumerator:
ENABLED 
DISABLED 
FOCUSSED 
COUNT 

Definition at line 104 of file text.hpp.


Constructor & Destructor Documentation

gui2::ttext_::ttext_ (  )  [inline]

Definition at line 31 of file text.hpp.


Member Function Documentation

void gui2::ttext_::set_active ( const   active  )  [inline, virtual]

Sets the control in the active state, when inactive a control can't be used and doesn't react to events.

(Note read-only for a ttext_ is a different state.)

Implements gui2::tcontrol.

Definition at line 42 of file text.hpp.

bool gui2::ttext_::get_active (  )  const [inline, virtual]

Gets the active state of the control.

Implements gui2::tcontrol.

Definition at line 43 of file text.hpp.

unsigned gui2::ttext_::get_state (  )  const [inline, virtual]

Returns the id of the state, which is also the index for the canvas.

Implements gui2::tcontrol.

Definition at line 44 of file text.hpp.

References state_.

void gui2::ttext_::mouse_move ( tevent_handler  )  [virtual]

Reimplemented from gui2::tevent_executor.

Reimplemented in gui2::ttext_box.

Definition at line 71 of file text.cpp.

References DBG_G_E.

void gui2::ttext_::mouse_left_button_down ( tevent_handler event  )  [virtual]

Reimplemented from gui2::tevent_executor.

Reimplemented in gui2::ttext_box.

Definition at line 78 of file text.cpp.

References DBG_G_E.

void gui2::ttext_::mouse_left_button_up ( tevent_handler  )  [virtual]

Reimplemented from gui2::tevent_executor.

Reimplemented in gui2::ttext_box.

Definition at line 86 of file text.cpp.

References DBG_G_E.

void gui2::ttext_::mouse_left_button_double_click ( tevent_handler  )  [virtual]

Reimplemented from gui2::tevent_executor.

Reimplemented in gui2::ttext_box.

Definition at line 92 of file text.cpp.

References DBG_G_E, sel_len_, sel_start_, and text_.

void gui2::ttext_::mouse_middle_button_click ( tevent_handler  )  [virtual]

Reimplemented from gui2::tevent_executor.

Definition at line 101 of file text.cpp.

References DBG_G_E, and paste_selection().

void gui2::ttext_::key_press ( tevent_handler ,
bool &  ,
SDLKey  ,
SDLMod  ,
Uint16   
) [virtual]

Handled, if there's a keyboard focus it will get the change to handle the key first, if not done it's send to the window.

SDLKey the sdl key code needed for special keys SDLMod the keyboard modifiers at moment of pressing Unit16 the unicode for the pressed key

Reimplemented from gui2::tevent_executor.

Definition at line 111 of file text.cpp.

References copy_selection(), gui::copypaste_modifier, DBG_G_E, delete_selection(), handle_key_backspace(), handle_key_clear_line(), handle_key_default(), handle_key_delete(), handle_key_down_arrow(), handle_key_end(), handle_key_home(), handle_key_left_arrow(), handle_key_page_down(), handle_key_page_up(), handle_key_right_arrow(), handle_key_up_arrow(), and paste_selection().

void gui2::ttext_::set_text ( const std::string &  text  ) 

std::string gui2::ttext_::get_text (  )  const [inline]

Definition at line 58 of file text.hpp.

References text_.

Referenced by gui2::tmp_method_selection::show(), and gui2::taddon_connect::show().

const std::string& gui2::ttext_::text (  )  const [inline]

virtual void gui2::ttext_::goto_end_of_line ( const bool  select = false  )  [protected, pure virtual]

Implemented in gui2::ttext_box.

Referenced by handle_key_end().

void gui2::ttext_::goto_end_of_data ( const bool  select = false  )  [inline, protected]

Definition at line 64 of file text.hpp.

References set_cursor(), and text_.

Referenced by gui2::ttext_box::goto_end_of_line(), handle_key_end(), and select_all().

virtual void gui2::ttext_::goto_start_of_line ( const bool  select = false  )  [protected, pure virtual]

Implemented in gui2::ttext_box.

Referenced by handle_key_home().

void gui2::ttext_::goto_start_of_data ( const bool  select = false  )  [inline, protected]

Definition at line 67 of file text.hpp.

References set_cursor().

Referenced by gui2::ttext_box::goto_start_of_line(), and handle_key_home().

void gui2::ttext_::select_all (  )  [inline, protected]

Definition at line 69 of file text.hpp.

References goto_end_of_data(), and sel_start_.

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

void gui2::ttext_::set_cursor ( const size_t  offset,
const bool  select 
) [protected]

size_t gui2::ttext_::get_sel_start (  )  const [inline, protected]

Definition at line 73 of file text.hpp.

References sel_start_.

void gui2::ttext_::set_sel_start ( const size_t  sel_start  )  [inline, protected]

Definition at line 74 of file text.hpp.

References sel_start_, and gui2::twidget::set_dirty().

size_t gui2::ttext_::get_sel_len (  )  const [inline, protected]

Definition at line 76 of file text.hpp.

References sel_len_.

void gui2::ttext_::set_sel_len ( const unsigned  sel_len  )  [inline, protected]

Definition at line 77 of file text.hpp.

References sel_len_, and gui2::twidget::set_dirty().

virtual void gui2::ttext_::insert_char ( Uint16  unicode  )  [protected, pure virtual]

Inserts a character at the cursor.

Implemented in gui2::ttext_box.

Referenced by handle_key_default().

virtual void gui2::ttext_::delete_char ( const bool  before_cursor  )  [protected, pure virtual]

Deletes the character.

Implemented in gui2::ttext_box.

Referenced by handle_key_backspace(), and handle_key_delete().

virtual void gui2::ttext_::delete_selection (  )  [protected, pure virtual]

Deletes the current selection.

Implemented in gui2::ttext_box.

Referenced by handle_key_delete(), key_press(), and paste_selection().

void gui2::ttext_::copy_selection ( const bool  mouse  )  [protected, virtual]

Copies the current selection.

Definition at line 257 of file text.cpp.

References copy_to_clipboard(), sel_len(), sel_start(), utils::string_to_wstring(), text(), text_, and utils::wstring_to_string().

Referenced by key_press(), and set_cursor().

void gui2::ttext_::paste_selection ( const bool  mouse  )  [protected, virtual]

std::string& gui2::ttext_::text (  )  [inline, protected]

Definition at line 96 of file text.hpp.

References text_.

size_t& gui2::ttext_::sel_start (  )  [inline, protected]

int& gui2::ttext_::sel_len (  )  [inline, protected]

void gui2::ttext_::set_state ( tstate  state  )  [private]

Definition at line 248 of file text.cpp.

References gui2::twidget::set_dirty(), and state_.

virtual void gui2::ttext_::calculate_char_offset (  )  [private, pure virtual]

Calculates the offsets of all chars.

Implemented in gui2::ttext_box.

Referenced by paste_selection(), and set_text().

virtual void gui2::ttext_::handle_key_up_arrow ( SDLMod  modifier,
bool &  handled 
) [private, pure virtual]

Implemented in gui2::ttext_box.

Referenced by key_press().

virtual void gui2::ttext_::handle_key_down_arrow ( SDLMod  modifier,
bool &  handled 
) [private, pure virtual]

Implemented in gui2::ttext_box.

Referenced by key_press().

virtual void gui2::ttext_::handle_key_clear_line ( SDLMod  modifier,
bool &  handled 
) [private, pure virtual]

Implemented in gui2::ttext_box.

Referenced by key_press().

void gui2::ttext_::handle_key_left_arrow ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 294 of file text.cpp.

References DBG_G_E, sel_len_, sel_start_, and set_cursor().

Referenced by key_press().

void gui2::ttext_::handle_key_right_arrow ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 307 of file text.cpp.

References DBG_G_E, sel_len_, sel_start_, set_cursor(), and text_.

Referenced by key_press().

void gui2::ttext_::handle_key_home ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 320 of file text.cpp.

References DBG_G_E, goto_start_of_data(), and goto_start_of_line().

Referenced by key_press().

void gui2::ttext_::handle_key_end ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 335 of file text.cpp.

References DBG_G_E, goto_end_of_data(), and goto_end_of_line().

Referenced by key_press().

void gui2::ttext_::handle_key_backspace ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 348 of file text.cpp.

References DBG_G_E, delete_char(), and sel_start_.

Referenced by key_press().

void gui2::ttext_::handle_key_delete ( SDLMod  modifier,
bool &  handled 
) [private, virtual]

Definition at line 360 of file text.cpp.

References DBG_G_E, delete_char(), delete_selection(), sel_len_, sel_start_, and text_.

Referenced by key_press().

void gui2::ttext_::handle_key_default ( bool &  handled,
SDLKey  key,
SDLMod  modifier,
Uint16  unicode 
) [private, virtual]

Definition at line 372 of file text.cpp.

References DBG_G_E, and insert_char().

Referenced by key_press().

virtual void gui2::ttext_::handle_key_page_up ( SDLMod  ,
bool &   
) [inline, private, virtual]

Definition at line 163 of file text.hpp.

Referenced by key_press().

virtual void gui2::ttext_::handle_key_page_down ( SDLMod  ,
bool &   
) [inline, private, virtual]

Definition at line 164 of file text.hpp.

Referenced by key_press().


Member Data Documentation

Definition at line 107 of file text.hpp.

Referenced by get_state(), and set_state().

std::string gui2::ttext_::text_ [private]

size_t gui2::ttext_::sel_start_ [private]

int gui2::ttext_::sel_len_ [private]

positive sel_len_ means selection to the right.

negative sel_len_ means selection to the left. sel_len_ == 0 means no selection.

Definition at line 120 of file text.hpp.

Referenced by get_sel_len(), handle_key_delete(), handle_key_left_arrow(), handle_key_right_arrow(), mouse_left_button_double_click(), sel_len(), set_cursor(), set_sel_len(), and set_text().

size_t gui2::ttext_::max_length_ [private]

Definition at line 121 of file text.hpp.

bool gui2::ttext_::dragging_ [private]

Is the mouse in dragging mode, this affects selection in mouse movee.

Reimplemented in gui2::ttext_box.

Definition at line 124 of file text.hpp.


The documentation for this class was generated from the following files:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs