summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-13 21:46:19 +0000
committerfrosch <frosch@openttd.org>2012-11-13 21:46:19 +0000
commit17025fa6ea110f0db0b1c2e29b7615b21c2f5a50 (patch)
treee172f8a486ffd070f0a04406e46d74b24a68348c /src
parent8cd77b6f6eb0e82ebcb4c0197786eeea08dd0263 (diff)
downloadopenttd-17025fa6ea110f0db0b1c2e29b7615b21c2f5a50.tar.xz
(svn r24724) -Codechange: Move drawing of editboxes to the widget drawing code.
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/fios_gui.cpp4
-rw-r--r--src/genworld_gui.cpp6
-rw-r--r--src/misc_gui.cpp14
-rw-r--r--src/network/network_chat_gui.cpp6
-rw-r--r--src/network/network_content_gui.cpp3
-rw-r--r--src/network/network_gui.cpp17
-rw-r--r--src/newgrf_gui.cpp6
-rw-r--r--src/querystring_gui.h3
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/signs_gui.cpp7
-rw-r--r--src/town_gui.cpp6
-rw-r--r--src/widget.cpp6
13 files changed, 7 insertions, 74 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 785d821a1..e08fac4db 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1099,8 +1099,6 @@ struct AIDebugWindow : public QueryStringBaseWindow {
if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
- if (this->show_break_box) this->DrawEditBox(WID_AID_BREAK_STR_EDIT_BOX);
-
/* Paint the company icons */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
NWidgetCore *button = this->GetWidget<NWidgetCore>(i + WID_AID_COMPANY_BUTTON_START);
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 566329e7e..b0e03fe02 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -491,10 +491,6 @@ public:
this->vscroll->SetCount(_fios_items.Length());
this->DrawWidgets();
-
- if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO || _saveload_mode == SLD_SAVE_HEIGHTMAP) {
- this->DrawEditBox(WID_SL_SAVE_OSK_TITLE);
- }
}
virtual void OnClick(Point pt, int widget, int click_count)
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 08dd60064..b28c968ae 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -521,12 +521,6 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
}
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- this->DrawEditBox(WID_GL_RANDOM_EDITBOX);
- }
-
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 630b75013..b99440230 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -773,7 +773,7 @@ void QueryString::HandleEditBox(Window *w, int wid)
}
}
-void QueryString::DrawEditBox(Window *w, int wid)
+void QueryString::DrawEditBox(const Window *w, int wid) const
{
const NWidgetBase *wi = w->GetWidget<NWidgetBase>(wid);
@@ -818,11 +818,6 @@ void QueryStringBaseWindow::HandleEditBox(int wid)
this->QueryString::HandleEditBox(this, wid);
}
-void QueryStringBaseWindow::DrawEditBox(int wid)
-{
- this->QueryString::DrawEditBox(this, wid);
-}
-
void QueryStringBaseWindow::OnOpenOSKWindow(int wid)
{
ShowOnScreenKeyboard(this, wid, 0, 0);
@@ -870,13 +865,6 @@ struct QueryStringWindow : public QueryStringBaseWindow
}
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
-
- this->DrawEditBox(WID_QS_TEXT);
- }
-
virtual void SetStringParameters(int widget) const
{
if (widget == WID_QS_CAPTION) SetDParam(0, this->caption);
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 9709bf263..7cab48730 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -463,12 +463,6 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
free(pre_buf);
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- this->DrawEditBox(WID_NC_TEXTBOX);
- }
-
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
{
Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index d85307206..1137d36a9 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -489,9 +489,6 @@ public:
this->DrawWidgets();
- /* Edit box to filter for keywords */
- this->DrawEditBox(WID_NCL_FILTER);
-
switch (this->content.SortType()) {
case WID_NCL_CHECKBOX - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_CHECKBOX, arrow); break;
case WID_NCL_TYPE - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_TYPE, arrow); break;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 0209f0f4f..77341af8a 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -588,8 +588,6 @@ public:
this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == NULL || !sel->online || sel->info.grfconfig == NULL || !sel->info.version_compatible || sel->info.compatible);
this->DrawWidgets();
- /* Edit box to set client name */
- this->DrawEditBox(WID_NG_CLIENT);
}
void DrawDetails(const Rect &r) const
@@ -1070,15 +1068,6 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
}
}
- virtual void OnPaint()
- {
- /* draw basic widgets */
- this->DrawWidgets();
-
- /* editbox to set game name */
- this->DrawEditBox(WID_NSS_GAMENAME);
- }
-
virtual void OnClick(Point pt, int widget, int click_count)
{
this->field = widget;
@@ -2155,12 +2144,6 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
NetworkChangeCompanyPassword(_local_company, this->edit_str_buf);
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- this->DrawEditBox(WID_NCP_PASSWORD);
- }
-
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 114895534..80010c301 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -736,12 +736,6 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
}
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- if (this->editable) this->DrawEditBox(WID_NS_FILTER);
- }
-
/**
* Pick the palette for the sprite of the grf to display.
* @param c grf to display.
diff --git a/src/querystring_gui.h b/src/querystring_gui.h
index 6296435fe..db4216aa6 100644
--- a/src/querystring_gui.h
+++ b/src/querystring_gui.h
@@ -55,7 +55,7 @@ struct QueryString {
private:
bool HasEditBoxFocus(const Window *w, int wid) const;
public:
- void DrawEditBox(Window *w, int wid);
+ void DrawEditBox(const Window *w, int wid) const;
void HandleEditBox(Window *w, int wid);
HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, EventState &state);
};
@@ -76,7 +76,6 @@ struct QueryStringBaseWindow : public Window, public QueryString {
free(this->edit_str_buf);
}
- void DrawEditBox(int wid);
void HandleEditBox(int wid);
HandleEditBoxResult HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index a51b7cb51..29f64415d 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -2047,7 +2047,6 @@ struct GameSettingsWindow : QueryStringBaseWindow {
this->valuedropdown_entry = NULL;
}
this->DrawWidgets();
- this->DrawEditBox(WID_GS_FILTER);
}
virtual void SetStringParameters(int widget) const
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 113a45736..2d2d1529d 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -204,7 +204,6 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
{
if (this->signs.NeedRebuild()) this->BuildSortSignList();
this->DrawWidgets();
- if (!this->IsShaded()) this->DrawEditBox(WID_SIL_FILTER_TEXT);
}
virtual void DrawWidget(const Rect &r, int widget) const
@@ -523,12 +522,6 @@ struct SignWindow : QueryStringBaseWindow, SignList {
}
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- if (!this->IsShaded()) this->DrawEditBox(WID_QES_TEXT);
- }
-
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 031869c88..9afbf5c8b 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -1056,12 +1056,6 @@ public:
if (success) this->RandomTownName();
}
- virtual void OnPaint()
- {
- this->DrawWidgets();
- if (!this->IsShaded()) this->DrawEditBox(WID_TF_TOWN_NAME_EDITBOX);
- }
-
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
diff --git a/src/widget.cpp b/src/widget.cpp
index 2b932f9a1..0b0ed6d8e 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -18,6 +18,7 @@
#include "transparency.h"
#include "core/geometry_func.hpp"
#include "settings_type.h"
+#include "querystring_gui.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -2364,9 +2365,12 @@ void NWidgetLeaf::Draw(const Window *w)
DrawMatrix(r, this->colour, clicked, this->widget_data);
break;
- case WWT_EDITBOX:
+ case WWT_EDITBOX: {
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, FR_LOWERED | FR_DARKENED);
+ const QueryString *query = dynamic_cast<const QueryString*>(w);
+ if (query != NULL) query->DrawEditBox(w, this->index);
break;
+ }
case WWT_CAPTION:
if (this->index >= 0) w->SetStringParameters(this->index);