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.
| ~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.

## 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 | ( | uint16 | size,
|  | uint16 | chars = `UINT16_MAX` |
| ) |  |  | `[inline]`

Initialize string.

Parameters:

  | size | Maximum size in bytes.
  | chars | Maximum size in chars.

Definition at line 40 of file querystring_gui.h.

## Member Function Documentation

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:

  | w | Window the edit box is in.
  | wid | Widget index.
  | from | Start of the string range.
  | to | End of the string range.

Returns:
  Rectangle encompassing the string range, relative to the window.

Definition at line 837 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, NWidgetBase::type, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_IMGBTN_LEFT, and WWT_EDITBOX.

Referenced by Window::GetTextBoundingRect().

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.

Referenced by Window::GetCaret().

Point QueryString::GetCaretPosition | ( | const Window * | w,
|  | int | wid |
| ) |  |  | const

Get the current caret position.

Parameters:

  | w | Window the edit box is in.
  | wid | Widget index.

Returns:
  Top-left location of the caret, relative to the window.

Definition at line 807 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, NWidgetBase::type, WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_IMGBTN_LEFT, and WWT_EDITBOX.

Referenced by Window::GetCaretPosition().

const char * QueryString::GetCharAtPosition | ( | const Window * | w,
|  | int | wid,
|  | const Point & | pt |
| ) |  |  | const

Get the character that is rendered at a position.

Parameters:

  | w | Window the edit box is in.
  | wid | Widget index.
  | pt | Position to test.

Returns:
  Pointer to the character at the position or NULL if no character is at the position.

Definition at line 874 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, NWidgetBase::type, WD_IMGBTN_LEFT, and WWT_EDITBOX.

Referenced by Window::GetTextCharacterAtPosition().

const char* QueryString::GetMarkedText | ( | size_t * | length | ) | const`[inline]`

Get the currently marked text.

Parameters:

  `[out]` | length | Length 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, Textbuf::markend, and Textbuf::markpos.

Referenced by Window::GetMarkedText().

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.

Referenced by Window::GetFocusedText().

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

- src/querystring_gui.h
- src/misc_gui.cpp