zenilib: Zeni::Text_Box Class Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
Zeni::Text_Box Class Reference
Zenilib

A Text_Box. More...

`#include <Widget.h>`

Inherits Zeni::Widget_Button.

Inherited by Zeni::Configurator_Video::Text_Element, and Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::Title.

## Public Member Functions

| Text_Box (const Point2f &upper_left_, const Point2f &lower_right_, const String &font_name_, const String &text_, const Color &text_color_, const bool &editable_=ZENI_DEFAULT_TEXTBOX_EDITABLE, const JUSTIFY &justify_=ZENI_DEFAULT_JUSTIFY, const int &tab_spaces_=ZENI_DEFAULT_TAB_SPACES)
| ~Text_Box ()
void | erase_lines (const unsigned int &begin, const unsigned int &end)
void | fax_BG_Renderer (const Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget a copy. More...
const Widget_Render_Function * | get_BG_Renderer () const
| Get the current Widget_Render_Function. More...
int | get_cursor_pos () const
const int & | get_edit_pos () const
const Font & | get_Font () const
const String & | get_font_name () const
const JUSTIFY & | get_justify () const
int | get_max_cursor_seek () const
size_t | get_max_lines () const
int | get_max_seek () const
size_t | get_num_lines () const
const String & | get_text () const
const Color & | get_text_color () const
void | give_BG_Renderer (Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget ownership. More...
void | lend_BG_Renderer (const Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget no ownership. More...
virtual void | on_accept ()
| Called when the cursor is released inside the button. More...
virtual void | on_change ()
virtual void | on_focus ()
virtual void | on_key (const SDL_Keysym &keysym, const bool &down)
virtual void | on_mouse_button (const Point2i &pos, const bool &down, const int &button)
virtual void | on_unfocus ()
virtual void | render_impl () const
void | seek (const int &edit_pos)
void | seek_cursor (const int &cursor_pos)
virtual void | set_editable (const bool &editable_)
void | set_focus (const bool &value)
void | set_font_name (const String &font_name_)
void | set_justify (const JUSTIFY &justify_)
virtual void | set_lower_right (const Point2f &lower_right_)
void | set_text (const String &text_)
void | set_text_color (const Color &text_color_)
virtual void | set_upper_left (const Point2f &upper_left_)
Public Member Functions inherited from Zeni::Widget_Button
| Widget_Button (const Point2f &upper_left_, const Point2f &lower_right_)
const State & | get_State () const
| Get the State of the button. More...
virtual void | on_click ()
| Called when the cursor downclicks the button. More...
virtual void | on_hover ()
| Called when the cursor passes over the button. More...
virtual void | on_mouse_motion (const Point2i &pos)
virtual void | on_reject ()
| Called when the cursor is released outside the button. More...
virtual void | on_stray ()
| Called when the cursor is dragged off the button after being clicked. More...
virtual void | on_unhover ()
| Called when the cursor leaves the button without clicking. More...
virtual void | on_unstray ()
| Called when the cursor is dragged back onto the button without releasing the clicker. More...
Public Member Functions inherited from Zeni::Widget
| Widget ()
virtual | ~Widget ()
void | fax_Renderer (const Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget a copy. More...
const float & | get_layer () const
const Widget_Render_Function * | get_Renderer () const
| Get the current Widget_Render_Function. More...
void | give_Renderer (Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget ownership. More...
const bool & | is_busy () const
const bool & | is_editable () const
void | lend_Renderer (const Widget_Render_Function *const &renderer)
| Set the current Widget_Render_Function, giving the Widget no ownership. More...
void | on_event (const SDL_KeyboardEvent &event)
void | on_event (const SDL_MouseButtonEvent &event)
void | on_event (const SDL_MouseButtonEvent &event, const Projector2D &projector)
void | on_event (const SDL_MouseMotionEvent &event)
void | on_event (const SDL_MouseMotionEvent &event, const Projector2D &projector)
virtual void | perform_logic ()
void | render () const
void | set_busy (const bool &busy_)
void | set_layer (const float &layer_=0.0f)
Public Member Functions inherited from Zeni::Widget_Rectangle
| Widget_Rectangle (const Point2f &upper_left_, const Point2f &lower_right_)
virtual | ~Widget_Rectangle ()
Point2f | get_center () const
float | get_height () const
Point2f | get_lower_left () const
const Point2f & | get_lower_right () const
const Point2f & | get_upper_left () const
Point2f | get_upper_right () const
float | get_width () const
bool | is_inside (const Point2i &pos) const

## Static Public Member Functions

static void | reformat_all ()
| Reformat all Text_Box instances. More...

## Additional Inherited Members

Public Types inherited from Zeni::Widget_Button
enum | State { NORMAL, CLICKED, HOVERED, STRAYED, UNACTIONABLE }

## Detailed Description

A Text_Box.

An (optionally) editable text box. It can behave as a simple text editor.

Author
  bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 816 of file Widget.h.

## Constructor & Destructor Documentation

Zeni::Text_Box::Text_Box | ( | const Point2f & | upper_left_,
|  | const Point2f & | lower_right_,
|  | const String & | font_name_,
|  | const String & | text_,
|  | const Color & | text_color_,
|  | const bool & | editable_ = `ZENI_DEFAULT_TEXTBOX_EDITABLE`,
|  | const JUSTIFY & | justify_ = `ZENI_DEFAULT_JUSTIFY`,
|  | const int & | tab_spaces_ = `ZENI_DEFAULT_TAB_SPACES`
| ) |  |

Definition at line 829 of file Widget.cpp.

References Zeni::get_Fonts(), Zeni::Singleton< TYPE >::lend_post_reinit(), Zeni::Singleton< Fonts >::remove_post_reinit(), and set_editable().

Zeni::Text_Box::~Text_Box | ( |  | ) |

Definition at line 853 of file Widget.cpp.

## Member Function Documentation

void Zeni::Text_Box::erase_lines | ( | const unsigned int & | begin,
|  | const unsigned int & | end
| ) |  |

inline

Definition at line 584 of file Widget.hxx.

References assert, get_num_lines(), i, Zeni::Widget_Renderer_Text::text, and u.

void Zeni::Text_Box::fax_BG_Renderer | ( | const Widget_Render_Function *const & | renderer | ) |

inline

Set the current Widget_Render_Function, giving the Widget a copy.

Definition at line 624 of file Widget.hxx.

References Zeni::Widget_Render_Function::get_duplicate(), and give_BG_Renderer().

const Widget_Render_Function * Zeni::Text_Box::get_BG_Renderer | ( |  | ) | const

inline

Get the current Widget_Render_Function.

Definition at line 608 of file Widget.hxx.

int Zeni::Text_Box::get_cursor_pos | ( |  | ) | const

Definition at line 1252 of file Widget.cpp.

References int, j, Zeni::Point2i::x, and Zeni::Point2i::y.

Referenced by on_key().

const int & Zeni::Text_Box::get_edit_pos | ( |  | ) | const

Definition at line 1248 of file Widget.cpp.

Referenced by set_lower_right(), and set_upper_left().

const Font & Zeni::Text_Box::get_Font | ( |  | ) | const

inline

Definition at line 540 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::font_name, and Zeni::get_Fonts().

Referenced by get_max_lines(), on_accept(), and render_impl().

const String & Zeni::Text_Box::get_font_name | ( |  | ) | const

inline

Definition at line 536 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::font_name.

const JUSTIFY & Zeni::Text_Box::get_justify | ( |  | ) | const

inline

Definition at line 552 of file Widget.hxx.

int Zeni::Text_Box::get_max_cursor_seek | ( |  | ) | const

Definition at line 1263 of file Widget.cpp.

References int, and u.

Referenced by on_key().

size_t Zeni::Text_Box::get_max_lines | ( |  | ) | const

inline

Definition at line 560 of file Widget.hxx.

References get_Font(), and Zeni::Widget_Rectangle::get_height().

Referenced by Zeni::Console_State::write_to_log().

int Zeni::Text_Box::get_max_seek | ( |  | ) | const

Definition at line 1259 of file Widget.cpp.

References get_text(), and int.

Referenced by set_focus(), and set_text().

size_t Zeni::Text_Box::get_num_lines | ( |  | ) | const

inline

Definition at line 556 of file Widget.hxx.

Referenced by erase_lines().

const String & Zeni::Text_Box::get_text | ( |  | ) | const

inline

Definition at line 544 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::text.

Referenced by get_max_seek(), on_accept(), on_key(), and seek().

const Color & Zeni::Text_Box::get_text_color | ( |  | ) | const

inline

Definition at line 548 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::color.

void Zeni::Text_Box::give_BG_Renderer | ( | Widget_Render_Function *const & | renderer | ) |

inline

Set the current Widget_Render_Function, giving the Widget ownership.

Definition at line 612 of file Widget.hxx.

Referenced by Zeni::Configurator_Video::Check_State::Check_State(), fax_BG_Renderer(), lend_BG_Renderer(), and Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::Title::Title().

void Zeni::Text_Box::lend_BG_Renderer | ( | const Widget_Render_Function *const & | renderer | ) |

inline

Set the current Widget_Render_Function, giving the Widget no ownership.

Definition at line 619 of file Widget.hxx.

References give_BG_Renderer().

void Zeni::Text_Box::on_accept | ( |  | ) |

virtual

Called when the cursor is released inside the button.

BEGIN JUSTIFICATION FIX

END JUSTIFICATION FIX

HACK: Pleasentness Increase

Reimplemented from Zeni::Widget_Button.

Definition at line 1013 of file Widget.cpp.

References assert, get_Font(), Zeni::Widget_Rectangle::get_lower_right(), get_text(), Zeni::Font::get_text_width(), Zeni::Widget_Rectangle::get_upper_left(), i, int, j, k, m, seek(), Zeni::String::size(), u, Zeni::Point2i::x, Zeni::Point2f::x, Zeni::Point2i::y, Zeni::ZENI_CENTER, Zeni::ZENI_LEFT, and Zeni::ZENI_RIGHT.

void Zeni::Text_Box::on_change | ( |  | ) |

virtual

Definition at line 1073 of file Widget.cpp.

Referenced by on_key().

void Zeni::Text_Box::on_focus | ( |  | ) |

virtual

Definition at line 1067 of file Widget.cpp.

Referenced by on_mouse_button(), and set_focus().

void Zeni::Text_Box::on_key | ( | const SDL_Keysym & | keysym,
|  | const bool & | down
| ) |  |

virtual

Reimplemented from Zeni::Widget.

Definition at line 861 of file Widget.cpp.

References get_cursor_pos(), Zeni::get_Game(), Zeni::Game::get_key_state(), get_max_cursor_seek(), get_text(), i, int, min, on_change(), SDLK_BACKSPACE, SDLK_DELETE, SDLK_DOWN, SDLK_END, SDLK_HOME, SDLK_LALT, SDLK_LCTRL, SDLK_LEFT, SDLK_LGUI, SDLK_LSHIFT, SDLK_RALT, SDLK_RCTRL, SDLK_RGUI, SDLK_RIGHT, SDLK_RSHIFT, SDLK_UP, seek(), seek_cursor(), Zeni::String::size(), Zeni::String::substr(), SDL_Keysym::sym, Zeni::Widget_Renderer_Text::text, Zeni::Gamestate_Base::to_char(), u, Zeni::Point2i::x, and Zeni::Point2i::y.

void Zeni::Text_Box::on_mouse_button | ( | const Point2i & | pos,
|  | const bool & | down,
|  | const int & | button
| ) |  |

virtual

Reimplemented from Zeni::Widget_Button.

Definition at line 989 of file Widget.cpp.

References Zeni::Widget_Rectangle::get_upper_left(), int, on_focus(), Zeni::Widget_Button::on_mouse_button(), on_unfocus(), SDL_BUTTON_LEFT, Zeni::Point2i::x, and Zeni::Point2i::y.

void Zeni::Text_Box::on_unfocus | ( |  | ) |

virtual

Definition at line 1070 of file Widget.cpp.

Referenced by on_mouse_button(), and set_focus().

void Zeni::Text_Box::reformat_all | ( |  | ) |

static

Reformat all Text_Box instances.

Definition at line 1397 of file Widget.cpp.

void Zeni::Text_Box::render_impl | ( |  | ) | const

virtual

Reimplemented from Zeni::Widget.

Definition at line 1076 of file Widget.cpp.

References Zeni::Widget_Renderer_Text::color, get_Font(), Zeni::Widget_Rectangle::get_lower_right(), Zeni::Font::get_text_height(), Zeni::Font::get_text_width(), get_time(), Zeni::get_Timer(), Zeni::Widget_Rectangle::get_upper_left(), Zeni::get_Video(), i, Zeni::Video::render(), Zeni::Font::render_text(), Zeni::Widget_Render_Function::render_to(), SDL_DEFAULT_REPEAT_DELAY, Zeni::Point2i::x, Zeni::Point2f::x, Zeni::Point2i::y, Zeni::Point2f::y, Zeni::ZENI_CENTER, Zeni::ZENI_LEFT, Zeni::ZENI_RIGHT, and ZENI_TEXT_CURSOR_WIDTH.

void Zeni::Text_Box::seek | ( | const int & | edit_pos | ) |

Definition at line 1274 of file Widget.cpp.

References get_text(), Zeni::Timer::get_time(), Zeni::get_Timer(), int, Zeni::Widget::is_editable(), j, Zeni::String::size(), u, Zeni::Point2i::x, and Zeni::Point2i::y.

Referenced by on_accept(), on_key(), set_focus(), set_font_name(), set_lower_right(), set_text(), and set_upper_left().

void Zeni::Text_Box::seek_cursor | ( | const int & | cursor_pos | ) |

Definition at line 1305 of file Widget.cpp.

References Zeni::Timer::get_time(), Zeni::get_Timer(), i, int, Zeni::Widget::is_editable(), j, u, Zeni::Point2i::x, and Zeni::Point2i::y.

Referenced by on_key().

void Zeni::Text_Box::set_editable | ( | const bool & | editable_ | ) |

virtual

Reimplemented from Zeni::Widget.

Definition at line 1230 of file Widget.cpp.

References Zeni::Widget::set_editable().

Referenced by Text_Box().

void Zeni::Text_Box::set_focus | ( | const bool & | value | ) |

Definition at line 1334 of file Widget.cpp.

References get_max_seek(), Zeni::Widget::is_editable(), on_focus(), on_unfocus(), and seek().

void Zeni::Text_Box::set_font_name | ( | const String & | font_name_ | ) |

inline

Definition at line 564 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::font_name, and seek().

void Zeni::Text_Box::set_justify | ( | const JUSTIFY & | justify_ | ) |

inline

Definition at line 580 of file Widget.hxx.

Referenced by Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::Title_State().

void Zeni::Text_Box::set_lower_right | ( | const Point2f & | lower_right_ | ) |

virtual

Reimplemented from Zeni::Widget_Rectangle.

Definition at line 1242 of file Widget.cpp.

References get_edit_pos(), seek(), and Zeni::Widget_Rectangle::set_lower_right().

void Zeni::Text_Box::set_text | ( | const String & | text_ | ) |

inline

Definition at line 570 of file Widget.hxx.

References get_max_seek(), min, seek(), and Zeni::Widget_Renderer_Text::text.

void Zeni::Text_Box::set_text_color | ( | const Color & | text_color_ | ) |

inline

Definition at line 576 of file Widget.hxx.

References Zeni::Widget_Renderer_Text::color.

void Zeni::Text_Box::set_upper_left | ( | const Point2f & | upper_left_ | ) |

virtual

Reimplemented from Zeni::Widget_Rectangle.

Definition at line 1236 of file Widget.cpp.

References get_edit_pos(), seek(), and Zeni::Widget_Rectangle::set_upper_left().

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

- zenilib/jni/external/zenilib/zeni_rest/Zeni/Widget.h
- zenilib/jni/external/zenilib/zeni_rest/Widget.cpp
- zenilib/jni/external/zenilib/zeni_rest/Zeni/Widget.hxx