Data Structures | Typedefs | Enumerations | Functions | Variables

# textbuf_gui.h File Reference

Stuff related to the text buffer GUI. More...

`#include "window_type.h"`
`#include "string_type.h"`
`#include "strings_type.h"`

Go to the source code of this file.

## Data Structures
struct | Textbuf
| Helper/buffer for input fields. More...
## Typedefs
typedef void | QueryCallbackProc (Window *, bool)
| Callback procedure for the ShowQuery method.
## Enumerations
enum | QueryStringFlags { QSF_NONE = 0, QSF_ACCEPT_UNCHANGED = 0x01, QSF_ENABLE_DEFAULT = 0x02, QSF_LEN_IN_CHARS = 0x04 }
| Flags used in ShowQueryString() call. More...
## Functions
bool | HandleCaret (Textbuf *tb)
| Handle the flashing of the caret.
void | DeleteTextBufferAll (Textbuf *tb)
| Delete every character in the textbuffer.
bool | DeleteTextBufferChar (Textbuf *tb, int delmode)
| Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.
bool | InsertTextBufferChar (Textbuf *tb, uint32 key)
bool | InsertTextBufferClipboard (Textbuf *tb)
| Insert a chunk of text from the clipboard onto the textbuffer.
bool | MoveTextBufferPos (Textbuf *tb, int navmode)
| Handle text navigation with arrow keys left/right.
void | InitializeTextBuffer (Textbuf *tb, char *buf, uint16 max_bytes)
| Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void | InitializeTextBuffer (Textbuf *tb, char *buf, uint16 max_bytes, uint16 max_chars)
| Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void | UpdateTextBufferSize (Textbuf *tb)
| Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.
void | ShowQueryString (StringID str, StringID caption, uint max_len, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
| Show a query popup window with a textbox in it.
void | ShowQuery (StringID caption, StringID message, Window *w, QueryCallbackProc *callback)
| Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre of its parent.
## Variables
static const uint | OSK_KEYBOARD_ENTRIES = 50
| The number of 'characters' on the on-screen keyboard.
char | _keyboard_opt [2][OSK_KEYBOARD_ENTRIES *4+1]
| The number of characters has to be OSK_KEYBOARD_ENTRIES.

## Detailed Description

Stuff related to the text buffer GUI.

Definition in file textbuf_gui.h.

## Typedef Documentation

typedef void QueryCallbackProc(Window *, bool)

Callback procedure for the ShowQuery method.

Definition at line 54 of file textbuf_gui.h.

## Enumeration Type Documentation

enum QueryStringFlags

Flags used in ShowQueryString() call.

Enumerator:

  QSF_ACCEPT_UNCHANGED | return success even when the text didn't change
  QSF_ENABLE_DEFAULT | enable the 'Default' button ("\0" is returned)
  QSF_LEN_IN_CHARS | the length of the string is counted in characters

Definition at line 44 of file textbuf_gui.h.

## Function Documentation

void DeleteTextBufferAll | ( | Textbuf * | tb | ) |

Delete every character in the textbuffer.

Parameters:

  | tb | Textbuf buffer to be emptied

Definition at line 778 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, Textbuf::max_bytes, and Textbuf::pixels.

Referenced by IConsoleWindow::OnKeyPress().

bool DeleteTextBufferChar | ( | Textbuf * | tb,
|  | int | delmode |
| ) |  |  |

Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.

Parameters:

  | tb | Textbuf type to be changed
  | delmode | Type of deletion, either WKC_BACKSPACE or WKC_DELETE

Returns:
  Return true on successful change of Textbuf, or false otherwise

Definition at line 761 of file misc_gui.cpp.

References Textbuf::bytes, and Textbuf::caretpos.

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

bool HandleCaret | ( | Textbuf * | tb | ) |

Handle the flashing of the caret.

Parameters:

  | tb | The text buffer to handle the caret of.

Returns:
  True if the caret state changes.

Definition at line 971 of file misc_gui.cpp.

References Textbuf::caret.

Referenced by IConsoleWindow::OnMouseLoop().

void InitializeTextBuffer | ( | Textbuf * | tb,
|  | char * | buf,
|  | uint16 | max_bytes,
|  | uint16 | max_chars |
| ) |  |  |

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:

  | tb | Textbuf type which is getting initialized
  | buf | the buffer that will be holding the data for input
  | max_bytes | maximum size in bytes, including terminating ''
  | max_chars | maximum size in chars, including terminating ''

Definition at line 927 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::caret, Textbuf::max_bytes, Textbuf::max_chars, and UpdateTextBufferSize().

void InitializeTextBuffer | ( | Textbuf * | tb,
|  | char * | buf,
|  | uint16 | max_bytes |
| ) |  |  |

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:

  | tb | Textbuf type which is getting initialized
  | buf | the buffer that will be holding the data for input
  | max_bytes | maximum size in bytes, including terminating ''

Definition at line 914 of file misc_gui.cpp.

References InitializeTextBuffer().

Referenced by AIDebugWindow::AIDebugWindow(), InitializeTextBuffer(), NetworkChatWindow::NetworkChatWindow(), and NetworkContentListWindow::NetworkContentListWindow().

bool InsertTextBufferClipboard | ( | Textbuf * | tb | ) |

Insert a chunk of text from the clipboard onto the textbuffer.

Get TEXT clipboard and append this up to the maximum length (either absolute or screenlength). If maxlength is zero, we don't care about the screenlength but only about the physical length of the string

Parameters:

  | tb | Textbuf type to be changed

Returns:
  true on successful change of Textbuf, or false otherwise

Definition at line 818 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, FS_NORMAL, GetCharacterWidth(), GetClipboardContents(), lengthof, Textbuf::max_bytes, Textbuf::max_chars, Textbuf::pixels, and Utf8CharLen().

Referenced by IConsoleWindow::OnKeyPress().

bool MoveTextBufferPos | ( | Textbuf * | tb,
|  | int | navmode |
| ) |  |  |

Handle text navigation with arrow keys left/right.

This defines where the caret will blink and the next characer interaction will occur

Parameters:

  | tb | Textbuf type where navigation occurs
  | navmode | Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME

Returns:
  Return true on successful change of Textbuf, or false otherwise

Definition at line 864 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, FS_NORMAL, GetCharacterWidth(), Textbuf::pixels, Utf8Decode(), and Utf8PrevChar().

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

void ShowQuery | ( | StringID | caption,
|  | StringID | message,
|  | Window * | parent,
|  | QueryCallbackProc * | callback |
| ) |  |  |

Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre of its parent.

Parameters:

  | caption | string shown as window caption
  | message | string that will be shown for the window
  | parent | pointer to parent window, if this pointer is NULL the parent becomes the main window WC_MAIN_WINDOW
  | callback | callback function pointer to set in the window descriptor

Definition at line 1395 of file misc_gui.cpp.

References FindWindowById(), Window::parent, QueryWindow::proc, WC_CONFIRM_POPUP_QUERY, WC_MAIN_WINDOW, and Window::window_class.

Referenced by CmdPause(), ScenarioEditorLandscapeGenerationWindow::OnClick(), GenerateProgressWindow::OnClick(), and DepotWindow::OnClick().

void ShowQueryString | ( | StringID | str,
|  | StringID | caption,
|  | uint | maxsize,
|  | Window * | parent,
|  | CharSetFilter | afilter,
|  | QueryStringFlags | flags |
| ) |  |  |

Show a query popup window with a textbox in it.

Parameters:

  | str | StringID for the text shown in the textbox
  | caption | StringID of text shown in caption of querywindow
  | maxsize | maximum size in bytes or characters (including terminating '') depending on flags
  | parent | pointer to a Window that will handle the events (ok/cancel) of this window. If NULL, results are handled by global function HandleOnEditText
  | afilter | filters out unwanted character input
  | flags | various flags,

See also:
  QueryStringFlags

Definition at line 1256 of file misc_gui.cpp.

References DeleteWindowByClass(), MAX_CHAR_LENGTH, QSF_LEN_IN_CHARS, and WC_QUERY_STRING.

Referenced by WaypointWindow::OnClick(), VehicleDetailsWindow::OnClick(), TownViewWindow::OnClick(), TimetableWindow::OnClick(), StationViewWindow::OnClick(), CustomCurrencyWindow::OnClick(), GameSettingsWindow::OnClick(), OrdersWindow::OnClick(), NewGRFParametersWindow::OnClick(), SpriteAlignerWindow::OnClick(), IndustryViewWindow::OnClick(), CreateScenarioWindow::OnClick(), DepotWindow::OnClick(), CompanyWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), CheatWindow::OnClick(), BuildVehicleWindow::OnClick(), AISettingsWindow::OnClick(), and ToolbarScenDatePanel().

void UpdateTextBufferSize | ( | Textbuf * | tb | ) |

Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.

Useful when copying in a larger amount of text at once

Parameters:

  | tb | Textbuf type which length is calculated

Definition at line 945 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, FS_NORMAL, GetCharacterWidth(), Textbuf::max_bytes, Textbuf::max_chars, Textbuf::pixels, and Utf8CharLen().

Referenced by AIDebugWindow::AIDebugWindow(), NetworkChatWindow::ChatTabCompletion(), SignListWindow::ClearFilterTextWidget(), IConsoleHistoryNavigate(), InitializeTextBuffer(), and OskWindow::OnClick().

## Variable Documentation

char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES *4+1]

The number of characters has to be OSK_KEYBOARD_ENTRIES.

However, these have to be UTF-8 encoded, which means up to 4 bytes per character. Furthermore the string needs to be ''-terminated.

Definition at line 25 of file osk_gui.cpp.

Referenced by GetKeyboardLayout().

const uint OSK_KEYBOARD_ENTRIES = 50`[static]`

The number of 'characters' on the on-screen keyboard.

Definition at line 60 of file textbuf_gui.h.

Referenced by GetKeyboardLayout(), and OskWindow::UpdateOskState().