OpenTTD Source  20240917-master-g9ab0a47812
QueryString Struct Reference

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. More...
 
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. More...
 
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. More...
 
ptrdiff_t GetCharAtPosition (const Window *w, WidgetID wid, const Point &pt) const
 Get the character that is rendered at a position. More...
 

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.
 

Detailed Description

Data stored about a string that can be modified in the GUI.

Definition at line 20 of file querystring_gui.h.

Constructor & Destructor Documentation

◆ QueryString()

QueryString::QueryString ( uint16_t  size,
uint16_t  chars = UINT16_MAX 
)
inline

Initialize string.

Parameters
sizeMaximum size in bytes.
charsMaximum size in chars.

Definition at line 38 of file querystring_gui.h.

Member Function Documentation

◆ GetBoundingRect()

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.

Parameters
wWindow the edit box is in.
widWidget index.
fromStart of the string range.
toEnd of the string range.
Returns
Rectangle encompassing the string range, relative to the window.

Definition at line 888 of file misc_gui.cpp.

References Window::GetWidget(), and NWidgetBase::type.

Referenced by Window::GetTextBoundingRect().

◆ GetCaretPosition()

Point QueryString::GetCaretPosition ( const Window w,
WidgetID  wid 
) const

Get the current caret position.

Parameters
wWindow the edit box is in.
widWidget index.
Returns
Top-left location of the caret, relative to the window.

Definition at line 860 of file misc_gui.cpp.

References Window::GetWidget(), and NWidgetBase::type.

Referenced by Window::GetCaretPosition().

◆ GetCharAtPosition()

ptrdiff_t QueryString::GetCharAtPosition ( const Window w,
WidgetID  wid,
const Point pt 
) const

Get the character that is rendered at a position.

Parameters
wWindow the edit box is in.
widWidget index.
ptPosition to test.
Returns
Index of the character position or -1 if no character is at the position.

Definition at line 918 of file misc_gui.cpp.

References Window::GetWidget(), and NWidgetBase::type.

Referenced by Window::GetTextCharacterAtPosition().


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