OpenTTD Source 20241224-master-gf74b0cf984
|
Data stored about a string that can be modified in the GUI. More...
#include <querystring_gui.h>
Public Member Functions | |
QueryString (uint16_t size, uint16_t chars=UINT16_MAX) | |
Initialize string. | |
void | DrawEditBox (const Window *w, WidgetID wid) const |
void | ClickEditBox (Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed) |
void | HandleEditBox (Window *w, WidgetID wid) |
Point | GetCaretPosition (const Window *w, WidgetID wid) const |
Get the current caret position. | |
Rect | GetBoundingRect (const Window *w, WidgetID wid, const char *from, const char *to) const |
Get the bounding rectangle for a range of the query string. | |
ptrdiff_t | GetCharAtPosition (const Window *w, WidgetID wid, const Point &pt) const |
Get the character that is rendered at a position. | |
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 |
std::optional< std::string > | 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 20 of file querystring_gui.h.
|
inline |
Initialize string.
size | Maximum size in bytes. |
chars | Maximum size in chars. |
Definition at line 38 of file querystring_gui.h.
void QueryString::ClickEditBox | ( | Window * | w, |
Point | pt, | ||
WidgetID | wid, | ||
int | click_count, | ||
bool | focus_changed | ||
) |
Definition at line 919 of file misc_gui.cpp.
Definition at line 783 of file misc_gui.cpp.
Rect QueryString::GetBoundingRect | ( | const Window * | w, |
WidgetID | 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 868 of file misc_gui.cpp.
References _current_text_dir, Textbuf::buf, Clamp(), FS_NORMAL, GetCharPosInString(), GetScaledSpriteSize(), Window::GetWidget(), RectPadding::Horizontal(), WidgetDimensions::imgbtn, Rect::Indent(), WidgetDimensions::scaled, ScrollEditBoxTextRect(), Rect::Shrink(), TD_RTL, NWidgetBase::type, and WWT_EDITBOX.
Referenced by Window::GetTextBoundingRect().
Get the current caret position.
w | Window the edit box is in. |
wid | Widget index. |
Definition at line 840 of file misc_gui.cpp.
References _current_text_dir, Textbuf::caretxoffs, GetScaledSpriteSize(), Window::GetWidget(), RectPadding::Horizontal(), WidgetDimensions::imgbtn, Rect::Indent(), WidgetDimensions::scaled, ScrollEditBoxTextRect(), Rect::Shrink(), TD_RTL, NWidgetBase::type, 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 898 of file misc_gui.cpp.
References _current_text_dir, Textbuf::buf, GetScaledSpriteSize(), Window::GetWidget(), RectPadding::Horizontal(), WidgetDimensions::imgbtn, Rect::Indent(), IsInsideMM(), WidgetDimensions::scaled, ScrollEditBoxTextRect(), Rect::Shrink(), TD_RTL, NWidgetBase::type, and WWT_EDITBOX.
Referenced by Window::GetTextCharacterAtPosition().
Definition at line 749 of file misc_gui.cpp.
|
static |
Clear editbox.
Definition at line 24 of file querystring_gui.h.
Referenced by Window::HandleEditBoxKey(), and NetworkContentListWindow::NetworkContentListWindow().
|
static |
Deselect editbox.
Definition at line 23 of file querystring_gui.h.
Referenced by Window::HandleEditBoxKey().
|
static |
int QueryString::cancel_button |
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition at line 28 of file querystring_gui.h.
Referenced by Window::HandleEditBoxKey(), NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), OskWindow::OnClick(), and SavePresetWindow::SavePresetWindow().
StringID QueryString::caption |
Definition at line 26 of file querystring_gui.h.
bool QueryString::handled |
Definition at line 31 of file querystring_gui.h.
int QueryString::ok_button |
Widget button of parent window to simulate when pressing OK in OSK.
Definition at line 27 of file querystring_gui.h.
Referenced by Window::HandleEditBoxKey(), NetworkChatWindow::NetworkChatWindow(), OskWindow::OnClick(), and SavePresetWindow::SavePresetWindow().
std::optional<std::string> QueryString::orig |
Definition at line 30 of file querystring_gui.h.
Textbuf QueryString::text |
Definition at line 29 of file querystring_gui.h.