|
OpenTTD Source 20260531-master-g0e951f3528
|
The On Screen Keyboard GUI. More...
#include "stdafx.h"#include "string_func.h"#include "strings_func.h"#include "debug.h"#include "window_func.h"#include "gfx_func.h"#include "querystring_gui.h"#include "video/video_driver.hpp"#include "zoom_func.h"#include "core/string_consumer.hpp"#include "widgets/osk_widget.h"#include "table/sprites.h"#include "table/strings.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | OskWindow |
Enumerations | |
| enum | KeyStateBits : uint8_t { KEYS_NONE , KEYS_SHIFT , KEYS_CAPS } |
Functions | |
| static void | AddKey (std::unique_ptr< NWidgetHorizontal > &hor, int pad_y, int num_half, WidgetType widtype, WidgetID widnum, const WidgetData &widdata) |
| Add a key widget to a row of the keyboard. | |
| static std::unique_ptr< NWidgetBase > | MakeTopKeys () |
| Construct the top row keys (cancel, ok, backspace). | |
| static std::unique_ptr< NWidgetBase > | MakeNumberKeys () |
| Construct the row containing the digit keys. | |
| static std::unique_ptr< NWidgetBase > | MakeQwertyKeys () |
| Construct the qwerty row keys. | |
| static std::unique_ptr< NWidgetBase > | MakeAsdfgKeys () |
| Construct the asdfg row keys. | |
| static std::unique_ptr< NWidgetBase > | MakeZxcvbKeys () |
| Construct the zxcvb row keys. | |
| static std::unique_ptr< NWidgetBase > | MakeSpacebarKeys () |
| Construct the spacebar row keys. | |
| void | GetKeyboardLayout () |
| Retrieve keyboard layout from language string or (if set) config file. | |
| void | ShowOnScreenKeyboard (Window *parent, WidgetID button) |
| Show the on-screen keyboard (osk) associated with a given textbox. | |
| void | UpdateOSKOriginalText (const Window *parent, WidgetID button) |
| Updates the original text of the OSK so when the 'parent' changes the original and you press on cancel you won't get the 'old' original text but the updated one. | |
| bool | IsOSKOpenedFor (const Window *w, WidgetID button) |
| Check whether the OSK is opened for a specific editbox. | |
Variables | |
| std::string | _keyboard_opt [2] |
| The number of characters has to be OSK_KEYBOARD_ENTRIES. | |
| static char32_t | _keyboard [2][OSK_KEYBOARD_ENTRIES] |
| static uint8_t | _keystate = KEYS_NONE |
| static const int | HALF_KEY_WIDTH = 7 |
| Width of 1/2 key in pixels. | |
| static const int | INTER_KEY_SPACE = 2 |
| Number of pixels between two keys. | |
| static const int | TOP_KEY_PADDING = 2 |
| Vertical padding for the top row of keys. | |
| static const int | KEY_PADDING = 6 |
| Vertical padding for remaining key rows. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_osk_widgets |
| static WindowDesc | _osk_desc (WindowPosition::Center, {}, 0, 0, WindowClass::OnScreenKeyboard, WindowClass::None, {}, _nested_osk_widgets) |
| Window definition for the on screen keyboard window. | |
The On Screen Keyboard GUI.
Definition in file osk_gui.cpp.
| enum KeyStateBits : uint8_t |
Definition at line 31 of file osk_gui.cpp.
|
static |
Add a key widget to a row of the keyboard.
| hor | Row container to add key widget to. |
| pad_y | Vertical padding of the key (all keys in a row should have equal padding). |
| num_half | Number of 1/2 key widths that this key has. |
| widtype | Widget type of the key. Must be either NWID_SPACER for an invisible key, or a WWT_* widget. |
| widnum | Widget number of the key. |
| widdata | Data value of the key widget. |
Definition at line 228 of file osk_gui.cpp.
References Grey, HALF_KEY_WIDTH, INTER_KEY_SPACE, Normal, and NWID_SPACER.
Referenced by MakeAsdfgKeys(), MakeNumberKeys(), MakeQwertyKeys(), MakeSpacebarKeys(), MakeTopKeys(), and MakeZxcvbKeys().
| void GetKeyboardLayout | ( | ) |
Retrieve keyboard layout from language string or (if set) config file.
Also check for invalid characters.
Definition at line 353 of file osk_gui.cpp.
References _keyboard_opt, StringConsumer::AnyBytesLeft(), GetString(), OSK_KEYBOARD_ENTRIES, and StringConsumer::ReadUtf8().
Referenced by ShowOnScreenKeyboard().
Check whether the OSK is opened for a specific editbox.
| w | Window to check for |
| button | Editbox of w to check for |
Definition at line 423 of file osk_gui.cpp.
References FindWindowById(), Window::parent, and OskWindow::text_btn.
|
static |
Construct the asdfg row keys.
Pointer to function returning a nested widget.
Definition at line 283 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, KEY_PADDING, WID_OSK_ASDFG_FIRST, WID_OSK_ASDFG_LAST, WID_OSK_CAPS, WWT_IMGBTN, and WWT_PUSHBTN.
|
static |
Construct the row containing the digit keys.
Pointer to function returning a nested widget.
Definition at line 257 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, KEY_PADDING, WID_OSK_NUMBERS_FIRST, WID_OSK_NUMBERS_LAST, and WWT_PUSHBTN.
|
static |
Construct the qwerty row keys.
Pointer to function returning a nested widget.
Definition at line 269 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, KEY_PADDING, NWID_SPACER, WID_OSK_QWERTY_FIRST, WID_OSK_QWERTY_LAST, WID_OSK_SPECIAL, WWT_PUSHBTN, and WWT_PUSHIMGBTN.
|
static |
Construct the spacebar row keys.
Pointer to function returning a nested widget.
Definition at line 310 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, KEY_PADDING, NWID_SPACER, WID_OSK_LEFT, WID_OSK_RIGHT, WID_OSK_SPACE, WWT_PUSHIMGBTN, and WWT_PUSHTXTBTN.
|
static |
Construct the top row keys (cancel, ok, backspace).
Pointer to function returning a nested widget.
Definition at line 245 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, TOP_KEY_PADDING, WID_OSK_BACKSPACE, WID_OSK_CANCEL, WID_OSK_OK, WWT_PUSHIMGBTN, and WWT_TEXTBTN.
|
static |
Construct the zxcvb row keys.
Pointer to function returning a nested widget.
Definition at line 296 of file osk_gui.cpp.
References AddKey(), INTER_KEY_SPACE, KEY_PADDING, NWID_SPACER, WID_OSK_SHIFT, WID_OSK_ZXCVB_FIRST, WID_OSK_ZXCVB_LAST, WWT_IMGBTN, and WWT_PUSHBTN.
Show the on-screen keyboard (osk) associated with a given textbox.
| parent | pointer to the Window where this keyboard originated from |
| button | widget number of parent's textbox |
Definition at line 392 of file osk_gui.cpp.
References _osk_desc, CloseWindowById(), and GetKeyboardLayout().
Updates the original text of the OSK so when the 'parent' changes the original and you press on cancel you won't get the 'old' original text but the updated one.
| parent | window that just updated its original text |
| button | widget number of parent's textbox to update |
Definition at line 407 of file osk_gui.cpp.
References FindWindowById(), Textbuf::GetText(), OskWindow::orig_str, Window::parent, OskWindow::qs, Window::SetDirty(), and OskWindow::text_btn.
|
static |
Definition at line 29 of file osk_gui.cpp.
| std::string _keyboard_opt[2] |
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.
Definition at line 28 of file osk_gui.cpp.
Referenced by GetKeyboardLayout().
|
static |
Definition at line 36 of file osk_gui.cpp.
|
staticconstexpr |
Definition at line 324 of file osk_gui.cpp.
|
static |
|
static |
Number of pixels between two keys.
Definition at line 213 of file osk_gui.cpp.
Referenced by AddKey(), MakeAsdfgKeys(), MakeNumberKeys(), MakeQwertyKeys(), MakeSpacebarKeys(), MakeTopKeys(), and MakeZxcvbKeys().
|
static |
Vertical padding for remaining key rows.
Definition at line 216 of file osk_gui.cpp.
Referenced by MakeAsdfgKeys(), MakeNumberKeys(), MakeQwertyKeys(), MakeSpacebarKeys(), and MakeZxcvbKeys().
|
static |
Vertical padding for the top row of keys.
Definition at line 215 of file osk_gui.cpp.
Referenced by MakeTopKeys().