(svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method cpp_gui
authorKUDr
Tue, 13 Feb 2007 22:09:37 +0000
branchcpp_gui
changeset 6246 2a4c2c4d66f0
parent 6245 6fa82c6ee8ca
child 6247 67e881450cf3
(svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
src/aircraft_gui.cpp
src/airport_gui.cpp
src/autoreplace_gui.cpp
src/build_vehicle_gui.cpp
src/genworld_gui.cpp
src/graph_gui.cpp
src/main_gui.cpp
src/music_gui.cpp
src/network/network_gui.cpp
src/newgrf_gui.cpp
src/news_gui.cpp
src/order_gui.cpp
src/player_gui.cpp
src/rail_gui.cpp
src/roadveh_gui.cpp
src/settings_gui.cpp
src/ship_gui.cpp
src/station_gui.cpp
src/town_gui.cpp
src/train_gui.cpp
src/vehicle_gui.cpp
src/viewport.cpp
src/window.cpp
src/window.h
--- a/src/aircraft_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/aircraft_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -58,11 +58,11 @@
 	case WE_PAINT: {
 		const Vehicle *v = GetVehicle(w->window_number);
 
-		SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
+		w->SetWidgetDisabledState(2, v->owner != _local_player);
 
 		/* Disable service-scroller when interval is set to disabled */
-		SetWindowWidgetDisabledState(w, 5, !_patches.servint_aircraft);
-		SetWindowWidgetDisabledState(w, 6, !_patches.servint_aircraft);
+		w->SetWidgetDisabledState(5, !_patches.servint_aircraft);
+		w->SetWidgetDisabledState(6, !_patches.servint_aircraft);
 
 		SetDParam(0, v->string_id);
 		SetDParam(1, v->unitnumber);
@@ -243,9 +243,9 @@
 		StringID str;
 		bool is_localplayer = v->owner == _local_player;
 
-		SetWindowWidgetDisabledState(w,  7, !is_localplayer);
-		SetWindowWidgetDisabledState(w,  8, !IsAircraftInHangarStopped(v) || !is_localplayer);
-		SetWindowWidgetDisabledState(w, 11, !is_localplayer);
+		w->SetWidgetDisabledState( 7, !is_localplayer);
+		w->SetWidgetDisabledState( 8, !IsAircraftInHangarStopped(v) || !is_localplayer);
+		w->SetWidgetDisabledState(11, !is_localplayer);
 
 
 		/* draw widgets & caption */
--- a/src/airport_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/airport_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -169,7 +169,7 @@
 		 * XXX TODO : all airports should be held in arrays, with all relevant data.
 		 * This should be part of newgrf-airports, i suppose
 		 */
-		for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i));
+		for (i = 0; i < 9; i++) w->SetWidgetDisabledState(i + 7, !HASBIT(avail_airports, i));
 
 		// select default the coverage area to 'Off' (16)
 		airport = GetAirport(_selected_airport_type);
--- a/src/autoreplace_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/autoreplace_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -237,7 +237,7 @@
 			 *    Either list is empty
 			 * or The selected replacement engine has a replacement (to prevent loops)
 			 * or The right list (new replacement) has the existing replacement vehicle selected */
-			SetWindowWidgetDisabledState(w, 4,
+			w->SetWidgetDisabledState(4,
 										 selected_id[0] == INVALID_ENGINE ||
 										 selected_id[1] == INVALID_ENGINE ||
 										 EngineReplacementForPlayer(p, selected_id[1]) != INVALID_ENGINE ||
@@ -246,7 +246,7 @@
 			/* Disable the "Stop Replacing" button if:
 			 *   The left list (existing vehicle) is empty
 			 *   or The selected vehicle has no replacement set up */
-			SetWindowWidgetDisabledState(w, 6,
+			w->SetWidgetDisabledState(6,
 										 selected_id[0] == INVALID_ENGINE ||
 										 !EngineHasReplacementForPlayer(p, selected_id[0]));
 
--- a/src/build_vehicle_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -786,7 +786,7 @@
 	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
 	uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
 
-	SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number == 0);
+	w->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, w->window_number == 0);
 
 	SetVScrollCount(w, EngList_Count(&bv->eng_list));
 	SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles
--- a/src/genworld_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/genworld_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -234,23 +234,23 @@
 	case WE_PAINT:
 		/* You can't select smoothness if not terragenesis */
 		if (mode == GLWP_GENERATE) {
-			SetWindowWidgetDisabledState(w, GLAND_SMOOTHNESS_TEXT,     _patches_newgame.land_generator == 0);
-			SetWindowWidgetDisabledState(w, GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
+			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_TEXT,     _patches_newgame.land_generator == 0);
+			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
 		}
 		/* Disable snowline if not hilly */
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_HILLY);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_HILLY);
 		/* Disable town, industry and trees in SE */
-		SetWindowWidgetDisabledState(w, GLAND_TOWN_TEXT,         _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_INDUSTRY_TEXT,     _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TREE_TEXT,         _game_mode == GM_EDITOR);
-		SetWindowWidgetDisabledState(w, GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TOWN_TEXT,         _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_INDUSTRY_TEXT,     _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TREE_TEXT,         _game_mode == GM_EDITOR);
+		w->SetWidgetDisabledState(GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
 
-		SetWindowWidgetDisabledState(w, GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_HILLY);
-		SetWindowWidgetDisabledState(w, GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= 13 || _opt_newgame.landscape != LT_HILLY);
+		w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_HILLY);
+		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= 13 || _opt_newgame.landscape != LT_HILLY);
 
 		SetWindowWidgetLoweredState(w, GLAND_TEMPERATE, _opt_newgame.landscape == LT_NORMAL);
 		SetWindowWidgetLoweredState(w, GLAND_ARCTIC,    _opt_newgame.landscape == LT_HILLY);
@@ -582,10 +582,10 @@
 	case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + CSCEN_TEMPERATE); break;
 
 	case WE_PAINT:
-		SetWindowWidgetDisabledState(w, CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
-		SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
-		SetWindowWidgetDisabledState(w, CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= 15);
+		w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
+		w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= 15);
 
 		SetWindowWidgetLoweredState(w, CSCEN_TEMPERATE, _opt_newgame.landscape == LT_NORMAL);
 		SetWindowWidgetLoweredState(w, CSCEN_ARCTIC,    _opt_newgame.landscape == LT_HILLY);
--- a/src/graph_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/graph_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -1068,7 +1068,7 @@
 
 			/* Disable the players who are not active */
 			for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
-				SetWindowWidgetDisabledState(w, i + 13, !GetPlayer(i)->is_active);
+				w->SetWidgetDisabledState(i + 13, !GetPlayer(i)->is_active);
 			}
 			/* Update all player stats with the current data
 			 * (this is because _score_info is not saved to a savegame) */
--- a/src/main_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/main_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -2014,8 +2014,8 @@
 {
 	switch (e->event) {
 	case WE_PAINT:
-		SetWindowWidgetDisabledState(w, 6, _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, 7, _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
 
 		// Draw brown-red toolbar bg.
 		GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
@@ -2441,8 +2441,8 @@
 
 	w->flash_timeout = 0;
 
-	SetWindowWidgetDisabledState(w, 0, _networking && !_network_server); // if not server, disable pause button
-	SetWindowWidgetDisabledState(w, 1, _networking); // if networking, disable fast-forward button
+	w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
+	w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
 
 	/* 'w' is for sure a WC_MAIN_TOOLBAR */
 	PositionMainToolbar(w);
--- a/src/music_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/music_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -200,7 +200,7 @@
 		uint i;
 		int y;
 
-		SetWindowWidgetDisabledState(w, 11, msf.playlist <= 3);
+		w->SetWidgetDisabledState(11, msf.playlist <= 3);
 		LowerWindowWidget(w, 3);
 		LowerWindowWidget(w, 4);
 		w->DrawWidgets();
--- a/src/network/network_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/network/network_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -243,9 +243,9 @@
 		}
 		if (ld->flags & VL_RESORT) SortNetworkGameList(&WP(w, network_ql_d));
 
-		SetWindowWidgetDisabledState(w, 17, sel == NULL);
+		w->SetWidgetDisabledState(17, sel == NULL);
 		/* Join Button disabling conditions */
-		SetWindowWidgetDisabledState(w, 16, sel == NULL || // no Selected Server
+		w->SetWidgetDisabledState(16, sel == NULL || // no Selected Server
 				!sel->online || // Server offline
 				sel->info.clients_on >= sel->info.clients_max || // Server full
 				!sel->info.compatible); // Revision mismatch
@@ -824,11 +824,11 @@
 		const NetworkGameInfo *gi = &nd->server->info;
 		int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
 
-		SetWindowWidgetDisabledState(w, 7, nd->company == (byte)-1);
-		SetWindowWidgetDisabledState(w, 8, gi->companies_on >= gi->companies_max);
+		w->SetWidgetDisabledState(7, nd->company == (byte)-1);
+		w->SetWidgetDisabledState(8, gi->companies_on >= gi->companies_max);
 		/* You can not join a server as spectator when it has no companies active..
 		 * it causes some nasty crashes */
-		SetWindowWidgetDisabledState(w, 9, gi->spectators_on >= gi->spectators_max ||
+		w->SetWidgetDisabledState(9, gi->spectators_on >= gi->spectators_max ||
 				gi->companies_on == 0);
 
 		w->DrawWidgets();
--- a/src/newgrf_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/newgrf_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -106,7 +106,7 @@
 			w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10;
 			SetVScrollCount(w, n);
 
-			SetWindowWidgetDisabledState(w, 6, WP(w, newgrf_add_d).sel == NULL);
+			w->SetWidgetDisabledState(6, WP(w, newgrf_add_d).sel == NULL);
 			w->DrawWidgets();
 
 			GfxFillRect(w->widget[3].left + 1, w->widget[3].top + 1, w->widget[3].right, w->widget[3].bottom, 0xD7);
@@ -243,14 +243,14 @@
 {
 	bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable;
 
-	SetWindowWidgetDisabledState(w, 3, !WP(w, newgrf_d).editable);
+	w->SetWidgetDisabledState(3, !WP(w, newgrf_d).editable);
 	w->SetWidgetsDisabledState(disable_all,
 		SNGRFS_REMOVE,
 		SNGRFS_MOVE_UP,
 		SNGRFS_MOVE_DOWN,
 		WIDGET_LIST_END
 	);
-	SetWindowWidgetDisabledState(w, SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all);
+	w->SetWidgetDisabledState(SNGRFS_SET_PARAMETERS, !WP(w, newgrf_d).show_params || disable_all);
 
 	if (!disable_all) {
 		/* All widgets are now enabled, so disable widgets we can't use */
@@ -269,7 +269,7 @@
 
 	w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
 	SetVScrollCount(w, i);
-	SetWindowWidgetDisabledState(w, SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable);
+	w->SetWidgetDisabledState(SNGRFS_APPLY_CHANGES, !WP(w, newgrf_d).editable);
 }
 
 
--- a/src/news_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/news_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -720,8 +720,8 @@
 {
 	element *= 2;
 
-	SetWindowWidgetDisabledState(w, element + 3, value == 0);
-	SetWindowWidgetDisabledState(w, element + 3 + 1, value == 2);
+	w->SetWidgetDisabledState(element + 3, value == 0);
+	w->SetWidgetDisabledState(element + 3 + 1, value == 2);
 }
 
 static void MessageOptionsWndProc(Window *w, WindowEvent *e)
--- a/src/order_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/order_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -90,20 +90,20 @@
 
 	if (v->owner == _local_player) {
 		/* skip */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_SKIP, v->num_orders == 0);
+		w->SetWidgetDisabledState(ORDER_WIDGET_SKIP, v->num_orders == 0);
 
 		/* delete */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_DELETE,
+		w->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
 				(uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel);
 
 		/* non-stop only for trains */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_NON_STOP,  v->type != VEH_Train || order == NULL);
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_FULL_LOAD, order == NULL); // full load
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_UNLOAD,    order == NULL); // unload
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_TRANSFER,  order == NULL); // transfer
+		w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP,  v->type != VEH_Train || order == NULL);
+		w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL); // full load
+		w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD,    order == NULL); // unload
+		w->SetWidgetDisabledState(ORDER_WIDGET_TRANSFER,  order == NULL); // transfer
 		/* Disable list of vehicles with the same shared orders if there is no list */
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
-		SetWindowWidgetDisabledState(w, ORDER_WIDGET_REFIT,     order == NULL); // Refit
+		w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
+		w->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
 		HideWindowWidget(w, ORDER_WIDGET_REFIT); // Refit
 	} else {
 		DisableWindowWidget(w, ORDER_WIDGET_TRANSFER);
--- a/src/player_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/player_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -154,7 +154,7 @@
 
 		if (player == _local_player) {
 			/* borrow/repay buttons only exist for local player */
-			SetWindowWidgetDisabledState(w, 7, p->current_loan == 0);
+			w->SetWidgetDisabledState(7, p->current_loan == 0);
 		}
 
 		SetDParam(0, p->name_1);
@@ -332,10 +332,10 @@
 			int y = 51;
 
 			/* Disable dropdown controls if no scheme is selected */
-			SetWindowWidgetDisabledState(w,  9, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 10, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 11, (WP(w, livery_d).sel == 0));
-			SetWindowWidgetDisabledState(w, 12, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState( 9, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(10, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(11, (WP(w, livery_d).sel == 0));
+			w->SetWidgetDisabledState(12, (WP(w, livery_d).sel == 0));
 
 			if (!(WP(w, livery_d).sel == 0)) {
 				for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
@@ -685,7 +685,7 @@
 			SetWindowWidgetHiddenState(w, PCW_WIDGET_COMPANY_NAME,   !local);
 			w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
 			if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
-			SetWindowWidgetDisabledState(w, PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
+			w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
 			SetWindowWidgetHiddenState(w, PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
 			SetWindowWidgetHiddenState(w, PCW_WIDGET_BUY_SHARE,        local);
 			SetWindowWidgetHiddenState(w, PCW_WIDGET_SELL_SHARE,       local);
@@ -694,14 +694,14 @@
 			if (!local) {
 				if (_patches.allow_shares) { // Shares are allowed
 					/* If all shares are owned by someone (none by nobody), disable buy button */
-					SetWindowWidgetDisabledState(w, PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
+					w->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
 							/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
 							(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
 							/* Spectators cannot do anything of course */
 							_local_player == PLAYER_SPECTATOR);
 
 					/* If the player doesn't own any shares, disable sell button */
-					SetWindowWidgetDisabledState(w, PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
+					w->SetWidgetDisabledState(PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
 							/* Spectators cannot do anything of course */
 							_local_player == PLAYER_SPECTATOR);
 				} else { // Shares are not allowed, disable buy/sell buttons
--- a/src/rail_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/rail_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -443,7 +443,7 @@
 		case RTW_BUILD_SIGNALS:
 			/* Removal button is enabled only if the rail/signal/waypoint/station
 			 * button is still lowered.  Once raised, it has to be disabled */
-			SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
+			w->SetWidgetDisabledState(RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
 			break;
 
 		default:
@@ -717,11 +717,11 @@
 		for (bits = 0; bits < 7; bits++) {
 			bool disable = bits >= _patches.station_spread;
 			if (statspec == NULL) {
-				SetWindowWidgetDisabledState(w, bits +  5, disable);
-				SetWindowWidgetDisabledState(w, bits + 12, disable);
+				w->SetWidgetDisabledState(bits +  5, disable);
+				w->SetWidgetDisabledState(bits + 12, disable);
 			} else {
-				SetWindowWidgetDisabledState(w, bits +  5, HASBIT(statspec->disallowed_platforms, bits) || disable);
-				SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths,   bits) || disable);
+				w->SetWidgetDisabledState(bits +  5, HASBIT(statspec->disallowed_platforms, bits) || disable);
+				w->SetWidgetDisabledState(bits + 12, HASBIT(statspec->disallowed_lengths,   bits) || disable);
 			}
 		}
 
--- a/src/roadveh_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/roadveh_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -33,10 +33,10 @@
 		const Vehicle *v = GetVehicle(w->window_number);
 		StringID str;
 
-		SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
+		w->SetWidgetDisabledState(2, v->owner != _local_player);
 		// disable service-scroller when interval is set to disabled
-		SetWindowWidgetDisabledState(w, 5, !_patches.servint_roadveh);
-		SetWindowWidgetDisabledState(w, 6, !_patches.servint_roadveh);
+		w->SetWidgetDisabledState(5, !_patches.servint_roadveh);
+		w->SetWidgetDisabledState(6, !_patches.servint_roadveh);
 
 		SetDParam(0, v->string_id);
 		SetDParam(1, v->unitnumber);
@@ -184,11 +184,11 @@
 		StringID str;
 		bool is_localplayer = v->owner == _local_player;
 
-		SetWindowWidgetDisabledState(w,  7, !is_localplayer);
-		SetWindowWidgetDisabledState(w,  8, !is_localplayer);
-		SetWindowWidgetDisabledState(w, 11, !is_localplayer);
+		w->SetWidgetDisabledState( 7, !is_localplayer);
+		w->SetWidgetDisabledState( 8, !is_localplayer);
+		w->SetWidgetDisabledState(11, !is_localplayer);
 		/* Disable refit button if vehicle not refittable */
-		SetWindowWidgetDisabledState(w, 12, !is_localplayer ||
+		w->SetWidgetDisabledState(12, !is_localplayer ||
 				_engine_info[v->engine_type].refit_mask == 0);
 
 		/* draw widgets & caption */
--- a/src/settings_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/settings_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -97,7 +97,7 @@
 		int i;
 		StringID str = STR_02BE_DEFAULT;
 
-		SetWindowWidgetDisabledState(w, 21, !(_vehicle_design_names & 1));
+		w->SetWidgetDisabledState(21, !(_vehicle_design_names & 1));
 		if (!IsWindowWidgetDisabled(w, 21)) str = STR_02BF_CUSTOM;
 		SetDParam(0, str);
 		SetDParam(1, _currency_specs[_opt_ptr->currency].name);
@@ -386,12 +386,12 @@
 	switch (e->event) {
 	case WE_CREATE: // Setup disabled buttons when creating window
 		/* disable all other difficulty buttons during gameplay except for 'custom' */
-		SetWindowWidgetDisabledState(w,  3, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  4, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  5, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  6, _game_mode == GM_NORMAL);
-		SetWindowWidgetDisabledState(w,  7, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
-		SetWindowWidgetDisabledState(w, 10, _networking && !_network_server); // Save-button in multiplayer (and if client)
+		w->SetWidgetDisabledState( 3, _game_mode == GM_NORMAL);
+		w->SetWidgetDisabledState( 4, _game_mode == GM_NORMAL);
+		w->SetWidgetDisabledState( 5, _game_mode == GM_NORMAL);
+		w->SetWidgetDisabledState( 6, _game_mode == GM_NORMAL);
+		w->SetWidgetDisabledState( 7, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
+		w->SetWidgetDisabledState(10, _networking && !_network_server); // Save-button in multiplayer (and if client)
 
 		break;
 	case WE_PAINT: {
--- a/src/ship_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/ship_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -31,10 +31,10 @@
 		const Vehicle *v = GetVehicle(w->window_number);
 		StringID str;
 
-		SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
+		w->SetWidgetDisabledState(2, v->owner != _local_player);
 		// disable service-scroller when interval is set to disabled
-		SetWindowWidgetDisabledState(w, 5, !_patches.servint_ships);
-		SetWindowWidgetDisabledState(w, 6, !_patches.servint_ships);
+		w->SetWidgetDisabledState(5, !_patches.servint_ships);
+		w->SetWidgetDisabledState(6, !_patches.servint_ships);
 
 		SetDParam(0, v->string_id);
 		SetDParam(1, v->unitnumber);
@@ -194,11 +194,11 @@
 			bool refitable_and_stopped_in_depot = ShipVehInfo(v->engine_type)->refittable && IsShipInDepotStopped(v);
 			bool is_localplayer = v->owner == _local_player;
 
-			SetWindowWidgetDisabledState(w,  7, !is_localplayer);
-			SetWindowWidgetDisabledState(w,  8,
+			w->SetWidgetDisabledState( 7, !is_localplayer);
+			w->SetWidgetDisabledState( 8,
 			                             !is_localplayer ||      // Disable if owner is not local player
 			                             !refitable_and_stopped_in_depot); // Disable if the ship is not refitable or stopped in a depot
-			SetWindowWidgetDisabledState(w, 11, !is_localplayer);
+			w->SetWidgetDisabledState(11, !is_localplayer);
 
 			/* draw widgets & caption */
 			SetDParam(0, v->string_id);
--- a/src/station_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/station_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -620,11 +620,11 @@
 	}
 	SetVScrollCount(w, num);
 
-	SetWindowWidgetDisabledState(w,  9, st->owner != _local_player);
-	SetWindowWidgetDisabledState(w, 10, !(st->facilities & FACIL_TRAIN));
-	SetWindowWidgetDisabledState(w, 11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
-	SetWindowWidgetDisabledState(w, 12, !(st->facilities & FACIL_AIRPORT));
-	SetWindowWidgetDisabledState(w, 13, !(st->facilities & FACIL_DOCK));
+	w->SetWidgetDisabledState( 9, st->owner != _local_player);
+	w->SetWidgetDisabledState(10, !(st->facilities & FACIL_TRAIN));
+	w->SetWidgetDisabledState(11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
+	w->SetWidgetDisabledState(12, !(st->facilities & FACIL_AIRPORT));
+	w->SetWidgetDisabledState(13, !(st->facilities & FACIL_DOCK));
 
 	SetDParam(0, st->index);
 	SetDParam(1, st->facilities);
--- a/src/town_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/town_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -106,7 +106,7 @@
 		if (WP(w,def_d).data_1 != -1 && !HASBIT(buttons, WP(w,def_d).data_1))
 			WP(w,def_d).data_1 = -1;
 
-		SetWindowWidgetDisabledState(w, 6, WP(w, def_d).data_1 == -1);
+		w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
 
 		{
 			int y;
@@ -235,7 +235,7 @@
 	switch (e->event) {
 	case WE_PAINT:
 		// disable renaming town in network games if you are not the server
-		SetWindowWidgetDisabledState(w, 8, _networking && !_network_server);
+		w->SetWidgetDisabledState(8, _networking && !_network_server);
 
 		SetDParam(0, t->index);
 		w->DrawWidgets();
--- a/src/train_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/train_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -146,10 +146,10 @@
 		v = GetVehicle(w->window_number);
 
 		is_localplayer = v->owner == _local_player;
-		SetWindowWidgetDisabledState(w,  7, !is_localplayer);
-		SetWindowWidgetDisabledState(w,  8, !is_localplayer);
-		SetWindowWidgetDisabledState(w,  9, !is_localplayer);
-		SetWindowWidgetDisabledState(w, 13, !is_localplayer);
+		w->SetWidgetDisabledState( 7, !is_localplayer);
+		w->SetWidgetDisabledState( 8, !is_localplayer);
+		w->SetWidgetDisabledState( 9, !is_localplayer);
+		w->SetWidgetDisabledState(13, !is_localplayer);
 
 		/* Disable cargo refit button, until we know we can enable it below. */
 		DisableWindowWidget(w, 12);
@@ -406,11 +406,11 @@
 	SetVScrollCount(w, num);
 
 	DisableWindowWidget(w, det_tab + 9);
-	SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
+	w->SetWidgetDisabledState(2, v->owner != _local_player);
 
 	/* disable service-scroller when interval is set to disabled */
-	SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
-	SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
+	w->SetWidgetDisabledState(6, !_patches.servint_trains);
+	w->SetWidgetDisabledState(7, !_patches.servint_trains);
 
 	SetDParam(0, v->string_id);
 	SetDParam(1, v->unitnumber);
--- a/src/vehicle_gui.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/vehicle_gui.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -816,7 +816,7 @@
 	 * Some windows contains actions only fit for the owner */
 	if (player == _local_player) {
 		HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
-		SetWindowWidgetDisabledState(w, VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
+		w->SetWidgetDisabledState(VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
 	} else {
 		w->SetWidgetsHiddenState(true,
 			VLW_WIDGET_AVAILABLE_VEHICLES,
--- a/src/viewport.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/viewport.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -404,10 +404,10 @@
  * @param widget_zoom_out widget index for window with zoom-out button */
 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 {
-	SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == 0);
+	w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == 0);
 	w->InvalidateWidget(widget_zoom_in);
 
-	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == 2);
+	w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == 2);
 	w->InvalidateWidget(widget_zoom_out);
 }
 
--- a/src/window.cpp	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/window.cpp	Tue Feb 13 22:09:37 2007 +0000
@@ -271,7 +271,7 @@
 	va_start(wdg_list, widgets);
 
 	while (widgets != WIDGET_LIST_END) {
-		SetWindowWidgetDisabledState(this, widgets, disab_stat);
+		SetWidgetDisabledState(widgets, disab_stat);
 		widgets = va_arg(wdg_list, int);
 	}
 
--- a/src/window.h	Tue Feb 13 19:35:55 2007 +0000
+++ b/src/window.h	Tue Feb 13 22:09:37 2007 +0000
@@ -350,7 +350,7 @@
 	}
 };
 
-class Window : public CountedObject {
+struct Window : public CountedObject {
 public:
 	static WindowList s_list;
 
@@ -437,6 +437,8 @@
 	void ScrollbarClickHandler(const Widget *wi, int x, int y);
 public:
 
+	void SetWidgetDisabledState(byte widget_index, bool disab_stat);
+
 	//int32 AddRef()
 	//{
 	//	const char *name = NULL;
@@ -777,10 +779,10 @@
  * @param widget_index : index of this widget in the window
  * @param disab_stat : status to use ie: disabled = true, enabled = false
  */
-static inline void SetWindowWidgetDisabledState(Window *w, byte widget_index, bool disab_stat)
+inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat)
 {
-	assert(widget_index < w->widget_count);
-	SB(w->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat);
+	assert(widget_index < widget_count);
+	SB(widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat);
 }
 
 /**
@@ -790,7 +792,7 @@
  */
 static inline void DisableWindowWidget(Window *w, byte widget_index)
 {
-	SetWindowWidgetDisabledState(w, widget_index, true);
+	w->SetWidgetDisabledState(widget_index, true);
 }
 
 /**
@@ -800,7 +802,7 @@
  */
 static inline void EnableWindowWidget(Window *w, byte widget_index)
 {
-	SetWindowWidgetDisabledState(w, widget_index, false);
+	w->SetWidgetDisabledState(widget_index, false);
 }
 
 /**