changeset 9273:72a6d2e60834 draft

(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
author rubidium <rubidium@openttd.org>
date Sat, 17 May 2008 12:48:06 +0000
parents 22954a91c5aa
children 85a62fb8608f
files src/airport_gui.cpp src/autoreplace_gui.cpp src/bridge_gui.cpp src/build_vehicle_gui.cpp src/cheat_gui.cpp src/depot_gui.cpp src/dock_gui.cpp src/engine_gui.cpp src/genworld_gui.cpp src/graph_gui.cpp src/group_gui.cpp src/industry_gui.cpp src/intro_gui.cpp src/main_gui.cpp src/misc_gui.cpp src/music_gui.cpp src/network/network_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/order_gui.cpp src/osk_gui.cpp src/player_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/settings_gui.cpp src/signs_gui.cpp src/smallmap_gui.cpp src/station_gui.cpp src/statusbar_gui.cpp src/subsidy_gui.cpp src/terraform_gui.cpp src/timetable_gui.cpp src/toolbar_gui.cpp src/town_gui.cpp src/transparency_gui.cpp src/tree_gui.cpp src/vehicle_gui.cpp src/viewport.cpp src/widget.cpp src/widgets/dropdown.cpp src/window_gui.h
diffstat 41 files changed, 158 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -69,7 +69,7 @@
 {
 	switch (e->event) {
 		case WE_PAINT:
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			break;
 
 		case WE_CLICK:
@@ -197,7 +197,7 @@
 
 		if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		/* strings such as 'Size' and 'Coverage Area' */
 		int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false);
 		text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -360,7 +360,7 @@
 			this->widget[RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN].data = _rail_types_list[sel_railtype];
 		}
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* sets up the string for the vehicle that is being replaced to */
 		if (selected_id[0] != INVALID_ENGINE) {
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -75,7 +75,7 @@
 			break;
 
 		case WE_PAINT: {
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			uint y = 15;
 			for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1114,7 +1114,7 @@
 		/* Set text of sort by dropdown */
 		this->widget[BUILD_VEHICLE_WIDGET_SORT_DROPDOWN].data = _sort_listing[this->vehicle_type][this->sort_criteria];
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		DrawEngineList(this->vehicle_type, this->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, this->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, this->eng_list, this->vscroll.pos, max, this->sel_engine, 0, DEFAULT_GROUP);
 
@@ -1129,7 +1129,7 @@
 			}
 		}
 
-		DrawSortButtonState(this, BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
+		this->DrawSortButtonState(BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
 	}
 
 	virtual void OnDoubleClick(Point pt, int widget)
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -129,7 +129,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, width - 50);
 
 		for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) {
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -365,7 +365,7 @@
 			SetDParam(0, depot->town_index);
 		}
 
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		num = this->vscroll.pos * boxes_in_each_row;
 		maxval = min(this->engine_count, num + (rows_in_display * boxes_in_each_row));
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -129,7 +129,7 @@
 {
 	switch (e->event) {
 	case WE_PAINT:
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 		w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), 7, 8, 9, WIDGET_LIST_END);
 		break;
 
@@ -238,7 +238,7 @@
 	case WE_PAINT: {
 		int rad = (_patches.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
 
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		if (_station_show_coverage) {
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
@@ -318,7 +318,7 @@
 	case WE_CREATE: w->LowerWidget(_ship_depot_direction + 3); break;
 
 	case WE_PAINT:
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		DrawShipDepotSprite(67, 35, 0);
 		DrawShipDepotSprite(35, 51, 1);
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -74,7 +74,7 @@
 		const DrawEngineInfo* dei;
 		int width;
 
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		SetDParam(0, GetEngineCategoryName(engine));
 		DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -315,7 +315,7 @@
 		SetDParam(2, 1 << _patches_newgame.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
 		SetDParam(3, _patches_newgame.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		this->DrawEditBox(GLAND_RANDOM_EDITBOX);
 
@@ -667,7 +667,7 @@
 		SetDParam(2, 1 << _patches_newgame.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
 		SetDParam(3, _patches_newgame.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 	}
 
 	virtual void OnClick(Point pt, int widget)
@@ -873,7 +873,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw the % complete with a bar and a text */
 		DrawFrameRect(19, 20, (this->width - 18), 37, 14, FR_BORDERONLY);
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -285,7 +285,7 @@
 				w->RaiseWidget(p->index + 3);
 			}
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			FOR_ALL_PLAYERS(p) {
 				if (!p->is_active) continue;
@@ -384,7 +384,7 @@
 			GraphDrawer gd;
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			gd.left = 2;
 			gd.top = 18;
@@ -455,7 +455,7 @@
 			GraphDrawer gd;
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			gd.left = 2;
 			gd.top = 18;
@@ -522,7 +522,7 @@
 			GraphDrawer gd;
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			gd.left = 2;
 			gd.top = 18;
@@ -589,7 +589,7 @@
 			GraphDrawer gd;
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			gd.left = 2;
 			gd.top = 18;
@@ -658,7 +658,7 @@
 			GraphDrawer gd;
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			gd.left = 2;
 			gd.top = 18;
@@ -724,7 +724,7 @@
 		case WE_PAINT: {
 			GraphDrawer gd;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			int x = 495;
 			int y = 24;
@@ -886,7 +886,7 @@
 			const Player* plist[MAX_PLAYERS];
 			const Player* p;
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			uint pl_num = 0;
 			FOR_ALL_PLAYERS(p) if (p->is_active) plist[pl_num++] = p;
@@ -973,7 +973,7 @@
 		int color_done, color_notdone;
 
 		/* Draw standard stuff */
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Check if the currently selected player is still active. */
 		if (player == INVALID_PLAYER || !GetPlayer(player)->is_active) {
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -403,7 +403,7 @@
 		/* Set text of sort by dropdown */
 		this->widget[GRP_WIDGET_SORT_BY_DROPDOWN].data = _vehicle_sort_listing[this->vehicles.sort_type];
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw Matrix Group
 			* The selected group is drawn in white */
@@ -451,7 +451,7 @@
 			DrawStringRightAligned(187, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
 		}
 
-		DrawSortButtonState(this, GRP_WIDGET_SORT_BY_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
+		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
 
 		/* Draw Matrix Vehicle according to the vehicle list built before */
 		max = min(this->vscroll2.pos + this->vscroll2.cap, this->vehicles.list_length);
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -204,7 +204,7 @@
 
 		SetVScrollCount(this, this->count);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* and now with the matrix painting */
 		for (byte i = 0; i < this->vscroll.cap && ((i + this->vscroll.pos) < this->count); i++) {
@@ -481,7 +481,7 @@
 		bool has_accept = false;
 
 		SetDParam(0, this->window_number);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		if (HasBit(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) {
 			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
@@ -564,7 +564,7 @@
 			return;
 		}
 
-		DrawWindowViewport(this);
+		this->DrawViewport();
 	}
 
 	virtual void OnClick(Point pt, int widget)
@@ -840,8 +840,8 @@
 
 			SetVScrollCount(w, _num_industry_sort);
 
-			DrawWindowWidgets(w);
-			DrawSortButtonState(w, IDW_SORTBYNAME + (_industry_sort_order >> 1), _industry_sort_order & 1 ? SBS_DOWN : SBS_UP);
+			w->DrawWidgets();
+			w->DrawSortButtonState(IDW_SORTBYNAME + (_industry_sort_order >> 1), _industry_sort_order & 1 ? SBS_DOWN : SBS_UP);
 
 			uint pos = w->vscroll.pos;
 			int n = 0;
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -82,7 +82,7 @@
 			w->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _opt_newgame.landscape == LT_TROPIC);
 			w->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _opt_newgame.landscape == LT_TOYLAND);
 			SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			break;
 
 		case WE_CLICK:
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -224,7 +224,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowViewport(this);
+		this->DrawViewport();
 		if (_game_mode == GM_MENU) {
 			int off_x = _screen.width / 2;
 
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -83,7 +83,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		DoDrawStringCentered(140, 16, this->landinfo_data[0], TC_LIGHT_BLUE);
 		DoDrawStringCentered(140, 27, this->landinfo_data[1], TC_FROMSTRING);
@@ -289,7 +289,7 @@
 			"  Chris Sawyer - For an amazing game!"
 		};
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Show original copyright and revision version */
 		DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING);
@@ -371,7 +371,7 @@
 		};
 
 		CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
 
 		/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages.
@@ -998,7 +998,7 @@
 	virtual void OnPaint()
 	{
 		SetDParam(0, this->caption);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		this->DrawEditBox(QUERY_STR_WIDGET_TEXT);
 	}
@@ -1153,7 +1153,7 @@
 	virtual void OnPaint()
 	{
 		CopyInDParam(0, this->params, lengthof(this->params));
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		CopyInDParam(0, this->params, lengthof(this->params));
 
 		DrawStringMultiCenter(this->width / 2, (this->height / 2) - 10, this->message, this->width - 2);
@@ -1419,7 +1419,7 @@
 		int y;
 
 		SetVScrollCount(this, _fios_num);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		DrawFiosTexts(this->width);
 
 		if (_savegame_sort_dirty) {
@@ -1428,7 +1428,7 @@
 		}
 
 		GfxFillRect(this->widget[7].left + 1, this->widget[7].top + 1, this->widget[7].right, this->widget[7].bottom, 0xD7);
-		DrawSortButtonState(this, _savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
+		this->DrawSortButtonState(_savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
 
 		y = this->widget[7].top + 1;
 		for (pos = this->vscroll.pos; pos < _fios_num; pos++) {
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -204,7 +204,7 @@
 		w->SetWidgetDisabledState(11, msf.playlist <= 3);
 		w->LowerWidget(3);
 		w->LowerWidget(4);
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		GfxFillRect(3, 23, 3 + 177, 23 + 191, 0);
 		GfxFillRect(251, 23, 251 + 177, 23 + 191, 0);
@@ -346,7 +346,7 @@
 
 		w->RaiseWidget(7);
 		w->RaiseWidget(9);
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		GfxFillRect(187, 16, 200, 33, 0);
 
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -318,7 +318,7 @@
 
 		SetDParam(0, 0x00);
 		SetDParam(1, _lan_internet_types_dropdown[_network_lan_internet]);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Edit box to set player name */
 		this->DrawEditBox(NGWW_PLAYER);
@@ -327,9 +327,9 @@
 
 		/* Sort based on widgets: name, clients, compatibility */
 		switch (this->servers.sort_type) {
-			case NGWW_NAME    - NGWW_NAME: DrawSortButtonState(this, NGWW_NAME,    arrow); break;
-			case NGWW_CLIENTS - NGWW_NAME: DrawSortButtonState(this, NGWW_CLIENTS, arrow); break;
-			case NGWW_INFO    - NGWW_NAME: DrawSortButtonState(this, NGWW_INFO,    arrow); break;
+			case NGWW_NAME    - NGWW_NAME: this->DrawSortButtonState(NGWW_NAME,    arrow); break;
+			case NGWW_CLIENTS - NGWW_NAME: this->DrawSortButtonState(NGWW_CLIENTS, arrow); break;
+			case NGWW_INFO    - NGWW_NAME: this->DrawSortButtonState(NGWW_INFO,    arrow); break;
 		}
 
 		uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3;
@@ -727,7 +727,7 @@
 		SetDParam(3, _network_game_info.companies_max);
 		SetDParam(4, _network_game_info.spectators_max);
 		SetDParam(5, STR_NETWORK_LANG_ANY + _network_game_info.server_lang);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* editbox to set game name */
 		this->DrawEditBox(NSSW_GAMENAME);
@@ -1036,7 +1036,7 @@
 
 		/* Draw window widgets */
 		SetDParamStr(0, gi->server_name);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw company list */
 		pos = this->vscroll.pos;
@@ -1410,7 +1410,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw the actions */
 		int sel = this->sel_index;
@@ -1514,7 +1514,7 @@
 		/* Check if we need to reset the height */
 		if (!this->CheckClientListHeight()) return;
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int y = CLNWND_OFFSET;
 
@@ -1606,7 +1606,7 @@
 	virtual void OnPaint()
 	{
 		uint8 progress; // used for progress bar
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_GREY);
 		switch (_network_join_status) {
@@ -1851,7 +1851,7 @@
 			STR_NETWORK_CHAT_CLIENT_CAPTION
 		};
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		assert((uint)this->dtype < lengthof(chat_captions));
 		DrawStringRightAligned(this->widget[2].left - 2, this->widget[2].top + 1, chat_captions[this->dtype], TC_BLACK);
@@ -1953,7 +1953,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		this->DrawEditBox(4);
 	}
 
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -150,7 +150,7 @@
 		SetVScrollCount(this, n);
 
 		this->SetWidgetDisabledState(ANGRFW_ADD, this->sel == NULL || this->sel->IsOpenTTDBaseGRF());
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		GfxFillRect(wl->left + 1, wl->top + 1, wl->right, wl->bottom, 0xD7);
 
@@ -345,7 +345,7 @@
 			if (this->sel->IsOpenTTDBaseGRF()) this->DisableWidget(SNGRFS_REMOVE);
 		}
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw NewGRF list */
 		int y = this->widget[SNGRFS_FILE_LIST].top;
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -182,7 +182,7 @@
 					/* Back up transparency options to draw news view */
 					TransparencyOptionBits to_backup = _transparency_opt;
 					_transparency_opt = 0;
-					DrawWindowViewport(this);
+					this->DrawViewport();
 					_transparency_opt = to_backup;
 
 					/* Shade the viewport into gray, or color*/
@@ -204,12 +204,12 @@
 				break;
 
 			default:
-				DrawWindowWidgets(this);
+				this->DrawWidgets();
 				if (!(this->ni->flags & NF_VIEWPORT)) {
 					CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
 					DrawStringMultiCenter(140, 38, this->ni->string_id, 276);
 				} else {
-					DrawWindowViewport(this);
+					this->DrawViewport();
 					CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
 					DrawStringMultiCenter(this->width / 2, this->height - 16, this->ni->string_id, this->width - 4);
 				}
@@ -647,7 +647,7 @@
 			int y = 19;
 
 			SetVScrollCount(w, _total_news);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			if (_total_news == 0) break;
 			NewsID show = min(_total_news, w->vscroll.cap);
@@ -764,7 +764,7 @@
 		if (_news_ticker_sound) this->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
 
 		this->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = _message_opt[this->state];
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw the string of each setting on each button. */
 		for (int i = 0, y = 26; i < NT_END; i++, y += 12) {
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -709,7 +709,7 @@
 		}
 
 		SetDParam(0, this->vehicle->index);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int y = 15;
 
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -98,7 +98,7 @@
 		this->ChangeOskDiabledState(shift);
 
 		SetDParam(0, this->caption);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		for (uint i = 0; i < OSK_KEYBOARD_ENTRIES; i++) {
 			DrawCharCentered(_keyboard[shift][i],
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -193,7 +193,7 @@
 		SetDParam(0, p->index);
 		SetDParam(1, p->index);
 		SetDParam(2, LOAN_INTERVAL);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		DrawPlayerEconomyStats(p, this->small);
 	}
@@ -398,7 +398,7 @@
 		SetDParam(0, STR_00D1_DARK_BLUE + p->livery[scheme].colour1);
 		SetDParam(1, STR_00D1_DARK_BLUE + p->livery[scheme].colour2);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
 			if (_livery_class[scheme] == this->livery_class) {
@@ -834,7 +834,7 @@
 				PFW_WIDGET_GLASSES, PFW_WIDGET_GLASSES_L, PFW_WIDGET_GLASSES_R, WIDGET_LIST_END);
 		}
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw dynamic button value and labels for the advanced player face selection window */
 		if (this->advanced) {
@@ -1213,7 +1213,7 @@
 		SetDParam(0, p->index);
 		SetDParam(1, p->index);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Player face */
 		DrawPlayerFace(p->face, p->player_color, 2, 16);
@@ -1367,7 +1367,7 @@
 			Player *p = GetPlayer((PlayerID)w->window_number);
 			SetDParam(0, STR_COMPANY_NAME);
 			SetDParam(1, p->index);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			DrawPlayerFace(p->face, p->player_color, 2, 16);
 
@@ -1436,7 +1436,7 @@
 		this->widget[0].right = this->width - 1;
 		this->widget[0].bottom = this->height - 1;
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Center Highscore/Endscreen background */
 		*x = max(0, (_screen.width  / 2) - (640 / 2));
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -567,7 +567,7 @@
 	switch (e->event) {
 	case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
 
-	case WE_PAINT: DrawWindowWidgets(w); break;
+	case WE_PAINT: w->DrawWidgets(); break;
 
 	case WE_CLICK:
 		if (e->we.click.widget >= RTW_BUILD_NS) {
@@ -899,7 +899,7 @@
 		}
 
 		SetDParam(0, GetStationClassName(_railstation.station_class));
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		int y_offset = newstations ? 90 : 0;
 
@@ -1277,7 +1277,7 @@
 			w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1);
 			w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20);
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			/* The 'hardcoded' off sets are needed because they are reused sprites. */
 			DrawSignalSprite(w, BSW_SEMAPHORE_NORM,  SPR_IMG_SIGNAL_SEMAPHORE_NORM,   0, 12); // xsize of sprite + 1 ==  9
@@ -1399,7 +1399,7 @@
 	case WE_CREATE: w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); break;
 
 	case WE_PAINT: {
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		DrawTrainDepotSprite(70, 17, DIAGDIR_NE, _cur_railtype);
 		DrawTrainDepotSprite(70, 69, DIAGDIR_SE, _cur_railtype);
@@ -1477,7 +1477,7 @@
 			w->SetWidgetLoweredState(i + BRWW_WAYPOINT_1, (w->hscroll.pos + i) == _cur_waypoint_type);
 		}
 
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 
 		for (i = 0; i < w->hscroll.cap; i++) {
 			if (w->hscroll.pos + i < w->hscroll.count) {
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -468,7 +468,7 @@
 				RTW_BUS_STATION,
 				RTW_TRUCK_STATION,
 				WIDGET_LIST_END);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			break;
 
 		case WE_CLICK:
@@ -733,7 +733,7 @@
 			break;
 
 		case WE_PAINT:
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
 			DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
@@ -849,7 +849,7 @@
 			break;
 
 		case WE_PAINT: {
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			if (_station_show_coverage) {
 				int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -194,7 +194,7 @@
 			SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
 			w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
 		} break;
 
@@ -565,7 +565,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* XXX - Disabled buttons in normal gameplay or during muliplayer as non server.
 		 *       Bitshifted for each button to see if that bit is set. If it is set, the
@@ -903,7 +903,7 @@
 		uint i;
 
 		/* Set up selected category */
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		x = 5;
 		y = 47;
@@ -1159,7 +1159,7 @@
 	{
 		int x;
 		int y = 20;
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* exchange rate */
 		DrawArrowButtons(10, y, 3, GB(this->click, 0, 2), true, true);
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -75,7 +75,7 @@
 			SetVScrollCount(w, _num_sign_sort);
 
 			SetDParam(0, w->vscroll.count);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			/* No signs? */
 			int y = 16; // offset from top of widget
@@ -197,7 +197,7 @@
 	virtual void OnPaint()
 	{
 		SetDParam(0, this->caption);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
 	}
 
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -847,7 +847,7 @@
 
 		/* draw the window */
 		SetDParam(0, STR_00E5_CONTOURS + _smallmap_type);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		tbl = _legend_table[_smallmap_type];
 
@@ -1153,8 +1153,8 @@
 		/* set the number in the title bar */
 		SetDParam(0, this->window_number + 1);
 
-		DrawWindowWidgets(this);
-		DrawWindowViewport(this);
+		this->DrawWidgets();
+		this->DrawViewport();
 	}
 
 	virtual void OnClick(Point pt, int widget)
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -369,10 +369,10 @@
 		/* Set text of sort by dropdown */
 		this->widget[SLW_SORTDROPBTN].data = _station_sort_listing[this->sort_type];
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* draw arrow pointing up/down for ascending/descending sorting */
-		DrawSortButtonState(this, SLW_SORTBY, this->flags & VL_DESC ? SBS_DOWN : SBS_UP);
+		this->DrawSortButtonState(SLW_SORTBY, this->flags & VL_DESC ? SBS_DOWN : SBS_UP);
 
 		int cg_ofst;
 		int x = 89;
@@ -813,7 +813,7 @@
 
 		SetDParam(0, st->index);
 		SetDParam(1, st->facilities);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int x = 2;  ///< coordinates used for printing waiting/accepted/rating of cargo
 		int y = 15;
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -80,7 +80,7 @@
 	{
 		const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		SetDParam(0, _date);
 		DrawStringCentered(70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
 
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -96,7 +96,7 @@
 	int x;
 	int y;
 
-	DrawWindowWidgets(w);
+	w->DrawWidgets();
 
 	ConvertDateToYMD(_date, &ymd);
 
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -236,7 +236,7 @@
 {
 	switch (e->event) {
 	case WE_PAINT:
-		DrawWindowWidgets(w);
+		w->DrawWidgets();
 		break;
 
 	case WE_CLICK:
@@ -578,7 +578,7 @@
 			break;
 
 		case WE_PAINT: {
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			int n = _terraform_size * _terraform_size;
 			const int8 *coords = &_multi_terraform_coords[0][0];
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -108,7 +108,7 @@
 		this->SetWidgetLoweredState(TTV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
 
 		SetDParam(0, v->index);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int y = 15;
 		int i = this->vscroll.pos;
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -684,7 +684,7 @@
 			w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
 			w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			break;
 
 		case WE_CLICK:
@@ -887,7 +887,7 @@
 			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB2);
 			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
 
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
 			DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
@@ -1146,7 +1146,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		for (int i = 0, x = 1, y = 1; i != this->item_count; i++, y += 10) {
 			TextColour color = HasBit(this->disabled_items, i) ? TC_GREY : (this->sel_index == i) ? TC_WHITE : TC_BLACK;
@@ -1323,7 +1323,7 @@
 	virtual void OnPaint()
 	{
 		this->UpdatePlayerMenuHeight();
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int x = 1;
 		int y = 1;
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -167,7 +167,7 @@
 		this->SetWidgetDisabledState(6, this->sel_index == -1);
 
 		SetDParam(0, this->window_number);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING);
 
@@ -310,7 +310,7 @@
 			w->SetWidgetDisabledState(TVW_CHANGENAME, _networking && !_network_server);
 
 			SetDParam(0, t->index);
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 
 			SetDParam(0, t->population);
 			SetDParam(1, t->num_houses);
@@ -324,7 +324,7 @@
 			SetDParam(1, t->max_mail);
 			DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
 
-			DrawWindowViewport(w);
+			w->DrawViewport();
 			break;
 
 		case WE_CLICK:
@@ -489,8 +489,8 @@
 
 			SetVScrollCount(w, _num_town_sort);
 
-			DrawWindowWidgets(w);
-			DrawSortButtonState(w, (_town_sort_order <= 1) ? TDW_SORTNAME : TDW_SORTPOPULATION, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
+			w->DrawWidgets();
+			w->DrawSortButtonState((_town_sort_order <= 1) ? TDW_SORTNAME : TDW_SORTPOPULATION, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
 
 			{
 				int n = 0;
@@ -626,7 +626,7 @@
 {
 	switch (e->event) {
 		case WE_PAINT:
-			DrawWindowWidgets(w);
+			w->DrawWidgets();
 			break;
 
 		case WE_CREATE:
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -49,7 +49,7 @@
 			this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS)));
 		}
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 		for (uint i = TO_SIGNS; i < TO_END; i++) {
 			if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, this->widget[TTW_WIDGET_SIGNS + i].left + 1, this->widget[TTW_WIDGET_SIGNS + i].top + 1);
 		}
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -72,7 +72,7 @@
 			{ 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED }
 		};
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int i = this->base = _tree_base_by_landscape[_opt.landscape];
 		int count = this->count = _tree_count_by_landscape[_opt.landscape];
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -394,7 +394,7 @@
 		SetVScrollCount(this, this->list->num_lines);
 
 		SetDParam(0, v->index);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		this->cargo = DrawVehicleRefitWindow(this->list, this->sel, this->vscroll.pos, this->vscroll.cap, this->resize.step_height);
 
@@ -1028,12 +1028,12 @@
 			VLW_WIDGET_START_ALL,
 			WIDGET_LIST_END);
 
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* draw sorting criteria string */
 		DrawString(85, 15, _vehicle_sort_listing[this->vehicles.sort_type], TC_BLACK);
 		/* draw arrow pointing up/down for ascending/descending sorting */
-		DrawSortButtonState(this, VLW_WIDGET_SORT_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
+		this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
 
 		max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.list_length);
 		for (i = this->vscroll.pos; i < max; ++i) {
@@ -1508,7 +1508,7 @@
 
 
 		SetDParam(0, v->index);
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		/* Draw running cost */
 		SetDParam(1, v->age / 366);
@@ -1942,7 +1942,7 @@
 
 	/* draw widgets & caption */
 	SetDParam(0, v->index);
-	DrawWindowWidgets(w);
+	w->DrawWidgets();
 
 	if (v->vehstatus & VS_CRASHED) {
 		str = STR_8863_CRASHED;
@@ -2021,7 +2021,7 @@
 	/* draw the flag plus orders */
 	DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1);
 	DrawStringCenteredTruncated(w->widget[VVW_WIDGET_START_STOP_VEH].left + 8, w->widget[VVW_WIDGET_START_STOP_VEH].right, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1, str, TC_FROMSTRING);
-	DrawWindowViewport(w);
+	w->DrawViewport();
 }
 
 /** Command indices for the _vehicle_command_translation_table. */
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1536,17 +1536,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 += this->left;
+	dpi->top += this->top;
+
+	ViewportDraw(this->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height);
+
+	dpi->left -= this->left;
+	dpi->top -= this->top;
 }
 
 static inline void ClampViewportToMap(const ViewPort *vp, int &x, int &y)
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -190,20 +190,20 @@
  * Paint all widgets of a window.
  * @param w Window
  */
-void DrawWindowWidgets(const Window *w)
+void Window::DrawWidgets() const
 {
 	const DrawPixelInfo* dpi = _cur_dpi;
 
-	for (uint i = 0; i < w->widget_count; i++) {
-		const Widget *wi = &w->widget[i];
-		bool clicked = w->IsWidgetLowered(i);
+	for (uint i = 0; i < this->widget_count; i++) {
+		const Widget *wi = &this->widget[i];
+		bool clicked = this->IsWidgetLowered(i);
 		Rect r;
 
 		if (dpi->left > (r.right = wi->right) ||
 				dpi->left + dpi->width <= (r.left = wi->left) ||
 				dpi->top > (r.bottom = wi->bottom) ||
 				dpi->top + dpi->height <= (r.top = wi->top) ||
-				w->IsWidgetHidden(i)) {
+				this->IsWidgetHidden(i)) {
 			continue;
 		}
 
@@ -304,11 +304,11 @@
 			assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
 
 			/* draw up/down buttons */
-			clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
+			clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
 			DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK);
 
-			clicked = (((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN));
+			clicked = (((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN));
 			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
 
@@ -325,8 +325,8 @@
 			GfxFillRect(r.left + 7, r.top + 10, r.left + 7, r.bottom - 10, c1);
 			GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
 
-			Point pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom);
-			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE);
+			Point pt = HandleScrollbarHittest(&this->vscroll, r.top, r.bottom);
+			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE);
 			break;
 		}
 
@@ -335,11 +335,11 @@
 			assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
 
 			/* draw up/down buttons */
-			clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
+			clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
 			DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color,  (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK);
 
-			clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2));
+			clicked = ((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2));
 			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color,  (clicked) ? FR_LOWERED : FR_NONE);
 			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
 
@@ -356,8 +356,8 @@
 			GfxFillRect(r.left + 7, r.top + 10, r.left + 7, r.bottom - 10, c1);
 			GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
 
-			Point pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom);
-			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE);
+			Point pt = HandleScrollbarHittest(&this->vscroll2, r.top, r.bottom);
+			DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE);
 			break;
 		}
 
@@ -366,11 +366,11 @@
 			assert(wi->data == 0);
 			assert(r.bottom - r.top == 11); // To ensure the same sizes are used everywhere!
 
-			clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
+			clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
 			DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DrawSprite(SPR_ARROW_LEFT, PAL_NONE, r.left + 1 + clicked, r.top + 1 + clicked);
 
-			clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
+			clicked = ((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
 			DrawFrameRect(r.right - 9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, r.right - 8 + clicked, r.top + 1 + clicked);
 
@@ -388,8 +388,8 @@
 			GfxFillRect(r.left + 10, r.top + 8, r.right - 10, r.top + 8, c2);
 
 			/* draw actual scrollbar */
-			Point pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right);
-			DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE);
+			Point pt = HandleScrollbarHittest(&this->hscroll, r.left, r.right);
+			DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE);
 
 			break;
 		}
@@ -429,7 +429,7 @@
 			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
 
-			clicked = !!(w->flags4 & WF_STICKY);
+			clicked = !!(this->flags4 & WF_STICKY);
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, PAL_NONE, r.left + 2 + clicked, r.top + 3 + clicked);
 			break;
@@ -438,7 +438,7 @@
 			assert(wi->data == 0);
 			assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
 
-			clicked = !!(w->flags4 & WF_SIZING);
+			clicked = !!(this->flags4 & WF_SIZING);
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
 			DrawSprite(SPR_WINDOW_RESIZE, PAL_NONE, r.left + 3 + clicked, r.top + 3 + clicked);
 			break;
@@ -457,10 +457,10 @@
 		case WWT_CAPTION:
 			assert(r.bottom - r.top == 13); // To ensure the same sizes are used everywhere!
 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY);
-			DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
+			DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->color, (this->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
 
-			if (w->caption_color != 0xFF) {
-				GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_player_colors[w->caption_color]][4]);
+			if (this->caption_color != 0xFF) {
+				GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_player_colors[this->caption_color]][4]);
 			}
 
 			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top + 2, wi->data, 0x84);
@@ -489,14 +489,14 @@
 		}
 		}
 
-		if (w->IsWidgetDisabled(i)) {
+		if (this->IsWidgetDisabled(i)) {
 			GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
 		}
 	}
 
 
-	if (w->flags4 & WF_WHITE_BORDER_MASK) {
-		DrawFrameRect(0, 0, w->width - 1, w->height - 1, 0xF, FR_BORDERONLY);
+	if (this->flags4 & WF_WHITE_BORDER_MASK) {
+		DrawFrameRect(0, 0, this->width - 1, this->height - 1, 0xF, FR_BORDERONLY);
 	}
 
 }
@@ -597,10 +597,10 @@
  * @param widget Sort button widget
  * @param state State of sort button
  */
-void DrawSortButtonState(const Window *w, int widget, SortButtonState state)
+void Window::DrawSortButtonState(int widget, SortButtonState state) const
 {
 	if (state == SBS_OFF) return;
 
-	int offset = w->IsWidgetLowered(widget) ? 1 : 0;
-	DoDrawString(state == SBS_DOWN ? DOWNARROW : UPARROW, w->widget[widget].right - 11 + offset, w->widget[widget].top + 1 + offset, TC_BLACK);
+	int offset = this->IsWidgetLowered(widget) ? 1 : 0;
+	DoDrawString(state == SBS_DOWN ? DOWNARROW : UPARROW, this->widget[widget].right - 11 + offset, this->widget[widget].top + 1 + offset, TC_BLACK);
 }
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -118,7 +118,7 @@
 
 	virtual void OnPaint()
 	{
-		DrawWindowWidgets(this);
+		this->DrawWidgets();
 
 		int x = 1;
 		int y = 2;
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -245,6 +245,12 @@
 	uint step_height; ///< Step-size of height resize changes
 };
 
+enum SortButtonState {
+	SBS_OFF,
+	SBS_DOWN,
+	SBS_UP,
+};
+
 /**
  * Data structure for a window viewport
  */
@@ -322,6 +328,10 @@
 	void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
 	void InvalidateWidget(byte widget_index) const;
 
+	void DrawWidgets() const;
+	void DrawViewport() const;
+	void DrawSortButtonState(int widget, SortButtonState state) const;
+
 	void SetDirty() const;
 
 	/*** Event handling ***/
@@ -612,8 +622,6 @@
 	return new Wcls(desc, window_number);
 }
 
-void DrawWindowViewport(const Window *w);
-
 void RelocateAllWindows(int neww, int newh);
 
 /* misc_gui.cpp */
@@ -625,17 +633,6 @@
 
 /* widget.cpp */
 int GetWidgetFromPos(const Window *w, int x, int y);
-void DrawWindowWidgets(const Window *w);
-
-enum SortButtonState {
-	SBS_OFF,
-	SBS_DOWN,
-	SBS_UP,
-};
-
-void DrawSortButtonState(const Window *w, int widget, SortButtonState state);
-
-
 
 /* window.cpp */
 extern Window *_z_windows[];