summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-05-30 12:06:18 +0000
committeralberth <alberth@openttd.org>2010-05-30 12:06:18 +0000
commit113f3ef0ebafcc637d061e955a162751cf011f8f (patch)
tree97b540ea5d7e931e802972ccbcee537744239343 /src
parentfc82d9cd77224c458c05ce2fd749e58e9cee5299 (diff)
downloadopenttd-113f3ef0ebafcc637d061e955a162751cf011f8f.tar.xz
(svn r19904) -Codechange: Make EventState usable outside Window context.
Diffstat (limited to 'src')
-rw-r--r--src/misc_gui.cpp6
-rw-r--r--src/querystring_gui.h2
-rw-r--r--src/window.cpp6
-rw-r--r--src/window_gui.h12
4 files changed, 13 insertions, 13 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 4dc79cbba..fa24d574b 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1158,11 +1158,11 @@ bool QueryString::HasEditBoxFocus(const Window *w, int wid) const
return w->parent->nested_focus != NULL && w->parent->nested_focus->type == WWT_EDITBOX;
}
-HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state)
+HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, EventState &state)
{
if (!QueryString::HasEditBoxFocus(w, wid)) return HEBR_NOT_FOCUSED;
- state = Window::ES_HANDLED;
+ state = ES_HANDLED;
switch (keycode) {
case WKC_ESC: return HEBR_CANCEL;
@@ -1196,7 +1196,7 @@ HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key
if (IsValidChar(key, this->afilter)) {
if (InsertTextBufferChar(&this->text, key)) w->SetWidgetDirty(wid);
} else {
- state = Window::ES_NOT_HANDLED;
+ state = ES_NOT_HANDLED;
}
}
diff --git a/src/querystring_gui.h b/src/querystring_gui.h
index 494e38c8e..62810a044 100644
--- a/src/querystring_gui.h
+++ b/src/querystring_gui.h
@@ -56,7 +56,7 @@ private:
public:
void DrawEditBox(Window *w, int wid);
void HandleEditBox(Window *w, int wid);
- HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state);
+ HandleEditBoxResult HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, EventState &state);
};
struct QueryStringBaseWindow : public Window, public QueryString {
diff --git a/src/window.cpp b/src/window.cpp
index 117244988..85eb02eda 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1938,14 +1938,14 @@ void HandleKeypress(uint32 raw_key)
/* Check if the focused window has a focused editbox */
if (EditBoxInGlobalFocus()) {
/* All input will in this case go to the focused window */
- if (_focused_window->OnKeyPress(key, keycode) == Window::ES_HANDLED) return;
+ if (_focused_window->OnKeyPress(key, keycode) == ES_HANDLED) return;
}
/* Call the event, start with the uppermost window, but ignore the toolbar. */
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
if (w->window_class == WC_MAIN_TOOLBAR) continue;
- if (w->OnKeyPress(key, keycode) == Window::ES_HANDLED) return;
+ if (w->OnKeyPress(key, keycode) == ES_HANDLED) return;
}
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
@@ -1961,7 +1961,7 @@ void HandleCtrlChanged()
/* Call the event, start with the uppermost window. */
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- if (w->OnCTRLStateChange() == Window::ES_HANDLED) return;
+ if (w->OnCTRLStateChange() == ES_HANDLED) return;
}
}
diff --git a/src/window_gui.h b/src/window_gui.h
index 68fbfc90e..b1512abf9 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -19,6 +19,12 @@
#include "tile_type.h"
#include "widget_type.h"
+/** State of handling an event. */
+enum EventState {
+ ES_HANDLED, ///< The passed event is handled.
+ ES_NOT_HANDLED, ///< The passed event is not handled.
+};
+
/**
* Flags to describe the look of the frame
*/
@@ -334,12 +340,6 @@ struct ViewportData : ViewPort {
* Data structure for an opened window
*/
struct Window : ZeroedMemoryAllocator {
- /** State whether an event is handled or not */
- enum EventState {
- ES_HANDLED, ///< The passed event is handled
- ES_NOT_HANDLED, ///< The passed event is not handled
- };
-
protected:
void InitializeData(const WindowDesc *desc, WindowNumber window_number);
void InitializePositionSize(int x, int y, int min_width, int min_height);