(svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods cpp_gui
authorbjarni
Tue, 13 Feb 2007 18:07:36 +0000
branchcpp_gui
changeset 6244 4b42fb40e6d2
parent 6243 8f231ee779cb
child 6245 6fa82c6ee8ca
(svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
src/aircraft_gui.cpp
src/industry_gui.cpp
src/main_gui.cpp
src/news_gui.cpp
src/roadveh_gui.cpp
src/ship_gui.cpp
src/smallmap_gui.cpp
src/town_gui.cpp
src/train_gui.cpp
src/viewport.cpp
src/window.cpp
src/window.h
--- a/src/aircraft_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/aircraft_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -294,7 +294,7 @@
 		/* draw the flag plus orders */
 		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
 		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
-		DrawWindowViewport(w);
+		w->DrawViewport();
 	} break;
 
 	case WE_CLICK: {
--- a/src/industry_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/industry_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -343,7 +343,7 @@
 			}
 		}
 
-		DrawWindowViewport(w);
+		w->DrawViewport();
 		}
 		break;
 
--- a/src/main_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/main_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -2239,7 +2239,7 @@
 
 	switch (e->event) {
 	case WE_PAINT:
-		DrawWindowViewport(w);
+		w->DrawViewport();
 		if (_game_mode == GM_MENU) {
 			off_x = _screen.width / 2;
 
--- a/src/news_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/news_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -139,7 +139,7 @@
 				} else {
 					byte bk = _display_opt;
 					_display_opt &= ~DO_TRANS_BUILDINGS;
-					DrawWindowViewport(w);
+					w->DrawViewport();
 					_display_opt = bk;
 
 					/* Shade the viewport into gray, or color*/
@@ -166,7 +166,7 @@
 					COPY_IN_DPARAM(0, ni->params, lengthof(ni->params));
 					DrawStringMultiCenter(140, 38, ni->string_id, 276);
 				} else {
-					DrawWindowViewport(w);
+					w->DrawViewport();
 					COPY_IN_DPARAM(0, ni->params, lengthof(ni->params));
 					DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, 276);
 				}
--- a/src/roadveh_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/roadveh_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -240,7 +240,7 @@
 		/* draw the flag plus orders */
 		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
 		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
-		DrawWindowViewport(w);
+		w->DrawViewport();
 	} break;
 
 	case WE_CLICK: {
--- a/src/ship_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/ship_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -247,7 +247,7 @@
 		/* draw the flag plus orders */
 		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
 		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
-		DrawWindowViewport(w);
+		w->DrawViewport();
 	} break;
 
 		case WE_CLICK: {
--- a/src/smallmap_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/smallmap_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -1020,7 +1020,7 @@
 		SetDParam(0, w->window_number + 1);
 
 		w->DrawWidgets();
-		DrawWindowViewport(w);
+		w->DrawViewport();
 		break;
 
 	case WE_CLICK:
--- a/src/town_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/town_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -252,7 +252,7 @@
 		SetDParam(1, t->max_mail);
 		DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, 0);
 
-		DrawWindowViewport(w);
+		w->DrawViewport();
 		break;
 
 	case WE_CLICK:
--- a/src/train_gui.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/train_gui.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -231,7 +231,7 @@
 		/* draw the flag plus orders */
 		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
 		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
-		DrawWindowViewport(w);
+		w->DrawViewport();
 	}	break;
 
 	case WE_CLICK: {
--- a/src/viewport.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/viewport.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -1332,17 +1332,17 @@
 	ViewportDrawChk(vp, left, top, right, bottom);
 }
 
-void DrawWindowViewport(const Window *w)
+void Window::DrawViewport() const
 {
 	DrawPixelInfo *dpi = _cur_dpi;
 
-	dpi->left += w->left;
-	dpi->top += w->top;
-
-	ViewportDraw(w->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height);
-
-	dpi->left -= w->left;
-	dpi->top -= w->top;
+	dpi->left += left;
+	dpi->top += top;
+
+	ViewportDraw(viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height);
+
+	dpi->left -= left;
+	dpi->top -= top;
 }
 
 void UpdateViewportPosition(Window *w)
--- a/src/window.cpp	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/window.cpp	Tue Feb 13 18:07:36 2007 +0000
@@ -1889,17 +1889,17 @@
 	}
 }
 
-void InvalidateThisWindowData(Window *w)
+void Window::InvalidateData()
 {
-	CallWindowEventNP(w, WE_INVALIDATE_DATA);
-	w->SetDirty();
+	CallWindowEventNP(this, WE_INVALIDATE_DATA);
+	this->SetDirty();
 }
 
 void InvalidateWindowData(WindowClass cls, WindowNumber number)
 {
 	Window *w;
 	FOR_ALL_WINDOWS(w) {
-		if (w->window_class == cls && w->window_number == number) InvalidateThisWindowData(w);
+		if (w->window_class == cls && w->window_number == number) w->InvalidateData();
 	}
 }
 
@@ -1907,7 +1907,7 @@
 {
 	Window *w;
 	FOR_ALL_WINDOWS(w) {
-		if (w->window_class == cls) InvalidateThisWindowData(w);
+		if (w->window_class == cls) w->InvalidateData();
 	}
 }
 
--- a/src/window.h	Tue Feb 13 13:00:37 2007 +0000
+++ b/src/window.h	Tue Feb 13 18:07:36 2007 +0000
@@ -418,8 +418,12 @@
 
 	void AssignWidget(const Widget *widget);
 
+	void InvalidateData();
 	void InvalidateWidget(byte widget_index) const;
 
+	/* viewport.cpp */
+	void DrawViewport() const;
+
 	/* widget.cpp */
 	int GetWidgetFromPos(int x, int y) const;
 	void DrawWidgets() const;
@@ -755,7 +759,7 @@
 Window *AllocateWindowDesc(const WindowDesc *desc);
 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number);
 
-void DrawWindowViewport(const Window *w);
+//void DrawWindowViewport(const Window *w);
 
 /**
  * Sets the enabled/disabled status of a widget.
@@ -908,7 +912,7 @@
 void UnInitWindowSystem(void);
 void ResetWindowSystem(void);
 void InputLoop(void);
-void InvalidateThisWindowData(Window *w);
+//void InvalidateThisWindowData(Window *w);
 void InvalidateWindowData(WindowClass cls, WindowNumber number);
 //void RaiseWindowButtons(Window *w);
 void RelocateAllWindows(int neww, int newh);