# HG changeset patch # User bjarni # Date 1171390056 0 # Node ID 4b42fb40e6d27a82fbdf49fc980ee39f4e5a6aae # Parent 8f231ee779cbe7578be7d38395ec0d8d96c3c29e (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods diff -r 8f231ee779cb -r 4b42fb40e6d2 src/aircraft_gui.cpp --- 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: { diff -r 8f231ee779cb -r 4b42fb40e6d2 src/industry_gui.cpp --- 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; diff -r 8f231ee779cb -r 4b42fb40e6d2 src/main_gui.cpp --- 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; diff -r 8f231ee779cb -r 4b42fb40e6d2 src/news_gui.cpp --- 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); } diff -r 8f231ee779cb -r 4b42fb40e6d2 src/roadveh_gui.cpp --- 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: { diff -r 8f231ee779cb -r 4b42fb40e6d2 src/ship_gui.cpp --- 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: { diff -r 8f231ee779cb -r 4b42fb40e6d2 src/smallmap_gui.cpp --- 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: diff -r 8f231ee779cb -r 4b42fb40e6d2 src/town_gui.cpp --- 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: diff -r 8f231ee779cb -r 4b42fb40e6d2 src/train_gui.cpp --- 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: { diff -r 8f231ee779cb -r 4b42fb40e6d2 src/viewport.cpp --- 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) diff -r 8f231ee779cb -r 4b42fb40e6d2 src/window.cpp --- 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(); } } diff -r 8f231ee779cb -r 4b42fb40e6d2 src/window.h --- 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);