OpenTTD
|
Data stored about a string that can be modified in the GUI. More...
#include <querystring_gui.h>
Public Member Functions | |
QueryString (uint16 size, uint16 chars=UINT16_MAX) | |
Initialize string. | |
~QueryString () | |
Make sure everything gets freed. | |
void | DrawEditBox (const Window *w, int wid) const |
void | ClickEditBox (Window *w, Point pt, int wid, int click_count, bool focus_changed) |
void | HandleEditBox (Window *w, int wid) |
Point | GetCaretPosition (const Window *w, int wid) const |
Get the current caret position. | |
Rect | GetBoundingRect (const Window *w, int wid, const char *from, const char *to) const |
Get the bounding rectangle for a range of the query string. | |
const char * | GetCharAtPosition (const Window *w, int wid, const Point &pt) const |
Get the character that is rendered at a position. | |
const char * | GetText () const |
Get the current text. | |
const char * | GetCaret () const |
Get the position of the caret in the text buffer. | |
const char * | GetMarkedText (size_t *length) const |
Get the currently marked text. |
Data Fields | |
StringID | caption |
int | ok_button |
Widget button of parent window to simulate when pressing OK in OSK. | |
int | cancel_button |
Widget button of parent window to simulate when pressing CANCEL in OSK. | |
Textbuf | text |
const char * | orig |
bool | handled |
Static Public Attributes | |
static const int | ACTION_NOTHING = -1 |
Nothing. | |
static const int | ACTION_DESELECT = -2 |
Deselect editbox. | |
static const int | ACTION_CLEAR = -3 |
Clear editbox. |
Data stored about a string that can be modified in the GUI.
Definition at line 22 of file querystring_gui.h.
|
inline |
Initialize string.
size | Maximum size in bytes. |
chars | Maximum size in chars. |
Definition at line 40 of file querystring_gui.h.
Rect QueryString::GetBoundingRect | ( | const Window * | w, |
int | wid, | ||
const char * | from, | ||
const char * | to | ||
) | const |
Get the bounding rectangle for a range of the query string.
w | Window the edit box is in. |
wid | Widget index. |
from | Start of the string range. |
to | End of the string range. |
Definition at line 840 of file misc_gui.cpp.
References _current_text_dir, Textbuf::buf, Textbuf::caretxoffs, Clamp(), NWidgetBase::current_x, NWidgetBase::current_y, FS_NORMAL, GetCharPosInString(), GetSpriteSize(), Window::GetWidget(), min(), Textbuf::pixels, NWidgetBase::pos_x, NWidgetBase::pos_y, TD_RTL, NWidgetBase::type, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_IMGBTN_LEFT, WD_IMGBTN_RIGHT, and WWT_EDITBOX.
Referenced by Window::GetTextBoundingRect().
|
inline |
Get the position of the caret in the text buffer.
Definition at line 74 of file querystring_gui.h.
References Textbuf::buf, and Textbuf::caretpos.
Referenced by Window::GetCaret().
Get the current caret position.
w | Window the edit box is in. |
wid | Widget index. |
Definition at line 810 of file misc_gui.cpp.
References _current_text_dir, Textbuf::caretxoffs, NWidgetBase::current_x, GetSpriteSize(), Window::GetWidget(), min(), Textbuf::pixels, NWidgetBase::pos_x, NWidgetBase::pos_y, TD_RTL, NWidgetBase::type, WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_IMGBTN_LEFT, WD_IMGBTN_RIGHT, and WWT_EDITBOX.
Referenced by Window::GetCaretPosition().
Get the character that is rendered at a position.
w | Window the edit box is in. |
wid | Widget index. |
pt | Position to test. |
Definition at line 877 of file misc_gui.cpp.
References _current_text_dir, Textbuf::buf, Textbuf::caretxoffs, NWidgetBase::current_x, NWidgetBase::current_y, GetSpriteSize(), Window::GetWidget(), IsInsideMM(), min(), Textbuf::pixels, NWidgetBase::pos_x, NWidgetBase::pos_y, TD_RTL, NWidgetBase::type, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, WD_IMGBTN_LEFT, WD_IMGBTN_RIGHT, and WWT_EDITBOX.
Referenced by Window::GetTextCharacterAtPosition().
|
inline |
Get the currently marked text.
[out] | length | Length of the marked text. |
Definition at line 84 of file querystring_gui.h.
References Textbuf::buf, Textbuf::markend, and Textbuf::markpos.
Referenced by Window::GetMarkedText().
|
inline |
Get the current text.
Definition at line 65 of file querystring_gui.h.
References Textbuf::buf.
Referenced by Window::GetFocusedText().