summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-12-30 13:16:31 +0000
committeralberth <alberth@openttd.org>2010-12-30 13:16:31 +0000
commit22a13850cb0640d4fdfd8da66bc46ce20e2eb309 (patch)
treeaab09e147008a843c11fcb356d7e9c7993ea680d
parent703ff560c19e2b21597e9ed25b3e394a2085702a (diff)
downloadopenttd-22a13850cb0640d4fdfd8da66bc46ce20e2eb309.tar.xz
(svn r21665) -Codechange: Make GetCallbackWnd a method of _thd.
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/tilehighlight_type.h1
-rw-r--r--src/viewport.cpp13
-rw-r--r--src/window.cpp11
-rw-r--r--src/window_gui.h2
5 files changed, 17 insertions, 12 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 37c9841d0..c53e40ba5 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -482,7 +482,7 @@ public:
this->SetDirty();
- if (GetCallbackWnd() == this &&
+ if (_thd.GetCallbackWnd() == this &&
((_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
this->selected_type == INVALID_INDUSTRYTYPE ||
!this->enabled[this->selected_index])) {
diff --git a/src/tilehighlight_type.h b/src/tilehighlight_type.h
index 291b950d4..0e9ce8bc6 100644
--- a/src/tilehighlight_type.h
+++ b/src/tilehighlight_type.h
@@ -75,6 +75,7 @@ struct TileHighlightData {
ViewportDragDropSelectionProcess select_proc; ///< The procedure that has to be called when the selection is done.
bool IsDraggingDiagonal();
+ Window *GetCallbackWnd();
};
#endif /* TILEHIGHLIGHT_TYPE_H */
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 2ff4cf635..1b8e5965b 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1871,7 +1871,7 @@ static void PlaceObject()
_tile_fract_coords.x = pt.x & TILE_UNIT_MASK;
_tile_fract_coords.y = pt.y & TILE_UNIT_MASK;
- w = GetCallbackWnd();
+ w = _thd.GetCallbackWnd();
if (w != NULL) w->OnPlaceObject(pt, TileVirtXY(pt.x, pt.y));
}
@@ -2017,6 +2017,17 @@ bool TileHighlightData::IsDraggingDiagonal()
}
/**
+ * Get the window that started the current highlighting.
+ * @return The window that requested the current tile highlighting, or \c NULL if not available.
+ */
+Window *TileHighlightData::GetCallbackWnd()
+{
+ return FindWindowById(this->window_class, this->window_number);
+}
+
+
+
+/**
* Updates tile highlighting for all cases.
* Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size
* Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice,
diff --git a/src/window.cpp b/src/window.cpp
index ae9a683ac..3e601d212 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1400,16 +1400,11 @@ static void DecreaseWindowCounters()
}
}
-Window *GetCallbackWnd()
-{
- return FindWindowById(_thd.window_class, _thd.window_number);
-}
-
static void HandlePlacePresize()
{
if (_special_mouse_mode != WSM_PRESIZE) return;
- Window *w = GetCallbackWnd();
+ Window *w = _thd.GetCallbackWnd();
if (w == NULL) return;
Point pt = GetTileBelowCursor();
@@ -1430,7 +1425,7 @@ static EventState HandleDragDrop()
if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
if (_left_button_down) return ES_HANDLED;
- Window *w = GetCallbackWnd();
+ Window *w = _thd.GetCallbackWnd();
if (w != NULL) {
/* send an event in client coordinates. */
@@ -1454,7 +1449,7 @@ static EventState HandleMouseDrag()
if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
if (!_left_button_down || (_cursor.delta.x == 0 && _cursor.delta.y == 0)) return ES_NOT_HANDLED;
- Window *w = GetCallbackWnd();
+ Window *w = _thd.GetCallbackWnd();
if (w != NULL) {
/* Send an event in client coordinates. */
diff --git a/src/window_gui.h b/src/window_gui.h
index 90e3135be..34347bfe6 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -821,8 +821,6 @@ enum SpecialMouseMode {
};
extern SpecialMouseMode _special_mouse_mode;
-Window *GetCallbackWnd();
-
void SetFocusedWindow(Window *w);
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);