summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-03 13:59:05 +0000
committerrubidium <rubidium@openttd.org>2009-01-03 13:59:05 +0000
commite5c1a7b5c3afcdfd0671b6476055822eba665205 (patch)
treef69467d5bbbf0587e6289219150ab4a8313edf8c
parent0d54db5f9fb3a3987f908645ca9693684f34674b (diff)
downloadopenttd-e5c1a7b5c3afcdfd0671b6476055822eba665205.tar.xz
(svn r14804) -Codechange: unify opening the OSK (Zuu)
-rw-r--r--src/genworld_gui.cpp4
-rw-r--r--src/misc_gui.cpp18
-rw-r--r--src/network/network_chat_gui.cpp9
-rw-r--r--src/network/network_gui.cpp17
-rw-r--r--src/querystring_gui.h1
-rw-r--r--src/signs_gui.cpp9
-rw-r--r--src/window.cpp8
-rw-r--r--src/window_gui.h2
8 files changed, 35 insertions, 33 deletions
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 6091d75b6..0ec38e93a 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -373,10 +373,6 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->SetDirty();
break;
- case GLAND_RANDOM_EDITBOX: // edit box for random seed
- ShowOnScreenKeyboard(this, GLAND_RANDOM_EDITBOX, 0, 0);
- break;
-
case GLAND_GENERATE_BUTTON: // Generate
_settings_game = _settings_newgame;
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index b38fcc6d3..2fa1ee449 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1061,6 +1061,11 @@ void QueryStringBaseWindow::DrawEditBox(int wid)
this->QueryString::DrawEditBox(this, wid);
}
+void QueryStringBaseWindow::OnOpenOSKWindow(int wid)
+{
+ ShowOnScreenKeyboard(this, wid, 0, 0);
+}
+
enum QueryStringWidgets {
QUERY_STR_WIDGET_TEXT = 3,
QUERY_STR_WIDGET_DEFAULT,
@@ -1103,10 +1108,6 @@ struct QueryStringWindow : public QueryStringBaseWindow
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case QUERY_STR_WIDGET_TEXT:
- ShowOnScreenKeyboard(this, QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
- break;
-
case QUERY_STR_WIDGET_DEFAULT:
this->text.buf[0] = '\0';
/* Fallthrough */
@@ -1140,6 +1141,11 @@ struct QueryStringWindow : public QueryStringBaseWindow
return state;
}
+ virtual void OnOpenOSKWindow(int wid)
+ {
+ ShowOnScreenKeyboard(this, wid, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
+ }
+
~QueryStringWindow()
{
if (!this->handled && this->parent != NULL) {
@@ -1594,10 +1600,6 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
break;
}
- case 10: // edit box
- ShowOnScreenKeyboard(this, widget, 0, 0);
- break;
-
case 11: case 12: // Delete, Save game
break;
}
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 56b86687e..4a1e209b3 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -448,10 +448,6 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case 2:
- ShowOnScreenKeyboard(this, 2, 0, 3);
- break;
-
case 3: /* Send */
SendChat(this->text.buf, this->dtype, this->dest);
/* FALLTHROUGH */
@@ -485,6 +481,11 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
}
return state;
}
+
+ virtual void OnOpenOSKWindow(int wid)
+ {
+ ShowOnScreenKeyboard(this, wid, 0, 3);
+ }
};
static const Widget _chat_window_widgets[] = {
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 2c1ca0537..007901341 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -473,10 +473,6 @@ public:
{
this->field = widget;
switch (widget) {
- case NGWW_CLIENT:
- ShowOnScreenKeyboard(this, NGWW_CLIENT, 0, 0);
- break;
-
case NGWW_CANCEL: // Cancel button
DeleteWindowById(WC_NETWORK_WINDOW, 0);
break;
@@ -917,10 +913,6 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
ShowNetworkGameWindow();
break;
- case NSSW_GAMENAME:
- ShowOnScreenKeyboard(this, NSSW_GAMENAME, 0, 0);
- break;
-
case NSSW_SETPWD: // Set password button
this->widget_id = NSSW_SETPWD;
SetDParamStr(0, _settings_client.network.server_password);
@@ -1907,10 +1899,6 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
this->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD);
this->SetDirty();
break;
-
- case NCPWW_PASSWORD:
- ShowOnScreenKeyboard(this, NCPWW_PASSWORD, NCPWW_CANCEL, NCPWW_OK);
- break;
}
}
@@ -1935,6 +1923,11 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
}
return state;
}
+
+ virtual void OnOpenOSKWindow(int wid)
+ {
+ ShowOnScreenKeyboard(this, wid, NCPWW_CANCEL, NCPWW_OK);
+ }
};
static const Widget _ncp_window_widgets[] = {
diff --git a/src/querystring_gui.h b/src/querystring_gui.h
index 8946abd25..42f8d44fb 100644
--- a/src/querystring_gui.h
+++ b/src/querystring_gui.h
@@ -67,6 +67,7 @@ struct QueryStringBaseWindow : public Window, public QueryString {
void DrawEditBox(int wid);
void HandleEditBox(int wid);
int HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
+ virtual void OnOpenOSKWindow(int wid);
};
void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok);
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index fd7e62356..314a2fbf9 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -278,10 +278,6 @@ struct SignWindow : QueryStringBaseWindow, SignList {
break;
}
- case QUERY_EDIT_SIGN_WIDGET_TEXT:
- ShowOnScreenKeyboard(this, widget, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK);
- break;
-
case QUERY_EDIT_SIGN_WIDGET_DELETE:
/* Only need to set the buffer to null, the rest is handled as the OK button */
RenameSign(this->cur_sign, "");
@@ -319,6 +315,11 @@ struct SignWindow : QueryStringBaseWindow, SignList {
{
this->HandleEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
}
+
+ virtual void OnOpenOSKWindow(int wid)
+ {
+ ShowOnScreenKeyboard(this, wid, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK);
+ }
};
static const Widget _query_sign_edit_widgets[] = {
diff --git a/src/window.cpp b/src/window.cpp
index 00b81c1d4..bf79b2b88 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -24,6 +24,7 @@
#include "window_func.h"
#include "tilehighlight_func.h"
#include "network/network.h"
+#include "querystring_gui.h"
#include "table/sprites.h"
@@ -184,6 +185,13 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
}
} else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_SCROLL2BAR || wi->type == WWT_HSCROLLBAR) {
ScrollbarClickHandler(w, wi, x, y);
+ } else if (wi->type == WWT_EDITBOX) {
+ /* Open the OSK window if clicked on an edit box */
+ QueryStringBaseWindow *qs = dynamic_cast<QueryStringBaseWindow*>(w);
+ if (qs != NULL) {
+ const int widget_index = wi - w->widget;
+ qs->OnOpenOSKWindow(widget_index);
+ }
}
if (w->desc_flags & WDF_STD_BTN) {
diff --git a/src/window_gui.h b/src/window_gui.h
index 0fbd4c1a5..1dff3b971 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -477,7 +477,7 @@ enum WindowWidgetTypes {
WWT_CLOSEBOX, ///< Close box (at top-left of a window)
WWT_DROPDOWN, ///< Raised drop down list (regular)
WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
- WWT_EDITBOX, ///< a textbox for typing (don't forget to call ShowOnScreenKeyboard() when clicked)
+ WWT_EDITBOX, ///< a textbox for typing
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
WWT_MASK = 0x1F,