OpenTTD Source
1.11.2
|
#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 "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 { KEYS_NONE, KEYS_SHIFT, KEYS_CAPS } |
Functions | |
static void | AddKey (NWidgetHorizontal *hor, int height, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index) |
Add a key widget to a row of the keyboard. More... | |
static NWidgetBase * | MakeTopKeys (int *biggest_index) |
Construct the top row keys (cancel, ok, backspace). | |
static NWidgetBase * | MakeNumberKeys (int *biggest_index) |
Construct the row containing the digit keys. | |
static NWidgetBase * | MakeQwertyKeys (int *biggest_index) |
Construct the qwerty row keys. | |
static NWidgetBase * | MakeAsdfgKeys (int *biggest_index) |
Construct the asdfg row keys. | |
static NWidgetBase * | MakeZxcvbKeys (int *biggest_index) |
Construct the zxcvb row keys. | |
static NWidgetBase * | MakeSpacebarKeys (int *biggest_index) |
Construct the spacebar row keys. | |
void | GetKeyboardLayout () |
Retrieve keyboard layout from language string or (if set) config file. More... | |
void | ShowOnScreenKeyboard (Window *parent, int button) |
Show the on-screen keyboard (osk) associated with a given textbox. More... | |
void | UpdateOSKOriginalText (const Window *parent, int 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. More... | |
bool | IsOSKOpenedFor (const Window *w, int button) |
Check whether the OSK is opened for a specific editbox. More... | |
Variables | |
char | _keyboard_opt [2][OSK_KEYBOARD_ENTRIES *4+1] |
The number of characters has to be OSK_KEYBOARD_ENTRIES. More... | |
static WChar | _keyboard [2][OSK_KEYBOARD_ENTRIES] |
static byte | _keystate = KEYS_NONE |
static const int | HALF_KEY_WIDTH = 7 |
static const int | INTER_KEY_SPACE = 2 |
static const NWidgetPart | _nested_osk_widgets [] |
static WindowDesc | _osk_desc (WDP_CENTER, "query_osk", 0, 0, WC_OSK, WC_NONE, 0, _nested_osk_widgets, lengthof(_nested_osk_widgets)) |
The On Screen Keyboard GUI
Definition in file osk_gui.cpp.
|
static |
Add a key widget to a row of the keyboard.
hor | Row container to add key widget to. |
height | Height of the key (all keys in a row should have equal height). |
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. |
biggest_index | Collected biggest widget index so far. |
Definition at line 229 of file osk_gui.cpp.
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 356 of file osk_gui.cpp.
References _keyboard_opt, OSK_KEYBOARD_ENTRIES, and StrEmpty().
Referenced by ShowOnScreenKeyboard().
bool IsOSKOpenedFor | ( | const Window * | w, |
int | button | ||
) |
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 443 of file osk_gui.cpp.
References FindWindowById(), Window::parent, OskWindow::text_btn, and WC_OSK.
void ShowOnScreenKeyboard | ( | Window * | parent, |
int | button | ||
) |
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 411 of file osk_gui.cpp.
References DeleteWindowById(), GetKeyboardLayout(), and WC_OSK.
void UpdateOSKOriginalText | ( | const Window * | parent, |
int | 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.
parent | window that just updated its original text |
button | widget number of parent's textbox to update |
Definition at line 426 of file osk_gui.cpp.
References Textbuf::buf, FindWindowById(), free(), OskWindow::orig_str_buf, Window::parent, OskWindow::qs, Window::SetDirty(), stredup(), OskWindow::text_btn, and WC_OSK.
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 '\0'-terminated.
Definition at line 27 of file osk_gui.cpp.
Referenced by GetKeyboardLayout().
|
static |
Definition at line 330 of file osk_gui.cpp.