OpenTTD
Public Member Functions | Data Fields | Static Public Attributes
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 size, uint16 chars=UINT16_MAX)
 Initialize string. More...
 
 ~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. More...
 
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. More...
 
const char * GetCharAtPosition (const Window *w, int wid, const Point &pt) const
 Get the character that is rendered at a position. More...
 
const char * GetText () const
 Get the current text. More...
 
const char * GetCaret () const
 Get the position of the caret in the text buffer. More...
 
const char * GetMarkedText (size_t *length) const
 Get the currently marked text. 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
 
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.
 

Detailed Description

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

Definition at line 22 of file querystring_gui.h.

Constructor & Destructor Documentation

◆ QueryString()

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

Initialize string.

Parameters
sizeMaximum size in bytes.
charsMaximum size in chars.

Definition at line 40 of file querystring_gui.h.

Member Function Documentation

◆ GetBoundingRect()

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.

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 849 of file misc_gui.cpp.

References Window::GetWidget().

Referenced by ~QueryString().

◆ GetCaret()

const char* QueryString::GetCaret ( ) const
inline

Get the position of the caret in the text buffer.

Returns
Pointer to the caret in the text buffer.

Definition at line 74 of file querystring_gui.h.

References Textbuf::buf, and Textbuf::caretpos.

◆ GetCaretPosition()

Point QueryString::GetCaretPosition ( const Window w,
int  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 819 of file misc_gui.cpp.

References Window::GetWidget().

Referenced by ~QueryString().

◆ GetCharAtPosition()

const char * QueryString::GetCharAtPosition ( const Window w,
int  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
Pointer to the character at the position or NULL if no character is at the position.

Definition at line 886 of file misc_gui.cpp.

References Window::GetWidget().

Referenced by ~QueryString().

◆ GetMarkedText()

const char* QueryString::GetMarkedText ( size_t *  length) const
inline

Get the currently marked text.

Parameters
[out]lengthLength of the marked text.
Returns
Begining of the marked area or NULL if no text is marked.

Definition at line 84 of file querystring_gui.h.

References Textbuf::buf, IsOSKOpenedFor(), Textbuf::markend, Textbuf::markpos, ShowOnScreenKeyboard(), and UpdateOSKOriginalText().

◆ GetText()

const char* QueryString::GetText ( ) const
inline

Get the current text.

Returns
Current text.

Definition at line 65 of file querystring_gui.h.

References Textbuf::buf.


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