(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI: cpp_gui
authorKUDr
Sun, 18 Feb 2007 14:17:28 +0000
branchcpp_gui
changeset 6258 a2f86b8fd99b
parent 6257 2ffe947969ca
child 6259 0f36789984b1
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
-Window related AllocateXxx() functions turned into Window methods
-current Widget renamed to OldWidget
-Widget base class added (still not used)
-CompositeWidget added (also not used)
-Widget rectangle/point handling moved to new file: misc/rect.hpp
-18 new .cpp files added in new dir for several widget types (most of them not used yet)
projects/openttd.vcproj
projects/openttd_vs80.vcproj
source.list
src/aircraft_gui.cpp
src/airport_gui.cpp
src/autoreplace_gui.cpp
src/bridge_gui.cpp
src/build_vehicle_gui.cpp
src/console.cpp
src/console.h
src/depot_gui.cpp
src/dock_gui.cpp
src/economy.cpp
src/engine_gui.cpp
src/functions.h
src/genworld.cpp
src/genworld_gui.cpp
src/graph_gui.cpp
src/gui.h
src/industry_gui.cpp
src/intro_gui.cpp
src/main_gui.cpp
src/misc/rect.hpp
src/misc_cmd.cpp
src/misc_gui.cpp
src/music_gui.cpp
src/network/network_gui.cpp
src/newgrf_gui.cpp
src/news.h
src/news_gui.cpp
src/openttd.cpp
src/openttd.h
src/order_gui.cpp
src/player_gui.cpp
src/rail_gui.cpp
src/road_gui.cpp
src/roadveh_gui.cpp
src/settings_gui.cpp
src/ship_gui.cpp
src/signs_gui.cpp
src/smallmap_gui.cpp
src/sound.cpp
src/station_gui.cpp
src/subsidy_gui.cpp
src/terraform_gui.cpp
src/town_gui.cpp
src/train_gui.cpp
src/vehicle.cpp
src/vehicle_gui.cpp
src/vehicle_gui.h
src/viewport.cpp
src/viewport.h
src/widget.cpp
src/widget/widget_base.cpp
src/widget/widget_button.cpp
src/widget/widget_button_img.cpp
src/widget/widget_button_img2.cpp
src/widget/widget_button_txt.cpp
src/widget/widget_button_txt2.cpp
src/widget/widget_caption.cpp
src/widget/widget_closebox.cpp
src/widget/widget_composite.cpp
src/widget/widget_frame.cpp
src/widget/widget_hscrollbar.cpp
src/widget/widget_inset.cpp
src/widget/widget_label.cpp
src/widget/widget_list.cpp
src/widget/widget_panel.cpp
src/widget/widget_resizebox.cpp
src/widget/widget_scrollbar.cpp
src/widget/widget_stickybox.cpp
src/window.cpp
src/window.h
--- a/projects/openttd.vcproj	Sat Feb 17 13:08:51 2007 +0000
+++ b/projects/openttd.vcproj	Sun Feb 18 14:17:28 2007 +0000
@@ -1047,6 +1047,67 @@
 			<File
 				RelativePath=".\..\src\misc\hashtable.hpp">
 			</File>
+			<File
+				RelativePath=".\..\src\misc\rect.hpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Widget"
+			Filter="">
+			<File
+				RelativePath=".\..\src\widget\widget_base.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_img2.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_img.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_txt2.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_txt.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_caption.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_closebox.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_composite.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_frame.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_hscrollbar.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_inset.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_label.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_list.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_panel.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_resizebox.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_scrollbar.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_stickybox.cpp">
+			</File>
 		</Filter>
 		<Filter
 			Name="YAPF"
--- a/projects/openttd_vs80.vcproj	Sat Feb 17 13:08:51 2007 +0000
+++ b/projects/openttd_vs80.vcproj	Sun Feb 18 14:17:28 2007 +0000
@@ -1330,6 +1330,67 @@
 			<File
 				RelativePath=".\..\src\misc\hashtable.hpp">
 			</File>
+			<File
+				RelativePath=".\..\src\misc\rect.hpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Widget"
+			Filter="">
+			<File
+				RelativePath=".\..\src\widget\widget_base.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_img2.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_img.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_txt2.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_button_txt.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_caption.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_closebox.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_composite.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_frame.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_hscrollbar.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_inset.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_label.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_list.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_panel.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_resizebox.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_scrollbar.cpp">
+			</File>
+			<File
+				RelativePath=".\..\src\widget\widget_stickybox.cpp">
+			</File>
 		</Filter>
 		<Filter
 			Name="YAPF"
--- a/source.list	Sat Feb 17 13:08:51 2007 +0000
+++ b/source.list	Sun Feb 18 14:17:28 2007 +0000
@@ -321,6 +321,27 @@
 misc/crc32.hpp
 misc/fixedsizearray.hpp
 misc/hashtable.hpp
+misc/rect.hpp
+
+# Widget
+widget/widget_base.cpp
+widget/widget_button.cpp
+widget/widget_button_img2.cpp
+widget/widget_button_img.cpp
+widget/widget_button_txt2.cpp
+widget/widget_button_txt.cpp
+widget/widget_caption.cpp
+widget/widget_closebox.cpp
+widget/widget_composite.cpp
+widget/widget_frame.cpp
+widget/widget_hscrollbar.cpp
+widget/widget_inset.cpp
+widget/widget_label.cpp
+widget/widget_list.cpp
+widget/widget_panel.cpp
+widget/widget_resizebox.cpp
+widget/widget_scrollbar.cpp
+widget/widget_stickybox.cpp
 
 # YAPF
 yapf/follow_track.cpp
--- a/src/aircraft_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/aircraft_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -52,7 +52,7 @@
 	if (success) ShowAircraftViewWindow(GetVehicle(_new_vehicle_id));
 }
 
-static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
+static void AircraftDetailsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -180,7 +180,7 @@
 }
 
 
-static const Widget _aircraft_details_widgets[] = {
+static const OldWidget _aircraft_details_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   349,     0,    13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS },
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   350,   389,     0,    13, STR_01AA_NAME,    STR_A032_NAME_AIRCRAFT },
@@ -203,20 +203,20 @@
 
 static void ShowAircraftDetailsWindow(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 	VehicleID veh = v->index;
 
 	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
-	w = AllocateWindowDescFront(&_aircraft_details_desc, veh);
+	w = BaseWindow::AllocateFront(&_aircraft_details_desc, veh);
 	w->caption_color = v->owner;
 //	w->vscroll.cap = 6;
 //	w->traindetails_d.tab = 0;
 }
 
 
-static const Widget _aircraft_view_widgets[] = {
+static const OldWidget _aircraft_view_widgets[] = {
 {   WWT_CLOSEBOX,  RESIZE_NONE,  14,   0,  10,   0,  13, STR_00C5,                 STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION, RESIZE_RIGHT,  14,  11, 237,   0,  13, STR_A00A,                 STR_018C_WINDOW_TITLE_DRAG_THIS },
 {  WWT_STICKYBOX,    RESIZE_LR,  14, 238, 249,   0,  13, 0x0,                      STR_STICKY_BUTTON },
@@ -235,7 +235,7 @@
 };
 
 
-static void AircraftViewWndProc(Window *w, WindowEvent *e)
+static void AircraftViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -343,8 +343,8 @@
 		const Vehicle *v = GetVehicle(w->window_number);
 		bool plane_stopped = IsAircraftInHangarStopped(v);
 
-		/* Widget 7 (send to hangar) must be hidden if the plane is already stopped in hangar.
-		 * Widget 11 (clone) should then be shown, since cloning is allowed only while in hangar and stopped.
+		/* OldWidget 7 (send to hangar) must be hidden if the plane is already stopped in hangar.
+		 * OldWidget 11 (clone) should then be shown, since cloning is allowed only while in hangar and stopped.
 		 * This sytem allows to have two buttons, on top of each other*/
 		if (plane_stopped != w->IsWidgetHidden(7) || plane_stopped == w->IsWidgetHidden(11)) {
 			w->SetWidgetHiddenState( 7, plane_stopped);  // send to hangar
@@ -367,7 +367,7 @@
 
 void ShowAircraftViewWindow(const Vehicle *v)
 {
-	Window *w = AllocateWindowDescFront(&_aircraft_view_desc, v->index);
+	BaseWindow *w = BaseWindow::AllocateFront(&_aircraft_view_desc, v->index);
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
--- a/src/airport_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/airport_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -47,24 +47,24 @@
 };
 
 
-static void BuildAirClick_Airport(Window *w)
+static void BuildAirClick_Airport(BaseWindow *w)
 {
 	if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker();
 }
 
-static void BuildAirClick_Demolish(Window *w)
+static void BuildAirClick_Demolish(BaseWindow *w)
 {
 	HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea);
 }
 
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 static OnButtonClick * const _build_air_button_proc[] = {
 	BuildAirClick_Airport,
 	BuildAirClick_Demolish,
 };
 
-static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
+static void BuildAirToolbWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -101,7 +101,7 @@
 	case WE_ABORT_PLACE_OBJ:
 		w->RaiseButtons();
 
-		w = Window::FindById(WC_BUILD_STATION, 0);
+		w = BaseWindow::FindById(WC_BUILD_STATION, 0);
 		if (w != 0)
 			WP(w,def_d).close = true;
 		break;
@@ -112,7 +112,7 @@
 	}
 }
 
-static const Widget _air_toolbar_widgets[] = {
+static const OldWidget _air_toolbar_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,    51,     0,    13, STR_A000_AIRPORTS,   STR_018C_WINDOW_TITLE_DRAG_THIS },
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,    52,    63,     0,    13, 0x0,                 STR_STICKY_BUTTON },
@@ -135,11 +135,11 @@
 	if (!IsValidPlayer(_current_player)) return;
 
 	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
-	Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
+	BaseWindow *w = BaseWindow::AllocateFront(&_air_toolbar_desc, 0);
 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
 }
 
-static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
+static void BuildAirportPickerWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE:
@@ -219,7 +219,7 @@
 	}
 }
 
-static const Widget _build_airport_picker_widgets[] = {
+static const OldWidget _build_airport_picker_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3001_AIRPORT_SELECTION,       STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,    52, 0x0,                              STR_NULL},
@@ -256,7 +256,7 @@
 
 static void ShowBuildAirportPicker(void)
 {
-	AllocateWindowDesc(&_build_airport_desc);
+	BaseWindow::Allocate(&_build_airport_desc);
 }
 
 void InitializeAirportGui(void)
--- a/src/autoreplace_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/autoreplace_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -130,10 +130,10 @@
 }
 
 /** Generate a list
- * @param w Window, that contains the list
+ * @param w BaseWindow, that contains the list
  * @param draw_left true if generating the left list, otherwise false
  */
-static void GenerateReplaceVehList(Window *w, bool draw_left)
+static void GenerateReplaceVehList(BaseWindow *w, bool draw_left)
 {
 	Player *p = GetPlayer(_local_player);
 	EngineID e;
@@ -164,9 +164,9 @@
 }
 
 /** Generate the lists
- * @param w Window containing the lists
+ * @param w BaseWindow containing the lists
  */
-static void GenerateLists(Window *w)
+static void GenerateLists(BaseWindow *w)
 {
 	EngineID e = WP(w, replaceveh_d).sel_engine[0];
 
@@ -202,7 +202,7 @@
 
 void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count);
 
-static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
+static void ReplaceVehicleWndProc(BaseWindow *w, WindowEvent *e)
 {
 	/* Strings for the pulldown menu */
 	static const StringID _vehicle_type_names[] = {
@@ -298,7 +298,7 @@
 
 				/* Also draw the details if an engine is selected */
 				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
-					const Widget *wi = &w->widget[i == 0 ? 3 : 11];
+					const OldWidget *wi = &w->widget[i == 0 ? 3 : 11];
 					DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]);
 				}
 			}
@@ -394,7 +394,7 @@
 	}
 }
 
-static const Widget _replace_rail_vehicle_widgets[] = {
+static const OldWidget _replace_rail_vehicle_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,       STR_STICKY_BUTTON},
@@ -419,7 +419,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _replace_road_vehicle_widgets[] = {
+static const OldWidget _replace_road_vehicle_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE,  STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,                    STR_STICKY_BUTTON},
@@ -436,7 +436,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _replace_ship_aircraft_vehicle_widgets[] = {
+static const OldWidget _replace_ship_aircraft_vehicle_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE,  STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,                    STR_STICKY_BUTTON},
@@ -480,25 +480,25 @@
 
 void ShowReplaceVehicleWindow(byte vehicletype)
 {
-	Window *w;
+	BaseWindow *w;
 
 	DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
 
 	switch (vehicletype) {
 		case VEH_Train:
-			w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype);
+			w = BaseWindow::AllocateFront(&_replace_rail_vehicle_desc, vehicletype);
 			w->vscroll.cap  = 8;
 			w->resize.step_height = 14;
 			WP(w, replaceveh_d).wagon_btnstate = true;
 			break;
 		case VEH_Road:
-			w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype);
+			w = BaseWindow::AllocateFront(&_replace_road_vehicle_desc, vehicletype);
 			w->vscroll.cap  = 8;
 			w->resize.step_height = 14;
 			break;
 		case VEH_Ship:
 		case VEH_Aircraft:
-			w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype);
+			w = BaseWindow::AllocateFront(&_replace_ship_aircraft_vehicle_desc, vehicletype);
 			w->vscroll.cap  = 4;
 			w->resize.step_height = 24;
 			break;
--- a/src/bridge_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/bridge_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -30,7 +30,7 @@
 	if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
 }
 
-static void BuildBridge(Window *w, int i)
+static void BuildBridge(BaseWindow *w, int i)
 {
 	w->Close();
 	DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
@@ -38,7 +38,7 @@
 		CMD_BUILD_BRIDGE | CMD_AUTO | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
 }
 
-static void BuildBridgeWndProc(Window *w, WindowEvent *e)
+static void BuildBridgeWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -78,7 +78,7 @@
 	}
 }
 
-static const Widget _build_bridge_widgets[] = {
+static const OldWidget _build_bridge_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   199,     0,    13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_MATRIX,   RESIZE_NONE,     7,     0,   187,    14,   101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},
@@ -95,7 +95,7 @@
 };
 
 
-static const Widget _build_road_bridge_widgets[] = {
+static const OldWidget _build_road_bridge_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   199,     0,    13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_MATRIX,   RESIZE_NONE,     7,     0,   187,    14,   101, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},
@@ -158,7 +158,7 @@
 	_bridgedata.count = j;
 
 	if (j != 0) {
-		Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
+		BaseWindow *w = BaseWindow::Allocate((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
 		w->vscroll.cap = 4;
 		w->vscroll.count = (byte)j;
 	} else {
--- a/src/build_vehicle_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -40,7 +40,7 @@
 	BUILD_VEHICLE_WIDGET_RESIZE,
 };
 
-static const Widget _build_vehicle_widgets[] = {
+static const OldWidget _build_vehicle_widgets[] = {
 	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW },
 	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   227,     0,    13, 0x0,                     STR_018C_WINDOW_TITLE_DRAG_THIS },
 	{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,             STR_SORT_ORDER_TIP},
@@ -57,7 +57,7 @@
 };
 
 /* Setup widget strings to fit the different types of vehicles */
-static void SetupWindowStrings(Window *w, byte type)
+static void SetupWindowStrings(BaseWindow *w, byte type)
 {
 	switch (type) {
 		case VEH_Train:
@@ -594,7 +594,7 @@
 }
 
 /* Figure out what train EngineIDs to put in the list */
-static void GenerateBuildTrainList(Window *w)
+static void GenerateBuildTrainList(BaseWindow *w)
 {
 	EngineID eid, sel_id;
 	int num_engines = 0;
@@ -640,7 +640,7 @@
 }
 
 /* Figure out what road vehicle EngineIDs to put in the list */
-static void GenerateBuildRoadVehList(Window *w)
+static void GenerateBuildRoadVehList(BaseWindow *w)
 {
 	EngineID eid, sel_id;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -659,7 +659,7 @@
 }
 
 /* Figure out what ship EngineIDs to put in the list */
-static void GenerateBuildShipList(Window *w)
+static void GenerateBuildShipList(BaseWindow *w)
 {
 	EngineID eid, sel_id;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -678,7 +678,7 @@
 }
 
 /* Figure out what aircraft EngineIDs to put in the list */
-static void GenerateBuildAircraftList(Window *w)
+static void GenerateBuildAircraftList(BaseWindow *w)
 {
 	EngineID eid, sel_id;
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -720,7 +720,7 @@
 }
 
 /* Generate the list of vehicles */
-static void GenerateBuildList(Window *w)
+static void GenerateBuildList(BaseWindow *w)
 {
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
@@ -808,7 +808,7 @@
 	}
 }
 
-static void DrawBuildVehicleWindow(Window *w)
+static void DrawBuildVehicleWindow(BaseWindow *w)
 {
 	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
 	uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
@@ -822,7 +822,7 @@
 	DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false);
 
 	if (bv->sel_engine != INVALID_ENGINE) {
-		const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
+		const OldWidget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
 		DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
 	}
 
@@ -830,7 +830,7 @@
 	DoDrawString(bv->descending_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10);
 }
 
-static void BuildVehicleClickEvent(Window *w, WindowEvent *e)
+static void BuildVehicleClickEvent(BaseWindow *w, WindowEvent *e)
 {
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
@@ -895,7 +895,7 @@
 	}
 }
 
-static void NewVehicleWndProc(Window *w, WindowEvent *e)
+static void NewVehicleWndProc(BaseWindow *w, WindowEvent *e)
 {
 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 
@@ -966,13 +966,13 @@
 void ShowBuildVehicleWindow(TileIndex tile, byte type)
 {
 	buildvehicle_d *bv;
-	Window *w;
+	BaseWindow *w;
 
 	assert(IsPlayerBuildableVehicleType(type));
 
 	DeleteWindowById(WC_BUILD_VEHICLE, tile);
 
-	w = AllocateWindowDescFront(&_build_vehicle_desc, tile);
+	w = BaseWindow::AllocateFront(&_build_vehicle_desc, tile);
 
 	if (w == NULL) return;
 
--- a/src/console.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/console.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -51,7 +51,7 @@
 	_iconsole_cmdline.width = 0;
 	_iconsole_cmdline.caretpos = 0;
 	_iconsole_cmdline.caretxoffs = 0;
-	Window::SetDirtyById(WC_CONSOLE, 0);
+	BaseWindow::SetDirtyById(WC_CONSOLE, 0);
 }
 
 static inline void IConsoleResetHistoryPos(void) {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
@@ -61,7 +61,7 @@
 static void IConsoleHistoryNavigate(int direction);
 
 // ** console window ** //
-static void IConsoleWndProc(Window *w, WindowEvent *e)
+static void IConsoleWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static byte iconsole_scroll = ICON_BUFFER;
 
@@ -193,7 +193,7 @@
 	}
 }
 
-static const Widget _iconsole_window_widgets[] = {
+static const OldWidget _iconsole_window_widgets[] = {
 	{WIDGETS_END}
 };
 
@@ -278,7 +278,7 @@
 	CloseConsoleLogIfActive();
 }
 
-void IConsoleResize(Window *w)
+void IConsoleResize(BaseWindow *w)
 {
 	switch (_iconsole_mode) {
 		case ICONSOLE_OPENED:
@@ -299,7 +299,7 @@
 {
 	switch (_iconsole_mode) {
 		case ICONSOLE_CLOSED: {
-			Window *w = AllocateWindowDesc(&_iconsole_window_desc);
+			BaseWindow *w = BaseWindow::Allocate(&_iconsole_window_desc);
 			w->height = _screen.height / 3;
 			w->width = _screen.width;
 			_iconsole_mode = ICONSOLE_OPENED;
@@ -403,7 +403,7 @@
 
 	IConsoleWriteToLogFile(_iconsole_buffer[ICON_BUFFER]);
 
-	Window::SetDirtyById(WC_CONSOLE, 0);
+	BaseWindow::SetDirtyById(WC_CONSOLE, 0);
 }
 
 /**
--- a/src/console.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/console.h	Sun Feb 18 14:17:28 2007 +0000
@@ -118,7 +118,7 @@
 void IConsoleInit(void);
 void IConsoleFree(void);
 void IConsoleClearBuffer(void);
-void IConsoleResize(Window *w);
+void IConsoleResize(BaseWindow *w);
 void IConsoleSwitch(void);
 void IConsoleClose(void);
 void IConsoleOpen(void);
--- a/src/depot_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/depot_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -47,7 +47,7 @@
 	DEPOT_WIDGET_RESIZE,
 };
 
-/* Widget array for all depot windows.
+/* OldWidget array for all depot windows.
  * If a widget is needed in some windows only (like train specific), add it for all windows
  * and use HideWindowWidget in ShowDepotWindow() to remove it in the windows where it should not be
  * Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */
@@ -63,7 +63,7 @@
  * The reason is that they are placed relatively to the matrix and the matrix is just one pixel (in 0, 14).
  * The matrix and the rest of the window will be resized when the size of the boxes is set and then all the widgets will be inside the window.
  */
-static const Widget _depot_widgets[] = {
+static const OldWidget _depot_widgets[] = {
 	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},            // DEPOT_WIDGET_CLOSEBOX
 	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,    23,     0,    13, 0x0,                 STR_018C_WINDOW_TITLE_DRAG_THIS},  // DEPOT_WIDGET_CAPTION
 	{  WWT_STICKYBOX,     RESIZE_LR,    14,    24,    35,     0,    13, 0x0,                 STR_STICKY_BUTTON},                // DEPOT_WIDGET_STICKY
@@ -91,7 +91,7 @@
 	{   WIDGETS_END},
 };
 
-static void DepotWndProc(Window *w, WindowEvent *e);
+static void DepotWndProc(BaseWindow *w, WindowEvent *e);
 
 static const WindowDesc _train_depot_desc = {
 	WDP_AUTO, WDP_AUTO, 36, 27,
@@ -149,7 +149,7 @@
 	}
 }
 
-static void DepotSellAllConfirmationCallback(Window *w, bool confirmed)
+static void DepotSellAllConfirmationCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) {
 		TileIndex tile = w->window_number;
@@ -161,12 +161,12 @@
 const Sprite *GetAircraftSprite(EngineID engine);
 
 /** Draw a vehicle in the depot window in the box with the top left corner at x,y
- * @param *w Window to draw in
+ * @param *w BaseWindow to draw in
  * @param *v Vehicle to draw
  * @param x Left side of the box to draw in
  * @param y Top of the box to draw in
  */
-static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
+static void DrawVehicleInDepot(BaseWindow *w, const Vehicle *v, int x, int y)
 {
 	byte diff_x = 0, diff_y = 0;
 
@@ -206,7 +206,7 @@
 	DrawString(x, y + 2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
 }
 
-static void DrawDepotWindow(Window *w)
+static void DrawDepotWindow(BaseWindow *w)
 {
 	Vehicle **vl = WP(w, depot_d).vehicle_list;
 	TileIndex tile = w->window_number;
@@ -300,7 +300,7 @@
 	MODE_START_STOP   = -2,
 };
 
-static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
+static int GetVehicleFromDepotWndPt(const BaseWindow *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
 {
 	Vehicle **vl = WP(w, depot_d).vehicle_list;
 	uint xt, row, xm = 0, ym = 0;
@@ -410,7 +410,7 @@
 	DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
 }
 
-static void DepotClick(Window *w, int x, int y)
+static void DepotClick(BaseWindow *w, int x, int y)
 {
 	GetDepotVehiclePtData gdvp;
 	Vehicle *v = NULL;
@@ -479,7 +479,7 @@
  * @param *v is the original vehicle to clone
  * @param *w is the window of the depot where the clone is build
  */
-static void HandleCloneVehClick(const Vehicle *v, const Window *w)
+static void HandleCloneVehClick(const Vehicle *v, const BaseWindow *w)
 {
 	uint error_str;
 
@@ -504,14 +504,14 @@
 	ResetObjectToPlace();
 }
 
-static void ClonePlaceObj(const Window *w)
+static void ClonePlaceObj(const BaseWindow *w)
 {
 	const Vehicle *v = CheckMouseOverVehicle();
 
 	if (v != NULL) HandleCloneVehClick(v, w);
 }
 
-static void ResizeDepotButtons(Window *w)
+static void ResizeDepotButtons(BaseWindow *w)
 {
 	w->ResizeButtons(DEPOT_WIDGET_BUILD, DEPOT_WIDGET_LOCATION);
 
@@ -527,7 +527,7 @@
  * Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites
  * Vehicle specific text/sprites, that's in a widget, that's only shown for one vehicle type (like sell whole train) is set in the widget array
  */
-static void SetupStringsForDepotWindow(Window *w, byte type)
+static void SetupStringsForDepotWindow(BaseWindow *w, byte type)
 {
 	switch (type) {
 		case VEH_Train:
@@ -694,7 +694,7 @@
 	ResizeDefaultWindowSize(VEH_Aircraft);
 }
 
-static void CreateDepotListWindow(Window *w, byte type)
+static void CreateDepotListWindow(BaseWindow *w, byte type)
 {
 	WP(w, depot_d).type = type;
 	_backup_orders_tile = 0;
@@ -743,7 +743,7 @@
 
 void DepotSortList(Vehicle **v, uint16 length);
 
-static void DepotWndProc(Window *w, WindowEvent *e)
+static void DepotWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_CREATE:
@@ -972,18 +972,18 @@
  */
 void ShowDepotWindow(TileIndex tile, byte type)
 {
-	Window *w;
+	BaseWindow *w;
 
 	switch (type) {
 		default: NOT_REACHED();
 		case VEH_Train:
-			w = AllocateWindowDescFront(&_train_depot_desc, tile); break;
+			w = BaseWindow::AllocateFront(&_train_depot_desc, tile); break;
 		case VEH_Road:
-			w = AllocateWindowDescFront(&_road_depot_desc, tile); break;
+			w = BaseWindow::AllocateFront(&_road_depot_desc, tile); break;
 		case VEH_Ship:
-			w = AllocateWindowDescFront(&_ship_depot_desc, tile); break;
+			w = BaseWindow::AllocateFront(&_ship_depot_desc, tile); break;
 		case VEH_Aircraft:
-			w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); break;
+			w = BaseWindow::AllocateFront(&_aircraft_depot_desc, tile); break;
 	}
 
 	if (w != NULL) {
@@ -997,13 +997,13 @@
  */
 void DeleteDepotHighlightOfVehicle(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 
 	/* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either
 	 * If that is the case, we can skip looping though the windows and save time                                */
 	if (_special_mouse_mode != WSM_DRAGDROP) return;
 
-	w = Window::FindById(WC_VEHICLE_DEPOT, v->tile);
+	w = BaseWindow::FindById(WC_VEHICLE_DEPOT, v->tile);
 	if (w != NULL) {
 		WP(w, depot_d).sel = INVALID_VEHICLE;
 		ResetObjectToPlace();
--- a/src/dock_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/dock_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -75,38 +75,38 @@
 };
 
 
-static void BuildDocksClick_Canal(Window *w)
+static void BuildDocksClick_Canal(BaseWindow *w)
 {
 	HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal);
 }
 
-static void BuildDocksClick_Lock(Window *w)
+static void BuildDocksClick_Lock(BaseWindow *w)
 {
 	HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock);
 }
 
-static void BuildDocksClick_Demolish(Window *w)
+static void BuildDocksClick_Demolish(BaseWindow *w)
 {
 	HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea);
 }
 
-static void BuildDocksClick_Depot(Window *w)
+static void BuildDocksClick_Depot(BaseWindow *w)
 {
 	if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
 }
 
-static void BuildDocksClick_Dock(Window *w)
+static void BuildDocksClick_Dock(BaseWindow *w)
 {
 	if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker();
 }
 
-static void BuildDocksClick_Buoy(Window *w)
+static void BuildDocksClick_Buoy(BaseWindow *w)
 {
 	HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy);
 }
 
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 static OnButtonClick * const _build_docks_button_proc[] = {
 	BuildDocksClick_Canal,
 	BuildDocksClick_Lock,
@@ -117,7 +117,7 @@
 	BuildDocksClick_Buoy
 };
 
-static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
+static void BuildDocksToolbWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -162,10 +162,10 @@
 	case WE_ABORT_PLACE_OBJ:
 		w->RaiseButtons();
 
-		w = Window::FindById(WC_BUILD_STATION, 0);
+		w = BaseWindow::FindById(WC_BUILD_STATION, 0);
 		if (w != NULL) WP(w,def_d).close = true;
 
-		w = Window::FindById(WC_BUILD_DEPOT, 0);
+		w = BaseWindow::FindById(WC_BUILD_DEPOT, 0);
 		if (w != NULL) WP(w,def_d).close = true;
 		break;
 
@@ -190,7 +190,7 @@
 	}
 }
 
-static const Widget _build_docks_toolb_widgets[] = {
+static const OldWidget _build_docks_toolb_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   123,     0,    13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   124,   135,     0,    13, 0x0,                        STR_STICKY_BUTTON},
@@ -219,11 +219,11 @@
 	if (!IsValidPlayer(_current_player)) return;
 
 	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
-	Window *w = AllocateWindowDesc(&_build_docks_toolbar_desc);
+	BaseWindow *w = BaseWindow::Allocate(&_build_docks_toolbar_desc);
 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
 }
 
-static void BuildDockStationWndProc(Window *w, WindowEvent *e)
+static void BuildDockStationWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->LowerWidget(_station_show_coverage + 3); break;
@@ -270,7 +270,7 @@
 	}
 }
 
-static const Widget _build_dock_station_widgets[] = {
+static const OldWidget _build_dock_station_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3068_DOCK,                    STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,    74, 0x0,                              STR_NULL},
@@ -290,7 +290,7 @@
 
 static void ShowBuildDockStationPicker(void)
 {
-	AllocateWindowDesc(&_build_dock_station_desc);
+	BaseWindow::Allocate(&_build_dock_station_desc);
 }
 
 static void UpdateDocksDirection(void)
@@ -302,7 +302,7 @@
 	}
 }
 
-static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
+static void BuildDocksDepotWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->LowerWidget(_ship_depot_direction + 3); break;
@@ -340,7 +340,7 @@
 	}
 }
 
-static const Widget _build_docks_depot_widgets[] = {
+static const OldWidget _build_docks_depot_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   203,     0,    13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   203,    14,    85, 0x0,                             STR_NULL},
@@ -360,7 +360,7 @@
 
 static void ShowBuildDocksDepotPicker(void)
 {
-	AllocateWindowDesc(&_build_docks_depot_desc);
+	BaseWindow::Allocate(&_build_docks_depot_desc);
 	UpdateDocksDirection();
 }
 
--- a/src/economy.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/economy.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -461,7 +461,7 @@
 	}
 }
 
-void DrawNewsBankrupcy(Window *w)
+void DrawNewsBankrupcy(BaseWindow *w)
 {
 	Player *p;
 
--- a/src/engine_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/engine_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -37,7 +37,7 @@
 	return STR_8104_AIRCRAFT;
 }
 
-static const Widget _engine_preview_widgets[] = {
+static const OldWidget _engine_preview_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,                                  STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     5,    11,   299,     0,    13, STR_8100_MESSAGE_FROM_VEHICLE_MANUFACTURE, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     5,     0,   299,    14,   191, 0x0,                                       STR_NULL},
@@ -66,7 +66,7 @@
 	{DrawAircraftEngine,DrawAircraftEngineInfo},
 };
 
-static void EnginePreviewWndProc(Window *w, WindowEvent *e)
+static void EnginePreviewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -116,7 +116,7 @@
 
 void ShowEnginePreviewWindow(EngineID engine)
 {
-	AllocateWindowDescFront(&_engine_preview_desc, engine);
+	BaseWindow::AllocateFront(&_engine_preview_desc, engine);
 }
 
 static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
@@ -140,7 +140,7 @@
 	DrawStringMultiCenter(x, y, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, maxw);
 }
 
-void DrawNewsNewTrainAvail(Window *w)
+void DrawNewsNewTrainAvail(BaseWindow *w)
 {
 	EngineID engine;
 
@@ -181,7 +181,7 @@
 	DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
 }
 
-void DrawNewsNewAircraftAvail(Window *w)
+void DrawNewsNewAircraftAvail(BaseWindow *w)
 {
 	EngineID engine;
 
@@ -221,7 +221,7 @@
 	DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
 }
 
-void DrawNewsNewRoadVehAvail(Window *w)
+void DrawNewsNewRoadVehAvail(BaseWindow *w)
 {
 	EngineID engine;
 
@@ -258,7 +258,7 @@
 	DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
 }
 
-void DrawNewsNewShipAvail(Window *w)
+void DrawNewsNewShipAvail(BaseWindow *w)
 {
 	EngineID engine;
 
--- a/src/functions.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/functions.h	Sun Feb 18 14:17:28 2007 +0000
@@ -155,12 +155,12 @@
 void DeleteWindowById(WindowClass cls, WindowNumber number);
 void DeleteWindowByClass(WindowClass cls);
 
-void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w);
+void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, BaseWindow *w);
 void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num);
 
 void ResetObjectToPlace(void);
 
-bool ScrollWindowTo(int x, int y, Window * w);
+bool ScrollWindowTo(int x, int y, BaseWindow * w);
 
 bool ScrollMainWindowToTile(TileIndex tile);
 bool ScrollMainWindowTo(int x, int y);
--- a/src/genworld.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/genworld.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -142,7 +142,7 @@
 
 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
 	/* Show all vital windows again, because we have hidden them */
-	if (_gw.threaded && _game_mode != GM_MENU) Window::ShowVitalWindows();
+	if (_gw.threaded && _game_mode != GM_MENU) BaseWindow::ShowVitalWindows();
 	_gw.active   = false;
 	_gw.thread   = NULL;
 	_gw.proc     = NULL;
@@ -215,7 +215,7 @@
 
 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
 	/* Show all vital windows again, because we have hidden them */
-	if (_gw.threaded && _game_mode != GM_MENU) Window::ShowVitalWindows();
+	if (_gw.threaded && _game_mode != GM_MENU) BaseWindow::ShowVitalWindows();
 	_gw.active   = false;
 	_gw.thread   = NULL;
 	_gw.proc     = NULL;
@@ -278,15 +278,15 @@
 	}
 
 	/* Remove any open window */
-	Window::DeleteAllNonVitalWindows();
+	BaseWindow::DeleteAllNonVitalWindows();
 	/* Hide vital windows, because we don't allow to use them */
-	Window::HideVitalWindows();
+	BaseWindow::HideVitalWindows();
 
 	/* Don't show the dialog if we don't have a thread */
 	ShowGenerateWorldProgress();
 
 	/* Centre the view on the map */
-	if (Window::FindById(WC_MAIN_WINDOW, 0) != NULL) {
+	if (BaseWindow::FindById(WC_MAIN_WINDOW, 0) != NULL) {
 		ScrollMainWindowToTile(TileXY(MapSizeX() / 2, MapSizeY() / 2));
 	}
 }
--- a/src/genworld_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/genworld_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -91,7 +91,7 @@
 	GLAND_SMOOTHNESS_PULLDOWN
 };
 
-static const Widget _generate_landscape_widgets[] = {
+static const OldWidget _generate_landscape_widgets[] = {
 {  WWT_CLOSEBOX,  RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
 {      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 267, 0x0,                          STR_NULL},
@@ -137,7 +137,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _heightmap_load_widgets[] = {
+static const OldWidget _heightmap_load_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
 {      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 235, 0x0,                          STR_NULL},
@@ -180,7 +180,7 @@
 
 void StartGeneratingLandscape(glwp_modes mode)
 {
-	Window::DeleteAllNonVitalWindows();
+	BaseWindow::DeleteAllNonVitalWindows();
 
 	/* Copy all XXX_newgame to XXX when coming from outside the editor */
 	UpdatePatches();
@@ -197,12 +197,12 @@
 	}
 }
 
-static void HeightmapScaledTooMuchCallback(Window *w, bool confirmed)
+static void HeightmapScaledTooMuchCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) StartGeneratingLandscape((glwp_modes)w->window_number);
 }
 
-static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
+static void GenerateLandscapeWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static const StringID mapsizes[]    = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
 	static const StringID elevations[]  = {STR_682A_VERY_FLAT, STR_682B_FLAT, STR_682C_HILLY, STR_682D_MOUNTAINOUS, INVALID_STRING_ID};
@@ -526,7 +526,7 @@
 			return;
 	}
 
-	Window *w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
+	BaseWindow *w = BaseWindow::AllocateFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
 
 	if (w != NULL) InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
 }
@@ -574,7 +574,7 @@
 };
 
 
-static void CreateScenarioWndProc(Window *w, WindowEvent *e)
+static void CreateScenarioWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
 
@@ -688,7 +688,7 @@
 	}
 }
 
-static const Widget _create_scenario_widgets[] = {
+static const OldWidget _create_scenario_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_SE_CAPTION,          STR_NULL},
 {      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 169, 0x0,                     STR_NULL},
@@ -727,11 +727,11 @@
 void ShowCreateScenario(void)
 {
 	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
-	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
+	BaseWindow::AllocateFront(&_create_scenario_desc, GLWP_SCENARIO);
 }
 
 
-static const Widget _show_terrain_progress_widgets[] = {
+static const OldWidget _show_terrain_progress_widgets[] = {
 {    WWT_CAPTION,   RESIZE_NONE,    14,     0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
 {    WWT_TEXTBTN,   RESIZE_NONE,    15,    20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL}, // Abort button
@@ -748,7 +748,7 @@
 
 static tp_info _tp;
 
-static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
+static void AbortGeneratingWorldCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) {
 		AbortGeneratingWorld();
@@ -757,7 +757,7 @@
 	}
 }
 
-static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
+static void ShowTerrainProgressProc(BaseWindow* w, WindowEvent* e)
 {
 	switch (e->event) {
 	case WE_CLICK:
@@ -821,7 +821,7 @@
  */
 void ShowGenerateWorldProgress(void)
 {
-	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
+	BaseWindow::AllocateFront(&_show_terrain_progress_desc, 0);
 }
 
 static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
--- a/src/graph_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/graph_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -243,7 +243,7 @@
 /* GRAPH LEGEND */
 /****************/
 
-static void GraphLegendWndProc(Window *w, WindowEvent *e)
+static void GraphLegendWndProc(BaseWindow *w, WindowEvent *e)
 {
 	const Player* p;
 
@@ -292,7 +292,7 @@
 	}
 }
 
-static const Widget _graph_legend_widgets[] = {
+static const OldWidget _graph_legend_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   113, 0x0,                            STR_NULL},
@@ -317,7 +317,7 @@
 
 static void ShowGraphLegend(void)
 {
-	AllocateWindowDescFront(&_graph_legend_desc, 0);
+	BaseWindow::AllocateFront(&_graph_legend_desc, 0);
 }
 
 /********************/
@@ -355,7 +355,7 @@
 	gd->month = mo;
 }
 
-static void OperatingProfitWndProc(Window *w, WindowEvent *e)
+static void OperatingProfitWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -397,7 +397,7 @@
 	}
 }
 
-static const Widget _operating_profit_widgets[] = {
+static const OldWidget _operating_profit_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                    STR_704D_SHOW_KEY_TO_GRAPHS},
@@ -416,7 +416,7 @@
 
 void ShowOperatingProfitGraph(void)
 {
-	if (AllocateWindowDescFront(&_operating_profit_desc, 0)) {
+	if (BaseWindow::AllocateFront(&_operating_profit_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -426,7 +426,7 @@
 /* INCOME GRAPH */
 /****************/
 
-static void IncomeGraphWndProc(Window *w, WindowEvent *e)
+static void IncomeGraphWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -469,7 +469,7 @@
 	}
 }
 
-static const Widget _income_graph_widgets[] = {
+static const OldWidget _income_graph_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,          STR_704D_SHOW_KEY_TO_GRAPHS},
@@ -487,7 +487,7 @@
 
 void ShowIncomeGraph(void)
 {
-	if (AllocateWindowDescFront(&_income_graph_desc, 0)) {
+	if (BaseWindow::AllocateFront(&_income_graph_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -496,7 +496,7 @@
 /* DELIVERED CARGO */
 /*******************/
 
-static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e)
+static void DeliveredCargoGraphWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -539,7 +539,7 @@
 	}
 }
 
-static const Widget _delivered_cargo_graph_widgets[] = {
+static const OldWidget _delivered_cargo_graph_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                      STR_704D_SHOW_KEY_TO_GRAPHS},
@@ -557,7 +557,7 @@
 
 void ShowDeliveredCargoGraph(void)
 {
-	if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) {
+	if (BaseWindow::AllocateFront(&_delivered_cargo_graph_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -566,7 +566,7 @@
 /* PERFORMANCE HISTORY */
 /***********************/
 
-static void PerformanceHistoryWndProc(Window *w, WindowEvent *e)
+static void PerformanceHistoryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -611,7 +611,7 @@
 	}
 }
 
-static const Widget _performance_history_widgets[] = {
+static const OldWidget _performance_history_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                         STR_704D_SHOW_KEY_TO_GRAPHS},
@@ -630,7 +630,7 @@
 
 void ShowPerformanceHistoryGraph(void)
 {
-	if (AllocateWindowDescFront(&_performance_history_desc, 0)) {
+	if (BaseWindow::AllocateFront(&_performance_history_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -639,7 +639,7 @@
 /* COMPANY VALUE */
 /*****************/
 
-static void CompanyValueGraphWndProc(Window *w, WindowEvent *e)
+static void CompanyValueGraphWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -682,7 +682,7 @@
 	}
 }
 
-static const Widget _company_value_graph_widgets[] = {
+static const OldWidget _company_value_graph_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,            STR_704D_SHOW_KEY_TO_GRAPHS},
@@ -700,7 +700,7 @@
 
 void ShowCompanyValueGraph(void)
 {
-	if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) {
+	if (BaseWindow::AllocateFront(&_company_value_graph_desc, 0)) {
 		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 	}
 }
@@ -709,7 +709,7 @@
 /* PAYMENT RATES */
 /*****************/
 
-static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
+static void CargoPaymentRatesWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: {
@@ -781,7 +781,7 @@
 	}
 }
 
-static const Widget _cargo_payment_rates_widgets[] = {
+static const OldWidget _cargo_payment_rates_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   567,    14,   141, 0x0,                          STR_NULL},
@@ -811,7 +811,7 @@
 
 void ShowCargoPaymentRates(void)
 {
-	AllocateWindowDescFront(&_cargo_payment_rates_desc, 0);
+	BaseWindow::AllocateFront(&_cargo_payment_rates_desc, 0);
 }
 
 /************************/
@@ -850,7 +850,7 @@
 	return p2->old_economy[1].performance_history - p1->old_economy[1].performance_history;
 }
 
-static void CompanyLeagueWndProc(Window *w, WindowEvent *e)
+static void CompanyLeagueWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -884,7 +884,7 @@
 }
 
 
-static const Widget _company_league_widgets[] = {
+static const OldWidget _company_league_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,                      STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_NONE, 14,  11, 387,  0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX, RESIZE_NONE, 14, 388, 399,  0, 13, STR_NULL,                      STR_STICKY_BUTTON},
@@ -902,14 +902,14 @@
 
 void ShowCompanyLeagueTable(void)
 {
-	AllocateWindowDescFront(&_company_league_desc,0);
+	BaseWindow::AllocateFront(&_company_league_desc,0);
 }
 
 /*****************************/
 /* PERFORMANCE RATING DETAIL */
 /*****************************/
 
-static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
+static void PerformanceRatingDetailWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static PlayerID _performance_rating_detail_player = INVALID_PLAYER;
 
@@ -1106,7 +1106,7 @@
 	}
 }
 
-static const Widget _performance_rating_detail_widgets[] = {
+static const OldWidget _performance_rating_detail_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    14,    27, 0x0,                    STR_NULL},
@@ -1143,5 +1143,5 @@
 
 void ShowPerformanceRatingDetail(void)
 {
-	AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
+	BaseWindow::AllocateFront(&_performance_rating_detail_desc, 0);
 }
--- a/src/gui.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/gui.h	Sun Feb 18 14:17:28 2007 +0000
@@ -57,7 +57,7 @@
 void ShowBuildAirToolbar(void);
 
 /* terraform_gui.c */
-void ShowTerraformToolbar(Window *link = NULL);
+void ShowTerraformToolbar(BaseWindow *link = NULL);
 
 /* tgp_gui.c */
 void ShowGenerateLandscape(void);
@@ -92,19 +92,19 @@
 void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
 
 void DrawStationCoverageAreaText(int sx, int sy, uint mask,int rad);
-void CheckRedrawStationCoverage(const Window *w);
+void CheckRedrawStationCoverage(const BaseWindow *w);
 
 void ShowSmallMap(void);
 void ShowExtraViewPortWindow(void);
-void SetVScrollCount(Window *w, int num);
-void SetVScroll2Count(Window *w, int num);
-void SetHScrollCount(Window *w, int num);
+void SetVScrollCount(BaseWindow *w, int num);
+void SetVScroll2Count(BaseWindow *w, int num);
+void SetHScrollCount(BaseWindow *w, int num);
 
 void ShowCheatWindow(void);
 
-void DrawEditBox(Window *w, querystr_d *string, int wid);
-void HandleEditBox(Window *w, querystr_d *string, int wid);
-int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we);
+void DrawEditBox(BaseWindow *w, querystr_d *string, int wid);
+void HandleEditBox(BaseWindow *w, querystr_d *string, int wid);
+int HandleEditBoxKey(BaseWindow *w, querystr_d *string, int wid, WindowEvent *we);
 bool HandleCaret(Textbuf *tb);
 
 void DeleteTextBufferAll(Textbuf *tb);
@@ -125,8 +125,8 @@
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
 
 void ShowBuildIndustryWindow(void);
-void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
-void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool));
+void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, BaseWindow *parent, CharSetFilter afilter);
+void ShowQuery(StringID caption, StringID message, BaseWindow *w, void (*callback)(BaseWindow*, bool));
 void ShowMusicWindow(void);
 
 /* main_gui.c */
--- a/src/industry_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/industry_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -27,7 +27,7 @@
 
 static void UpdateIndustryProduction(Industry *i);
 
-static void BuildIndustryWndProc(Window *w, WindowEvent *e)
+static void BuildIndustryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -59,7 +59,7 @@
 	}
 }
 
-static const Widget _build_industry_land0_widgets[] = {
+static const OldWidget _build_industry_land0_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   115, 0x0,                            STR_NULL},
@@ -71,7 +71,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land1_widgets[] = {
+static const OldWidget _build_industry_land1_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   115, 0x0,                            STR_NULL},
@@ -83,7 +83,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land2_widgets[] = {
+static const OldWidget _build_industry_land2_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   115, 0x0,                            STR_NULL},
@@ -95,7 +95,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land3_widgets[] = {
+static const OldWidget _build_industry_land3_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   115, 0x0,                            STR_NULL},
@@ -106,7 +106,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land0_widgets_extra[] = {
+static const OldWidget _build_industry_land0_widgets_extra[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   187, 0x0,                            STR_NULL},
@@ -127,7 +127,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land1_widgets_extra[] = {
+static const OldWidget _build_industry_land1_widgets_extra[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   174, 0x0,                            STR_NULL},
@@ -146,7 +146,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land2_widgets_extra[] = {
+static const OldWidget _build_industry_land2_widgets_extra[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   200, 0x0,                            STR_NULL},
@@ -167,7 +167,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _build_industry_land3_widgets_extra[] = {
+static const OldWidget _build_industry_land3_widgets_extra[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   187, 0x0,                            STR_NULL},
@@ -270,7 +270,7 @@
 void ShowBuildIndustryWindow(void)
 {
 	if (!IsValidPlayer(_current_player)) return;
-	AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
+	BaseWindow::AllocateFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
 }
 
 static inline bool isProductionMinimum(const Industry *i, int pt) {
@@ -287,7 +287,7 @@
 		     (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES));
 }
 
-static void IndustryViewWndProc(Window *w, WindowEvent *e)
+static void IndustryViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	// WP(w,vp2_d).data_1 is for the editbox line
 	// WP(w,vp2_d).data_2 is for the clickline
@@ -419,7 +419,7 @@
 		i->total_production[1] = 8 * i->production_rate[1];
 }
 
-static const Widget _industry_view_widgets[] = {
+static const OldWidget _industry_view_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     9,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     9,    11,   247,     0,    13, STR_4801,          STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     9,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},
@@ -441,7 +441,7 @@
 
 void ShowIndustryViewWindow(int industry)
 {
-	Window *w = AllocateWindowDescFront(&_industry_view_desc, industry);
+	BaseWindow *w = BaseWindow::AllocateFront(&_industry_view_desc, industry);
 
 	if (w != NULL) {
 		w->flags4 |= WF_DISABLE_VP_SCROLL;
@@ -452,7 +452,7 @@
 	}
 }
 
-static const Widget _industry_directory_widgets[] = {
+static const OldWidget _industry_directory_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   495,     0,    13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    13,   496,   507,     0,    13, 0x0,                     STR_STICKY_BUTTON},
@@ -574,7 +574,7 @@
 }
 
 
-static void IndustryDirectoryWndProc(Window *w, WindowEvent *e)
+static void IndustryDirectoryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -683,7 +683,7 @@
 
 void ShowIndustryDirectory(void)
 {
-	Window *w = AllocateWindowDescFront(&_industry_directory_desc, 0);
+	BaseWindow *w = BaseWindow::AllocateFront(&_industry_directory_desc, 0);
 
 	if (w != NULL) {
 		w->vscroll.cap = 16;
--- a/src/intro_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/intro_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -17,7 +17,7 @@
 #include "network/network_gui.h"
 #include "newgrf.h"
 
-static const Widget _select_game_widgets[] = {
+static const OldWidget _select_game_widgets[] = {
 {    WWT_CAPTION, RESIZE_NONE, 13,   0, 335,   0,  13, STR_0307_OPENTTD,         STR_NULL},
 {      WWT_PANEL, RESIZE_NONE, 13,   0, 335,  14, 194, 0x0,                      STR_NULL},
 { WWT_PUSHTXTBTN, RESIZE_NONE, 12,  10, 167,  22,  33, STR_0140_NEW_GAME,        STR_02FB_START_A_NEW_GAME},
@@ -47,7 +47,7 @@
 	InvalidateWindowClasses(WC_SELECT_GAME);
 }
 
-static void SelectGameWndProc(Window *w, WindowEvent *e)
+static void SelectGameWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + 8); break;
@@ -99,10 +99,10 @@
 
 void ShowSelectGameWindow(void)
 {
-	AllocateWindowDesc(&_select_game_desc);
+	BaseWindow::Allocate(&_select_game_desc);
 }
 
-static void AskExitGameCallback(Window *w, bool confirmed)
+static void AskExitGameCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) _exit_game = true;
 }
@@ -133,7 +133,7 @@
 }
 
 
-static void AskExitToGameMenuCallback(Window *w, bool confirmed)
+static void AskExitToGameMenuCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) _switch_mode = SM_MENU;
 }
--- a/src/main_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/main_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -98,7 +98,7 @@
  * This code is shared for the majority of the pushbuttons.
  * Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters
  *
- * @param w Window which called the function
+ * @param w BaseWindow which called the function
  * @param widget ID of the widget (=button) that called this function
  * @param cursor How should the cursor image change? E.g. cursor with depot image in it
  * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
@@ -106,7 +106,7 @@
 
  * @return true if the button is clicked, false if it's unclicked
  */
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc)
+bool HandlePlacePushButton(BaseWindow *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc)
 {
 	if (w->IsWidgetDisabled(widget)) return false;
 
@@ -131,14 +131,14 @@
 }
 
 
-static void ToolbarPauseClick(Window *w)
+static void ToolbarPauseClick(BaseWindow *w)
 {
 	if (_networking && !_network_server) return; // only server can pause the game
 
 	if (DoCommandP(0, _pause ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
 }
 
-static void ToolbarFastForwardClick(Window *w)
+static void ToolbarFastForwardClick(BaseWindow *w)
 {
 	_fast_forward ^= true;
 	SndPlayFx(SND_15_BEEP);
@@ -423,7 +423,7 @@
 	MenuClickHelp,        /* 26 */
 };
 
-static void MenuWndProc(Window *w, WindowEvent *e)
+static void MenuWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_CREATE: w->widget[0].right = w->width - 1; break;
@@ -456,7 +456,7 @@
 	} break;
 
 	case WE_DESTROY: {
-			Window *v = Window::FindById(WC_MAIN_TOOLBAR, 0);
+			BaseWindow *v = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 			v->RaiseWidget(WP(w,menu_d).main_button);
 			v->SetDirty();
 			return;
@@ -468,7 +468,7 @@
 
 
 		if (index < 0) {
-			Window *w2 = Window::FindById(WC_MAIN_TOOLBAR,0);
+			BaseWindow *w2 = BaseWindow::FindById(WC_MAIN_TOOLBAR,0);
 			if (w2->GetWidgetFromPos(e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
 				index = WP(w,menu_d).sel_index;
 		}
@@ -498,13 +498,13 @@
 
 /* Dynamic widget length determined by toolbar-string length.
  * See PopupMainToolbMenu en MenuWndProc */
-static const Widget _menu_widgets[] = {
+static const OldWidget _menu_widgets[] = {
 {    WWT_PANEL, RESIZE_NONE, 14, 0,  0, 0, 0, 0x0, STR_NULL},
 { WIDGETS_END},
 };
 
 
-static const Widget _player_menu_widgets[] = {
+static const OldWidget _player_menu_widgets[] = {
 {    WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL},
 { WIDGETS_END},
 };
@@ -522,7 +522,7 @@
 	return -1;
 }
 
-static void UpdatePlayerMenuHeight(Window *w)
+static void UpdatePlayerMenuHeight(BaseWindow *w)
 {
 	byte num = ActivePlayerCount();
 
@@ -539,7 +539,7 @@
 	}
 }
 
-static void PlayerMenuWndProc(Window *w, WindowEvent *e)
+static void PlayerMenuWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -591,7 +591,7 @@
 		}
 
 	case WE_DESTROY: {
-		Window *v = Window::FindById(WC_MAIN_TOOLBAR, 0);
+		BaseWindow *v = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 		v->RaiseWidget(WP(w,menu_d).main_button);
 		v->SetDirty();
 		return;
@@ -610,7 +610,7 @@
 		}
 
 		if (index < 0) {
-			Window *w2 = Window::FindById(WC_MAIN_TOOLBAR,0);
+			BaseWindow *w2 = BaseWindow::FindById(WC_MAIN_TOOLBAR,0);
 			if (w2->GetWidgetFromPos(e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
 				index = WP(w,menu_d).sel_index;
 		}
@@ -688,7 +688,7 @@
  * @param item_count Number of strings in the list, see previous parameter
  * @param disabled_mask Bitmask of disabled strings in the list
  * @return Return a pointer to the newly created dropdown window */
-static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
+static BaseWindow *PopupMainToolbMenu(BaseWindow *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
 {
 	int width;
 	int x = w->widget[GB(parent_button, 0, 8)].left;
@@ -707,7 +707,7 @@
 	width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
 	x = w->left + clamp(x, 0, w->width - width); // or alternatively '_screen.width - width'
 
-	w = Window::Allocate(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
+	w = BaseWindow::Allocate(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
 	w->widget[0].bottom = item_count * 10 + 1;
 	w->flash_timeout = 0;
 
@@ -725,7 +725,7 @@
 	return w;
 }
 
-static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int gray)
+static BaseWindow *PopupMainPlayerToolbMenu(BaseWindow *w, int x, int main_button, int gray)
 {
 	x += w->left;
 
@@ -733,7 +733,7 @@
 	w->InvalidateWidget(main_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
-	w = Window::Allocate(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
+	w = BaseWindow::Allocate(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 	w->flash_timeout = 0;
 	WP(w,menu_d).item_count = 0;
 	WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
@@ -754,58 +754,58 @@
 	return w;
 }
 
-static void ToolbarSaveClick(Window *w)
+static void ToolbarSaveClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
 }
 
-static void ToolbarMapClick(Window *w)
+static void ToolbarMapClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
 }
 
-static void ToolbarTownClick(Window *w)
+static void ToolbarTownClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
 }
 
-static void ToolbarSubsidiesClick(Window *w)
+static void ToolbarSubsidiesClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
 }
 
-static void ToolbarStationsClick(Window *w)
+static void ToolbarStationsClick(BaseWindow *w)
 {
 	PopupMainPlayerToolbMenu(w, 162, 7, 0);
 }
 
-static void ToolbarMoneyClick(Window *w)
+static void ToolbarMoneyClick(BaseWindow *w)
 {
 	PopupMainPlayerToolbMenu(w, 191, 8, 0);
 }
 
-static void ToolbarPlayersClick(Window *w)
+static void ToolbarPlayersClick(BaseWindow *w)
 {
 	PopupMainPlayerToolbMenu(w, 213, 9, 0);
 }
 
-static void ToolbarGraphsClick(Window *w)
+static void ToolbarGraphsClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
 }
 
-static void ToolbarLeagueClick(Window *w)
+static void ToolbarLeagueClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
 }
 
-static void ToolbarIndustryClick(Window *w)
+static void ToolbarIndustryClick(BaseWindow *w)
 {
 	/* Disable build-industry menu if we are a spectator */
 	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
 }
 
-static void ToolbarTrainClick(Window *w)
+static void ToolbarTrainClick(BaseWindow *w)
 {
 	const Vehicle *v;
 	int dis = -1;
@@ -816,7 +816,7 @@
 	PopupMainPlayerToolbMenu(w, 310, 13, dis);
 }
 
-static void ToolbarRoadClick(Window *w)
+static void ToolbarRoadClick(BaseWindow *w)
 {
 	const Vehicle *v;
 	int dis = -1;
@@ -827,7 +827,7 @@
 	PopupMainPlayerToolbMenu(w, 332, 14, dis);
 }
 
-static void ToolbarShipClick(Window *w)
+static void ToolbarShipClick(BaseWindow *w)
 {
 	const Vehicle *v;
 	int dis = -1;
@@ -838,7 +838,7 @@
 	PopupMainPlayerToolbMenu(w, 354, 15, dis);
 }
 
-static void ToolbarAirClick(Window *w)
+static void ToolbarAirClick(BaseWindow *w)
 {
 	const Vehicle *v;
 	int dis = -1;
@@ -851,7 +851,7 @@
 
 /* Zooms a viewport in a window in or out */
 /* No button handling or what so ever */
-bool DoZoomInOutWindow(int how, Window *w)
+bool DoZoomInOutWindow(int how, BaseWindow *w)
 {
 	ViewPort *vp;
 
@@ -889,66 +889,66 @@
 	return true;
 }
 
-static void ToolbarZoomInClick(Window *w)
+static void ToolbarZoomInClick(BaseWindow *w)
 {
-	if (DoZoomInOutWindow(ZOOM_IN, Window::FindById(WC_MAIN_WINDOW, 0))) {
+	if (DoZoomInOutWindow(ZOOM_IN, BaseWindow::FindById(WC_MAIN_WINDOW, 0))) {
 		w->HandleButtonClick(17);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
 
-static void ToolbarZoomOutClick(Window *w)
+static void ToolbarZoomOutClick(BaseWindow *w)
 {
-	if (DoZoomInOutWindow(ZOOM_OUT,Window::FindById(WC_MAIN_WINDOW, 0))) {
+	if (DoZoomInOutWindow(ZOOM_OUT,BaseWindow::FindById(WC_MAIN_WINDOW, 0))) {
 		w->HandleButtonClick(18);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
 
-static void ToolbarBuildRailClick(Window *w)
+static void ToolbarBuildRailClick(BaseWindow *w)
 {
 	const Player *p = GetPlayer(_local_player);
-	Window *w2;
+	BaseWindow *w2;
 	w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
 	WP(w2,menu_d).sel_index = _last_built_railtype;
 }
 
-static void ToolbarBuildRoadClick(Window *w)
+static void ToolbarBuildRoadClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 1, 0);
 }
 
-static void ToolbarBuildWaterClick(Window *w)
+static void ToolbarBuildWaterClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
 }
 
-static void ToolbarBuildAirClick(Window *w)
+static void ToolbarBuildAirClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
 }
 
-static void ToolbarForestClick(Window *w)
+static void ToolbarForestClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
 }
 
-static void ToolbarMusicClick(Window *w)
+static void ToolbarMusicClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
 }
 
-static void ToolbarNewspaperClick(Window *w)
+static void ToolbarNewspaperClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
 }
 
-static void ToolbarHelpClick(Window *w)
+static void ToolbarHelpClick(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
 }
 
-static void ToolbarOptionsClick(Window *w)
+static void ToolbarOptionsClick(BaseWindow *w)
 {
 	uint16 x = 0;
 
@@ -966,12 +966,12 @@
 }
 
 
-static void ToolbarScenSaveOrLoad(Window *w)
+static void ToolbarScenSaveOrLoad(BaseWindow *w)
 {
 	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6, 0);
 }
 
-static void ToolbarScenDateBackward(Window *w)
+static void ToolbarScenDateBackward(BaseWindow *w)
 {
 	// don't allow too fast scrolling
 	if (w->autorepeat_timeout <= 2) {
@@ -984,7 +984,7 @@
 	_left_button_clicked = false;
 }
 
-static void ToolbarScenDateForward(Window *w)
+static void ToolbarScenDateForward(BaseWindow *w)
 {
 	// don't allow too fast scrolling
 	if (w->autorepeat_timeout <= 2) {
@@ -997,29 +997,29 @@
 	_left_button_clicked = false;
 }
 
-static void ToolbarScenMapTownDir(Window *w)
+static void ToolbarScenMapTownDir(BaseWindow *w)
 {
 	/* Scenario editor button, *hack*hack* use different button to activate */
 	PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4, 0);
 }
 
-static void ToolbarScenZoomIn(Window *w)
+static void ToolbarScenZoomIn(BaseWindow *w)
 {
-	if (DoZoomInOutWindow(ZOOM_IN, Window::FindById(WC_MAIN_WINDOW, 0))) {
+	if (DoZoomInOutWindow(ZOOM_IN, BaseWindow::FindById(WC_MAIN_WINDOW, 0))) {
 		w->HandleButtonClick(9);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
 
-static void ToolbarScenZoomOut(Window *w)
+static void ToolbarScenZoomOut(BaseWindow *w)
 {
-	if (DoZoomInOutWindow(ZOOM_OUT, Window::FindById(WC_MAIN_WINDOW, 0))) {
+	if (DoZoomInOutWindow(ZOOM_OUT, BaseWindow::FindById(WC_MAIN_WINDOW, 0))) {
 		w->HandleButtonClick(10);
 		SndPlayFx(SND_15_BEEP);
 	}
 }
 
-void ZoomInOrOutToCursorWindow(bool in, Window *w)
+void ZoomInOrOutToCursorWindow(bool in, BaseWindow *w)
 {
 	ViewPort *vp;
 	Point pt;
@@ -1143,7 +1143,7 @@
 	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_WaterArea);
 }
 
-static const Widget _scen_edit_land_gen_widgets[] = {
+static const OldWidget _scen_edit_land_gen_widgets[] = {
 {  WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW},
 {   WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_0223_LAND_GENERATION,  STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_STICKYBOX,   RESIZE_NONE,     7,   170,   181,     0,    13, STR_NULL,                  STR_STICKY_BUTTON},
@@ -1176,42 +1176,42 @@
 
 // TODO - Merge with terraform_gui.c (move there) after I have cooled down at its braindeadness
 // and changed OnButtonClick to include the widget as well in the function decleration. Post 0.4.0 - Darkvater
-static void EditorTerraformClick_Dynamite(Window *w)
+static void EditorTerraformClick_Dynamite(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
 }
 
-static void EditorTerraformClick_LowerBigLand(Window *w)
+static void EditorTerraformClick_LowerBigLand(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand);
 }
 
-static void EditorTerraformClick_RaiseBigLand(Window *w)
+static void EditorTerraformClick_RaiseBigLand(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand);
 }
 
-static void EditorTerraformClick_LevelLand(Window *w)
+static void EditorTerraformClick_LevelLand(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
 }
 
-static void EditorTerraformClick_WaterArea(Window *w)
+static void EditorTerraformClick_WaterArea(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, 1, PlaceProc_WaterArea);
 }
 
-static void EditorTerraformClick_RockyArea(Window *w)
+static void EditorTerraformClick_RockyArea(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, 1, PlaceProc_RockyArea);
 }
 
-static void EditorTerraformClick_DesertLightHouse(Window *w)
+static void EditorTerraformClick_DesertLightHouse(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, 1, (_opt.landscape == LT_DESERT) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
 }
 
-static void EditorTerraformClick_Transmitter(Window *w)
+static void EditorTerraformClick_Transmitter(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, 1, PlaceProc_Transmitter);
 }
@@ -1227,7 +1227,7 @@
 	'U'
 };
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 static OnButtonClick * const _editor_terraform_button_proc[] = {
 	EditorTerraformClick_Dynamite,
 	EditorTerraformClick_LowerBigLand,
@@ -1242,7 +1242,7 @@
 
 /** Callback function for the scenario editor 'reset landscape' confirmation window
  * @param yes_clicked boolean value, true when yes was clicked, false otherwise */
-static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
+static void ResetLandscapeConfirmationCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) {
 		Player *p;
@@ -1267,7 +1267,7 @@
 	}
 }
 
-static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
+static void ScenEditLandGenWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE:
@@ -1378,10 +1378,10 @@
 
 static inline void ShowEditorTerraformToolBar(void)
 {
-	AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0);
+	BaseWindow::AllocateFront(&_scen_edit_land_gen_desc, 0);
 }
 
-static void ToolbarScenGenLand(Window *w)
+static void ToolbarScenGenLand(BaseWindow *w)
 {
 	w->HandleButtonClick(11);
 	SndPlayFx(SND_15_BEEP);
@@ -1403,7 +1403,7 @@
 }
 
 
-static const Widget _scen_edit_town_gen_widgets[] = {
+static const OldWidget _scen_edit_town_gen_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   148,   159,     0,    13, 0x0,                      STR_STICKY_BUTTON},
@@ -1418,7 +1418,7 @@
 {   WIDGETS_END},
 };
 
-static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
+static void ScenEditTownGenWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -1492,16 +1492,16 @@
 	ScenEditTownGenWndProc,
 };
 
-static void ToolbarScenGenTown(Window *w)
+static void ToolbarScenGenTown(BaseWindow *w)
 {
 	w->HandleButtonClick(12);
 	SndPlayFx(SND_15_BEEP);
 
-	AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
+	BaseWindow::AllocateFront(&_scen_edit_town_gen_desc, 0);
 }
 
 
-static const Widget _scenedit_industry_normal_widgets[] = {
+static const OldWidget _scenedit_industry_normal_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_023F_INDUSTRY_GENERATION, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   224, 0x0,                          STR_NULL},
@@ -1524,7 +1524,7 @@
 };
 
 
-static const Widget _scenedit_industry_hilly_widgets[] = {
+static const OldWidget _scenedit_industry_hilly_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_023F_INDUSTRY_GENERATION,   STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   224, 0x0,                            STR_NULL},
@@ -1545,7 +1545,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _scenedit_industry_desert_widgets[] = {
+static const OldWidget _scenedit_industry_desert_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_023F_INDUSTRY_GENERATION,    STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   224, 0x0,                             STR_NULL},
@@ -1568,7 +1568,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _scenedit_industry_candy_widgets[] = {
+static const OldWidget _scenedit_industry_candy_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   169,     0,    13, STR_023F_INDUSTRY_GENERATION, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   169,    14,   224, 0x0,                          STR_NULL},
@@ -1634,7 +1634,7 @@
 static int _industry_type_to_place;
 bool _ignore_restrictions;
 
-static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
+static void ScenEditIndustryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	int button;
 
@@ -1735,40 +1735,40 @@
 };
 
 
-static void ToolbarScenGenIndustry(Window *w)
+static void ToolbarScenGenIndustry(BaseWindow *w)
 {
 	w->HandleButtonClick(13);
 	SndPlayFx(SND_15_BEEP);
-	AllocateWindowDescFront(_scenedit_industry_descs[_opt.landscape],0);
+	BaseWindow::AllocateFront(_scenedit_industry_descs[_opt.landscape],0);
 }
 
-static void ToolbarScenBuildRoad(Window *w)
+static void ToolbarScenBuildRoad(BaseWindow *w)
 {
 	w->HandleButtonClick(14);
 	SndPlayFx(SND_15_BEEP);
 	ShowBuildRoadScenToolbar();
 }
 
-static void ToolbarScenPlantTrees(Window *w)
+static void ToolbarScenPlantTrees(BaseWindow *w)
 {
 	w->HandleButtonClick(15);
 	SndPlayFx(SND_15_BEEP);
 	ShowBuildTreesScenToolbar();
 }
 
-static void ToolbarScenPlaceSign(Window *w)
+static void ToolbarScenPlaceSign(BaseWindow *w)
 {
 	w->HandleButtonClick(16);
 	SndPlayFx(SND_15_BEEP);
 	SelectSignTool();
 }
 
-static void ToolbarBtn_NULL(Window *w)
+static void ToolbarBtn_NULL(BaseWindow *w)
 {
 }
 
 
-typedef void ToolbarButtonProc(Window *w);
+typedef void ToolbarButtonProc(BaseWindow *w);
 
 static ToolbarButtonProc * const _toolbar_button_procs[] = {
 	ToolbarPauseClick,
@@ -1800,7 +1800,7 @@
 	ToolbarHelpClick,
 };
 
-static void MainToolbarWndProc(Window *w, WindowEvent *e)
+static void MainToolbarWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -1892,12 +1892,12 @@
 	}
 
 		case WE_MESSAGE:
-			HandleZoomMessage(w, Window::FindById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
+			HandleZoomMessage(w, BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
 			break;
 	}
 }
 
-static const Widget _toolb_normal_widgets[] = {
+static const OldWidget _toolb_normal_widgets[] = {
 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,    21,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,    22,    43,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,    44,    65,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},
@@ -1943,7 +1943,7 @@
 };
 
 
-static const Widget _toolb_scen_widgets[] = {
+static const OldWidget _toolb_scen_widgets[] = {
 {  WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},
 {  WWT_IMGBTN, RESIZE_NONE, 14,  22,  43,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},
 {  WWT_IMGBTN, RESIZE_NONE, 14,  44,  65,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
@@ -2010,7 +2010,7 @@
 	ToolbarHelpClick,
 };
 
-static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
+static void ScenEditToolbarWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -2080,7 +2080,7 @@
 		break;
 
 		case WE_MESSAGE:
-			HandleZoomMessage(w, Window::FindById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
+			HandleZoomMessage(w, BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
 			break;
 	}
 }
@@ -2142,7 +2142,7 @@
 	return x > 0;
 }
 
-static void StatusBarWndProc(Window *w, WindowEvent *e)
+static void StatusBarWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -2167,7 +2167,7 @@
 			DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0);
 		} else if (_pause) {
 			DrawStringCentered(320, 1, STR_0319_PAUSED, 0);
-		} else if (WP(w,def_d).data_1 > -1280 && Window::FindById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
+		} else if (WP(w,def_d).data_1 > -1280 && BaseWindow::FindById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
 			// Draw the scrolling news text
 			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1))
 				WP(w,def_d).data_1 = -1280;
@@ -2216,7 +2216,7 @@
 	}
 }
 
-static const Widget _main_status_widgets[] = {
+static const OldWidget _main_status_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   139,     0,    11, 0x0, STR_NULL},
 {    WWT_PUSHBTN,   RESIZE_NONE,    14,   140,   499,     0,    11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS},
 {    WWT_PUSHBTN,   RESIZE_NONE,    14,   500,   639,     0,    11, 0x0, STR_NULL},
@@ -2233,7 +2233,7 @@
 
 extern void UpdateAllStationVirtCoord(void);
 
-static void MainWindowWndProc(Window *w, WindowEvent *e)
+static void MainWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	int off_x;
 
@@ -2306,8 +2306,8 @@
 			}
 
 			case WKC_ESC: ResetObjectToPlace(); break;
-			case WKC_DELETE: Window::DeleteNonVitalWindows(); break;
-			case WKC_DELETE | WKC_SHIFT: Window::DeleteAllNonVitalWindows(); break;
+			case WKC_DELETE: BaseWindow::DeleteNonVitalWindows(); break;
+			case WKC_DELETE | WKC_SHIFT: BaseWindow::DeleteAllNonVitalWindows(); break;
 			case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
 
 #if defined(_DEBUG)
@@ -2402,7 +2402,7 @@
 void SetupColorsAndInitialWindow(void)
 {
 	uint i;
-	Window *w;
+	BaseWindow *w;
 	int width, height;
 
 	for (i = 0; i != 16; i++) {
@@ -2415,7 +2415,7 @@
 	width = _screen.width;
 	height = _screen.height;
 
-	w = Window::Allocate(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
+	w = BaseWindow::Allocate(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
 	AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0);
 
 	// XXX: these are not done
@@ -2427,16 +2427,16 @@
 
 		case GM_NORMAL:
 		case GM_EDITOR:
-			Window::ShowVitalWindows();
+			BaseWindow::ShowVitalWindows();
 			break;
 	}
 }
 
-void Window::ShowVitalWindows(void)
+void BaseWindow::ShowVitalWindows(void)
 {
-	Window *w;
-
-	w = AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
+	BaseWindow *w;
+
+	w = BaseWindow::Allocate((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
 	DoZoomInOutWindow(ZOOM_NONE, w);
 
 	w->flash_timeout = 0;
@@ -2451,7 +2451,7 @@
 	if (_game_mode == GM_EDITOR) return;
 
 	_main_status_desc.top = _screen.height - 12;
-	w = AllocateWindowDesc(&_main_status_desc);
+	w = BaseWindow::Allocate(&_main_status_desc);
 	w->flash_timeout = 0;
 
 	WP(w,def_d).data_1 = -1280;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/misc/rect.hpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,248 @@
+/* $Id$ */
+#ifndef RECT_H
+#define RECT_H
+
+/** Template based point */
+template <typename T> struct PointT {
+	T x, y;
+
+	PointT(T x_a = 0, T y_a = 0)
+		: x(x_a), y(y_a)
+	{}
+
+	template <typename Ta> PointT(const PointT<Ta> &src)
+		: x((T)src.x), y((T)src.y)
+	{}
+
+	PointT& operator =(const PointT &src)
+	{
+		x = (T)src.x;
+		y = (T)src.y;
+		return *this;
+	}
+
+	PointT operator -() const
+	{
+		return PointT(-x, -y);
+	}
+
+	void DoMove(T dx, T dy)
+	{
+		x += dx;
+		y += dy;
+	}
+
+	void DoMove(const PointT &offset)
+	{
+		DoMove((T)offset.x, (T)offset.y);
+	}
+
+	PointT operator +(const PointT &offset) const
+	{
+		PointT pt;
+		pt.DoMove(offset);
+		return pt;
+	}
+
+	PointT operator -(const PointT &offset) const
+	{
+		PointT pt;
+		pt.DoMove(-offset);
+		return pt;
+	}
+
+	PointT& operator +=(const PointT &offset)
+	{
+		DoMove(offset);
+		return *this;
+	}
+
+	PointT& operator -=(const PointT &offset)
+	{
+		DoMove(-offset);
+		return *this;
+	}
+};
+
+
+
+/** Template based rectangle */
+template <typename T> struct RectT
+{
+	PointT<T> top_left, bottom_right;
+
+	RectT(T left = 0, T top = 0, T right = 0, T bottom = 0)
+		: top_left(left, top), bottom_right(right, bottom)
+	{}
+
+	template <typename Ta> RectT(const RectT<Ta> &src)
+		: top_left(src.top_left), bottom_right(src.bottom_right)
+	{}
+
+	T Left() const
+	{
+		return top_left.x;
+	}
+
+	T Top() const
+	{
+		return top_left.y;
+	}
+
+	T Right() const
+	{
+		return bottom_right.x;
+	}
+
+	T Bottom() const
+	{
+		return bottom_right.y;
+	}
+
+	T Width() const
+	{
+		return bottom_right.x - top_left.x + 1;
+	}
+
+	T Height() const
+	{
+		return bottom_right.y - top_left.y + 1;
+	}
+
+	const PointT<T>& TopLeft() const
+	{
+		return top_left;
+	}
+
+	const PointT<T>& BottomRight() const
+	{
+		return bottom_right;
+	}
+
+	void SetLeft(T val)
+	{
+		top_left.x = val;
+	}
+
+	void SetTop(T val)
+	{
+		top_left.y = val;
+	}
+
+	void SetRight(T val)
+	{
+		bottom_right.x = val;
+	}
+
+	void SetBottom(T val)
+	{
+		bottom_right.y = val;
+	}
+
+	void SetWidth(T val)
+	{
+		bottom_right.x = top_left.x + val - 1;
+	}
+
+	void SetHeight(T val)
+	{
+		bottom_right.y = top_left.y + val - 1;
+	}
+
+	void SetTopLeft(const PointT<T> &pt)
+	{
+		top_left = pt;
+	}
+
+	void SetBottomRight(const PointT<T> &pt)
+	{
+		bottom_right = pt;
+	}
+
+	bool PtInRect(const PointT<T> &pt) const
+	{
+		return (top_left.x <= pt.x && pt.x <= bottom_right.x && top_left.y <= pt.y && pt.y <= bottom_right.y);
+	}
+
+	RectT& operator =(const RectT &src)
+	{
+		top_left     = src.top_left;
+		bottom_right = src.bottom_right;
+		return *this;
+	}
+
+	void DoMove(T dx, T dy)
+	{
+		DoMove(PointT<T>(dx, dy));
+	}
+
+	void DoMove(const PointT<T> &offset)
+	{
+		top_left.DoMove(offset);
+		bottom_right.DoMove(offset);
+	}
+
+	RectT operator +(const PointT<T> &offset) const
+	{
+		RectT r;
+		r.DoMove(offset);
+		return r;
+	}
+
+	RectT operator -(const PointT<T> &offset) const
+	{
+		RectT r;
+		r.DoMove(-offset);
+		return r;
+	}
+
+	RectT& operator +=(const PointT<T> &offset)
+	{
+		DoMove(offset);
+		return *this;
+	}
+
+	RectT& operator -=(const PointT<T> &offset)
+	{
+		DoMove(-offset);
+		return *this;
+	}
+
+	void DoUnion(const PointT<T> &pt)
+	{
+		if (pt.x < top_left.x) {
+			top_left.x = pt.x;
+		} else if (pt.x > bottom_right.x) {
+			bottom_right.x = pt.x;
+		}
+		if (pt.y < top_left.y) {
+			top_left.y = pt.y;
+		} else if (pt.y > bottom_right.y) {
+			bottom_right.y = pt.y;
+		}
+	}
+
+	void DoUnion(const RectT &rc)
+	{
+		if (rc.top_left.x < top_left.x) {
+			top_left.x = rc.top_left.x;
+		} else if (rc.bottom_right.x > bottom_right.x) {
+			bottom_right.x = rc.bottom_right.x;
+		}
+		if (rc.top_left.y < top_left.y) {
+			top_left.y = rc.top_left.y;
+		} else if (rc.bottom_right.y > bottom_right.y) {
+			bottom_right.y = rc.bottom_right.y;
+		}
+	}
+};
+
+
+
+typedef PointT<int16> Point16;
+typedef PointT<int32> Point32;
+
+typedef RectT<int16> Rect16;
+typedef RectT<int32> Rect32;
+
+#endif /*RECT_H*/
--- a/src/misc_cmd.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/misc_cmd.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -329,7 +329,7 @@
 		/* If we are a network-client, update the difficult setting (if it is open).
 		 * Use this instead of just dirtying the window because we need to load in
 		 * the new difficulty settings */
-		if (_networking && !_network_server && Window::FindById(WC_GAME_OPTIONS, 0) != NULL)
+		if (_networking && !_network_server && BaseWindow::FindById(WC_GAME_OPTIONS, 0) != NULL)
 			ShowGameDifficulty();
 	}
 	return 0;
--- a/src/misc_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/misc_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -49,7 +49,7 @@
 
 static char _landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE];
 
-static void LandInfoWndProc(Window *w, WindowEvent *e)
+static void LandInfoWndProc(BaseWindow *w, WindowEvent *e)
 {
 	if (e->event == WE_PAINT) {
 		w->DrawWidgets();
@@ -64,7 +64,7 @@
 	}
 }
 
-static const Widget _land_info_widgets[] = {
+static const OldWidget _land_info_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   279,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    92, 0x0,                            STR_NULL},
@@ -82,7 +82,7 @@
 static void Place_LandInfo(TileIndex tile)
 {
 	Player *p;
-	Window *w;
+	BaseWindow *w;
 	Town *t;
 	int64 old_money;
 	int64 costclear;
@@ -92,7 +92,7 @@
 
 	DeleteWindowById(WC_LAND_INFO, 0);
 
-	w = AllocateWindowDesc(&_land_info_desc);
+	w = BaseWindow::Allocate(&_land_info_desc);
 	WP(w, void_d).data = &_landinfo_data;
 
 	p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
@@ -244,7 +244,7 @@
 	"  Chris Sawyer - For an amazing game!"
 };
 
-static void AboutWindowProc(Window *w, WindowEvent *e)
+static void AboutWindowProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: /* Set up window counter and start position of scroller */
@@ -283,7 +283,7 @@
 	}
 }
 
-static const Widget _about_widgets[] = {
+static const OldWidget _about_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   419,     0,    13, STR_015B_OPENTTD, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   419,    14,   271, 0x0,              STR_NULL},
@@ -303,7 +303,7 @@
 void ShowAboutWindow(void)
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_about_desc);
+	BaseWindow::Allocate(&_about_desc);
 }
 
 static int _tree_to_plant;
@@ -321,7 +321,7 @@
 	{ 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED }
 };
 
-static void BuildTreesWndProc(Window *w, WindowEvent *e)
+static void BuildTreesWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -403,7 +403,7 @@
 	}
 }
 
-static const Widget _build_trees_widgets[] = {
+static const OldWidget _build_trees_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   142,     0,    13, STR_2802_TREES,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   142,    14,   170, 0x0,                   STR_NULL},
@@ -431,7 +431,7 @@
 	BuildTreesWndProc
 };
 
-static const Widget _build_trees_scen_widgets[] = {
+static const OldWidget _build_trees_scen_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   142,     0,    13, STR_2802_TREES,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   142,    14,   183, 0x0,                   STR_NULL},
@@ -464,12 +464,12 @@
 void ShowBuildTreesToolbar(void)
 {
 	if (!IsValidPlayer(_current_player)) return;
-	AllocateWindowDescFront(&_build_trees_desc, 0);
+	BaseWindow::AllocateFront(&_build_trees_desc, 0);
 }
 
 void ShowBuildTreesScenToolbar(void)
 {
-	AllocateWindowDescFront(&_build_trees_scen_desc, 0);
+	BaseWindow::AllocateFront(&_build_trees_scen_desc, 0);
 }
 
 static uint32 _errmsg_decode_params[20];
@@ -477,21 +477,21 @@
 static uint _errmsg_duration;
 
 
-static const Widget _errmsg_widgets[] = {
+static const OldWidget _errmsg_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     4,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     4,    11,   239,     0,    13, STR_00B2_MESSAGE, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     4,     0,   239,    14,    45, 0x0,              STR_NULL},
 {    WIDGETS_END},
 };
 
-static const Widget _errmsg_face_widgets[] = {
+static const OldWidget _errmsg_face_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     4,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     4,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,     4,     0,   333,    14,   136, 0x0,                   STR_NULL},
 {   WIDGETS_END},
 };
 
-static void ErrmsgWndProc(Window *w, WindowEvent *e)
+static void ErrmsgWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -553,7 +553,7 @@
 
 void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
 {
-	Window *w;
+	BaseWindow *w;
 	const ViewPort *vp;
 	Point pt;
 
@@ -572,7 +572,7 @@
 
 		if ( (x|y) != 0) {
 			pt = RemapCoords2(x, y);
-			vp = Window::FindById(WC_MAIN_WINDOW, 0)->viewport;
+			vp = BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport;
 
 			// move x pos to opposite corner
 			pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left;
@@ -586,18 +586,18 @@
 			pt.x = (_screen.width - 240) >> 1;
 			pt.y = (_screen.height - 46) >> 1;
 		}
-		w = Window::Allocate(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
+		w = BaseWindow::Allocate(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
 	} else {
 		if ( (x|y) != 0) {
 			pt = RemapCoords2(x, y);
-			vp = Window::FindById(WC_MAIN_WINDOW, 0)->viewport;
+			vp = BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport;
 			pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
 			pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
 		} else {
 			pt.x = (_screen.width - 334) >> 1;
 			pt.y = (_screen.height - 137) >> 1;
 		}
-		w = Window::Allocate(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
+		w = BaseWindow::Allocate(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
 	}
 
 	w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
@@ -638,13 +638,13 @@
 	AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250);
 }
 
-static const Widget _tooltips_widgets[] = {
+static const OldWidget _tooltips_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   199,     0,    31, 0x0, STR_NULL},
 {   WIDGETS_END},
 };
 
 
-static void TooltipsWndProc(Window *w, WindowEvent *e)
+static void TooltipsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -680,7 +680,7 @@
 {
 	char buffer[512];
 	BoundingRect br;
-	Window *w;
+	BaseWindow *w;
 	uint i;
 	int x, y;
 
@@ -708,7 +708,7 @@
 	if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
 	x = clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
 
-	w = Window::Allocate(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
+	w = BaseWindow::Allocate(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
 
 	WP(w, tooltips_d).string_id = str;
 	assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0]));
@@ -760,7 +760,7 @@
 	}
 }
 
-void CheckRedrawStationCoverage(const Window *w)
+void CheckRedrawStationCoverage(const BaseWindow *w)
 {
 	if (_thd.dirty & 1) {
 		_thd.dirty &= ~1;
@@ -768,7 +768,7 @@
 	}
 }
 
-void SetVScrollCount(Window *w, int num)
+void SetVScrollCount(BaseWindow *w, int num)
 {
 	w->vscroll.count = num;
 	num -= w->vscroll.cap;
@@ -776,7 +776,7 @@
 	if (num < w->vscroll.pos) w->vscroll.pos = num;
 }
 
-void SetVScroll2Count(Window *w, int num)
+void SetVScroll2Count(BaseWindow *w, int num)
 {
 	w->vscroll2.count = num;
 	num -= w->vscroll2.cap;
@@ -784,7 +784,7 @@
 	if (num < w->vscroll2.pos) w->vscroll2.pos = num;
 }
 
-void SetHScrollCount(Window *w, int num)
+void SetHScrollCount(BaseWindow *w, int num)
 {
 	w->hscroll.count = num;
 	num -= w->hscroll.cap;
@@ -962,7 +962,7 @@
 	tb->caretxoffs = tb->width;
 }
 
-int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e)
+int HandleEditBoxKey(BaseWindow *w, querystr_d *string, int wid, WindowEvent *e)
 {
 	e->we.keypress.cont = false;
 
@@ -1010,16 +1010,16 @@
 	return false;
 }
 
-void HandleEditBox(Window *w, querystr_d *string, int wid)
+void HandleEditBox(BaseWindow *w, querystr_d *string, int wid)
 {
 	if (HandleCaret(&string->text)) w->InvalidateWidget(wid);
 }
 
-void DrawEditBox(Window *w, querystr_d *string, int wid)
+void DrawEditBox(BaseWindow *w, querystr_d *string, int wid)
 {
 	DrawPixelInfo dpi, *old_dpi;
 	int delta;
-	const Widget *wi = &w->widget[wid];
+	const OldWidget *wi = &w->widget[wid];
 	const Textbuf *tb = &string->text;
 
 	GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
@@ -1055,7 +1055,7 @@
 };
 
 
-static void QueryStringWndProc(Window *w, WindowEvent *e)
+static void QueryStringWndProc(BaseWindow *w, WindowEvent *e)
 {
 	querystr_d *qs = &WP(w, querystr_d);
 
@@ -1076,7 +1076,7 @@
 				case QUERY_STR_WIDGET_OK:
 		press_ok:;
 					if (qs->orig == NULL || strcmp(qs->text.buf, qs->orig) != 0) {
-						Window *parent = w->parent;
+						BaseWindow *parent = w->parent;
 						qs->handled = true;
 
 						/* If the parent is NULL, the editbox is handled by general function
@@ -1111,7 +1111,7 @@
 		case WE_DESTROY: /* Call cancellation of query, if we have not handled it before */
 			if (!qs->handled && w->parent != NULL) {
 				WindowEvent e;
-				Window *parent = w->parent;
+				BaseWindow *parent = w->parent;
 
 				qs->handled = true;
 				e.event = WE_ON_EDIT_TEXT_CANCEL;
@@ -1122,7 +1122,7 @@
 		}
 }
 
-static const Widget _query_string_widgets[] = {
+static const OldWidget _query_string_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   259,     0,    13, STR_012D,        STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   259,    14,    29, 0x0,             STR_NULL},
@@ -1148,13 +1148,13 @@
  * @param maxlen maximum length in characters allowed. If bit 12 is set we
  * will not check the resulting string against to original string to return success
  * @param maxwidth maximum width in pixels allowed
- * @param parent pointer to a Window that will handle the events (ok/cancel) of this
+ * @param parent pointer to a BaseWindow that will handle the events (ok/cancel) of this
  * window. If NULL, results are handled by global function HandleOnEditText
  * @param afilter filters out unwanted character input */
-void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter)
+void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, BaseWindow *parent, CharSetFilter afilter)
 {
 	static char orig_str_buf[lengthof(_edit_str_buf)];
-	Window *w;
+	BaseWindow *w;
 	uint realmaxlen = maxlen & ~0x1000;
 
 	assert(realmaxlen < lengthof(_edit_str_buf));
@@ -1162,7 +1162,7 @@
 	DeleteWindowById(WC_QUERY_STRING, 0);
 	DeleteWindowById(WC_SAVELOAD, 0);
 
-	w = AllocateWindowDesc(&_query_string_desc);
+	w = BaseWindow::Allocate(&_query_string_desc);
 	w->parent = parent;
 
 	GetString(_edit_str_buf, str, lastof(_edit_str_buf));
@@ -1190,7 +1190,7 @@
 
 
 typedef struct query_d {
-	void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
+	void (*proc)(BaseWindow*, bool); ///< callback function executed on closing of popup. BaseWindow* points to parent, bool is true if 'yes' clicked, false otherwise
 	StringID message;            ///< message shown for query window
 	uint32 params[20];           ///< local copy of _decode_parameters
 	bool calledback;             ///< has callback been executed already (internal usage for WE_DESTROY event)
@@ -1198,7 +1198,7 @@
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d));
 
 
-static void QueryWndProc(Window *w, WindowEvent *e)
+static void QueryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	query_d *q = &WP(w, query_d);
 
@@ -1247,7 +1247,7 @@
 }
 
 
-static const Widget _query_widgets[] = {
+static const OldWidget _query_widgets[] = {
 {  WWT_CLOSEBOX, RESIZE_NONE,  4,   0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW},
 {   WWT_CAPTION, RESIZE_NONE,  4,  11, 209,   0,  13, STR_NULL,        STR_NULL},
 {     WWT_PANEL, RESIZE_NONE,  4,   0, 209,  14,  81, 0x0, /*OVERRIDE*/STR_NULL},
@@ -1273,12 +1273,12 @@
  * the main window WC_MAIN_WINDOW
  * @param x,y coordinates to show the window at
  * @param yes_no_callback callback function called when window is closed through any button */
-void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool))
+void ShowQuery(StringID caption, StringID message, BaseWindow *parent, void (*callback)(BaseWindow*, bool))
 {
-	Window *w = AllocateWindowDesc(&_query_desc);
+	BaseWindow *w = BaseWindow::Allocate(&_query_desc);
 	if (w == NULL) return;
 
-	if (parent == NULL) parent = Window::FindById(WC_MAIN_WINDOW, 0);
+	if (parent == NULL) parent = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 	w->parent = parent;
 	w->left = parent->left + (parent->width / 2) - (w->width / 2);
 	w->top = parent->top + (parent->height / 2) - (w->height / 2);
@@ -1293,7 +1293,7 @@
 }
 
 
-static const Widget _load_dialog_widgets[] = {
+static const OldWidget _load_dialog_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
@@ -1307,7 +1307,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _save_dialog_widgets[] = {
+static const OldWidget _save_dialog_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
@@ -1399,7 +1399,7 @@
 
 extern void StartupEngines(void);
 
-static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
+static void SaveLoadDlgWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static FiosItem o_dir;
 
@@ -1577,7 +1577,7 @@
 		CLRBIT(_no_scroll, SCROLL_SAVE);
 		break;
 	case WE_RESIZE: {
-		/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
+		/* OldWidget 2 and 3 have to go with halve speed, make it so obiwan */
 		uint diff = e->we.sizing.diff.x / 2;
 		w->widget[2].right += diff;
 		w->widget[3].left  += diff;
@@ -1621,7 +1621,7 @@
 		STR_4011_LOAD_HEIGHTMAP,
 	};
 
-	Window *w;
+	BaseWindow *w;
 	const WindowDesc *sld = &_save_dialog_desc;
 
 
@@ -1639,7 +1639,7 @@
 	}
 
 	assert((uint)mode < lengthof(saveload_captions));
-	w = AllocateWindowDesc(sld);
+	w = BaseWindow::Allocate(sld);
 	w->widget[1].data = saveload_captions[mode];
 	w->vscroll.cap = 24;
 	w->resize.step_width = 2;
@@ -1663,7 +1663,7 @@
 
 void RedrawAutosave(void)
 {
-	Window::SetDirtyById(WC_STATUS_BAR, 0);
+	BaseWindow::SetDirtyById(WC_STATUS_BAR, 0);
 }
 
 void SetFiosType(const byte fiostype)
@@ -1739,7 +1739,7 @@
 
 	SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
 	EnginesMonthlyLoop();
-	Window::SetDirtyById(WC_STATUS_BAR, 0);
+	BaseWindow::SetDirtyById(WC_STATUS_BAR, 0);
 	return _cur_year;
 }
 
@@ -1780,7 +1780,7 @@
 };
 
 
-static const Widget _cheat_widgets[] = {
+static const OldWidget _cheat_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,   STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   399,     0,    13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   399,    14,   169, 0x0,        STR_NULL},
@@ -1788,7 +1788,7 @@
 {   WIDGETS_END},
 };
 
-static void CheatsWndProc(Window *w, WindowEvent *e)
+static void CheatsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1923,5 +1923,5 @@
 void ShowCheatWindow(void)
 {
 	DeleteWindowById(WC_CHEATS, 0);
-	AllocateWindowDesc(&_cheats_desc);
+	BaseWindow::Allocate(&_cheats_desc);
 }
--- a/src/music_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/music_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -192,7 +192,7 @@
 	}
 }
 
-static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
+static void MusicTrackSelectionWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -304,7 +304,7 @@
 	}
 }
 
-static const Widget _music_track_selection_widgets[] = {
+static const OldWidget _music_track_selection_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   431,     0,    13, STR_01EB_MUSIC_PROGRAM_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   431,    14,   217, 0x0,                              STR_NULL},
@@ -333,10 +333,10 @@
 
 static void ShowMusicTrackSelection(void)
 {
-	AllocateWindowDescFront(&_music_track_selection_desc, 0);
+	BaseWindow::AllocateFront(&_music_track_selection_desc, 0);
 }
 
-static void MusicWindowWndProc(Window *w, WindowEvent *e)
+static void MusicWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -470,7 +470,7 @@
 
 }
 
-static const Widget _music_window_widgets[] = {
+static const OldWidget _music_window_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   299,     0,    13, STR_01D2_JAZZ_JUKEBOX, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,     0,    21,    14,    35, SPR_IMG_SKIP_TO_PREV,  STR_01DE_SKIP_TO_PREVIOUS_TRACK},
@@ -502,5 +502,5 @@
 
 void ShowMusicWindow(void)
 {
-	AllocateWindowDescFront(&_music_window_desc, 0);
+	BaseWindow::AllocateFront(&_music_window_desc, 0);
 }
--- a/src/network/network_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/network/network_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -218,7 +218,7 @@
 }
 
 /* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */
-static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
+static void NetworkGameWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_ql_d).n;
 	list_d *ld = &WP(w, network_ql_d).l;
@@ -508,7 +508,7 @@
 	}
 }
 
-static const Widget _network_game_window_widgets[] = {
+static const OldWidget _network_game_window_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   549,     0,    13, STR_NETWORK_MULTIPLAYER,     STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   549,    14,   263, 0x0,                         STR_NULL},
@@ -554,7 +554,7 @@
 void ShowNetworkGameWindow(void)
 {
 	static bool first = true;
-	Window *w;
+	BaseWindow *w;
 	DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
 	/* Only show once */
@@ -571,7 +571,7 @@
 		_ng_sorting.order = 0;    // sort ascending by default
 	}
 
-	w = AllocateWindowDesc(&_network_game_window_desc);
+	w = BaseWindow::Allocate(&_network_game_window_desc);
 	if (w != NULL) {
 		querystr_d *querystr = &WP(w, network_ql_d).q;
 
@@ -591,7 +591,7 @@
 };
 
 /* Uses network_ql_d (network_d, querystr_d and list_d) WP macro */
-static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
+static void NetworkStartServerWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_ql_d).n;
 
@@ -742,7 +742,7 @@
 	}
 }
 
-static const Widget _network_start_server_window_widgets[] = {
+static const OldWidget _network_start_server_window_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                      STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_START_GAME_WINDOW, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   243, 0x0,                           STR_NULL},
@@ -780,10 +780,10 @@
 
 static void ShowNetworkStartServerWindow(void)
 {
-	Window *w;
+	BaseWindow *w;
 	DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
-	w = AllocateWindowDesc(&_network_start_server_window_desc);
+	w = BaseWindow::Allocate(&_network_start_server_window_desc);
 	ttd_strlcpy(_edit_str_buf, _network_server_name, lengthof(_edit_str_buf));
 
 	_saveload_mode = SLD_NEW_GAME;
@@ -811,7 +811,7 @@
 }
 
 /* uses network_d WP macro */
-static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
+static void NetworkLobbyWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	network_d *nd = &WP(w, network_d);
 
@@ -956,7 +956,7 @@
 	}
 }
 
-static const Widget _network_lobby_window_widgets[] = {
+static const OldWidget _network_lobby_window_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION,   RESIZE_NONE,   BGC,    11,   419,     0,    13, STR_NETWORK_GAME_LOBBY,    STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,   BGC,     0,   419,    14,   234, 0x0,                       STR_NULL},
@@ -991,13 +991,13 @@
  * @param ngl Selected game pointer which is passed to the new window */
 static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
 {
-	Window *w;
+	BaseWindow *w;
 	DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
 	NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
 	NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
 
-	w = AllocateWindowDesc(&_network_lobby_window_desc);
+	w = BaseWindow::Allocate(&_network_lobby_window_desc);
 	if (w != NULL) {
 		WP(w, network_ql_d).n.server = ngl;
 		strcpy(_edit_str_buf, "");
@@ -1018,8 +1018,8 @@
 #define MAX_CLIENTLIST_ACTION 10
 
 // Some standard bullshit.. defines variables ;)
-static void ClientListWndProc(Window *w, WindowEvent *e);
-static void ClientListPopupWndProc(Window *w, WindowEvent *e);
+static void ClientListWndProc(BaseWindow *w, WindowEvent *e);
+static void ClientListPopupWndProc(BaseWindow *w, WindowEvent *e);
 static byte _selected_clientlist_item = 255;
 static byte _selected_clientlist_y = 0;
 static char _clientlist_action[MAX_CLIENTLIST_ACTION][50];
@@ -1030,7 +1030,7 @@
 	CLNWND_ROWSIZE = 10
 };
 
-static const Widget _client_list_widgets[] = {
+static const OldWidget _client_list_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_NETWORK_CLIENT_LIST,  STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -1038,7 +1038,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _client_list_popup_widgets[] = {
+static const OldWidget _client_list_popup_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   99,     0,     0,     0, STR_NULL},
 {   WIDGETS_END},
 };
@@ -1126,7 +1126,7 @@
 }
 
 // Finds the amount of clients and set the height correct
-static bool CheckClientListHeight(Window *w)
+static bool CheckClientListHeight(BaseWindow *w)
 {
 	int num = 0;
 	const NetworkClientInfo *ci;
@@ -1167,7 +1167,7 @@
 }
 
 // Show the popup (action list)
-static Window *PopupClientList(Window *w, int client_no, int x, int y)
+static BaseWindow *PopupClientList(BaseWindow *w, int client_no, int x, int y)
 {
 	int i, h;
 	const NetworkClientInfo *ci;
@@ -1224,7 +1224,7 @@
 	h = ClientListPopupHeigth();
 
 	// Allocate the popup
-	w = Window::Allocate(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
+	w = BaseWindow::Allocate(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
 	w->widget[0].bottom = w->widget[0].top + h;
 	w->widget[0].right = w->widget[0].left + 150;
 
@@ -1241,7 +1241,7 @@
 
 /** Main handle for the client popup list
  * uses menu_d WP macro */
-static void ClientListPopupWndProc(Window *w, WindowEvent *e)
+static void ClientListPopupWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1291,7 +1291,7 @@
 }
 
 // Main handle for clientlist
-static void ClientListWndProc(Window *w, WindowEvent *e)
+static void ClientListWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1370,7 +1370,7 @@
 
 void ShowClientList(void)
 {
-	AllocateWindowDescFront(&_client_list_desc, 0);
+	BaseWindow::AllocateFront(&_client_list_desc, 0);
 }
 
 
@@ -1387,11 +1387,11 @@
 		case NETWORK_GAME_PASSWORD:    caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
 		case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
 	}
-	ShowQueryString(STR_EMPTY, caption, 20, 180, Window::FindById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL);
+	ShowQueryString(STR_EMPTY, caption, 20, 180, BaseWindow::FindById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL);
 }
 
 
-static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
+static void NetworkJoinStatusWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1445,7 +1445,7 @@
 	}
 }
 
-static const Widget _network_join_status_window_widget[] = {
+static const OldWidget _network_join_status_window_widget[] = {
 {    WWT_CAPTION,   RESIZE_NONE,    14,     0,   249,     0,    13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,    84, 0x0,                    STR_NULL},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    75,   175,    69,    80, STR_NETWORK_DISCONNECT, STR_NULL},
@@ -1462,11 +1462,11 @@
 
 void ShowJoinStatusWindow(void)
 {
-	Window *w;
+	BaseWindow *w;
 	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
-	w = AllocateWindowDesc(&_network_join_status_window_desc);
+	w = BaseWindow::Allocate(&_network_join_status_window_desc);
 	/* Parent the status window to the lobby */
-	if (w != NULL) w->parent = Window::FindById(WC_NETWORK_WINDOW, 0);
+	if (w != NULL) w->parent = BaseWindow::FindById(WC_NETWORK_WINDOW, 0);
 }
 
 static void SendChat(const char *buf, DestType type, byte dest)
@@ -1530,7 +1530,7 @@
 /**
  * See if we can auto-complete the current text of the user.
  */
-static void ChatTabCompletion(Window *w)
+static void ChatTabCompletion(BaseWindow *w)
 {
 	static char _chat_tab_completion_buf[lengthof(_edit_str_buf)];
 	Textbuf *tb = &WP(w, querystr_d).text;
@@ -1616,7 +1616,7 @@
  * uses querystr_d->caption to store
  * - type of chat message (Private/Team/All) in bytes 0-7
  * - destination of chat message in the case of Team/Private in bytes 8-15 */
-static void ChatWindowWndProc(Window *w, WindowEvent *e)
+static void ChatWindowWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE:
@@ -1678,7 +1678,7 @@
 	}
 }
 
-static const Widget _chat_window_widgets[] = {
+static const OldWidget _chat_window_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {      WWT_PANEL, RESIZE_NONE, 14,  11, 639,  0, 13, 0x0,              STR_NULL}, // background
 {      WWT_PANEL, RESIZE_NONE, 14,  75, 577,  1, 12, 0x0,              STR_NULL}, // text box
@@ -1696,14 +1696,14 @@
 
 void ShowNetworkChatQueryWindow(DestType type, byte dest)
 {
-	Window *w;
+	BaseWindow *w;
 
 	DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
 
 	_edit_str_buf[0] = '\0';
 	_chat_tab_completion_active = false;
 
-	w = AllocateWindowDesc(&_chat_window_desc);
+	w = BaseWindow::Allocate(&_chat_window_desc);
 
 	w->LowerWidget(2);
 	WP(w, querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption
--- a/src/newgrf_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/newgrf_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -92,7 +92,7 @@
 } newgrf_add_d;
 
 
-static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
+static void NewGRFAddDlgWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -128,7 +128,7 @@
 			}
 
 			if (WP(w, newgrf_add_d).sel != NULL) {
-				const Widget *wi = &w->widget[5];
+				const OldWidget *wi = &w->widget[5];
 				ShowNewGRFInfo(WP(w, newgrf_add_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, false);
 			}
 			break;
@@ -187,7 +187,7 @@
 }
 
 
-static const Widget _newgrf_add_dlg_widgets[] = {
+static const OldWidget _newgrf_add_dlg_widgets[] = {
 {   WWT_CLOSEBOX,    RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION,   RESIZE_RIGHT, 14,  11, 306,   0,  13, STR_NEWGRF_ADD_CAPTION,  STR_018C_WINDOW_TITLE_DRAG_THIS },
 
@@ -239,7 +239,7 @@
 };
 
 
-static void SetupNewGRFState(Window *w)
+static void SetupNewGRFState(BaseWindow *w)
 {
 	bool disable_all = WP(w, newgrf_d).sel == NULL || !WP(w, newgrf_d).editable;
 
@@ -260,7 +260,7 @@
 }
 
 
-static void SetupNewGRFWindow(Window *w)
+static void SetupNewGRFWindow(BaseWindow *w)
 {
 	const GRFConfig *c;
 	int i;
@@ -275,7 +275,7 @@
 
 /** Callback function for the newgrf 'apply changes' confirmation window
  * @param yes_clicked boolean value, true when yes was clicked, false otherwise */
-static void NewGRFConfirmationCallback(Window *w, bool confirmed)
+static void NewGRFConfirmationCallback(BaseWindow *w, bool confirmed)
 {
 	if (confirmed) {
 		newgrf_d *nd = &WP(w, newgrf_d);
@@ -296,7 +296,7 @@
 }
 
 
-static void NewGRFWndProc(Window *w, WindowEvent *e)
+static void NewGRFWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -335,7 +335,7 @@
 
 			if (WP(w, newgrf_d).sel != NULL) {
 				/* Draw NewGRF file info */
-				const Widget *wi = &w->widget[SNGRFS_NEWGRF_INFO];
+				const OldWidget *wi = &w->widget[SNGRFS_NEWGRF_INFO];
 				ShowNewGRFInfo(WP(w, newgrf_d).sel, wi->left + 2, wi->top + 2, wi->right - wi->left - 2, WP(w, newgrf_d).show_params);
 			}
 
@@ -350,10 +350,10 @@
 			switch (e->we.click.widget) {
 				case SNGRFS_ADD: { /* Add GRF */
 					GRFConfig **list = WP(w, newgrf_d).list;
-					Window *w;
+					BaseWindow *w;
 
 					DeleteWindowByClass(WC_SAVELOAD);
-					w = AllocateWindowDesc(&_newgrf_add_dlg_desc);
+					w = BaseWindow::Allocate(&_newgrf_add_dlg_desc);
 					w->resize.step_height = 10;
 
 					WP(w, newgrf_add_d).list = list;
@@ -476,7 +476,7 @@
 }
 
 
-static const Widget _newgrf_widgets[] = {
+static const OldWidget _newgrf_widgets[] = {
 {   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
 
@@ -522,10 +522,10 @@
 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
 {
 	static GRFConfig *local = NULL;
-	Window *w;
+	BaseWindow *w;
 
 	DeleteWindowByClass(WC_GAME_OPTIONS);
-	w = AllocateWindowDesc(&_newgrf_desc);
+	w = BaseWindow::Allocate(&_newgrf_desc);
 	if (w == NULL) return;
 
 	w->resize.step_height = 14;
--- a/src/news.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/news.h	Sun Feb 18 14:17:28 2007 +0000
@@ -19,13 +19,13 @@
 };
 
 typedef bool ValidationProc ( uint data_a, uint data_b );
-typedef void DrawNewsCallbackProc(Window *w);
+typedef void DrawNewsCallbackProc(BaseWindow *w);
 typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
 
 #define NEWS_FLAGS(mode,flag,type,cb) ((cb)<<24 | (type)<<16 | (flag)<<8 | (mode))
 void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
 void NewsLoop(void);
-void DrawNewsBorder(const Window *w);
+void DrawNewsBorder(const BaseWindow *w);
 void InitNewsItemStructs(void);
 
 VARDEF NewsItem _statusbar_news_item;
--- a/src/news_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/news_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -53,11 +53,11 @@
 
 static byte _total_news = 0; // total news count
 
-void DrawNewsNewTrainAvail(Window *w);
-void DrawNewsNewRoadVehAvail(Window *w);
-void DrawNewsNewShipAvail(Window *w);
-void DrawNewsNewAircraftAvail(Window *w);
-void DrawNewsBankrupcy(Window *w);
+void DrawNewsNewTrainAvail(BaseWindow *w);
+void DrawNewsNewRoadVehAvail(BaseWindow *w);
+void DrawNewsNewShipAvail(BaseWindow *w);
+void DrawNewsNewAircraftAvail(BaseWindow *w);
+void DrawNewsBankrupcy(BaseWindow *w);
 static void MoveToNextItem(void);
 
 StringID GetNewsStringNewTrainAvail(const NewsItem *ni);
@@ -93,7 +93,7 @@
 	_total_news = 0;
 }
 
-void DrawNewsBorder(const Window *w)
+void DrawNewsBorder(const BaseWindow *w)
 {
 	int left = 0;
 	int right = w->width - 1;
@@ -110,11 +110,11 @@
 	DrawString(left + 2, top + 1, STR_00C6, 0);
 }
 
-static void NewsWindowProc(Window *w, WindowEvent *e)
+static void NewsWindowProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: { /* If chatbar is open at creation time, we need to go above it */
-		const Window *w1 = Window::FindById(WC_SEND_NETWORK_MSG, 0);
+		const BaseWindow *w1 = BaseWindow::FindById(WC_SEND_NETWORK_MSG, 0);
 		w->message.msg = (w1 != NULL) ? w1->height : 0;
 	} break;
 
@@ -291,7 +291,7 @@
 	  _current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
 
 	{ /* Add news to _latest_news */
-		Window *w;
+		BaseWindow *w;
 		NewsItem *ni = &_news_items[_latest_news];
 		memset(ni, 0, sizeof(*ni));
 
@@ -309,7 +309,7 @@
 		ni->date = _date;
 		COPY_OUT_DPARAM(ni->params, 0, lengthof(ni->params));
 
-		w = Window::FindById(WC_MESSAGE_HISTORY, 0);
+		w = BaseWindow::FindById(WC_MESSAGE_HISTORY, 0);
 		if (w == NULL) return;
 		w->SetDirty();
 		w->vscroll.count = _total_news;
@@ -320,7 +320,7 @@
 /* Don't show item if it's older than x days, corresponds with NewsType in news.h */
 static const byte _news_items_age[] = {60, 60, 90, 60, 90, 30, 150, 30, 90, 180};
 
-static const Widget _news_type13_widgets[] = {
+static const OldWidget _news_type13_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,    15,     0,   429,     0,   169, 0x0, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,    15,     0,    10,     0,    11, 0x0, STR_NULL},
 {   WIDGETS_END},
@@ -334,7 +334,7 @@
 	NewsWindowProc
 };
 
-static const Widget _news_type2_widgets[] = {
+static const OldWidget _news_type2_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,    15,     0,   429,     0,   129, 0x0, STR_NULL},
 {      WWT_PANEL,   RESIZE_NONE,    15,     0,    10,     0,    11, 0x0, STR_NULL},
 {   WIDGETS_END},
@@ -348,7 +348,7 @@
 	NewsWindowProc
 };
 
-static const Widget _news_type0_widgets[] = {
+static const OldWidget _news_type0_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,     5,     0,   279,    14,    86, 0x0,              STR_NULL},
 {   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     5,    11,   279,     0,    13, STR_012C_MESSAGE, STR_NULL},
@@ -402,7 +402,7 @@
 // open up an own newspaper window for the news item
 static void ShowNewspaper(NewsItem *ni)
 {
-	Window *w;
+	BaseWindow *w;
 	SoundFx sound;
 	int top;
 	ni->flags &= ~NF_FORCE_BIG;
@@ -416,7 +416,7 @@
 		case NM_NORMAL:
 		case NM_CALLBACK: {
 			_news_type13_desc.top = top;
-			w = AllocateWindowDesc(&_news_type13_desc);
+			w = BaseWindow::Allocate(&_news_type13_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
@@ -425,7 +425,7 @@
 
 		case NM_THIN: {
 			_news_type2_desc.top = top;
-			w = AllocateWindowDesc(&_news_type2_desc);
+			w = BaseWindow::Allocate(&_news_type2_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 2, 58, 0x1AA, 0x46,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
@@ -434,7 +434,7 @@
 
 		default: {
 			_news_type0_desc.top = top;
-			w = AllocateWindowDesc(&_news_type0_desc);
+			w = BaseWindow::Allocate(&_news_type0_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 3, 17, 0x112, 0x2F,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
@@ -452,12 +452,12 @@
 // show news item in the ticker
 static void ShowTicker(const NewsItem *ni)
 {
-	Window *w;
+	BaseWindow *w;
 
 	if (_news_ticker_sound) SndPlayFx(SND_16_MORSE);
 
 	_statusbar_news_item = *ni;
-	w = Window::FindById(WC_STATUS_BAR, 0);
+	w = BaseWindow::FindById(WC_STATUS_BAR, 0);
 	if (w != NULL) WP(w, def_d).data_1 = 360;
 }
 
@@ -466,7 +466,7 @@
 // Only if nothing is in the newsticker and no newspaper is displayed
 static bool ReadyForNextItem(void)
 {
-	const Window *w;
+	const BaseWindow *w;
 	NewsID item = (_forced_news == INVALID_NEWS) ? _current_news : _forced_news;
 	NewsItem *ni;
 
@@ -475,14 +475,14 @@
 
 	// Ticker message
 	// Check if the status bar message is still being displayed?
-	w = Window::FindById(WC_STATUS_BAR, 0);
+	w = BaseWindow::FindById(WC_STATUS_BAR, 0);
 	if (w != NULL && WP(w, const def_d).data_1 > -1280) return false;
 
 	// Newspaper message, decrement duration counter
 	if (ni->duration != 0) ni->duration--;
 
 	// neither newsticker nor newspaper are running
-	return (ni->duration == 0 || Window::FindById(WC_NEWS_WINDOW, 0) == NULL);
+	return (ni->duration == 0 || BaseWindow::FindById(WC_NEWS_WINDOW, 0) == NULL);
 }
 
 static void MoveToNextItem(void)
@@ -502,7 +502,7 @@
 
 		switch (GetNewsDisplayValue(ni->type)) {
 		case 0: { /* Off - show nothing only a small reminder in the status bar */
-			Window *w = Window::FindById(WC_STATUS_BAR, 0);
+			BaseWindow *w = BaseWindow::FindById(WC_STATUS_BAR, 0);
 
 			if (w != NULL) {
 				WP(w, def_d).data_2 = 91;
@@ -558,7 +558,7 @@
 	if (_forced_news == INVALID_NEWS) {
 		/* Not forced any news yet, show the current one, unless a news window is
 		 * open (which can only be the current one), then show the previous item */
-		const Window *w = Window::FindById(WC_NEWS_WINDOW, 0);
+		const BaseWindow *w = BaseWindow::FindById(WC_NEWS_WINDOW, 0);
 		ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : decreaseIndex(_current_news));
 	} else if (_forced_news == _oldest_news) {
 		/* We have reached the oldest news, start anew with the latest */
@@ -629,7 +629,7 @@
 }
 
 
-static void MessageHistoryWndProc(Window *w, WindowEvent *e)
+static void MessageHistoryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -675,7 +675,7 @@
 	}
 }
 
-static const Widget _message_history_widgets[] = {
+static const OldWidget _message_history_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   387,     0,    13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    13,   388,   399,     0,    13, 0x0,                 STR_STICKY_BUTTON},
@@ -695,10 +695,10 @@
 
 void ShowMessageHistory(void)
 {
-	Window *w;
+	BaseWindow *w;
 
 	DeleteWindowById(WC_MESSAGE_HISTORY, 0);
-	w = AllocateWindowDesc(&_message_history_desc);
+	w = BaseWindow::Allocate(&_message_history_desc);
 
 	if (w != NULL) {
 		w->vscroll.cap = 10;
@@ -716,7 +716,7 @@
  * Same-wise for all the others. Starting value of 3 is the first widget
  * group. These are grouped as [<][>] .. [<][>], etc.
  */
-static void SetMessageButtonStates(Window *w, byte value, int element)
+static void SetMessageButtonStates(BaseWindow *w, byte value, int element)
 {
 	element *= 2;
 
@@ -724,7 +724,7 @@
 	w->SetWidgetDisabledState(element + 3 + 1, value == 2);
 }
 
-static void MessageOptionsWndProc(Window *w, WindowEvent *e)
+static void MessageOptionsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static const StringID message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID};
 
@@ -820,7 +820,7 @@
 	}
 }
 
-static const Widget _message_options_widgets[] = {
+static const OldWidget _message_options_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,   10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,  409,     0,    13, STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    13,     0,  409,    14,   184, 0x0,                      STR_NULL},
@@ -874,7 +874,7 @@
 void ShowMessageOptions(void)
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_message_options_desc);
+	BaseWindow::Allocate(&_message_options_desc);
 }
 
 
@@ -888,7 +888,7 @@
 		if (ni->flags & NF_VEHICLE &&
 				ni->data_a == vid &&
 				(news == INVALID_STRING_ID || ni->string_id == news)) {
-			Window *w;
+			BaseWindow *w;
 
 			/* If we delete a forced news and it is just before the current news
 			 * then we need to advance to the next news (if any) */
@@ -912,7 +912,7 @@
 			 * We also need an update of the current, forced and visible (open window)
 			 * news's as this shifting could change the items they were pointing to */
 			if (_total_news != 0) {
-				w = Window::FindById(WC_NEWS_WINDOW, 0);
+				w = BaseWindow::FindById(WC_NEWS_WINDOW, 0);
 				NewsID visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
 
 				for (NewsID i = n;; i = decreaseIndex(i)) {
@@ -932,7 +932,7 @@
 			/*DEBUG(misc, 0, "-cur %3d, old %2d, lat %3d, for %3d, tot %2d",
 			  _current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
 
-			w = Window::FindById(WC_MESSAGE_HISTORY, 0);
+			w = BaseWindow::FindById(WC_MESSAGE_HISTORY, 0);
 			if (w != NULL) {
 				w->SetDirty();
 				w->vscroll.count = _total_news;
--- a/src/openttd.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/openttd.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -969,7 +969,7 @@
 static void ScrollMainViewport(int x, int y)
 {
 	if (_game_mode != GM_MENU) {
-		Window *w = Window::FindById(WC_MAIN_WINDOW, 0);
+		BaseWindow *w = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 		assert(w);
 
 		WP(w,vp_d).scrollpos_x += x << w->viewport->zoom;
@@ -1073,7 +1073,7 @@
 
 void BeforeSaveGame(void)
 {
-	const Window *w = Window::FindById(WC_MAIN_WINDOW, 0);
+	const BaseWindow *w = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 
 	if (w != NULL) {
 		_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x;
@@ -1175,7 +1175,7 @@
 bool AfterLoadGame(void)
 {
 	TileIndex map_size = MapSize();
-	Window *w;
+	BaseWindow *w;
 	ViewPort *vp;
 	Player *p;
 
@@ -1261,7 +1261,7 @@
 	ResetWindowSystem();
 	SetupColorsAndInitialWindow();
 
-	w = Window::FindById(WC_MAIN_WINDOW, 0);
+	w = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 
 	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
 	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
--- a/src/openttd.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/openttd.h	Sun Feb 18 14:17:28 2007 +0000
@@ -33,7 +33,7 @@
 typedef struct Vehicle Vehicle;
 typedef struct Depot Depot;
 typedef struct Waypoint Waypoint;
-typedef struct Window Window;
+typedef struct BaseWindow BaseWindow;
 typedef struct Station Station;
 typedef struct ViewPort ViewPort;
 typedef struct Town Town;
@@ -383,7 +383,8 @@
 
 
 enum WindowClass {
-	WC_NONE,
+	WC_UNKNOWN = -1,
+	WC_NONE = 0,
 	WC_MAIN_WINDOW = WC_NONE,
 	WC_MAIN_TOOLBAR,
 	WC_STATUS_BAR,
--- a/src/order_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/order_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -41,7 +41,7 @@
 	ORDER_WIDGET_RESIZE,
 };
 
-static int OrderGetSel(const Window *w)
+static int OrderGetSel(const BaseWindow *w)
 {
 	const Vehicle *v = GetVehicle(w->window_number);
 	int num = WP(w,order_d).sel;
@@ -67,7 +67,7 @@
 	STR_NULL
 };
 
-static void DrawOrdersWindow(Window *w)
+static void DrawOrdersWindow(BaseWindow *w)
 {
 	const Vehicle *v;
 	const Order *order;
@@ -314,7 +314,7 @@
 	return order;
 }
 
-static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
+static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, BaseWindow *w)
 {
 	if (u->type != v->type) return false;
 
@@ -336,7 +336,7 @@
 	return true;
 }
 
-static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w)
+static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, BaseWindow *w)
 {
 	Order cmd;
 	const Vehicle *u;
@@ -354,7 +354,7 @@
 	}
 }
 
-static void OrderClick_Goto(Window *w, const Vehicle *v)
+static void OrderClick_Goto(BaseWindow *w, const Vehicle *v)
 {
 	w->InvalidateWidget(ORDER_WIDGET_GOTO);
 	w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
@@ -366,37 +366,37 @@
 	}
 }
 
-static void OrderClick_FullLoad(Window *w, const Vehicle *v)
+static void OrderClick_FullLoad(BaseWindow *w, const Vehicle *v)
 {
 	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
 }
 
-static void OrderClick_Unload(Window *w, const Vehicle *v)
+static void OrderClick_Unload(BaseWindow *w, const Vehicle *v)
 {
 	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD,    NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
 }
 
-static void OrderClick_Nonstop(Window *w, const Vehicle *v)
+static void OrderClick_Nonstop(BaseWindow *w, const Vehicle *v)
 {
 	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_NON_STOP,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
 }
 
-static void OrderClick_Transfer(Window* w, const Vehicle* v)
+static void OrderClick_Transfer(BaseWindow* w, const Vehicle* v)
 {
 	DoCommandP(v->tile, v->index + (OrderGetSel(w) <<  16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
 }
 
-static void OrderClick_Skip(Window *w, const Vehicle *v)
+static void OrderClick_Skip(BaseWindow *w, const Vehicle *v)
 {
 	DoCommandP(v->tile, v->index, 0, NULL, CMD_SKIP_ORDER);
 }
 
-static void OrderClick_Delete(Window *w, const Vehicle *v)
+static void OrderClick_Delete(BaseWindow *w, const Vehicle *v)
 {
 	DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
 }
 
-static void OrderClick_Refit(Window *w, const Vehicle *v)
+static void OrderClick_Refit(BaseWindow *w, const Vehicle *v)
 {
 	if (_ctrl_pressed) {
 		/* Cancel refitting */
@@ -406,7 +406,7 @@
 	}
 }
 
-typedef void OnButtonVehClick(Window *w, const Vehicle *v);
+typedef void OnButtonVehClick(BaseWindow *w, const Vehicle *v);
 
 static OnButtonVehClick* const _order_button_proc[] = {
 	OrderClick_Skip,
@@ -427,7 +427,7 @@
 	'K'  //unload
 };
 
-static void OrdersWndProc(Window *w, WindowEvent *e)
+static void OrdersWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_CREATE:
@@ -440,7 +440,7 @@
 				assert(w->widget[ORDER_WIDGET_REFIT].right         == w->widget[ORDER_WIDGET_UNLOAD].right);
 				assert(w->widget[ORDER_WIDGET_REFIT].top           == w->widget[ORDER_WIDGET_UNLOAD].top);
 				assert(w->widget[ORDER_WIDGET_REFIT].bottom        == w->widget[ORDER_WIDGET_UNLOAD].bottom);
-				assert(w->widget[ORDER_WIDGET_REFIT].display_flags == w->widget[ORDER_WIDGET_UNLOAD].display_flags);
+				assert(w->widget[ORDER_WIDGET_REFIT].m_display_flags == w->widget[ORDER_WIDGET_UNLOAD].m_display_flags);
 			}
 			break;
 
@@ -587,7 +587,7 @@
 	}
 }
 
-static const Widget _orders_train_widgets[] = {
+static const OldWidget _orders_train_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   398,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_RB,      14,     0,   386,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
@@ -614,7 +614,7 @@
 	OrdersWndProc
 };
 
-static const Widget _orders_widgets[] = {
+static const OldWidget _orders_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   409,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_RB,      14,     0,   397,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
@@ -641,7 +641,7 @@
 	OrdersWndProc
 };
 
-static const Widget _other_orders_widgets[] = {
+static const OldWidget _other_orders_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   331,     0,    13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_RB,      14,     0,   319,    14,    75, 0x0,             STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
@@ -667,16 +667,16 @@
 
 void ShowOrdersWindow(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 	VehicleID veh = v->index;
 
 	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
 	if (v->owner != _local_player) {
-		w = AllocateWindowDescFront(&_other_orders_desc, veh);
+		w = BaseWindow::AllocateFront(&_other_orders_desc, veh);
 	} else {
-		w = AllocateWindowDescFront((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc, veh);
+		w = BaseWindow::AllocateFront((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc, veh);
 	}
 
 	if (w != NULL) {
--- a/src/player_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/player_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -100,7 +100,7 @@
 	DrawStringRightAligned(182, y, STR_7028, 0);
 }
 
-static const Widget _player_finances_widgets[] = {
+static const OldWidget _player_finances_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -112,7 +112,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _other_player_finances_widgets[] = {
+static const OldWidget _other_player_finances_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   379,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,   380,   394,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -122,7 +122,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _other_player_finances_small_widgets[] = {
+static const OldWidget _other_player_finances_small_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -132,7 +132,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _player_finances_small_widgets[] = {
+static const OldWidget _player_finances_small_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   253,     0,    13, STR_700E_FINANCES,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {     WWT_IMGBTN,   RESIZE_NONE,    14,   254,   267,     0,    13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
@@ -145,7 +145,7 @@
 };
 
 
-static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
+static void PlayerFinancesWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -222,7 +222,7 @@
 
 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
 {
-	Window *w;
+	BaseWindow *w;
 	int mode;
 
 	static const WindowDesc * const desc_table[2 * 2] = {
@@ -233,7 +233,7 @@
 	if (!IsValidPlayer(player)) return;
 
 	mode = (player != _local_player) * 2 + show_small;
-	w = AllocateWindowDescFront(desc_table[mode], player);
+	w = BaseWindow::AllocateFront(desc_table[mode], player);
 	if (w != NULL) {
 		w->caption_color = w->window_number;
 		WP(w,def_d).data_1 = mode;
@@ -291,7 +291,7 @@
 } livery_d;
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d));
 
-static void ShowColourDropDownMenu(Window *w, uint32 widget)
+static void ShowColourDropDownMenu(BaseWindow *w, uint32 widget)
 {
 	uint32 used_colours = 0;
 	const Livery *livery;
@@ -315,7 +315,7 @@
 	w->ShowDropDownMenu(_colour_dropdown, widget == 10 ? livery->colour1 : livery->colour2, widget, used_colours, 0);
 }
 
-static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
+static void SelectPlayerLiveryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_CREATE:
@@ -452,7 +452,7 @@
 	}
 }
 
-static const Widget _select_player_livery_2cc_widgets[] = {
+static const OldWidget _select_player_livery_2cc_widgets[] = {
 { WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
 {  WWT_CAPTION, RESIZE_NONE, 14,  11, 399,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
 {   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
@@ -479,7 +479,7 @@
 };
 
 
-static const Widget _select_player_livery_widgets[] = {
+static const OldWidget _select_player_livery_widgets[] = {
 { WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                  STR_018B_CLOSE_WINDOW },
 {  WWT_CAPTION, RESIZE_NONE, 14,  11, 274,   0,  13, STR_7007_NEW_COLOR_SCHEME, STR_018C_WINDOW_TITLE_DRAG_THIS },
 {   WWT_IMGBTN, RESIZE_NONE, 14,   0,  21,  14,  35, SPR_IMG_COMPANY_GENERAL,   STR_LIVERY_GENERAL_TIP },
@@ -505,7 +505,7 @@
 	SelectPlayerLiveryWndProc
 };
 
-static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
+static void SelectPlayerFaceWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -539,7 +539,7 @@
 	}
 }
 
-static const Widget _select_player_face_widgets[] = {
+static const OldWidget _select_player_face_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   189,     0,    13, STR_7043_FACE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   189,    14,   136, 0x0,                     STR_NULL},
@@ -575,7 +575,7 @@
 	PCW_WIDGET_COMPANY_PASSWORD,
 };
 
-static const Widget _player_company_widgets[] = {
+static const OldWidget _player_company_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   359,     0,    13, STR_7001,                          STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   359,    14,   157, 0x0,                               STR_NULL},
@@ -672,7 +672,7 @@
 	if (num >= 0) DrawString(120, 124, STR_707D_OWNED_BY + num, 0);
 }
 
-static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
+static void PlayerCompanyWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -742,7 +742,7 @@
 		case WE_CLICK:
 			switch (e->we.click.widget) {
 				case PCW_WIDGET_NEW_FACE: {
-					Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number);
+					BaseWindow *wf = BaseWindow::AllocateFront(&_select_player_face_desc, w->window_number);
 					if (wf != NULL) {
 						wf->caption_color = w->window_number;
 						WP(wf,facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face;
@@ -752,7 +752,7 @@
 				}
 
 				case PCW_WIDGET_COLOR_SCHEME: {
-					Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
+					BaseWindow *wf = BaseWindow::AllocateFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
 					if (wf != NULL) {
 						wf->caption_color = wf->window_number;
 						WP(wf,livery_d).livery_class = LC_OTHER;
@@ -877,17 +877,17 @@
 
 void ShowPlayerCompany(PlayerID player)
 {
-	Window *w;
+	BaseWindow *w;
 
 	if (!IsValidPlayer(player)) return;
 
-	w = AllocateWindowDescFront(&_player_company_desc, player);
+	w = BaseWindow::AllocateFront(&_player_company_desc, player);
 	if (w != NULL) w->caption_color = w->window_number;
 }
 
 
 
-static void BuyCompanyWndProc(Window *w, WindowEvent *e)
+static void BuyCompanyWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -919,7 +919,7 @@
 	}
 }
 
-static const Widget _buy_company_widgets[] = {
+static const OldWidget _buy_company_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     5,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     5,     0,   333,    14,   136, 0x0,                   STR_NULL},
@@ -939,13 +939,13 @@
 
 void ShowBuyCompanyDialog(uint player)
 {
-	AllocateWindowDescFront(&_buy_company_desc, player);
+	BaseWindow::AllocateFront(&_buy_company_desc, player);
 }
 
 /********** HIGHSCORE and ENDGAME windows */
 
 /* Always draw a maximized window and within there the centered background */
-static void SetupHighScoreEndWindow(Window *w, uint *x, uint *y)
+static void SetupHighScoreEndWindow(BaseWindow *w, uint *x, uint *y)
 {
 	uint i;
 	// resize window to "full-screen"
@@ -966,7 +966,7 @@
 extern StringID EndGameGetPerformanceTitleFromValue(uint value);
 
 /* End game window shown at the end of the game */
-static void EndGameWndProc(Window *w, WindowEvent *e)
+static void EndGameWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1004,7 +1004,7 @@
 	}
 }
 
-static void HighScoreWndProc(Window *w, WindowEvent *e)
+static void HighScoreWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1039,14 +1039,14 @@
 		break;
 
 	case WE_DESTROY: /* Get back all the hidden windows */
-		if (_game_mode != GM_MENU) Window::ShowVitalWindows();
+		if (_game_mode != GM_MENU) BaseWindow::ShowVitalWindows();
 
 		if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause
 		break;
 	}
 	}
 
-static const Widget _highscore_widgets[] = {
+static const OldWidget _highscore_widgets[] = {
 {      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
 {   WIDGETS_END},
 };
@@ -1072,16 +1072,16 @@
  * and is thus highlighted */
 void ShowHighscoreTable(int difficulty, int8 ranking)
 {
-	Window *w;
+	BaseWindow *w;
 
 	// pause game to show the chart
 	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
 
 	/* Close all always on-top windows to get a clean screen */
-	if (_game_mode != GM_MENU) Window::HideVitalWindows();
+	if (_game_mode != GM_MENU) BaseWindow::HideVitalWindows();
 
 	DeleteWindowByClass(WC_HIGHSCORE);
-	w = AllocateWindowDesc(&_highscore_desc);
+	w = BaseWindow::Allocate(&_highscore_desc);
 
 	if (w != NULL) {
 		MarkWholeScreenDirty();
@@ -1095,16 +1095,16 @@
  * if it was high enough */
 void ShowEndGameChart(void)
 {
-	Window *w;
+	BaseWindow *w;
 
 	/* Dedicated server doesn't need the highscore window */
 	if (_network_dedicated) return;
 	/* Pause in single-player to have a look at the highscore at your own leisure */
 	if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
 
-	Window::HideVitalWindows();
+	BaseWindow::HideVitalWindows();
 	DeleteWindowByClass(WC_ENDSCREEN);
-	w = AllocateWindowDesc(&_endgame_desc);
+	w = BaseWindow::Allocate(&_endgame_desc);
 
 	if (w != NULL) {
 		MarkWholeScreenDirty();
--- a/src/rail_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/rail_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -251,44 +251,44 @@
 };
 
 
-static void BuildRailClick_N(Window *w)
+static void BuildRailClick_N(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N);
 }
 
-static void BuildRailClick_NE(Window *w)
+static void BuildRailClick_NE(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE);
 }
 
-static void BuildRailClick_E(Window *w)
+static void BuildRailClick_E(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E);
 }
 
-static void BuildRailClick_NW(Window *w)
+static void BuildRailClick_NW(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW);
 }
 
-static void BuildRailClick_AutoRail(Window *w)
+static void BuildRailClick_AutoRail(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail);
 }
 
-static void BuildRailClick_Demolish(Window *w)
+static void BuildRailClick_Demolish(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
 }
 
-static void BuildRailClick_Depot(Window *w)
+static void BuildRailClick_Depot(BaseWindow *w)
 {
 	if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) {
 		ShowBuildTrainDepotPicker();
 	}
 }
 
-static void BuildRailClick_Waypoint(Window *w)
+static void BuildRailClick_Waypoint(BaseWindow *w)
 {
 	_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
 	if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) &&
@@ -297,27 +297,27 @@
 	}
 }
 
-static void BuildRailClick_Station(Window *w)
+static void BuildRailClick_Station(BaseWindow *w)
 {
 	if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder();
 }
 
-static void BuildRailClick_AutoSignals(Window *w)
+static void BuildRailClick_AutoSignals(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
 }
 
-static void BuildRailClick_Bridge(Window *w)
+static void BuildRailClick_Bridge(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge);
 }
 
-static void BuildRailClick_Tunnel(Window *w)
+static void BuildRailClick_Tunnel(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel);
 }
 
-static void BuildRailClick_Remove(Window *w)
+static void BuildRailClick_Remove(BaseWindow *w)
 {
 	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	w->SetDirty();
@@ -333,7 +333,7 @@
 	}
 }
 
-static void BuildRailClick_Convert(Window *w)
+static void BuildRailClick_Convert(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail);
 }
@@ -389,7 +389,7 @@
 }
 
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 
 static OnButtonClick * const _build_railroad_button_proc[] = {
 	BuildRailClick_N,
@@ -426,7 +426,7 @@
 };
 
 
-static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget)
+static void UpdateRemoveWidgetStatus(BaseWindow *w, int clicked_widget)
 {
 	/* If it is the removal button that has been clicked, do nothing,
 	 * as it is up to the other buttons to drive removal status */
@@ -455,7 +455,7 @@
 	}
 }
 
-static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
+static void BuildRailToolbWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
@@ -528,9 +528,9 @@
 		w->DisableWidget(RTW_REMOVE);
 		w->InvalidateWidget(RTW_REMOVE);
 
-		w = Window::FindById(WC_BUILD_STATION, 0);
+		w = BaseWindow::FindById(WC_BUILD_STATION, 0);
 		if (w != NULL) WP(w,def_d).close = true;
-		w = Window::FindById(WC_BUILD_DEPOT, 0);
+		w = BaseWindow::FindById(WC_BUILD_DEPOT, 0);
 		if (w != NULL) WP(w,def_d).close = true;
 		break;
 
@@ -548,7 +548,7 @@
 }
 
 
-static const Widget _build_rail_widgets[] = {
+static const OldWidget _build_rail_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   337,     0,    13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   338,   349,     0,    13, 0x0,                            STR_STICKY_BUTTON},
@@ -588,7 +588,7 @@
  * @param railtype the railtype to display
  * @param w the window to modify
  */
-static void SetupRailToolbar(RailType railtype, Window *w)
+static void SetupRailToolbar(RailType railtype, BaseWindow *w)
 {
 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
 
@@ -606,16 +606,16 @@
 
 void ShowBuildRailToolbar(RailType railtype, int button)
 {
-	Window *w;
+	BaseWindow *w;
 
 	if (!IsValidPlayer(_current_player)) return;
 	if (!ValParamRailtype(railtype)) return;
 
 	// don't recreate the window if we're clicking on a button and the window exists.
-	if (button < 0 || !(w = Window::FindById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
+	if (button < 0 || !(w = BaseWindow::FindById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
 		DeleteWindowById(WC_BUILD_TOOLBAR, 0);
 		_cur_railtype = railtype;
-		w = AllocateWindowDesc(&_build_rail_desc);
+		w = BaseWindow::Allocate(&_build_rail_desc);
 		SetupRailToolbar(railtype, w);
 	}
 
@@ -651,7 +651,7 @@
 }
 
 /* Check if the currently selected station size is allowed */
-static void CheckSelectedSize(Window *w, const StationSpec *statspec)
+static void CheckSelectedSize(BaseWindow *w, const StationSpec *statspec)
 {
 	if (statspec == NULL || _railstation.dragdrop) return;
 
@@ -674,7 +674,7 @@
 	}
 }
 
-static void StationBuildWndProc(Window *w, WindowEvent *e)
+static void StationBuildWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE:
@@ -902,7 +902,7 @@
 	}
 }
 
-static const Widget _station_builder_widgets[] = {
+static const OldWidget _station_builder_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,   199, 0x0,                             STR_NULL},
@@ -931,7 +931,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _newstation_builder_widgets[] = {
+static const OldWidget _newstation_builder_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,   289, 0x0,                             STR_NULL},
@@ -984,12 +984,12 @@
 
 static void ShowStationBuilder(void)
 {
-	Window *w;
+	BaseWindow *w;
 	if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
-		w = AllocateWindowDesc(&_station_builder_desc);
+		w = BaseWindow::Allocate(&_station_builder_desc);
 		_railstation.newstations = false;
 	} else {
-		w = AllocateWindowDesc(&_newstation_builder_desc);
+		w = BaseWindow::Allocate(&_newstation_builder_desc);
 		_railstation.newstations = true;
 		_railstation.station_count = GetNumCustomStations(_railstation.station_class);
 
@@ -999,7 +999,7 @@
 	}
 }
 
-static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
+static void BuildTrainDepotWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->LowerWidget(_build_depot_direction + 3); break;
@@ -1042,7 +1042,7 @@
 	}
 }
 
-static const Widget _build_depot_widgets[] = {
+static const OldWidget _build_depot_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                              STR_NULL},
@@ -1063,11 +1063,11 @@
 
 static void ShowBuildTrainDepotPicker(void)
 {
-	AllocateWindowDesc(&_build_depot_desc);
+	BaseWindow::Allocate(&_build_depot_desc);
 }
 
 
-static void BuildWaypointWndProc(Window *w, WindowEvent *e)
+static void BuildWaypointWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -1124,7 +1124,7 @@
 	}
 }
 
-static const Widget _build_waypoint_widgets[] = {
+static const OldWidget _build_waypoint_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   343,     0,    13, STR_WAYPOINT, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   343,    14,    91, 0x0,          0},
@@ -1149,7 +1149,7 @@
 
 static void ShowBuildWaypointPicker(void)
 {
-	Window *w = AllocateWindowDesc(&_build_waypoint_desc);
+	BaseWindow *w = BaseWindow::Allocate(&_build_waypoint_desc);
 	w->hscroll.cap = 5;
 	w->hscroll.count = _waypoint_count;
 }
@@ -1167,9 +1167,9 @@
 {
 	extern RailType _last_built_railtype;
 	if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
-		Window *w;
+		BaseWindow *w;
 		_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
-		w = Window::FindById(WC_BUILD_TOOLBAR, 0);
+		w = BaseWindow::FindById(WC_BUILD_TOOLBAR, 0);
 		if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
 			SetupRailToolbar(_cur_railtype, w);
 			w->SetDirty();
--- a/src/road_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/road_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -141,53 +141,53 @@
 };
 
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 
-static void BuildRoadClick_NE(Window *w)
+static void BuildRoadClick_NE(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_ROAD_X, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE);
 }
 
-static void BuildRoadClick_NW(Window *w)
+static void BuildRoadClick_NW(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_ROAD_Y, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW);
 }
 
 
-static void BuildRoadClick_Demolish(Window *w)
+static void BuildRoadClick_Demolish(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea);
 }
 
-static void BuildRoadClick_Depot(Window *w)
+static void BuildRoadClick_Depot(BaseWindow *w)
 {
 	if (_game_mode == GM_EDITOR) return;
 	if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
 }
 
-static void BuildRoadClick_BusStation(Window *w)
+static void BuildRoadClick_BusStation(BaseWindow *w)
 {
 	if (_game_mode == GM_EDITOR) return;
 	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
 }
 
-static void BuildRoadClick_TruckStation(Window *w)
+static void BuildRoadClick_TruckStation(BaseWindow *w)
 {
 	if (_game_mode == GM_EDITOR) return;
 	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
 }
 
-static void BuildRoadClick_Bridge(Window *w)
+static void BuildRoadClick_Bridge(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge);
 }
 
-static void BuildRoadClick_Tunnel(Window *w)
+static void BuildRoadClick_Tunnel(BaseWindow *w)
 {
 	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel);
 }
 
-static void BuildRoadClick_Remove(Window *w)
+static void BuildRoadClick_Remove(BaseWindow *w)
 {
 	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
 	w->SetDirty();
@@ -209,7 +209,7 @@
 	BuildRoadClick_Remove
 };
 
-static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
+static void BuildRoadToolbWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->DisableWidget(RTW_REMOVE); break;
@@ -252,11 +252,11 @@
 		w->DisableWidget(RTW_REMOVE);
 		w->InvalidateWidget(RTW_REMOVE);
 
-		w = Window::FindById(WC_BUS_STATION, 0);
+		w = BaseWindow::FindById(WC_BUS_STATION, 0);
 		if (w != NULL) WP(w,def_d).close = true;
-		w = Window::FindById(WC_TRUCK_STATION, 0);
+		w = BaseWindow::FindById(WC_TRUCK_STATION, 0);
 		if (w != NULL) WP(w,def_d).close = true;
-		w = Window::FindById(WC_BUILD_DEPOT, 0);
+		w = BaseWindow::FindById(WC_BUILD_DEPOT, 0);
 		if (w != NULL) WP(w,def_d).close = true;
 		break;
 
@@ -319,7 +319,7 @@
 	}
 }
 
-static const Widget _build_road_widgets[] = {
+static const OldWidget _build_road_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   205,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   206,   217,     0,    13, 0x0,                        STR_STICKY_BUTTON},
@@ -349,11 +349,11 @@
 	if (!IsValidPlayer(_current_player)) return;
 
 	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
-	Window *w = AllocateWindowDesc(&_build_road_desc);
+	BaseWindow *w = BaseWindow::Allocate(&_build_road_desc);
 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
 }
 
-static const Widget _build_road_scen_widgets[] = {
+static const OldWidget _build_road_scen_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,     7,   140,   151,     0,    13, 0x0,                        STR_STICKY_BUTTON},
@@ -380,10 +380,10 @@
 
 void ShowBuildRoadScenToolbar(void)
 {
-	AllocateWindowDescFront(&_build_road_scen_desc, 0);
+	BaseWindow::AllocateFront(&_build_road_scen_desc, 0);
 }
 
-static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
+static void BuildRoadDepotWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: w->LowerWidget(_road_depot_orientation + 3); break;
@@ -419,7 +419,7 @@
 	}
 }
 
-static const Widget _build_road_depot_widgets[] = {
+static const OldWidget _build_road_depot_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},
@@ -440,10 +440,10 @@
 
 static void ShowRoadDepotPicker(void)
 {
-	AllocateWindowDesc(&_build_road_depot_desc);
+	BaseWindow::Allocate(&_build_road_depot_desc);
 }
 
-static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
+static void RoadStationPickerWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE:
@@ -517,7 +517,7 @@
 	}
 }
 
-static const Widget _bus_station_picker_widgets[] = {
+static const OldWidget _bus_station_picker_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},
@@ -543,10 +543,10 @@
 
 static void ShowBusStationPicker(void)
 {
-	AllocateWindowDesc(&_bus_station_picker_desc);
+	BaseWindow::Allocate(&_bus_station_picker_desc);
 }
 
-static const Widget _truck_station_picker_widgets[] = {
+static const OldWidget _truck_station_picker_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3043_TRUCK_STATION_ORIENT,    STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},
@@ -572,7 +572,7 @@
 
 static void ShowTruckStationPicker(void)
 {
-	AllocateWindowDesc(&_truck_station_picker_desc);
+	BaseWindow::Allocate(&_truck_station_picker_desc);
 }
 
 void InitializeRoadGui(void)
--- a/src/roadveh_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/roadveh_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -26,7 +26,7 @@
 	}
 }
 
-static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
+static void RoadVehDetailsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -139,7 +139,7 @@
 	}
 }
 
-static const Widget _roadveh_details_widgets[] = {
+static const OldWidget _roadveh_details_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   339,     0,    13, STR_900C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   340,   379,     0,    13, STR_01AA_NAME,    STR_902E_NAME_ROAD_VEHICLE},
@@ -161,13 +161,13 @@
 
 static void ShowRoadVehDetailsWindow(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 	VehicleID veh = v->index;
 
 	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
-	w = AllocateWindowDescFront(&_roadveh_details_desc, veh);
+	w = BaseWindow::AllocateFront(&_roadveh_details_desc, veh);
 	w->caption_color = v->owner;
 }
 
@@ -176,7 +176,7 @@
 	if (success) ShowRoadVehViewWindow(GetVehicle(_new_vehicle_id));
 }
 
-static void RoadVehViewWndProc(Window *w, WindowEvent *e)
+static void RoadVehViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -291,8 +291,8 @@
 			const Vehicle *v = GetVehicle(w->window_number);
 			bool rv_stopped = IsRoadVehInDepotStopped(v);
 
-			/* Widget 7 (send to depot) must be hidden if the truck/bus is already stopped in depot.
-			 * Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
+			/* OldWidget 7 (send to depot) must be hidden if the truck/bus is already stopped in depot.
+			 * OldWidget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
 			 * This sytem allows to have two buttons, on top of each other.
 			 * The same system applies to widget 8 and 12, force turn around and refit. */
 			if (rv_stopped != w->IsWidgetHidden(7) || rv_stopped == w->IsWidgetHidden(11)) {
@@ -306,7 +306,7 @@
 	}
 }
 
-static const Widget _roadveh_view_widgets[] = {
+static const OldWidget _roadveh_view_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE,  14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION, RESIZE_RIGHT, 14,  11, 237,   0,  13, STR_9002,                STR_018C_WINDOW_TITLE_DRAG_THIS },
 {  WWT_STICKYBOX, RESIZE_LR,    14, 238, 249,   0,  13, 0x0,                     STR_STICKY_BUTTON },
@@ -335,7 +335,7 @@
 
 void ShowRoadVehViewWindow(const Vehicle *v)
 {
-	Window *w = AllocateWindowDescFront(&_roadveh_view_desc, v->index);
+	BaseWindow *w = BaseWindow::AllocateFront(&_roadveh_view_desc, v->index);
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
--- a/src/settings_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/settings_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -90,7 +90,7 @@
 
 static void ShowCustCurrency(void);
 
-static void GameOptionsWndProc(Window *w, WindowEvent *e)
+static void GameOptionsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -239,7 +239,7 @@
 	return 0;
 }
 
-static const Widget _game_options_widgets[] = {
+static const OldWidget _game_options_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
@@ -292,7 +292,7 @@
 void ShowGameOptions(void)
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_game_options_desc);
+	BaseWindow::Allocate(&_game_options_desc);
 }
 
 typedef struct {
@@ -381,7 +381,7 @@
 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E
 
-static void GameDifficultyWndProc(Window *w, WindowEvent *e)
+static void GameDifficultyWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: // Setup disabled buttons when creating window
@@ -527,7 +527,7 @@
 
 #undef DIFF_INGAME_DISABLED_BUTTONS
 
-static const Widget _game_difficulty_widgets[] = {
+static const OldWidget _game_difficulty_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,                          STR_NULL},
@@ -557,7 +557,7 @@
 	/* Copy current settings (ingame or in intro) to temporary holding place
 	 * change that when setting stuff, copy back on clicking 'OK' */
 	_opt_mod_temp = *_opt_ptr;
-	AllocateWindowDesc(&_game_difficulty_desc);
+	BaseWindow::Allocate(&_game_difficulty_desc);
 }
 
 static const char *_patches_ui[] = {
@@ -681,7 +681,7 @@
 /** The main patches window. Shows a number of categories on top and
  * a selection of patches in that category.
  * Uses WP(w, def_d) macro - data_1, data_2, data_3 */
-static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
+static void PatchesSelectionWndProc(BaseWindow *w, WindowEvent *e)
 {
 	static Patches *patches_ptr;
 
@@ -891,7 +891,7 @@
 	}
 }
 
-static const Widget _patches_selection_widgets[] = {
+static const OldWidget _patches_selection_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
@@ -917,7 +917,7 @@
 void ShowPatchesSelection(void)
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_patches_selection_desc);
+	BaseWindow::Allocate(&_patches_selection_desc);
 }
 
 
@@ -948,7 +948,7 @@
 
 static char _str_separator[2];
 
-static void CustCurrencyWndProc(Window *w, WindowEvent *e)
+static void CustCurrencyWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -1119,7 +1119,7 @@
 	}
 }
 
-static const Widget _cust_currency_widgets[] = {
+static const OldWidget _cust_currency_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
@@ -1140,5 +1140,5 @@
 	_str_separator[1] = '\0';
 
 	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
-	AllocateWindowDesc(&_cust_currency_desc);
+	BaseWindow::Allocate(&_cust_currency_desc);
 }
--- a/src/ship_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/ship_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -24,7 +24,7 @@
 	}
 }
 
-static void ShipDetailsWndProc(Window *w, WindowEvent *e)
+static void ShipDetailsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -136,7 +136,7 @@
 }
 
 
-static const Widget _ship_details_widgets[] = {
+static const OldWidget _ship_details_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   364,     0,    13, STR_9811_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   365,   404,     0,    13, STR_01AA_NAME,    STR_982F_NAME_SHIP},
@@ -158,12 +158,12 @@
 
 static void ShowShipDetailsWindow(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 	VehicleID veh = v->index;
 
 	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
-	w = AllocateWindowDescFront(&_ship_details_desc, veh);
+	w = BaseWindow::AllocateFront(&_ship_details_desc, veh);
 	w->caption_color = v->owner;
 }
 
@@ -185,7 +185,7 @@
 	if (success) ShowShipViewWindow(GetVehicle(_new_vehicle_id));
 }
 
-static void ShipViewWndProc(Window *w, WindowEvent *e)
+static void ShipViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -296,8 +296,8 @@
 			const Vehicle *v = GetVehicle(w->window_number);
 			bool ship_stopped = IsShipInDepotStopped(v);
 
-			/* Widget 7 (send to depot) must be hidden if the ship is already stopped in depot.
-			 * Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
+			/* OldWidget 7 (send to depot) must be hidden if the ship is already stopped in depot.
+			 * OldWidget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
 			 * This sytem allows to have two buttons, on top of each otherother*/
 			if (ship_stopped != w->IsWidgetHidden(7) || ship_stopped == w->IsWidgetHidden(11)) {
 				w->SetWidgetHiddenState( 7, ship_stopped);  // send to depot
@@ -308,7 +308,7 @@
 	}
 }
 
-static const Widget _ship_view_widgets[] = {
+static const OldWidget _ship_view_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE,  14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_RIGHT, 14,  11, 237,   0,  13, STR_980F,                STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX, RESIZE_LR,    14, 238, 249,   0,  13, 0x0,                     STR_STICKY_BUTTON},
@@ -336,7 +336,7 @@
 
 void ShowShipViewWindow(const Vehicle *v)
 {
-	Window *w = AllocateWindowDescFront(&_ship_view_desc, v->index);
+	BaseWindow *w = BaseWindow::AllocateFront(&_ship_view_desc, v->index);
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
--- a/src/signs_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/signs_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -56,7 +56,7 @@
 	DEBUG(misc, 3, "Resorting global signs list");
 }
 
-static void SignListWndProc(Window *w, WindowEvent *e)
+static void SignListWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -118,7 +118,7 @@
 	}
 }
 
-static const Widget _sign_list_widget[] = {
+static const OldWidget _sign_list_widget[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_SIGN_LIST_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,                   STR_STICKY_BUTTON},
@@ -139,9 +139,9 @@
 
 void ShowSignList(void)
 {
-	Window *w;
+	BaseWindow *w;
 
-	w = AllocateWindowDescFront(&_sign_list_desc, 0);
+	w = BaseWindow::AllocateFront(&_sign_list_desc, 0);
 	if (w != NULL) {
 		w->vscroll.cap = 12;
 		w->resize.step_height = 10;
--- a/src/smallmap_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/smallmap_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -23,7 +23,7 @@
 #include "sound.h"
 #include "variables.h"
 
-static const Widget _smallmap_widgets[] = {
+static const OldWidget _smallmap_widgets[] = {
 {  WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {   WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   433,     0,    13, STR_00B0_MAP,            STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_STICKYBOX,     RESIZE_LR,    13,   434,   445,     0,    13, 0x0,                     STR_STICKY_BUTTON},
@@ -579,11 +579,11 @@
  * <li>Town names (optional)</li>
  *
  * @param dpi pointer to pixel to write onto
- * @param w pointer to Window struct
+ * @param w pointer to BaseWindow struct
  * @param type type of map requested (vegetation, owners, routes, etc)
  * @param show_towns true if the town names should be displayed, false if not.
  */
-static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns)
+static void DrawSmallMap(DrawPixelInfo *dpi, BaseWindow *w, int type, bool show_towns)
 {
 	DrawPixelInfo *old_dpi;
 	int dx,dy, x, y, x2, y2;
@@ -762,7 +762,7 @@
 		Point pt;
 
 		// Find main viewport.
-		vp = Window::FindById(WC_MAIN_WINDOW,0)->viewport;
+		vp = BaseWindow::FindById(WC_MAIN_WINDOW,0)->viewport;
 
 		pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0);
 
@@ -785,11 +785,11 @@
 	_cur_dpi = old_dpi;
 }
 
-void SmallMapCenterOnCurrentPos(Window *w)
+void SmallMapCenterOnCurrentPos(BaseWindow *w)
 {
 	int x, y;
 	ViewPort *vp;
-	vp = Window::FindById(WC_MAIN_WINDOW, 0)->viewport;
+	vp = BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport;
 
 	x  = ((vp->virtual_width  - (w->widget[4].right  - w->widget[4].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4;
 	y  = ((vp->virtual_height - (w->widget[4].bottom - w->widget[4].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
@@ -798,7 +798,7 @@
 	w->SetDirty();
 }
 
-static void SmallMapWindowProc(Window *w, WindowEvent *e)
+static void SmallMapWindowProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -840,7 +840,7 @@
 		case WE_CLICK:
 			switch (e->we.click.widget) {
 				case 4: { // Map window
-					Window *w2 = Window::FindById(WC_MAIN_WINDOW, 0);
+					BaseWindow *w2 = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 					Point pt;
 
 					/*
@@ -978,9 +978,9 @@
 
 void ShowSmallMap(void)
 {
-	Window *w;
+	BaseWindow *w;
 
-	w = AllocateWindowDescFront(&_smallmap_desc, 0);
+	w = BaseWindow::AllocateFront(&_smallmap_desc, 0);
 	if (w == NULL) return;
 
 	w->LowerWidget(_smallmap_type + 5);
@@ -991,8 +991,8 @@
 	SmallMapCenterOnCurrentPos(w);
 }
 
-/* Extra ViewPort Window Stuff */
-static const Widget _extra_view_port_widgets[] = {
+/* Extra ViewPort BaseWindow Stuff */
+static const OldWidget _extra_view_port_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   287,     0,    13, STR_EXTRA_VIEW_PORT_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    14,   288,   299,     0,    13, 0x0,                              STR_STICKY_BUTTON},
@@ -1008,7 +1008,7 @@
 {   WIDGETS_END},
 };
 
-static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
+static void ExtraViewPortWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_CREATE: /* Disable zoom in button */
@@ -1029,7 +1029,7 @@
 			case 6: DoZoomInOutWindow(ZOOM_OUT, w); break;
 
 		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
-			Window *w2 = Window::FindById(WC_MAIN_WINDOW, 0);
+			BaseWindow *w2 = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
 			int y = WP(w, vp_d).scrollpos_y;
 
@@ -1039,7 +1039,7 @@
 		} break;
 
 		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
-			const Window *w2 = Window::FindById(WC_MAIN_WINDOW, 0);
+			const BaseWindow *w2 = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 			int x = WP(w2, const vp_d).scrollpos_x;
 			int y = WP(w2, const vp_d).scrollpos_y;
 
@@ -1091,17 +1091,17 @@
 
 void ShowExtraViewPortWindow(void)
 {
-	Window *w, *v;
+	BaseWindow *w, *v;
 	int i = 0;
 
 	// find next free window number for extra viewport
-	while (Window::FindById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
+	while (BaseWindow::FindById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
 
-	w = AllocateWindowDescFront(&_extra_view_port_desc, i);
+	w = BaseWindow::AllocateFront(&_extra_view_port_desc, i);
 	if (w != NULL) {
 		int x, y;
 		// the main window with the main view
-		v = Window::FindById(WC_MAIN_WINDOW, 0);
+		v = BaseWindow::FindById(WC_MAIN_WINDOW, 0);
 		// New viewport start ats (zero,zero)
 		AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
 
--- a/src/sound.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/sound.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -196,7 +196,7 @@
 
 	if (msf.effect_vol == 0) return;
 
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		const ViewPort *vp = w->viewport;
 
--- a/src/station_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/station_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -171,7 +171,7 @@
 
 void RebuildStationLists(void)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == WC_STATION_LIST) {
@@ -183,7 +183,7 @@
 
 void ResortStationLists(void)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == WC_STATION_LIST) {
@@ -259,7 +259,7 @@
 	sl->flags &= ~SL_RESORT;
 }
 
-static void PlayerStationsWndProc(Window *w, WindowEvent *e)
+static void PlayerStationsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	const PlayerID owner = (PlayerID)w->window_number;
 	static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
@@ -499,7 +499,7 @@
 	}
 }
 
-static const Widget _player_stations_widgets[] = {
+static const OldWidget _player_stations_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,               STR_STICKY_BUTTON},
@@ -552,11 +552,11 @@
 
 void ShowPlayerStations(PlayerID player)
 {
-	Window *w;
+	BaseWindow *w;
 
 	if (!IsValidPlayer(player)) return;
 
-	w = AllocateWindowDescFront(&_player_stations_desc, player);
+	w = BaseWindow::AllocateFront(&_player_stations_desc, player);
 	if (w != NULL) {
 		w->caption_color = (byte)w->window_number;
 		w->vscroll.cap = 12;
@@ -565,7 +565,7 @@
 	}
 }
 
-static const Widget _station_view_expanded_widgets[] = {
+static const OldWidget _station_view_expanded_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
@@ -583,7 +583,7 @@
 {   WIDGETS_END},
 };
 
-static const Widget _station_view_widgets[] = {
+static const OldWidget _station_view_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   236,     0,    13, STR_300A_0,        STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   237,   248,     0,    13, 0x0,               STR_STICKY_BUTTON},
@@ -601,7 +601,7 @@
 {   WIDGETS_END},
 };
 
-static void DrawStationViewWindow(Window *w)
+static void DrawStationViewWindow(BaseWindow *w)
 {
 	StationID station_id = w->window_number;
 	const Station* st = GetStation(station_id);
@@ -725,7 +725,7 @@
 }
 
 
-static void StationViewWndProc(Window *w, WindowEvent *e)
+static void StationViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -820,9 +820,9 @@
 
 void ShowStationViewWindow(StationID station)
 {
-	Window *w;
+	BaseWindow *w;
 
-	w = AllocateWindowDescFront(&_station_view_desc, station);
+	w = BaseWindow::AllocateFront(&_station_view_desc, station);
 	if (w != NULL) {
 		PlayerID owner = GetStation(w->window_number)->owner;
 		if (owner != OWNER_NONE) w->caption_color = owner;
--- a/src/subsidy_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/subsidy_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -74,7 +74,7 @@
 	}
 }
 
-static void DrawSubsidiesWindow(const Window *w)
+static void DrawSubsidiesWindow(const BaseWindow *w)
 {
 	YearMonthDay ymd;
 	const Subsidy *s;
@@ -138,7 +138,7 @@
 	if (num == 0) DrawString(x + 2, y, STR_202A_NONE, 0);
 }
 
-static void SubsidiesListWndProc(Window *w, WindowEvent *e)
+static void SubsidiesListWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: DrawSubsidiesWindow(w); break;
@@ -153,7 +153,7 @@
 	}
 }
 
-static const Widget _subsidies_list_widgets[] = {
+static const OldWidget _subsidies_list_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE, 13,  11, 617,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE, 13, 618, 629,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
@@ -172,5 +172,5 @@
 
 void ShowSubsidiesList(void)
 {
-	AllocateWindowDescFront(&_subsidies_list_desc, 0);
+	BaseWindow::AllocateFront(&_subsidies_list_desc, 0);
 }
--- a/src/terraform_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/terraform_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -124,7 +124,7 @@
 	return true;
 }
 
-typedef void OnButtonClick(Window *w);
+typedef void OnButtonClick(BaseWindow *w);
 
 static const uint16 _terraform_keycodes[] = {
 	'Q',
@@ -162,38 +162,38 @@
 	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
 }
 
-static void TerraformClick_Lower(Window *w)
+static void TerraformClick_Lower(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand);
 }
 
-static void TerraformClick_Raise(Window *w)
+static void TerraformClick_Raise(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand);
 }
 
-static void TerraformClick_Level(Window *w)
+static void TerraformClick_Level(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
 }
 
-static void TerraformClick_Dynamite(Window *w)
+static void TerraformClick_Dynamite(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea);
 }
 
-static void TerraformClick_BuyLand(Window *w)
+static void TerraformClick_BuyLand(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand);
 }
 
-static void TerraformClick_Trees(Window *w)
+static void TerraformClick_Trees(BaseWindow *w)
 {
 	/* This button is NOT a place-push-button, so don't treat it as such */
 	ShowBuildTreesToolbar();
 }
 
-static void TerraformClick_PlaceSign(Window *w)
+static void TerraformClick_PlaceSign(BaseWindow *w)
 {
 	HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign);
 }
@@ -208,7 +208,7 @@
 	TerraformClick_PlaceSign,
 };
 
-static void TerraformToolbWndProc(Window *w, WindowEvent *e)
+static void TerraformToolbWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -253,7 +253,7 @@
 	}
 }
 
-static const Widget _terraform_widgets[] = {
+static const OldWidget _terraform_widgets[] = {
 { WWT_CLOSEBOX,   RESIZE_NONE,     7,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 {  WWT_CAPTION,   RESIZE_NONE,     7,  11, 145,   0,  13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {WWT_STICKYBOX,   RESIZE_NONE,     7, 146, 157,   0,  13, STR_NULL,                STR_STICKY_BUTTON},
@@ -278,10 +278,10 @@
 	TerraformToolbWndProc
 };
 
-void ShowTerraformToolbar(Window *link)
+void ShowTerraformToolbar(BaseWindow *link)
 {
 	if (!IsValidPlayer(_current_player)) return;
-	Window *w = AllocateWindowDescFront(&_terraform_desc, 0);
+	BaseWindow *w = BaseWindow::AllocateFront(&_terraform_desc, 0);
 	if (w != NULL && link != NULL) {
 		/* Align the terraform toolbar under the main toolbar and put the linked
 		 * toolbar to left of it
--- a/src/town_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/town_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -18,7 +18,7 @@
 #include "variables.h"
 #include "helpers.hpp"
 
-static const Widget _town_authority_widgets[] = {
+static const OldWidget _town_authority_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   316,     0,    13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS},
 {      WWT_PANEL,   RESIZE_NONE,    13,     0,   316,    14,   105, 0x0,                      STR_NULL},
@@ -93,7 +93,7 @@
 	return -1;
 }
 
-static void TownAuthorityWndProc(Window *w, WindowEvent *e)
+static void TownAuthorityWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -220,7 +220,7 @@
 
 static void ShowTownAuthorityWindow(uint town)
 {
-	Window *w = AllocateWindowDescFront(&_town_authority_desc, town);
+	BaseWindow *w = BaseWindow::AllocateFront(&_town_authority_desc, town);
 
 	if (w != NULL) {
 		w->vscroll.cap = 5;
@@ -228,7 +228,7 @@
 	}
 }
 
-static void TownViewWndProc(Window *w, WindowEvent *e)
+static void TownViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	Town *t = GetTown(w->window_number);
 
@@ -291,7 +291,7 @@
 }
 
 
-static const Widget _town_view_widgets[] = {
+static const OldWidget _town_view_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   247,     0,    13, STR_2005,                 STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    13,   248,   259,     0,    13, 0x0,                      STR_STICKY_BUTTON},
@@ -312,7 +312,7 @@
 	TownViewWndProc
 };
 
-static const Widget _town_view_scen_widgets[] = {
+static const OldWidget _town_view_scen_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   172,     0,    13, STR_2005,          STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    13,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},
@@ -337,12 +337,12 @@
 
 void ShowTownViewWindow(TownID town)
 {
-	Window *w;
+	BaseWindow *w;
 
 	if (_game_mode != GM_EDITOR) {
-		w = AllocateWindowDescFront(&_town_view_desc, town);
+		w = BaseWindow::AllocateFront(&_town_view_desc, town);
 	} else {
-		w = AllocateWindowDescFront(&_town_view_scen_desc, town);
+		w = BaseWindow::AllocateFront(&_town_view_scen_desc, town);
 	}
 
 	if (w != NULL) {
@@ -351,7 +351,7 @@
 	}
 }
 
-static const Widget _town_directory_widgets[] = {
+static const OldWidget _town_directory_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   195,     0,    13, STR_2000_TOWNS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,   RESIZE_NONE,    13,   196,   207,     0,    13, 0x0,                    STR_STICKY_BUTTON},
@@ -424,7 +424,7 @@
 }
 
 
-static void TownDirectoryWndProc(Window *w, WindowEvent *e)
+static void TownDirectoryWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -515,7 +515,7 @@
 
 void ShowTownDirectory(void)
 {
-	Window *w = AllocateWindowDescFront(&_town_directory_desc, 0);
+	BaseWindow *w = BaseWindow::AllocateFront(&_town_directory_desc, 0);
 
 	if (w != NULL) {
 		w->vscroll.cap = 16;
--- a/src/train_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/train_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -113,7 +113,7 @@
 	_cur_dpi = old_dpi;
 }
 
-static const Widget _train_view_widgets[] = {
+static const OldWidget _train_view_widgets[] = {
 {   WWT_CLOSEBOX,  RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
 {    WWT_CAPTION, RESIZE_RIGHT, 14,  11, 237,   0,  13, STR_882E,                STR_018C_WINDOW_TITLE_DRAG_THIS },
 {  WWT_STICKYBOX,    RESIZE_LR, 14, 238, 249,   0,  13, 0x0,                     STR_STICKY_BUTTON },
@@ -135,7 +135,7 @@
 
 static void ShowTrainDetailsWindow(const Vehicle *v);
 
-static void TrainViewWndProc(Window *w, WindowEvent *e)
+static void TrainViewWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT: {
@@ -287,8 +287,8 @@
 		const Vehicle *v = GetVehicle(w->window_number);
 		bool train_stopped = CheckTrainStoppedInDepot(v)  >= 0;
 
-		/* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar.
-		 * Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
+		/* OldWidget 7 (send to depot) must be hidden if the train is already stopped in hangar.
+		 * OldWidget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
 		 * This sytem allows to have two buttons, on top of each other.
 		 * The same system applies to widget 9 and 12, reverse direction and refit*/
 		if (train_stopped != w->IsWidgetHidden(7) || train_stopped == w->IsWidgetHidden(13)) {
@@ -314,7 +314,7 @@
 
 void ShowTrainViewWindow(const Vehicle *v)
 {
-	Window *w = AllocateWindowDescFront(&_train_view_desc,v->index);
+	BaseWindow *w = BaseWindow::AllocateFront(&_train_view_desc,v->index);
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
@@ -364,7 +364,7 @@
 }
 
 
-static void DrawTrainDetailsWindow(Window *w)
+static void DrawTrainDetailsWindow(BaseWindow *w)
 {
 	byte det_tab = WP(w, traindetails_d).tab;
 	const Vehicle *v;
@@ -506,7 +506,7 @@
 	}
 }
 
-static void TrainDetailsWndProc(Window *w, WindowEvent *e)
+static void TrainDetailsWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 	case WE_PAINT:
@@ -569,7 +569,7 @@
 	}
 }
 
-static const Widget _train_details_widgets[] = {
+static const OldWidget _train_details_widgets[] = {
 {   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION, RESIZE_RIGHT,  14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 { WWT_PUSHTXTBTN, RESIZE_LR,     14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
@@ -599,13 +599,13 @@
 
 static void ShowTrainDetailsWindow(const Vehicle *v)
 {
-	Window *w;
+	BaseWindow *w;
 	VehicleID veh = v->index;
 
 	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
-	w = AllocateWindowDescFront(&_train_details_desc, veh);
+	w = BaseWindow::AllocateFront(&_train_details_desc, veh);
 
 	w->caption_color = v->owner;
 	w->vscroll.cap = 6;
--- a/src/vehicle.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/vehicle.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -1607,7 +1607,7 @@
  *   - bit 0-4 Vehicle type
  *   - bit 5 false = start vehicles, true = stop vehicles
  *   - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
- *   - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
+ *   - bit 8-11 Vehicle List BaseWindow type (ignored unless bit 1 is set)
  */
 int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
--- a/src/vehicle_gui.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/vehicle_gui.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -91,7 +91,7 @@
 
 void RebuildVehicleLists(void)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 		switch (w->window_class) {
@@ -110,7 +110,7 @@
 
 void ResortVehicleLists(void)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 
@@ -316,7 +316,7 @@
 	return selected;
 }
 
-static void VehicleRefitWndProc(Window *w, WindowEvent *e)
+static void VehicleRefitWndProc(BaseWindow *w, WindowEvent *e)
 {
 	switch (e->event) {
 		case WE_PAINT: {
@@ -405,7 +405,7 @@
 }
 
 
-static const Widget _vehicle_refit_widgets[] = {
+static const OldWidget _vehicle_refit_widgets[] = {
 	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                            STR_018B_CLOSE_WINDOW},
 	{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   239,     0,    13, STR_983B_REFIT,                      STR_018C_WINDOW_TITLE_DRAG_THIS},
 	{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,   239,    14,    27, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, STR_983D_SELECT_TYPE_OF_CARGO_FOR},
@@ -430,11 +430,11 @@
 */
 void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
 {
-	Window *w;
+	BaseWindow *w;
 
 	DeleteWindowById(WC_VEHICLE_REFIT, v->index);
 
-	w = AllocateWindowDescFront(&_vehicle_refit_desc, v->index);
+	w = BaseWindow::AllocateFront(&_vehicle_refit_desc, v->index);
 	WP(w, refit_d).order = order;
 
 	if (w != NULL) {
@@ -719,27 +719,27 @@
  */
 void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v)
 {
-	Window *w;
+	BaseWindow *w;
 
-	w = Window::FindById(WC_VEHICLE_VIEW, from_v->index);
+	w = BaseWindow::FindById(WC_VEHICLE_VIEW, from_v->index);
 	if (w != NULL) {
 		w->window_number = to_v->index;
 		WP(w, vp_d).follow_vehicle = to_v->index;
 		w->SetDirty();
 
-		w = Window::FindById(WC_VEHICLE_ORDERS, from_v->index);
+		w = BaseWindow::FindById(WC_VEHICLE_ORDERS, from_v->index);
 		if (w != NULL) {
 			w->window_number = to_v->index;
 			w->SetDirty();
 		}
 
-		w = Window::FindById(WC_VEHICLE_REFIT, from_v->index);
+		w = BaseWindow::FindById(WC_VEHICLE_REFIT, from_v->index);
 		if (w != NULL) {
 			w->window_number = to_v->index;
 			w->SetDirty();
 		}
 
-		w = Window::FindById(WC_VEHICLE_DETAILS, from_v->index);
+		w = BaseWindow::FindById(WC_VEHICLE_DETAILS, from_v->index);
 		if (w != NULL) {
 			w->window_number = to_v->index;
 			w->SetDirty();
@@ -777,7 +777,7 @@
 	VLW_WIDGET_RESIZE,
 };
 
-static const Widget _vehicle_list_widgets[] = {
+static const OldWidget _vehicle_list_widgets[] = {
 	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,             STR_018B_CLOSE_WINDOW},
 	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   247,     0,    13, 0x0,                  STR_018C_WINDOW_TITLE_DRAG_THIS},
 	{  WWT_STICKYBOX,     RESIZE_LR,    14,   248,   259,     0,    13, 0x0,                  STR_STICKY_BUTTON},
@@ -787,7 +787,7 @@
 	{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   259,    14,    25, 0x0,                  STR_NULL},
 	{     WWT_MATRIX,     RESIZE_RB,    14,     0,   247,    26,   169, 0x0,                  STR_NULL},
 	{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   248,   259,    26,   169, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
-	/* Widget to be shown for other players hiding the following 6 widgets */
+	/* OldWidget to be shown for other players hiding the following 6 widgets */
 	{      WWT_PANEL,    RESIZE_RTB,    14,     0,   247,   170,   181, 0x0,                  STR_NULL},
 
 	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   105,   170,   181, 0x0,                  STR_AVAILABLE_ENGINES_TIP},
@@ -801,7 +801,7 @@
 	{   WIDGETS_END},
 };
 
-static void CreateVehicleListWindow(Window *w)
+static void CreateVehicleListWindow(BaseWindow *w)
 {
 	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 	uint16 window_type = w->window_number & VLW_MASK;
@@ -947,7 +947,7 @@
 	}
 }
 
-static void DrawVehicleListWindow(Window *w)
+static void DrawVehicleListWindow(BaseWindow *w)
 {
 	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 	int x = 2;
@@ -1062,7 +1062,7 @@
  * 11-15 vehicle type (using VEH_, but can be compressed to fewer bytes if needed)
  * 16-31 StationID or OrderID depending on window type (bit 8-10)
  **/
-void PlayerVehWndProc(Window *w, WindowEvent *e)
+void PlayerVehWndProc(BaseWindow *w, WindowEvent *e)
 {
 	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
@@ -1236,7 +1236,7 @@
 
 static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number)
 {
-	Window *w;
+	BaseWindow *w;
 	WindowNumber num;
 
 	if (!IsValidPlayer(player)) return;
@@ -1249,18 +1249,18 @@
 	switch (vehicle_type) {
 		default: NOT_REACHED();
 		case VEH_Train:
-			w = AllocateWindowDescFront(&_player_vehicle_list_train_desc, num);
+			w = BaseWindow::AllocateFront(&_player_vehicle_list_train_desc, num);
 			if (w != NULL) w->Resize(65, 38);
 			break;
 		case VEH_Road:
-			w = AllocateWindowDescFront(&_player_vehicle_list_road_veh_desc, num);
+			w = BaseWindow::AllocateFront(&_player_vehicle_list_road_veh_desc, num);
 			if (w != NULL) w->Resize(0, 38);
 			break;
 		case VEH_Ship:
-			w = AllocateWindowDescFront(&_player_vehicle_list_ship_desc, num);
+			w = BaseWindow::AllocateFront(&_player_vehicle_list_ship_desc, num);
 			break;
 		case VEH_Aircraft:
-			w = AllocateWindowDescFront(&_player_vehicle_list_aircraft_desc, num);
+			w = BaseWindow::AllocateFront(&_player_vehicle_list_aircraft_desc, num);
 			break;
 	}
 
--- a/src/vehicle_gui.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/vehicle_gui.h	Sun Feb 18 14:17:28 2007 +0000
@@ -16,7 +16,7 @@
 
 #define PERIODIC_RESORT_DAYS 10
 
-/* Vehicle List Window type flags */
+/* Vehicle List BaseWindow type flags */
 enum {
 	VLW_STANDARD      = 0 << 8,
 	VLW_SHARED_ORDERS = 1 << 8,
@@ -30,7 +30,7 @@
 	return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST);
 }
 
-void PlayerVehWndProc(Window *w, WindowEvent *e);
+void PlayerVehWndProc(BaseWindow *w, WindowEvent *e);
 
 void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number);
 
--- a/src/viewport.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/viewport.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -118,7 +118,7 @@
 TileHighlightData _thd;
 static TileInfo *_cur_ti;
 
-extern void SmallMapCenterOnCurrentPos(Window *w);
+extern void SmallMapCenterOnCurrentPos(BaseWindow *w);
 
 static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z)
 {
@@ -133,14 +133,14 @@
 	_active_viewports = 0;
 }
 
-void DeleteWindowViewport(Window *w)
+void DeleteWindowViewport(BaseWindow *w)
 {
 	CLRBIT(_active_viewports, w->viewport - _viewports);
 	w->viewport->width = 0;
 	w->viewport = NULL;
 }
 
-void AssignWindowViewport(Window *w, int x, int y,
+void AssignWindowViewport(BaseWindow *w, int x, int y,
 	int width, int height, uint32 follow_flags, byte zoom)
 {
 	ViewPort *vp;
@@ -188,10 +188,10 @@
 
 static void DoSetViewportPosition(WindowList::Iterator vit, int left, int top, int width, int height)
 {
-	//Window *w = (*wit).w;
-
-	for (WindowList::Iterator wit = vit; wit != Window::s_list.m_list.end(); wit++) {
-		const Window *w = (*wit).w;
+	//BaseWindow *w = (*wit).w;
+
+	for (WindowList::Iterator wit = vit; wit != BaseWindow::s_list.m_list.end(); wit++) {
+		const BaseWindow *w = (*wit).w;
 
 		if (left + width > w->left &&
 				w->left + w->width > left &&
@@ -255,7 +255,7 @@
 	}
 }
 
-static void SetViewportPosition(Window *w, int x, int y)
+static void SetViewportPosition(BaseWindow *w, int x, int y)
 {
 	ViewPort *vp = w->viewport;
 	int old_left = vp->virtual_left;
@@ -301,13 +301,13 @@
 		i = top + height - _screen.height;
 		if (i >= 0) height -= i;
 
-		WindowList::Iterator it = Window::s_list.Find(w);
+		WindowList::Iterator it = BaseWindow::s_list.Find(w);
 		if (height > 0) DoSetViewportPosition(++it, left, top, width, height);
 	}
 }
 
 
-ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
+ViewPort *IsPtInWindowViewport(const BaseWindow *w, int x, int y)
 {
 	ViewPort *vp = w->viewport;
 
@@ -360,11 +360,11 @@
  * when you just want the tile, make x = zoom_x and y = zoom_y */
 static Point GetTileFromScreenXY(int x, int y, int zoom_x, int zoom_y)
 {
-	Window *w;
+	BaseWindow *w;
 	ViewPort *vp;
 	Point pt;
 
-	if ( (w = FindWindowFromPt(x, y)) != NULL &&
+	if ( (w = BaseWindow::FindFromPt(x, y)) != NULL &&
 			 (vp = IsPtInWindowViewport(w, x, y)) != NULL)
 				return TranslateXYToTileCoord(vp, zoom_x, zoom_y);
 
@@ -378,7 +378,7 @@
 }
 
 
-Point GetTileZoomCenterWindow(bool in, Window * w)
+Point GetTileZoomCenterWindow(bool in, BaseWindow * w)
 {
 	int x, y;
 	ViewPort * vp;
@@ -402,7 +402,7 @@
  * @param vp pointer to the viewport whose zoom-level the buttons represent
  * @param widget_zoom_in widget index for window with zoom-in button
  * @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)
+void HandleZoomMessage(BaseWindow *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 {
 	w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == 0);
 	w->InvalidateWidget(widget_zoom_in);
@@ -1332,7 +1332,7 @@
 	ViewportDrawChk(vp, left, top, right, bottom);
 }
 
-void Window::DrawViewport() const
+void BaseWindow::DrawViewport() const
 {
 	DrawPixelInfo *dpi = _cur_dpi;
 
@@ -1345,7 +1345,7 @@
 	dpi->top -= top;
 }
 
-void UpdateViewportPosition(Window *w)
+void UpdateViewportPosition(BaseWindow *w)
 {
 	const ViewPort *vp = w->viewport;
 
@@ -1746,13 +1746,13 @@
 
 Vehicle *CheckMouseOverVehicle(void)
 {
-	const Window *w;
+	const BaseWindow *w;
 	const ViewPort *vp;
 
 	int x = _cursor.pos.x;
 	int y = _cursor.pos.y;
 
-	w = FindWindowFromPt(x, y);
+	w = BaseWindow::FindFromPt(x, y);
 	if (w == NULL) return NULL;
 
 	vp = IsPtInWindowViewport(w, x, y);
@@ -1764,7 +1764,7 @@
 void PlaceObject(void)
 {
 	Point pt;
-	Window *w;
+	BaseWindow *w;
 
 	pt = GetTileBelowCursor();
 	if (pt.x == -1) return;
@@ -1790,7 +1790,7 @@
 
 
 /* scrolls the viewport in a window to a given location */
-bool ScrollWindowTo(int x , int y, Window *w)
+bool ScrollWindowTo(int x , int y, BaseWindow *w)
 {
 	Point pt;
 
@@ -1808,8 +1808,8 @@
 
 bool ScrollMainWindowTo(int x, int y)
 {
-	Window *w;
-	bool res = ScrollWindowTo(x, y, Window::FindById(WC_MAIN_WINDOW, 0));
+	BaseWindow *w;
+	bool res = ScrollWindowTo(x, y, BaseWindow::FindById(WC_MAIN_WINDOW, 0));
 
 	/* If a user scrolls to a tile (via what way what so ever) and already is on
 	 *  that tile (e.g.: pressed twice), move the smallmap to that location,
@@ -1817,7 +1817,7 @@
 
 	if (res) return res;
 
-	w = Window::FindById(WC_SMALLMAP, 0);
+	w = BaseWindow::FindById(WC_SMALLMAP, 0);
 	if (w == NULL) return res;
 
 	SmallMapCenterOnCurrentPos(w);
@@ -2388,7 +2388,7 @@
 // while dragging
 bool VpHandlePlaceSizingDrag(void)
 {
-	Window *w;
+	BaseWindow *w;
 	WindowEvent e;
 
 	if (_special_mouse_mode != WSM_SIZING) return true;
@@ -2396,7 +2396,7 @@
 	e.we.place.userdata = _thd.userdata;
 
 	// stop drag mode if the window has been closed
-	w = Window::FindById(_thd.window_class,_thd.window_number);
+	w = BaseWindow::FindById(_thd.window_class,_thd.window_number);
 	if (w == NULL) {
 		ResetObjectToPlace();
 		return false;
@@ -2436,7 +2436,7 @@
 	return false;
 }
 
-void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w)
+void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, BaseWindow *w)
 {
 	SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number);
 }
@@ -2445,12 +2445,12 @@
 
 void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num)
 {
-	Window *w;
+	BaseWindow *w;
 
 	// undo clicking on button
 	if (_thd.place_mode != 0) {
 		_thd.place_mode = 0;
-		w = Window::FindById(_thd.window_class, _thd.window_number);
+		w = BaseWindow::FindById(_thd.window_class, _thd.window_number);
 		if (w != NULL) w->CallEventNP(WE_ABORT_PLACE_OBJ);
 	}
 
--- a/src/viewport.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/viewport.h	Sun Feb 18 14:17:28 2007 +0000
@@ -17,12 +17,12 @@
 
 /* viewport.c */
 void InitViewports(void);
-void DeleteWindowViewport(Window *w);
-void AssignWindowViewport(Window *w, int x, int y,
+void DeleteWindowViewport(BaseWindow *w);
+void AssignWindowViewport(BaseWindow *w, int x, int y,
 	int width, int height, uint32 follow_flags, byte zoom);
-ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
+ViewPort *IsPtInWindowViewport(const BaseWindow *w, int x, int y);
 Point GetTileBelowCursor(void);
-void UpdateViewportPosition(Window *w);
+void UpdateViewportPosition(BaseWindow *w);
 
 enum {
 	ZOOM_IN   = 0,
@@ -30,12 +30,12 @@
 	ZOOM_NONE = 2, // hack, used to update the button status
 };
 
-bool DoZoomInOutWindow(int how, Window *w);
-void ZoomInOrOutToCursorWindow(bool in, Window * w);
-Point GetTileZoomCenterWindow(bool in, Window * w);
-void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
+bool DoZoomInOutWindow(int how, BaseWindow *w);
+void ZoomInOrOutToCursorWindow(bool in, BaseWindow * w);
+Point GetTileZoomCenterWindow(bool in, BaseWindow * w);
+void HandleZoomMessage(BaseWindow *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
 
-static inline void MaxZoomInOut(int how, Window *w)
+static inline void MaxZoomInOut(int how, BaseWindow *w)
 {
 	while (DoZoomInOutWindow(how, w) ) {};
 }
@@ -139,7 +139,7 @@
 
 
 // common button handler
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc);
+bool HandlePlacePushButton(BaseWindow *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc);
 
 VARDEF Point _tile_fract_coords;
 
--- a/src/widget.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/widget.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -44,7 +44,7 @@
  *   y   - The Y coordinate of the mouse click.
  */
 
-void Window::ScrollbarClickHandler(const Widget *wi, int x, int y)
+void BaseWindow::ScrollbarClickHandler(const OldWidget *wi, int x, int y)
 {
 	int mi, ma, pos;
 	Scrollbar *sb;
@@ -125,10 +125,10 @@
 
 /** Returns the index for the widget located at the given position
  * relative to the window. It includes all widget-corner pixels as well.
- * @param  x,y Window client coordinates
+ * @param  x,y BaseWindow client coordinates
  * @return A widget index, or -1 if no widget was found.
  */
-int Window::GetWidgetFromPos(int x, int y) const
+int BaseWindow::GetWidgetFromPos(int x, int y) const
 {
 	uint index;
 	int found_index = -1;
@@ -136,7 +136,7 @@
 	// Go through the widgets and check if we find the widget that the coordinate is
 	// inside.
 	for (index = 0; index < widget_count; index++) {
-		const Widget *wi = &widget[index];
+		const OldWidget *wi = &widget[index];
 		if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
 
 		if (x >= wi->left && x <= wi->right && y >= wi->top &&  y <= wi->bottom &&
@@ -181,14 +181,14 @@
 }
 
 
-void Window::DrawWidgets() const
+void BaseWindow::DrawWidgets() const
 {
 	const DrawPixelInfo* dpi = _cur_dpi;
 	Rect r;
 	uint i;
 
 	for (i = 0; i < widget_count; i++) {
-		const Widget *wi = &widget[i];
+		const OldWidget *wi = &widget[i];
 		bool clicked = IsWidgetLowered(i);
 
 		if (dpi->left > (r.right=/*w->left + */wi->right) ||
@@ -469,13 +469,13 @@
 
 }
 
-static const Widget _dropdown_menu_widgets[] = {
+static const OldWidget _dropdown_menu_widgets[] = {
 {      WWT_PANEL,   RESIZE_NONE,     0,     0, 0,     0, 0, 0x0, STR_NULL},
 {  WWT_SCROLLBAR,   RESIZE_NONE,     0,     0, 0,     0, 0, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
 {   WIDGETS_END},
 };
 
-static int GetDropdownItem(const Window *w)
+static int GetDropdownItem(const BaseWindow *w)
 {
 	byte item, counter;
 	int y;
@@ -499,7 +499,7 @@
 	return item;
 }
 
-static void DropdownMenuWndProc(Window *w, WindowEvent *e)
+static void DropdownMenuWndProc(BaseWindow *w, WindowEvent *e)
 {
 	int item;
 
@@ -553,7 +553,7 @@
 		} break;
 
 		case WE_MOUSELOOP: {
-			Window *w2 = Window::FindById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
+			BaseWindow *w2 = BaseWindow::FindById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 			if (w2 == NULL) {
 				w->Close();
 				return;
@@ -586,7 +586,7 @@
 		} break;
 
 		case WE_DESTROY: {
-			Window *w2 = Window::FindById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
+			BaseWindow *w2 = BaseWindow::FindById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 			if (w2 != NULL) {
 				w2->RaiseWidget(WP(w,dropdown_d).parent_button);
 				w2->InvalidateWidget(WP(w,dropdown_d).parent_button);
@@ -595,12 +595,12 @@
 	}
 }
 
-void Window::ShowDropDownMenu(const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask)
+void BaseWindow::ShowDropDownMenu(const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask)
 {
 	int i;
-	const Widget *wi;
-	Window *w1;
-	const Window *w2;
+	const OldWidget *wi;
+	BaseWindow *w1;
+	const BaseWindow *w2;
 	bool is_dropdown_menu_shown = IsWidgetLowered(button);
 	int menu_top, menu_height;
 	int screen_top, screen_bottom;
@@ -631,12 +631,12 @@
 	menu_top = top + wi->bottom + 2;
 	menu_height = i * 10 + 4;
 
-	w2 = Window::FindById(WC_STATUS_BAR, 0);
+	w2 = BaseWindow::FindById(WC_STATUS_BAR, 0);
 	screen_bottom = w2 == NULL ? _screen.height : w2->top;
 
 	/* Check if the dropdown will fully fit below the widget */
 	if (menu_top + menu_height >= screen_bottom) {
-		w2 = Window::FindById(WC_MAIN_TOOLBAR, 0);
+		w2 = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 		screen_top = w2 == NULL ? 0 : w2->top + w2->height;
 
 		/* If not, check if it will fit above the widget */
@@ -651,7 +651,7 @@
 		}
 	}
 
-	w1 = Window::Allocate(
+	w1 = BaseWindow::Allocate(
 		left + wi[-1].left + 1,
 		menu_top,
 		wi->right - wi[-1].left + 1,
@@ -698,7 +698,7 @@
 }
 
 
-static void ResizeWidgets(Window *w, byte a, byte b)
+static void ResizeWidgets(BaseWindow *w, byte a, byte b)
 {
 	int16 offset = w->widget[a].left;
 	int16 length = w->widget[b].right - offset;
@@ -708,7 +708,7 @@
 	w->widget[b].left  = w->widget[a].right + 1;
 }
 
-static void ResizeWidgets(Window *w, byte a, byte b, byte c)
+static void ResizeWidgets(BaseWindow *w, byte a, byte b, byte c)
 {
 	int16 offset = w->widget[a].left;
 	int16 length = w->widget[c].right - offset;
@@ -729,7 +729,7 @@
  * @param left The leftmost widget to resize
  * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
  */
-void Window::ResizeButtons(byte first, byte last)
+void BaseWindow::ResizeButtons(byte first, byte last)
 {
 	int16 num_widgets = last - first + 1;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_base.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,125 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+int16 Widget::Left() const
+{
+	return m_rect.Left();
+}
+
+int16 Widget::Top() const
+{
+	return m_rect.Top();
+}
+
+int16 Widget::Right() const
+{
+	return m_rect.Right();
+}
+
+int16 Widget::Bottom() const
+{
+	return m_rect.Bottom();
+}
+
+int16 Widget::Width() const
+{
+	return m_rect.Width();
+}
+
+int16 Widget::Height() const
+{
+	return m_rect.Height();
+}
+
+const Point16& Widget::TopLeft() const
+{
+	return m_rect.TopLeft();
+}
+
+const Point16& Widget::BottomRight() const
+{
+	return m_rect.BottomRight();
+}
+
+const Rect16& Widget::GetRect() const
+{
+	return m_rect;
+}
+
+
+void Widget::SetLeft(int16 val)
+{
+	m_rect.SetLeft(val);
+}
+
+void Widget::SetTop(int16 val)
+{
+	m_rect.SetTop(val);
+}
+
+void Widget::SetRight(int16 val)
+{
+	m_rect.SetRight(val);
+}
+
+void Widget::SetBottom(int16 val)
+{
+	m_rect.SetBottom(val);
+}
+
+void Widget::SetWidth(int16 val)
+{
+	m_rect.SetWidth(val);
+}
+
+void Widget::SetHeight(int16 val)
+{
+	m_rect.SetHeight(val);
+}
+
+void Widget::SetTopLeft(const Point16 &pt)
+{
+	m_rect.SetTopLeft(pt);
+}
+
+void Widget::SetBottomRight(const Point16 &pt)
+{
+	m_rect.SetBottomRight(pt);
+}
+
+void Widget::SetRect(const Rect16 &rect)
+{
+	m_rect = rect;
+}
+
+WidgetId Widget::GetId() const
+{
+	return m_id;
+}
+
+/*virtual*/ Widget* Widget::WidgetFromPt(const Point16 &pt)
+{
+	if (m_rect.PtInRect(pt)) return this;
+	return NULL;
+}
+
+/*virtual*/ void Widget::Close()
+{
+	m_is_closing = true;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_button.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_button_img.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_button_img2.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_button_txt.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_button_txt2.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_caption.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_closebox.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_composite.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,79 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
+void CompositeWidget::AddWidget(Widget *wd)
+{
+	WidgetId id = wd->GetId();
+	std::pair<WidgetIterator, bool> pib = m_widgets.insert(Widgets::value_type(id, wd));
+	assert(pib.second);
+}
+
+Widget* CompositeWidget::GetWidget(WidgetId id)
+{
+	WidgetIterator it = m_widgets.find(id);
+	return (it != m_widgets.end()) ? (*it).second : NULL;
+}
+
+Widget* CompositeWidget::RemoveWidget(WidgetId id)
+{
+	WidgetIterator it = m_widgets.find(id);
+	if (it == m_widgets.end()) return NULL;
+	Widget *wd = (*it).second;
+	assert(wd->m_container == this);
+	wd->m_container = NULL;
+	m_widgets.erase(it);
+	return wd;
+}
+
+/*virtual*/ Widget* CompositeWidget::WidgetFromPt(const Point16 &pt_parent)
+{
+	Point16 pt_local = pt_parent - TopLeft();
+	bool inside_me = m_rect.PtInRect(pt_parent);
+	for (WidgetReverseIterator rit = m_widgets.rbegin(); rit != m_widgets.rend(); ++rit) {
+		/* get next child */
+		Widget *wd_child = (*rit).second;
+		/* ask the child recursively */
+		Widget *wd = wd_child->WidgetFromPt(pt_local);
+		if (wd != NULL) {
+			/* if the widget we found is inside me it is what we are searching for */
+			if (inside_me) return wd;
+			/* the point is outside me. The widget is clipped unless it is on-top widget */
+			if (wd->m_dont_clip) return wd;
+			/* try next child */
+		}
+	}
+	return inside_me ? this : NULL;
+}
+
+/*virtual*/ void CompositeWidget::Close()
+{
+	/* mark all children as closed in safe way */
+	for (WidgetReverseIterator rit_next = m_widgets.rbegin(); rit_next != m_widgets.rend(); ) {
+		/* save the iterator (it can be invalidated) and move forward */
+		WidgetReverseIterator rit = rit_next++;
+		/* get child */
+		Widget *wd_child = (*rit).second;
+		/* tell him we are closing */
+		wd_child->Close();
+	}
+	/* remove children */
+	m_widgets.clear();
+	/* mark self as closed */
+	super::Close();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_frame.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_hscrollbar.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_inset.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_label.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_list.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_panel.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_resizebox.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_scrollbar.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widget/widget_stickybox.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -0,0 +1,19 @@
+/* $Id$ */
+
+#include "../stdafx.h"
+#include <stdarg.h>
+#include "../openttd.h"
+#include "../debug.h"
+#include "../functions.h"
+#include "../map.h"
+#include "../player.h"
+#include "../window.h"
+#include "../gfx.h"
+#include "../viewport.h"
+#include "../console.h"
+#include "../variables.h"
+#include "../table/sprites.h"
+#include "../genworld.h"
+#include "../helpers.hpp"
+
+
--- a/src/window.cpp	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/window.cpp	Sun Feb 18 14:17:28 2007 +0000
@@ -19,13 +19,13 @@
 // delta between mouse cursor and upper left corner of dragged window
 static Point _drag_delta;
 
-/*static*/ WindowList Window::s_list;
+/*static*/ WindowList BaseWindow::s_list;
 
-//static Window _windows[25];
-//Window *_z_windows[lengthof(_windows)];
-//Window **_last_z_window; ///< always points to the next free space in the z-array
+//static BaseWindow _windows[25];
+//BaseWindow *_z_windows[lengthof(_windows)];
+//BaseWindow **_last_z_window; ///< always points to the next free space in the z-array
 
-void WindowList::Add(Window *w)
+void WindowList::Add(BaseWindow *w)
 {
 	/* we will add the new window before first vital window or at the end */
 	Iterator it = w->IsVital() ? m_list.end() : FindFirstVitalWindow();
@@ -33,22 +33,22 @@
 	m_list.insert(it, w);
 }
 
-void WindowList::Remove(Window *w)
+void WindowList::Remove(BaseWindow *w)
 {
 	Iterator it = Find(w);
 	if (it != m_list.end()) m_list.erase(it);
 }
 
-static bool MatchWindow(WindowList::Iterator it, Window *w)
+static bool MatchWindow(WindowList::Iterator it, BaseWindow *w)
 {
 	return (*it).w == w;
 }
 
-WindowList::Iterator WindowList::Find(Window *w)
+WindowList::Iterator WindowList::Find(BaseWindow *w)
 {
 	Iterator it = EnumT(&MatchWindow, w);
 	if (it == m_list.end()) {
-		DEBUG(misc, 3, "Window (cls %d, number %d) is not open, probably removed by recursive calls",
+		DEBUG(misc, 3, "BaseWindow (cls %d, number %d) is not open, probably removed by recursive calls",
 			w->window_class, w->window_number);
 	}
 	return it;
@@ -87,84 +87,193 @@
 	return EnumT(&MatchClassAndId, cls, num);
 }
 
+static bool MatchXY(WindowList::Iterator it, int x, int y)
+{
+	BaseWindow *w = (*it).w;
+	return IS_INSIDE_1D(x, w->left, w->width) && IS_INSIDE_1D(y, w->top, w->height);
+}
+
+/** Do a search for a window at specific coordinates. For this we start
+* at the topmost window, obviously and work our way down to the bottom
+* @return a pointer to the found window if any, NULL otherwise */
+WindowList::Iterator WindowList::FindFromPt(int x, int y)
+{
+	return ReverseEnumT(&MatchXY, x, y);
+}
+
+
+
+
+BaseWindow::BaseWindow(const WindowDesc *desc, WindowNumber num)
+{
+	ZeroInit();
+	Create(desc, num);
+}
+
+/*virtual*/ bool BaseWindow::Create(const WindowDesc *desc, WindowNumber num)
+{
+	window_class = desc->cls;
+	flash_timeout = 3; // just opened windows have a white border
+	caption_color = 0xFF;
+	left = desc->left;
+	top = desc->top;
+	width = desc->width;
+	height = desc->height;
+	wndproc = desc->proc;
+	desc_flags = desc->flags;
+	AssignWidget(desc->widgets);
+	resize.width = width;
+	resize.height = height;
+	resize.step_width = 1;
+	resize.step_height = 1;
+	window_number = num;
+
+	/* add our new window into z-order list */
+	BaseWindow::s_list.Add(this);
+
+	SetDirty();
+	CallEventNP(WE_CREATE);
+	return true;
+}
+
+/**
+* Open a new window. If there is no space for a new window, close an open
+* window. Try to avoid stickied windows, but if there is no else, close one of
+* those as well. Then make sure all created windows are below some always-on-top
+* ones. Finally set all variables and call the WE_CREATE event
+* @param x offset in pixels from the left of the screen
+* @param y offset in pixels from the top of the screen
+* @param width width in pixels of the window
+* @param height height in pixels of the window
+* @param *proc @see WindowProc function to call when any messages/updates happen to the window
+* @param cls @see WindowClass class of the window, used for identification and grouping
+* @param *widget @see OldWidget pointer to the window layout and various elements
+* @return @see BaseWindow pointer of the newly created window
+*/
+/*static*/ BaseWindow* BaseWindow::Allocate(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const OldWidget *widget)
+{
+	WindowDesc desc = {x, y, width, height, cls, WC_NONE, 0, widget, proc};
+	return new BaseWindow(&desc, 0);
+}
+
+/**
+* Open a new window.
+* @param *desc The pointer to the WindowDesc to be created
+* @param window_number the window number of the new window
+* @return @see BaseWindow pointer of the newly created window
+*/
+BaseWindow *BaseWindow::AllocateFront(const WindowDesc *desc, int window_number)
+{
+	if (BaseWindow::BringToFrontById(desc->cls, window_number) != NULL) return NULL;
+	BaseWindow *w = Allocate(desc, window_number);
+	return w;
+}
+
+static Point GetAutoPlacePosition(int width, int height);
+
+/*static*/ BaseWindow* BaseWindow::Allocate(const WindowDesc *desc, int window_number)
+{
+	Point pt;
+	BaseWindow *w;
+
+	/* By default position a child window at an offset of 10/10 of its parent.
+	* However if it falls too extremely outside window positions, reposition
+	* it to an automatic place */
+	if (desc->parent_cls != WC_MAIN_WINDOW &&
+		(w = BaseWindow::FindById(desc->parent_cls, window_number)) != NULL &&
+		w->left < _screen.width - 20 && w->left > -60 && w->top < _screen.height - 20) {
+
+			pt.x = w->left + 10;
+			if (pt.x > _screen.width + 10 - desc->width) {
+				pt.x = (_screen.width + 10 - desc->width) - 20;
+			}
+			pt.y = w->top + 10;
+	} else {
+		switch (desc->left) {
+			case WDP_ALIGN_TBR: { /* Align the right side with the top toolbar */
+				w = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
+				pt.x = (w->left + w->width) - desc->width;
+													}	break;
+			case WDP_ALIGN_TBL: /* Align the left side with the top toolbar */
+				pt.x = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0)->left;
+				break;
+			case WDP_AUTO: /* Find a good automatic position for the window */
+				pt = GetAutoPlacePosition(desc->width, desc->height);
+				goto allocate_window;
+			case WDP_CENTER: /* Centre the window horizontally */
+				pt.x = (_screen.width - desc->width) / 2;
+				break;
+			default:
+				pt.x = desc->left;
+				if (pt.x < 0) pt.x += _screen.width; // negative is from right of the screen
+		}
+
+		switch (desc->top) {
+			case WDP_CENTER: /* Centre the window vertically */
+				pt.y = (_screen.height - desc->height) / 2;
+				break;
+				/* WDP_AUTO sets the position at once and is controlled by desc->left.
+				* Both left and top must be set to WDP_AUTO */
+			case WDP_AUTO:
+				NOT_REACHED();
+				assert(desc->left == WDP_AUTO && desc->top != WDP_AUTO);
+				/* fallthrough */
+			default:
+				pt.y = desc->top;
+				if (pt.y < 0) pt.y += _screen.height; // negative is from bottom of the screen
+				break;
+		}
+	}
+
+allocate_window:
+	WindowDesc d2 = *desc;
+	d2.left = pt.x;
+	d2.top  = pt.y;
+	w = new BaseWindow(&d2, window_number);
+	return w;
+}
+
+
 /* Open a new window.
 * This function is called from AllocateWindow() or AllocateWindowDesc()
 * See descriptions for those functions for usage
 * See AllocateWindow() for description of arguments.
 * Only addition here is window_number, which is the window_number being assigned to the new window
 */
-Window::Window(
-							 int x, int y, int w, int h,
-							 WindowProc *proc, WindowClass cls, const Widget *widget, int wnd_number)
-{
-	//Window *w = FindFreeWindow();
-
-	///* We have run out of windows, close one and use that as the place for our new one */
-	//if (w == NULL) {
-	//	w = FindDeletableWindow();
-	//	if (w == NULL) w = ForceFindDeletableWindow();
-	//	w->Close();
-	//}
-
-	// Set up window properties
-	//memset(w, 0, sizeof(*w));
-	ZeroInit();
-
-	window_class = cls;
-	flash_timeout = 3; // just opened windows have a white border
-	caption_color = 0xFF;
-	left = x;
-	top = y;
-	width = w;
-	height = h;
-	wndproc = proc;
-	this->AssignWidget(widget);
-	resize.width = width;
-	resize.height = height;
-	resize.step_width = 1;
-	resize.step_height = 1;
-	window_number = wnd_number;
-
-	//{
-	//	Window **wz = _last_z_window;
+//BaseWindow::BaseWindow(
+//							 int x, int y, int w, int h,
+//							 WindowProc *proc, WindowClass cls, const OldWidget *widget, int wnd_number)
+//{
+//	ZeroInit();
+//
+//	window_class = cls;
+//	flash_timeout = 3; // just opened windows have a white border
+//	caption_color = 0xFF;
+//	left = x;
+//	top = y;
+//	width = w;
+//	height = h;
+//	wndproc = proc;
+//	this->AssignWidget(widget);
+//	resize.width = width;
+//	resize.height = height;
+//	resize.step_width = 1;
+//	resize.step_height = 1;
+//	window_number = wnd_number;
+//
+//	/* add our new window into z-order list */
+//	BaseWindow::s_list.Add(this);
+//
+//	SetDirty();
+//	CallEventNP(WE_CREATE);
+//}
 
-	//	/* Hacky way of specifying always-on-top windows. These windows are
-	//	 * always above other windows because they are moved below them.
-	//	 * status-bar is above news-window because it has been created earlier.
-	//	 * Also, as the chat-window is excluded from this, it will always be
-	//	 * the last window, thus always on top.
-	//	 * XXX - Yes, ugly, probably needs something like w->always_on_top flag
-	//	 * to implement correctly, but even then you need some kind of distinction
-	//	 * between on-top of chat/news and status windows, because these conflict */
-	//	if (wz != _z_windows && w->window_class != WC_SEND_NETWORK_MSG) {
-	//		if (FindWindowById(WC_MAIN_TOOLBAR, 0)     != NULL) wz--;
-	//		if (FindWindowById(WC_STATUS_BAR, 0)       != NULL) wz--;
-	//		if (FindWindowById(WC_NEWS_WINDOW, 0)      != NULL) wz--;
-	//		if (FindWindowById(WC_SEND_NETWORK_MSG, 0) != NULL) wz--;
-
-	//		assert(wz >= _z_windows);
-	//		if (wz != _last_z_window) memmove(wz + 1, wz, (byte*)_last_z_window - (byte*)wz);
-	//	}
-
-	//	*wz = w;
-	//	_last_z_window++;
-	//}
-
-	/* add our new window into z-order list */
-	Window::s_list.Add(this);
-
-	SetDirty();
-	this->CallEventNP(WE_CREATE);
-
-	//return w;
-}
-
-/** Find the Window whose parent pointer points to this window
-* @parent w Window to find child of
-* @return return a Window pointer that is the child of w, or NULL otherwise */
-Window* Window::FindChild() const
+/** Find the BaseWindow whose parent pointer points to this window
+* @parent w BaseWindow to find child of
+* @return return a BaseWindow pointer that is the child of w, or NULL otherwise */
+BaseWindow* BaseWindow::FindChild() const
 {
-	Window *v;
+	BaseWindow *v;
 	FOR_ALL_WINDOWS(v) {
 		if (v->parent == this) return v;
 	}
@@ -172,16 +281,16 @@
 	return NULL;
 }
 
-void Window::SetDirty() const
+void BaseWindow::SetDirty() const
 {
 	if (this == NULL) return;
 	SetDirtyBlocks(left, top, left + width, top + height);
 }
 
-/*virtual*/ void Window::FinalRelease()
+/*virtual*/ void BaseWindow::FinalRelease()
 {
 	/* Delete any children a window might have in a head-recursive manner */
-	Window *v = FindChild();
+	BaseWindow *v = FindChild();
 	if (v != NULL) v->Close();
 
 	if (_thd.place_mode != VHM_NONE &&
@@ -200,55 +309,43 @@
 	parent = NULL;
 }
 
-/*virtual*/ void Window::Close()
+/*virtual*/ void BaseWindow::Close()
 {
 	s_list.Remove(this);
 }
 
-/*virtual*/ bool Window::IsVital()
+/*virtual*/ bool BaseWindow::IsVital()
 {
 	WindowClass wc = window_class;
 	return (wc == WC_MAIN_TOOLBAR || wc == WC_STATUS_BAR || wc == WC_NEWS_WINDOW || wc == WC_SEND_NETWORK_MSG);
 }
 
-/**
-* Open a new window. If there is no space for a new window, close an open
-* window. Try to avoid stickied windows, but if there is no else, close one of
-* those as well. Then make sure all created windows are below some always-on-top
-* ones. Finally set all variables and call the WE_CREATE event
-* @param x offset in pixels from the left of the screen
-* @param y offset in pixels from the top of the screen
-* @param width width in pixels of the window
-* @param height height in pixels of the window
-* @param *proc @see WindowProc function to call when any messages/updates happen to the window
-* @param cls @see WindowClass class of the window, used for identification and grouping
-* @param *widget @see Widget pointer to the window layout and various elements
-* @return @see Window pointer of the newly created window
-*/
-/*static*/ Window* Window::Allocate(
-																		int x, int y, int width, int height,
-																		WindowProc *proc, WindowClass cls, const Widget *widget)
-{
-	return new Window(x, y, width, height, proc, cls, widget, 0);
-}
-
-/*static*/ Window* Window::Get(WindowList::Iterator it)
+/*static*/ BaseWindow* BaseWindow::Get(WindowList::Iterator it)
 {
 	return (it != s_list.m_list.end()) ? (*it).w : NULL;
 }
 
-/*static*/ Window* Window::FindById(WindowClass cls, WindowNumber num)
+/** Do a search for a window at specific coordinates. For this we start
+ * at the topmost window, obviously and work our way down to the bottom
+ * @return a pointer to the found window if any, NULL otherwise */
+/*static*/ BaseWindow *BaseWindow::FindFromPt(int x, int y)
+{
+	return Get(s_list.FindFromPt(x, y));
+}
+
+
+/*static*/ BaseWindow* BaseWindow::FindById(WindowClass cls, WindowNumber num)
 {
 	return Get(s_list.FindById(cls, num));
 }
 
-/*static*/ void Window::SetDirtyById(WindowClass cls, WindowNumber num)
+/*static*/ void BaseWindow::SetDirtyById(WindowClass cls, WindowNumber num)
 {
-	Window *w = FindById(cls, num);
+	BaseWindow *w = FindById(cls, num);
 	if (w != NULL) w->SetDirty();
 }
 
-void CDECL Window::SetWidgetsDisabledState(bool disab_stat, int widgets, ...)
+void CDECL BaseWindow::SetWidgetsDisabledState(bool disab_stat, int widgets, ...)
 {
 	va_list wdg_list;
 
@@ -262,7 +359,7 @@
 	va_end(wdg_list);
 }
 
-void CDECL Window::SetWidgetsHiddenState(bool hidden_stat, int widgets, ...)
+void CDECL BaseWindow::SetWidgetsHiddenState(bool hidden_stat, int widgets, ...)
 {
 	va_list wdg_list;
 
@@ -276,7 +373,7 @@
 	va_end(wdg_list);
 }
 
-void CDECL Window::SetWidgetsLoweredState(bool lowered_stat, int widgets, ...)
+void CDECL BaseWindow::SetWidgetsLoweredState(bool lowered_stat, int widgets, ...)
 {
 	va_list wdg_list;
 
@@ -290,7 +387,7 @@
 	va_end(wdg_list);
 }
 
-void Window::RaiseButtons()
+void BaseWindow::RaiseButtons()
 {
 	uint i;
 
@@ -302,7 +399,7 @@
 	}
 }
 
-void Window::HandleButtonClick(byte widget)
+void BaseWindow::HandleButtonClick(byte widget)
 {
 	LowerWidget(widget);
 	autorepeat_timeout = 5;
@@ -317,12 +414,12 @@
 * @param w window that is put into the foreground
 * @return pointer to the window, the same as the input pointer
 */
-void Window::BringToFront()
+void BaseWindow::BringToFront()
 {
 	WindowPtr wp = this;
-	WindowList::Iterator it = Window::s_list.Find(this);
-	Window::s_list.Remove(this);
-	Window::s_list.Add(this);
+	WindowList::Iterator it = BaseWindow::s_list.Find(this);
+	BaseWindow::s_list.Remove(this);
+	BaseWindow::s_list.Add(this);
 
 	SetDirty();
 }
@@ -331,9 +428,9 @@
 * gets a white border for a brief period of time to visualize its
 * "activation"
 * @return a pointer to the window thus activated */
-/*static*/ Window* Window::BringToFrontById(WindowClass cls, WindowNumber num)
+/*static*/ BaseWindow* BaseWindow::BringToFrontById(WindowClass cls, WindowNumber num)
 {
-	Window *w = FindById(cls, num);
+	BaseWindow *w = FindById(cls, num);
 	if (w != NULL) {
 		w->flash_timeout = 3;
 		w->BringToFront();
@@ -343,7 +440,7 @@
 
 static bool _dragging_window;
 
-void Window::StartDrag()
+void BaseWindow::StartDrag()
 {
 	flags4 |= WF_DRAGGING;
 	_dragging_window = true;
@@ -355,10 +452,10 @@
 	DeleteWindowById(WC_DROPDOWN_MENU, 0);
 }
 
-bool Window::ContinueDrag()
+bool BaseWindow::ContinueDrag()
 {
-	const Widget *t = &widget[1]; // the title bar ... ugh
-	const Window *v;
+	const OldWidget *t = &widget[1]; // the title bar ... ugh
+	const BaseWindow *v;
 	int x;
 	int y;
 	int nx;
@@ -379,7 +476,7 @@
 	ny = y;
 
 	if (_patches.window_snap_radius != 0) {
-		Window *v;
+		BaseWindow *v;
 
 		int hsnap = _patches.window_snap_radius;
 		int vsnap = _patches.window_snap_radius;
@@ -460,7 +557,7 @@
 	ny = clamp(ny, 0, _screen.height - 13);
 
 	// Make sure the title bar isn't hidden by behind the main tool bar
-	v = Window::FindById(WC_MAIN_TOOLBAR, 0);
+	v = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 	if (v != NULL) {
 		int v_bottom = v->top + v->height;
 		int v_right = v->left + v->width;
@@ -494,7 +591,7 @@
 	return false;
 }
 
-void Window::StartSizing()
+void BaseWindow::StartSizing()
 {
 	flags4 |= WF_SIZING;
 	_dragging_window = true;
@@ -506,7 +603,7 @@
 	DeleteWindowById(WC_DROPDOWN_MENU, 0);
 }
 
-bool Window::ContinueSizing()
+bool BaseWindow::ContinueSizing()
 {
 	WindowEvent e;
 	int x, y;
@@ -535,7 +632,7 @@
 	if ((int)height + y < (int)resize.height)
 		y = resize.height - height;
 
-	/* Window already on size */
+	/* BaseWindow already on size */
 	if (x == 0 && y == 0) return false;
 
 	/* Now find the new cursor pos.. this is NOT _cursor, because
@@ -556,13 +653,13 @@
 
 }
 
-/*static*/ bool Window::HandleWindowDragging(void)
+/*static*/ bool BaseWindow::HandleWindowDragging(void)
 {
 	// Get out immediately if no window is being dragged at all.
 	if (!_dragging_window) return true;
 
 	// Otherwise find the window...
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		if (w->flags4 & WF_DRAGGING) {
 			return w->ContinueDrag();
@@ -576,10 +673,10 @@
 
 
 
-void Window::DispatchLeftClickEvent(int x, int y)
+void BaseWindow::DispatchLeftClickEvent(int x, int y)
 {
 	WindowEvent e;
-	const Widget *wi;
+	const OldWidget *wi;
 
 	e.we.click.pt.x = x;
 	e.we.click.pt.y = y;
@@ -602,9 +699,11 @@
 				case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */
 					HandleButtonClick(e.we.click.widget);
 					break;
+				default:
+					break;
 			}
 		} else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_SCROLL2BAR || wi->type == WWT_HSCROLLBAR) {
-			this->ScrollbarClickHandler(wi, e.we.click.pt.x, e.we.click.pt.y);
+			ScrollbarClickHandler(wi, e.we.click.pt.x, e.we.click.pt.y);
 		}
 
 		if (desc_flags & WDF_STD_BTN) {
@@ -635,7 +734,7 @@
 	wndproc(this, &e);
 }
 
-void Window::DispatchRightClickEvent(int x, int y)
+void BaseWindow::DispatchRightClickEvent(int x, int y)
 {
 	WindowEvent e;
 
@@ -659,13 +758,13 @@
 
 /** Dispatch the mousewheel-action to the window which will scroll any
  * compatible scrollbars if the mouse is pointed over the bar or its contents
- * @param *w Window
+ * @param *w BaseWindow
  * @param widget the widget where the scrollwheel was used
  * @param wheel scroll up or down
  */
-void Window::DispatchMouseWheelEvent(int widget_idx, int wheel)
+void BaseWindow::DispatchMouseWheelEvent(int widget_idx, int wheel)
 {
-	const Widget *wi1, *wi2;
+	const OldWidget *wi1, *wi2;
 	Scrollbar *sb;
 
 	if (widget_idx < 0) return;
@@ -692,10 +791,10 @@
 
 static void DrawOverlappedWindow(WindowList::Iterator wit, int left, int top, int right, int bottom)
 {
-	Window *w = (*wit).w;
+	BaseWindow *w = (*wit).w;
 
-	for (WindowList::Iterator vit = wit; ++vit != Window::s_list.m_list.end(); ) {
-		const Window *v = (*vit).w;
+	for (WindowList::Iterator vit = wit; ++vit != BaseWindow::s_list.m_list.end(); ) {
+		const BaseWindow *v = (*vit).w;
 		int x;
 
 		if (right > v->left &&
@@ -748,7 +847,7 @@
 	DrawPixelInfo bk;
 	_cur_dpi = &bk;
 
-	const Window *w = NULL;
+	const BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (right > w->left &&
 			bottom > w->top &&
@@ -760,7 +859,7 @@
 }
 
 
-void Window::CallEventNP(int event)
+void BaseWindow::CallEventNP(int event)
 {
 	WindowEvent e;
 
@@ -770,21 +869,21 @@
 
 /** Find the z-value of a window. A window must already be open
  * or the behaviour is undefined but function should never fail */
-//WindowList::Iterator FindWindowZPosition(const Window *w)
+//WindowList::Iterator FindWindowZPosition(const BaseWindow *w)
 //{
-//	Window *wz;
+//	BaseWindow *wz;
 //	FOR_ALL_WINDOWS(wz) {
 //		if (wz == w) return it;
 //	}
 //
-//	DEBUG(misc, 3, "Window (cls %d, number %d) is not open, probably removed by recursive calls",
+//	DEBUG(misc, 3, "BaseWindow (cls %d, number %d) is not open, probably removed by recursive calls",
 //		w->window_class, w->window_number);
-//	return Window::s_list.m_list.end();
+//	return BaseWindow::s_list.m_list.end();
 //}
 
-//Window *FindWindowById(WindowClass cls, WindowNumber number)
+//BaseWindow *FindWindowById(WindowClass cls, WindowNumber number)
 //{
-//	Window *w;
+//	BaseWindow *w;
 //
 //	FOR_ALL_WINDOWS(w) {
 //		if (w->window_class == cls && w->window_number == number) return w;
@@ -795,7 +894,7 @@
 
 void DeleteWindowById(WindowClass cls, WindowNumber number)
 {
-	Window *w = Window::FindById(cls, number);
+	BaseWindow *w = BaseWindow::FindById(cls, number);
 	if (w != NULL) w->Close();
 }
 
@@ -806,7 +905,7 @@
 	/* When we find the window to delete, we need to restart the search
 	 * as deleting this window could cascade in deleting (many) others
 	 * anywhere in the z-array */
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls) {
 			w->Close();
@@ -826,7 +925,7 @@
 	/* When we find the window to delete, we need to restart the search
 	 * as deleting this window could cascade in deleting (many) others
 	 * anywhere in the z-array */
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		if (w->caption_color == id) {
 			w->Close();
@@ -845,7 +944,7 @@
  * @param new_player PlayerID of the new owner of the window */
 void ChangeWindowOwner(PlayerID old_player, PlayerID new_player)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 
@@ -871,9 +970,9 @@
  * - Any sticked windows since we wanted to keep these
  * @return w pointer to the window that is going to be deleted
  */
-//static Window *FindDeletableWindow(void)
+//static BaseWindow *FindDeletableWindow(void)
 //{
-//	Window *w;
+//	BaseWindow *w;
 //	FOR_ALL_WINDOWS(w) {
 //		if (w->window_class != WC_MAIN_WINDOW && !IsVitalWindow(w) && !(w->flags4 & WF_STICKY)) {
 //			return w;
@@ -889,35 +988,35 @@
 
 /** A window must be freed, and all are marked as important windows. Ease the
  * restriction a bit by allowing to delete sticky windows. Keep important/vital
- * windows intact (Main window, Toolbar, Statusbar, News Window, Chatbar)
+ * windows intact (Main window, Toolbar, Statusbar, News BaseWindow, Chatbar)
  * Start finding an appropiate candidate from the lowest z-values (bottom)
  * @see FindDeletableWindow()
  * @return w Pointer to the window that is being deleted
  */
-//static Window *ForceFindDeletableWindow(void)
+//static BaseWindow *ForceFindDeletableWindow(void)
 //{
-//	Window* const *wz;
+//	BaseWindow* const *wz;
 //
 //	for (wz = _z_windows;; wz++) {
-//		Window *w = *wz;
+//		BaseWindow *w = *wz;
 //		assert(wz < _last_z_window);
 //		if (w->window_class != WC_MAIN_WINDOW && !IsVitalWindow(w)) return w;
 //	}
 //}
 
-bool Window::IsOfPrototype(const Widget *widgets) const
+bool BaseWindow::IsOfPrototype(const OldWidget *widgets) const
 {
 	return (original_widget == widgets);
 }
 
 /* Copies 'widget' to 'w->widget' to allow for resizable windows */
-void Window::AssignWidget(const Widget *widget_array)
+void BaseWindow::AssignWidget(const OldWidget *widget_array)
 {
 	original_widget = widget_array;
 
 	if (widget_array != NULL) {
 		uint index = 1;
-		const Widget *wi;
+		const OldWidget *wi;
 
 		for (wi = widget_array; wi->type != WWT_LAST; wi++) index++;
 
@@ -930,12 +1029,12 @@
 	}
 }
 
-//static Window *FindFreeWindow(void)
+//static BaseWindow *FindFreeWindow(void)
 //{
-//	Window *w;
+//	BaseWindow *w;
 //
 //	for (w = _windows; w < endof(_windows); w++) {
-//		Window* const *wz;
+//		BaseWindow* const *wz;
 //		bool window_in_use = false;
 //
 //		FOR_ALL_WINDOWS(wz) {
@@ -973,7 +1072,7 @@
 		return false;
 
 	// Make sure it is not obscured by any window.
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == WC_MAIN_WINDOW) continue;
 
@@ -1001,7 +1100,7 @@
 	if (top < 22 || top > _screen.height - (height>>2)) return false;
 
 	// Make sure it is not obscured by any window.
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == WC_MAIN_WINDOW) continue;
 
@@ -1019,7 +1118,7 @@
 static Point GetAutoPlacePosition(int width, int height)
 {
 	Point pt;
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	_awap_r.width = width;
 	_awap_r.height = height;
@@ -1071,105 +1170,15 @@
 	return pt;
 }
 
-static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number)
-{
-	Point pt;
-	Window *w;
-
-	/* By default position a child window at an offset of 10/10 of its parent.
-	 * However if it falls too extremely outside window positions, reposition
-	 * it to an automatic place */
-	if (desc->parent_cls != 0 /* WC_MAIN_WINDOW */ &&
-			(w = Window::FindById(desc->parent_cls, window_number)) != NULL &&
-			w->left < _screen.width - 20 && w->left > -60 && w->top < _screen.height - 20) {
-
-		pt.x = w->left + 10;
-		if (pt.x > _screen.width + 10 - desc->width) {
-			pt.x = (_screen.width + 10 - desc->width) - 20;
-		}
-		pt.y = w->top + 10;
-	} else {
-		switch (desc->left) {
-			case WDP_ALIGN_TBR: { /* Align the right side with the top toolbar */
-				w = Window::FindById(WC_MAIN_TOOLBAR, 0);
-				pt.x = (w->left + w->width) - desc->width;
-			}	break;
-			case WDP_ALIGN_TBL: /* Align the left side with the top toolbar */
-				pt.x = Window::FindById(WC_MAIN_TOOLBAR, 0)->left;
-				break;
-			case WDP_AUTO: /* Find a good automatic position for the window */
-				pt = GetAutoPlacePosition(desc->width, desc->height);
-				goto allocate_window;
-			case WDP_CENTER: /* Centre the window horizontally */
-				pt.x = (_screen.width - desc->width) / 2;
-				break;
-			default:
-				pt.x = desc->left;
-				if (pt.x < 0) pt.x += _screen.width; // negative is from right of the screen
-		}
-
-		switch (desc->top) {
-			case WDP_CENTER: /* Centre the window vertically */
-				pt.y = (_screen.height - desc->height) / 2;
-				break;
-			/* WDP_AUTO sets the position at once and is controlled by desc->left.
-			 * Both left and top must be set to WDP_AUTO */
-			case WDP_AUTO:
-				NOT_REACHED();
-				assert(desc->left == WDP_AUTO && desc->top != WDP_AUTO);
-				/* fallthrough */
-			default:
-				pt.y = desc->top;
-				if (pt.y < 0) pt.y += _screen.height; // negative is from bottom of the screen
-				break;
-		}
-	}
-
-allocate_window:
-	w = new Window(pt.x, pt.y, desc->width, desc->height, desc->proc, desc->cls, desc->widgets, window_number);
-	w->desc_flags = desc->flags;
-	return w;
-}
-
-/**
- * Open a new window.
- * @param *desc The pointer to the WindowDesc to be created
- * @return @see Window pointer of the newly created window
- */
-Window *AllocateWindowDesc(const WindowDesc *desc)
-{
-	return LocalAllocateWindowDesc(desc, 0);
-}
-
-/**
- * Open a new window.
- * @param *desc The pointer to the WindowDesc to be created
- * @param window_number the window number of the new window
- * @return @see Window pointer of the newly created window
- */
-Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number)
-{
-	Window *w;
-
-	if (Window::BringToFrontById(desc->cls, window_number) != NULL) return NULL;
-	w = LocalAllocateWindowDesc(desc, window_number);
-	return w;
-}
-
-/** Do a search for a window at specific coordinates. For this we start
- * at the topmost window, obviously and work our way down to the bottom
- * @return a pointer to the found window if any, NULL otherwise */
-Window *FindWindowFromPt(int x, int y)
-{
-	Window *w;
-	REVERSED_FOR_ALL_WINDOWS(w) {
-		if (IS_INSIDE_1D(x, w->left, w->width) && IS_INSIDE_1D(y, w->top, w->height)) {
-			return w;
-		}
-	}
-
-	return NULL;
-}
+///**
+// * Open a new window.
+// * @param *desc The pointer to the WindowDesc to be created
+// * @return @see BaseWindow pointer of the newly created window
+// */
+//BaseWindow *AllocateWindowDesc(const WindowDesc *desc)
+//{
+//	return LocalAllocateWindowDesc(desc, 0);
+//}
 
 void InitWindowSystem(void)
 {
@@ -1183,9 +1192,9 @@
 
 void UnInitWindowSystem(void)
 {
-	Window::s_list.m_list.clear();
+	BaseWindow::s_list.m_list.clear();
 
-//	Window **wz;
+//	BaseWindow **wz;
 //
 //restart_search:
 //	/* Delete all windows, reset z-array.
@@ -1213,7 +1222,7 @@
 
 static void DecreaseWindowCounters(void)
 {
-	Window *w;
+	BaseWindow *w;
 	REVERSED_FOR_ALL_WINDOWS(w) {
 		// Unclick scrollbar buttons if they are pressed.
 		if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
@@ -1231,14 +1240,14 @@
 	}
 }
 
-Window *GetCallbackWnd(void)
+BaseWindow *GetCallbackWnd(void)
 {
-	return Window::FindById(_thd.window_class, _thd.window_number);
+	return BaseWindow::FindById(_thd.window_class, _thd.window_number);
 }
 
 static void HandlePlacePresize(void)
 {
-	Window *w;
+	BaseWindow *w;
 	WindowEvent e;
 
 	if (_special_mouse_mode != WSM_PRESIZE) return;
@@ -1258,7 +1267,7 @@
 
 static bool HandleDragDrop(void)
 {
-	Window *w;
+	BaseWindow *w;
 	WindowEvent e;
 
 	if (_special_mouse_mode != WSM_DRAGDROP) return true;
@@ -1282,12 +1291,12 @@
 
 static bool HandlePopupMenu(void)
 {
-	Window *w;
+	BaseWindow *w;
 	WindowEvent e;
 
 	if (!_popup_menu_active) return true;
 
-	w = Window::FindById(WC_TOOLBAR_MENU, 0);
+	w = BaseWindow::FindById(WC_TOOLBAR_MENU, 0);
 	if (w == NULL) {
 		_popup_menu_active = false;
 		return false;
@@ -1312,12 +1321,12 @@
 	static WindowClass  last_cls;
 	static WindowNumber last_num;
 
-	Window *w;
+	BaseWindow *w;
 	WindowEvent e;
 
-	Window *last_w = Window::FindById(last_cls, last_num);
+	BaseWindow *last_w = BaseWindow::FindById(last_cls, last_num);
 
-	w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
+	w = BaseWindow::FindFromPt(_cursor.pos.x, _cursor.pos.y);
 
 	// We changed window, put a MOUSEOVER event to the last window
 	if (last_w != NULL && last_w != w) {
@@ -1350,9 +1359,9 @@
  * ensuring proper redrawal.
  * @param x delta x-size of changed window (positive if larger, etc.(
  * @param y delta y-size of changed window */
-void Window::Resize(int x, int y)
+void BaseWindow::Resize(int x, int y)
 {
-	Widget *wi;
+	OldWidget *wi;
 	bool resize_height = false;
 	bool resize_width = false;
 
@@ -1361,7 +1370,7 @@
 	this->SetDirty();
 	for (wi = widget; wi->type != WWT_LAST; wi++) {
 		/* Isolate the resizing flags */
-		byte rsizeflag = GB(wi->display_flags, 0, 4);
+		byte rsizeflag = GB(wi->m_display_flags, 0, 4);
 
 		if (rsizeflag == RESIZE_NONE) continue;
 
@@ -1404,7 +1413,7 @@
 	if (!_scrolling_scrollbar) return true;
 
 	// Find the scrolling window
-	Window *w;
+	BaseWindow *w;
 	FOR_ALL_WINDOWS(w) {
 		if (w->flags4 & WF_SCROLL_MIDDLE) {
 			// Abort if no button is clicked any more.
@@ -1442,11 +1451,11 @@
 static bool HandleViewportScroll(void)
 {
 	WindowEvent e;
-	Window *w;
+	BaseWindow *w;
 
 	if (!_scrolling_viewport) return true;
 
-	w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
+	w = BaseWindow::FindFromPt(_cursor.pos.x, _cursor.pos.y);
 
 	if (!_right_button_down || w == NULL) {
 		_cursor.fix_at = false;
@@ -1477,9 +1486,9 @@
  * are so-called system-windows, the window will not be moved.
  * The function will return false when a child window of this window is a
  * modal-popup; function returns a false and child window gets a white border
- * @param w Window to bring on-top
+ * @param w BaseWindow to bring on-top
  * @return false if the window has an active modal child, true otherwise */
-static bool MaybeBringWindowToFront(Window *w)
+static bool MaybeBringWindowToFront(BaseWindow *w)
 {
 	bool bring_to_front = false;
 
@@ -1490,9 +1499,9 @@
 		return true;
 	}
 
-	WindowList::Iterator wit = Window::s_list.Find(w);
-	for (WindowList::Iterator it = wit; it != Window::s_list.m_list.end(); it++) {
-		Window *u = (*it).w;
+	WindowList::Iterator wit = BaseWindow::s_list.Find(w);
+	for (WindowList::Iterator it = wit; it != BaseWindow::s_list.m_list.end(); it++) {
+		BaseWindow *u = (*it).w;
 
 		/* A modal child will prevent the activation of the parent window */
 		if (u->parent == w && (u->desc_flags & WDF_MODAL)) {
@@ -1508,7 +1517,7 @@
 			continue;
 		}
 
-		/* Window sizes don't interfere, leave z-order alone */
+		/* BaseWindow sizes don't interfere, leave z-order alone */
 		if (w->left + w->width <= u->left ||
 				u->left + u->width <= w->left ||
 				w->top  + w->height <= u->top ||
@@ -1524,12 +1533,12 @@
 }
 
 /** Send a message from one window to another. The receiving window is found by
- * @param w @see Window pointer pointing to the other window
+ * @param w @see BaseWindow pointer pointing to the other window
  * @param msg Specifies the message to be sent
  * @param wparam Specifies additional message-specific information
  * @param lparam Specifies additional message-specific information
  */
-static void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam)
+static void SendWindowMessageW(BaseWindow *w, uint msg, uint wparam, uint lparam)
 {
 	WindowEvent e;
 
@@ -1550,7 +1559,7 @@
  */
 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam)
 {
-	Window *w = Window::FindById(wnd_class, wnd_num);
+	BaseWindow *w = BaseWindow::FindById(wnd_class, wnd_num);
 	if (w != NULL) SendWindowMessageW(w, msg, wparam, lparam);
 }
 
@@ -1563,7 +1572,7 @@
  */
 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == wnd_class) SendWindowMessageW(w, msg, wparam, lparam);
@@ -1599,16 +1608,16 @@
 	e.we.keypress.cont = true;
 
 	// check if we have a query string window open before allowing hotkeys
-	if (Window::FindById(WC_QUERY_STRING,       0) != NULL ||
-			Window::FindById(WC_SEND_NETWORK_MSG,   0) != NULL ||
-			Window::FindById(WC_GENERATE_LANDSCAPE, 0) != NULL ||
-			Window::FindById(WC_CONSOLE,            0) != NULL ||
-			Window::FindById(WC_SAVELOAD,           0) != NULL) {
+	if (BaseWindow::FindById(WC_QUERY_STRING,       0) != NULL ||
+			BaseWindow::FindById(WC_SEND_NETWORK_MSG,   0) != NULL ||
+			BaseWindow::FindById(WC_GENERATE_LANDSCAPE, 0) != NULL ||
+			BaseWindow::FindById(WC_CONSOLE,            0) != NULL ||
+			BaseWindow::FindById(WC_SAVELOAD,           0) != NULL) {
 		query_open = true;
 	}
 
 	// Call the event, start with the uppermost window.
-	Window *w;
+	BaseWindow *w;
 	REVERSED_FOR_ALL_WINDOWS(w) {
 		// if a query window is open, only call the event for certain window types
 		if (query_open &&
@@ -1624,7 +1633,7 @@
 	}
 
 	if (e.we.keypress.cont) {
-		Window *w = Window::FindById(WC_MAIN_TOOLBAR, 0);
+		BaseWindow *w = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 		// When there is no toolbar w is null, check for that
 		if (w != NULL) w->wndproc(w, &e);
 	}
@@ -1637,7 +1646,7 @@
 
 static void HandleAutoscroll(void)
 {
-	Window *w;
+	BaseWindow *w;
 	ViewPort *vp;
 	int x = _cursor.pos.x;
 	int y = _cursor.pos.y;
@@ -1650,7 +1659,7 @@
 	}
 
 	if (_patches.autoscroll && _game_mode != GM_MENU && !IsGeneratingWorld()) {
-		w = FindWindowFromPt(x, y);
+		w = BaseWindow::FindFromPt(x, y);
 		if (w == NULL || w->flags4 & WF_DISABLE_VP_SCROLL) return;
 		vp = IsPtInWindowViewport(w, x, y);
 		if (vp != NULL) {
@@ -1676,7 +1685,7 @@
 void MouseLoop(int click, int mousewheel)
 {
 	int x,y;
-	Window *w;
+	BaseWindow *w;
 	ViewPort *vp;
 
 	DecreaseWindowCounters();
@@ -1685,7 +1694,7 @@
 	if (!VpHandlePlaceSizingDrag())      return;
 	if (!HandleDragDrop())               return;
 	if (!HandlePopupMenu())              return;
-	if (!Window::HandleWindowDragging()) return;
+	if (!BaseWindow::HandleWindowDragging()) return;
 	if (!HandleScrollbarScrolling())     return;
 	if (!HandleViewportScroll())         return;
 	if (!HandleMouseOver())              return;
@@ -1695,7 +1704,7 @@
 
 	if (click == 0 && mousewheel == 0) return;
 
-	w = FindWindowFromPt(x, y);
+	w = BaseWindow::FindFromPt(x, y);
 	if (w == NULL) return;
 	if (!MaybeBringWindowToFront(w)) return;
 	vp = IsPtInWindowViewport(w, x, y);
@@ -1799,7 +1808,7 @@
 	static int we4_timer = 0;
 	int t = we4_timer + 1;
 
-	Window *w;
+	BaseWindow *w;
 	if (t >= 100) {
 		REVERSED_FOR_ALL_WINDOWS(w) {
 			w->CallEventNP(WE_4);
@@ -1809,7 +1818,7 @@
 	we4_timer = t;
 
 	REVERSED_FOR_ALL_WINDOWS(w) {
-		if (w->flash_timeout > 0 && (--w->flash_timeout) == 0) {printf("ef\n"); w->SetDirty();}
+		if (w->flash_timeout > 0 && (--w->flash_timeout) == 0) w->SetDirty();
 	}
 
 	DrawDirtyBlocks();
@@ -1823,7 +1832,7 @@
 }
 
 
-int Window::GetMenuItemIndex(int x, int y) const
+int BaseWindow::GetMenuItemIndex(int x, int y) const
 {
 	if ((x -= left) >= 0 && x < width && (y -= top + 1) >= 0) {
 		y /= 10;
@@ -1838,16 +1847,16 @@
 
 void InvalidateWindow(WindowClass cls, WindowNumber number)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls && w->window_number == number) w->SetDirty();
 	}
 }
 
-void Window::InvalidateWidget(byte widget_index) const
+void BaseWindow::InvalidateWidget(byte widget_index) const
 {
-	const Widget *wi = &widget[widget_index];
+	const OldWidget *wi = &widget[widget_index];
 
 	/* Don't redraw the window if the widget is invisible or of no-type */
 	if (wi->type == WWT_EMPTY || IsWidgetHidden(widget_index)) return;
@@ -1857,7 +1866,7 @@
 
 void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls && w->window_number == number) {
 			w->InvalidateWidget(widget_index);
@@ -1867,13 +1876,13 @@
 
 void InvalidateWindowClasses(WindowClass cls)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls) w->SetDirty();
 	}
 }
 
-void Window::InvalidateData()
+void BaseWindow::InvalidateData()
 {
 	this->CallEventNP(WE_INVALIDATE_DATA);
 	this->SetDirty();
@@ -1881,7 +1890,7 @@
 
 void InvalidateWindowData(WindowClass cls, WindowNumber number)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls && w->window_number == number) w->InvalidateData();
 	}
@@ -1889,7 +1898,7 @@
 
 void InvalidateWindowClassesData(WindowClass cls)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class == cls) w->InvalidateData();
 	}
@@ -1897,20 +1906,20 @@
 
 void CallWindowTickEvent(void)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	REVERSED_FOR_ALL_WINDOWS(w) {
 		w->CallEventNP(WE_TICK);
 	}
 }
 
-void Window::DeleteNonVitalWindows(void)
+void BaseWindow::DeleteNonVitalWindows(void)
 {
 
 restart_search:
 	/* When we find the window to delete, we need to restart the search
 	 * as deleting this window could cascade in deleting (many) others
 	 * anywhere in the z-array */
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->window_class != WC_MAIN_WINDOW &&
 				w->window_class != WC_SELECT_GAME &&
@@ -1931,7 +1940,7 @@
  * with this function. It closes all windows calling the standard function,
  * then, does a little hacked loop of closing all stickied windows. Note
  * that standard windows (status bar, etc.) are not stickied, so these aren't affected */
-void Window::DeleteAllNonVitalWindows(void)
+void BaseWindow::DeleteAllNonVitalWindows(void)
 {
 	/* Delete every window except for stickied ones, then sticky ones as well */
 	DeleteNonVitalWindows();
@@ -1940,7 +1949,7 @@
 	/* When we find the window to delete, we need to restart the search
 	 * as deleting this window could cascade in deleting (many) others
 	 * anywhere in the z-array */
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		if (w->flags4 & WF_STICKY) {
 			w->Close();
@@ -1950,19 +1959,19 @@
 }
 
 /* Delete all always on-top windows to get an empty screen */
-void Window::HideVitalWindows(void)
+void BaseWindow::HideVitalWindows(void)
 {
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 	DeleteWindowById(WC_MAIN_TOOLBAR, 0);
 	DeleteWindowById(WC_STATUS_BAR, 0);
 }
 
-int PositionMainToolbar(Window *w)
+int PositionMainToolbar(BaseWindow *w)
 {
 	DEBUG(misc, 5, "Repositioning Main Toolbar...");
 
 	if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
-		w = Window::FindById(WC_MAIN_TOOLBAR, 0);
+		w = BaseWindow::FindById(WC_MAIN_TOOLBAR, 0);
 	}
 
 	switch (_patches.toolbar_pos) {
@@ -1976,7 +1985,7 @@
 
 void RelocateAllWindows(int neww, int newh)
 {
-	Window *w = NULL;
+	BaseWindow *w = NULL;
 	FOR_ALL_WINDOWS(w) {
 		int left, top;
 
--- a/src/window.h	Sat Feb 17 13:08:51 2007 +0000
+++ b/src/window.h	Sun Feb 18 14:17:28 2007 +0000
@@ -4,16 +4,18 @@
 #define WINDOW_H
 
 #include <list>
+#include <map>
 #include "macros.h"
 #include "string.h"
 #include "order.h"
 #include "rail.h"
 #include "airport.h"
+#include "misc/rect.hpp"
 #include "misc/countedptr.hpp"
 
 typedef struct WindowEvent WindowEvent;
 
-typedef void WindowProc(Window *w, WindowEvent *e);
+typedef void WindowProc(BaseWindow *w, WindowEvent *e);
 
 /* How the resize system works:
     First, you need to add a WWT_RESIZEBOX to the widgets, and you need
@@ -42,7 +44,7 @@
      w->resize.width or w->resize.height.
    That was all.. good luck, and enjoy :) -- TrueLight */
 
-typedef enum ResizeFlags {
+enum ResizeFlag {
 	RESIZE_NONE   = 0,
 
 	RESIZE_LEFT   = 1,
@@ -64,7 +66,9 @@
 	WIDG_DISABLED = 4,  // widget is greyed out, not available
 	WIDG_HIDDEN   = 5,  // widget is made invisible
 	WIDG_LOWERED  = 6,  // widget is paint lowered, a pressed button in fact
-} ResizeFlag;
+};
+
+DECLARE_ENUM_AS_BIT_SET(ResizeFlag);
 
 enum WindowFlags {
 	//WF_TIMEOUT_SHL       = 0,
@@ -91,14 +95,56 @@
 	WIDGET_LIST_END = -1,
 };
 
-typedef struct Widget {
-	byte type;                        ///< Widget type, see @WindowWidgetTypes
-	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
-	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
-	int16 left, right, top, bottom;   ///< The position offsets inside the window
-	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
-	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
-} Widget;
+/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
+enum WindowWidgetBehaviours {
+	WWB_PUSHBUTTON  = 1 << 5,
+
+	WWB_MASK        = 0xE0,
+};
+
+
+enum WindowWidgetTypes {
+	WWT_EMPTY,
+
+	WWT_PANEL,      /* simple depressed panel */
+	WWT_INSET,      /* pressed (inset) panel, most commonly used as combo box _text_ area */
+	WWT_IMGBTN,     /* button with image */
+	WWT_IMGBTN_2,   /* button with diff image when clicked */
+
+	WWT_TEXTBTN,    /* button with text */
+	WWT_TEXTBTN_2,  /* button with diff text when clicked */
+	WWT_LABEL,      /* centered label */
+	WWT_MATRIX,
+	WWT_SCROLLBAR,
+	WWT_FRAME,      /* frame */
+	WWT_CAPTION,
+
+	WWT_HSCROLLBAR,
+	WWT_STICKYBOX,
+	WWT_SCROLL2BAR, /* 2nd vertical scrollbar*/
+	WWT_RESIZEBOX,
+	WWT_CLOSEBOX,
+	WWT_LAST,       /* Last Item. use WIDGETS_END to fill up padding!! */
+
+	WWT_MASK = 0x1F,
+
+	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
+	WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
+	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
+};
+
+#define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
+
+
+
+
+struct Widget;
+typedef CCountedPtr<Widget> WidgetPtr;
+
+struct CompositeWidget;
+typedef CCountedPtr<CompositeWidget> CompositeWidgetPtr;
+
+typedef int32 WidgetId;
 
 typedef enum FrameFlags {
 	FR_NONE         = 0x00,
@@ -207,12 +253,14 @@
 	} we;
 };
 
+struct OldWidget;
+
 typedef struct WindowDesc {
 	int16 left, top, width, height;
 	WindowClass cls;
 	WindowClass parent_cls;
 	uint32 flags;
-	const Widget *widgets;
+	const OldWidget *widgets;
 	WindowProc *proc;
 } WindowDesc;
 
@@ -268,13 +316,99 @@
 		int lparam;
 } WindowMessage;
 
-struct Window;
-typedef CCountedPtr<Window> WindowPtr;
+struct OldWidget {
+	WindowWidgetTypes type;           ///< OldWidget type, see @WindowWidgetTypes
+	byte m_display_flags;             ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
+	byte color;                       ///< OldWidget colour, see docs/ottd-colourtext-palette.png
+	int16 left, right, top, bottom;   ///< The position offsets inside the window
+	uint16 data;                      ///< The String/Image or special code (list-matrixes) of a widget
+	StringID tooltips;                ///< Tooltips that are shown when rightclicking on a widget
+};
+
+
+struct Widget : public SimpleCountedObject {
+	//	byte type;                        ///< Widget type, see @WindowWidgetTypes
+	CompositeWidget *m_container;       ///< widget container (can be any panel or window)
+	WidgetId m_id;                      ///< Widget id in its container
+	Rect16 m_rect;                      ///< The position offsets relative to the container
+	uint16 m_data;                      ///< The String/Image or special code (list-matrixes) of a widget
+	byte m_display_flags;               ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags
+	byte m_color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
+	bool m_is_closing : 1;              ///< Widget was logically destroyed
+	bool m_dont_clip : 1;               ///< should not be clipped by parent (container)
+	StringID m_tooltips;                ///< Tooltips that are shown when rightclicking on a widget
+
+	Widget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
+		: m_container(container)
+		, m_id(id)
+		, m_rect(rect)
+		, m_data(0)
+		, m_display_flags(display_flags)
+		, m_color(color)
+		, m_is_closing(false)
+		, m_dont_clip(false)
+		, m_tooltips(tooltips)
+	{}
+
+	int16 Left() const;
+	int16 Top() const;
+	int16 Right() const;
+	int16 Bottom() const;
+	int16 Width() const;
+	int16 Height() const;
+	const Point16& TopLeft() const;
+	const Point16& BottomRight() const;
+	const Rect16& GetRect() const;
+
+	void SetLeft(int16 val);
+	void SetTop(int16 val);
+	void SetRight(int16 val);
+	void SetBottom(int16 val);
+	void SetWidth(int16 val);
+	void SetHeight(int16 val);
+	void SetTopLeft(const Point16 &pt);
+	void SetBottomRight(const Point16 &pt);
+	void SetRect(const Rect16 &rect);
+
+	WidgetId GetId() const;
+
+	virtual Widget* WidgetFromPt(const Point16 &pt);
+
+	virtual void Close();
+	virtual bool OnLeftClick(WindowEvent *ev) = 0;
+};
+
+struct CompositeWidget : public Widget {
+	typedef Widget super;
+	typedef std::map<WidgetId, WidgetPtr> Widgets;
+	typedef Widgets::iterator WidgetIterator;
+	typedef Widgets::reverse_iterator WidgetReverseIterator;
+
+protected:
+	Widgets m_widgets;
+
+public:
+	CompositeWidget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
+		: Widget(container, id, display_flags, color, rect, tooltips)
+	{}
+
+	void AddWidget(Widget *wd);
+	Widget* GetWidget(WidgetId id);
+	Widget* RemoveWidget(WidgetId id);
+
+	/*virtual*/ Widget* WidgetFromPt(const Point16 &pt);
+
+	virtual void Close();
+};
+
+
+struct BaseWindow;
+typedef CCountedPtr<BaseWindow> WindowPtr;
 
 struct WindowList {
 	struct Item {
 		WindowPtr w;
-		Item(Window *v = NULL) : w(v) {}
+		Item(BaseWindow *v = NULL) : w(v) {}
 		Item(const Item &src) : w(src.w) {}
 		~Item()
 		{}
@@ -285,12 +419,13 @@
 
 	List m_list;
 
-	void Add(Window *w);
-	void Remove(Window *w);
-	Iterator Find(Window *w);
+	void Add(BaseWindow *w);
+	void Remove(BaseWindow *w);
+	Iterator Find(BaseWindow *w);
 	Iterator FindFirstVitalWindow();
 	Iterator FindByClass(WindowClass cls);
 	Iterator FindById(WindowClass cls, WindowNumber num);
+	Iterator FindFromPt(int x, int y);
 
 	Iterator EnumT(bool (*enum_proc)(Iterator))
 	{
@@ -333,9 +468,19 @@
 		}
 		return m_list.end();
 	}
+
+	template <class Tmatch_1, class Tmatch_2> Iterator ReverseEnumT(bool (*enum_proc)(Iterator, Tmatch_1, Tmatch_2), Tmatch_1 match_1, Tmatch_2 match_2)
+	{
+		for (Iterator it = m_list.end(); it != m_list.begin(); ) {
+			--it;
+			if (enum_proc(it, match_1, match_2)) return it;
+		}
+		return m_list.end();
+	}
+
 };
 
-struct Window : public SimpleCountedObject {
+struct BaseWindow : public SimpleCountedObject {
 public:
 	static WindowList s_list;
 
@@ -355,23 +500,29 @@
 
 	WindowProc *wndproc;
 	ViewPort *viewport;
-	const Widget *original_widget;
-	Widget *widget;
+	const OldWidget *original_widget;
+	OldWidget *widget;
 	uint widget_count;
 	uint32 desc_flags;
 
 	WindowMessage message;
-	Window *parent;
+	BaseWindow *parent;
 	byte custom[WINDOW_CUSTOM_SIZE];
 
-	Window(int x, int y, int w, int h, WindowProc *proc, WindowClass cls, const Widget *widget, int wnd_number);
+//	BaseWindow(int x, int y, int w, int h, WindowProc *proc, WindowClass cls, const OldWidget *widget, int wnd_number);
+	BaseWindow(const WindowDesc *desc, WindowNumber num = 0);
+	virtual bool Create(const WindowDesc *desc, WindowNumber num = 0);
+
+	static BaseWindow* Allocate(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const OldWidget *widget);
+	static BaseWindow* Allocate(const WindowDesc *desc, int window_number = 0);
+	static BaseWindow* AllocateFront(const WindowDesc *desc, int window_number = 0);
 
 	void ZeroInit()
 	{
-		memset(&flags4, 0, sizeof(*this) - cpp_offsetof(Window, flags4));
+		memset(&flags4, 0, sizeof(*this) - cpp_offsetof(BaseWindow, flags4));
 	}
 
-	Window* FindChild() const;
+	BaseWindow* FindChild() const;
 	void SetDirty() const;
 	void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
 	void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...);
@@ -379,7 +530,7 @@
 	void RaiseButtons();
 	void HandleButtonClick(byte widget);
 	void BringToFront();
-	static Window* BringToFrontById(WindowClass cls, WindowNumber number);
+	static BaseWindow* BringToFrontById(WindowClass cls, WindowNumber number);
 	void StartDrag();
 	bool ContinueDrag();
 	void StartSizing();
@@ -393,18 +544,18 @@
 	virtual void Close();
 	virtual bool IsVital();
 
-	static Window* Allocate(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget);
-	static Window* Get(WindowList::Iterator it);
-	static Window* FindById(WindowClass cls, WindowNumber num);
+	static BaseWindow* Get(WindowList::Iterator it);
+	static BaseWindow* FindFromPt(int x, int y);
+	static BaseWindow* FindById(WindowClass cls, WindowNumber num);
 	static void SetDirtyById(WindowClass cls, WindowNumber num);
 
-	bool IsOfPrototype(const Widget *widgets) const;
+	bool IsOfPrototype(const OldWidget *widgets) const;
 	int GetMenuItemIndex(int x, int y) const;
 	void Resize(int x, int y);
 
 	void CallEventNP(int event);
 
-	void AssignWidget(const Widget *widget);
+	void AssignWidget(const OldWidget *widget);
 
 	void InvalidateData();
 	void InvalidateWidget(byte widget_index) const;
@@ -424,7 +575,7 @@
 	void ResizeButtons(byte left, byte right);
 
 private:
-	void ScrollbarClickHandler(const Widget *wi, int x, int y);
+	void ScrollbarClickHandler(const OldWidget *wi, int x, int y);
 public:
 
 	/*inline*/ void SetWidgetDisabledState(byte widget_index, bool disab_stat);
@@ -482,16 +633,16 @@
 		}
 	};
 
-	//template <class Tmatch> Window* EnumT(Tmatch m)
+	//template <class Tmatch> BaseWindow* EnumT(Tmatch m)
 	//{
-	//	WindowList::Iterator it = Window::s_list.EnumT(EnumMatch<Tmatch>(m));
-	//	return (it == Window::s_list.m_list.end()) ? NULL : (*it).w;
+	//	WindowList::Iterator it = BaseWindow::s_list.EnumT(EnumMatch<Tmatch>(m));
+	//	return (it == BaseWindow::s_list.m_list.end()) ? NULL : (*it).w;
 	//}
 
-	//template <class Tmatch> Window* ReverseEnumT(Tmatch m)
+	//template <class Tmatch> BaseWindow* ReverseEnumT(Tmatch m)
 	//{
-	//	WindowList::Iterator it = Window::s_list.ReverseEnumT(EnumMatch<Tmatch>(m));
-	//	return (it == Window::s_list.m_list.end()) ? NULL : (*it).w;
+	//	WindowList::Iterator it = BaseWindow::s_list.ReverseEnumT(EnumMatch<Tmatch>(m));
+	//	return (it == BaseWindow::s_list.m_list.end()) ? NULL : (*it).w;
 	//}
 
 };
@@ -499,10 +650,10 @@
 
 
 #define FOR_ALL_WINDOWS(wz) \
-	for (WindowList::Iterator it = Window::s_list.m_list.begin(); it != Window::s_list.m_list.end() && (wz = (*it).w) != NULL; it++)
+	for (WindowList::Iterator it = BaseWindow::s_list.m_list.begin(); it != BaseWindow::s_list.m_list.end() && (wz = (*it).w) != NULL; it++)
 
 #define REVERSED_FOR_ALL_WINDOWS(wz) \
-	for (WindowList::ReverseIterator it = Window::s_list.m_list.rbegin(); it != Window::s_list.m_list.rend() && (wz = (*it).w) != NULL; it++)
+	for (WindowList::ReverseIterator it = BaseWindow::s_list.m_list.rbegin(); it != BaseWindow::s_list.m_list.rend() && (wz = (*it).w) != NULL; it++)
 
 
 typedef struct querystr_d {
@@ -707,61 +858,21 @@
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
 
 
-/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
-enum WindowWidgetBehaviours {
-	WWB_PUSHBUTTON  = 1 << 5,
-
-	WWB_MASK        = 0xE0,
-};
-
-
-enum WindowWidgetTypes {
-	WWT_EMPTY,
-
-	WWT_PANEL,      /* simple depressed panel */
-	WWT_INSET,      /* pressed (inset) panel, most commonly used as combo box _text_ area */
-	WWT_IMGBTN,     /* button with image */
-	WWT_IMGBTN_2,   /* button with diff image when clicked */
-
-	WWT_TEXTBTN,    /* button with text */
-	WWT_TEXTBTN_2,  /* button with diff text when clicked */
-	WWT_LABEL,      /* centered label */
-	WWT_MATRIX,
-	WWT_SCROLLBAR,
-	WWT_FRAME,      /* frame */
-	WWT_CAPTION,
-
-	WWT_HSCROLLBAR,
-	WWT_STICKYBOX,
-	WWT_SCROLL2BAR, /* 2nd vertical scrollbar*/
-	WWT_RESIZEBOX,
-	WWT_CLOSEBOX,
-	WWT_LAST,       /* Last Item. use WIDGETS_END to fill up padding!! */
-
-	WWT_MASK = 0x1F,
-
-	WWT_PUSHBTN     = WWT_PANEL   | WWB_PUSHBUTTON,
-	WWT_PUSHTXTBTN  = WWT_TEXTBTN | WWB_PUSHBUTTON,
-	WWT_PUSHIMGBTN  = WWT_IMGBTN  | WWB_PUSHBUTTON,
-};
-
-#define WIDGETS_END WWT_LAST,   RESIZE_NONE,     0,     0,     0,     0,     0, 0, STR_NULL
-
 /* window.c */
-//void CallWindowEventNP(Window *w, int event);
+//void CallWindowEventNP(BaseWindow *w, int event);
 void CallWindowTickEvent(void);
-//void SetWindowDirty(const Window *w);
+//void SetWindowDirty(const BaseWindow *w);
 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam);
 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
 
-//Window *FindWindowById(WindowClass cls, WindowNumber number);
-//void DeleteWindow(Window *w);
+//BaseWindow *FindWindowById(WindowClass cls, WindowNumber number);
+//void DeleteWindow(BaseWindow *w);
 void DeletePlayerWindows(PlayerID pi);
 void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
-//Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
-Window *FindWindowFromPt(int x, int y);
+//BaseWindow *BringWindowToFrontById(WindowClass cls, WindowNumber number);
+//BaseWindow *FindWindowFromPt(int x, int y);
 
-//Window *AllocateWindow(
+//BaseWindow *AllocateWindow(
 //							int x,
 //							int y,
 //							int width,
@@ -770,170 +881,170 @@
 //							WindowClass cls,
 //							const Widget *widget);
 
-Window *AllocateWindowDesc(const WindowDesc *desc);
-Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number);
+//BaseWindow *AllocateWindowDesc(const WindowDesc *desc);
+//BaseWindow *AllocateWindowDescFront(const WindowDesc *desc, int window_number);
 
-//void DrawWindowViewport(const Window *w);
+//void DrawWindowViewport(const BaseWindow *w);
 
 /**
  * Sets the enabled/disabled status of a widget.
  * By default, widgets are enabled.
  * On certain conditions, they have to be disabled.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  * @param disab_stat : status to use ie: disabled = true, enabled = false
  */
-inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat)
+inline void BaseWindow::SetWidgetDisabledState(byte widget_index, bool disab_stat)
 {
 	assert(widget_index < widget_count);
-	SB(widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat);
+	SB(widget[widget_index].m_display_flags, WIDG_DISABLED, 1, !!disab_stat);
 }
 
 /**
  * Sets a widget to disabled.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::DisableWidget(byte widget_index)
+inline void BaseWindow::DisableWidget(byte widget_index)
 {
 	SetWidgetDisabledState(widget_index, true);
 }
 
 /**
  * Sets a widget to Enabled.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::EnableWidget(byte widget_index)
+inline void BaseWindow::EnableWidget(byte widget_index)
 {
 	SetWidgetDisabledState(widget_index, false);
 }
 
 /**
  * Gets the enabled/disabled status of a widget.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  * @return status of the widget ie: disabled = true, enabled = false
  */
-inline bool Window::IsWidgetDisabled(byte widget_index) const
+inline bool BaseWindow::IsWidgetDisabled(byte widget_index) const
 {
 	assert(widget_index < widget_count);
-	return HASBIT(widget[widget_index].display_flags, WIDG_DISABLED);
+	return HASBIT(widget[widget_index].m_display_flags, WIDG_DISABLED);
 }
 
 /**
  * Sets the hidden/shown status of a widget.
  * By default, widgets are visible.
  * On certain conditions, they have to be hidden.
- * @param w Window on which the widget is located
+ * @param w BaseWindow on which the widget is located
  * @param widget_index index of this widget in the window
  * @param hidden_stat status to use ie. hidden = true, visible = false
  */
-inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat)
+inline void BaseWindow::SetWidgetHiddenState(byte widget_index, bool hidden_stat)
 {
 	assert(widget_index < widget_count);
-	SB(widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
+	SB(widget[widget_index].m_display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
 }
 
 /**
  * Sets a widget hidden.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::HideWidget(byte widget_index)
+inline void BaseWindow::HideWidget(byte widget_index)
 {
 	SetWidgetHiddenState(widget_index, true);
 }
 
 /**
  * Sets a widget visible.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::ShowWidget(byte widget_index)
+inline void BaseWindow::ShowWidget(byte widget_index)
 {
 	SetWidgetHiddenState(widget_index, false);
 }
 
 /**
  * Gets the visibility of a widget.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  * @return status of the widget ie: hidden = true, visible = false
  */
-inline bool Window::IsWidgetHidden(byte widget_index) const
+inline bool BaseWindow::IsWidgetHidden(byte widget_index) const
 {
 	assert(widget_index < widget_count);
-	return HASBIT(widget[widget_index].display_flags, WIDG_HIDDEN);
+	return HASBIT(widget[widget_index].m_display_flags, WIDG_HIDDEN);
 }
 
 /**
  * Sets the lowered/raised status of a widget.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  * @param hidden_stat : status to use ie: lowered = true, raised = false
  */
-inline void Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat)
+inline void BaseWindow::SetWidgetLoweredState(byte widget_index, bool lowered_stat)
 {
 	assert(widget_index < widget_count);
-	SB(widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat);
+	SB(widget[widget_index].m_display_flags, WIDG_LOWERED, 1, !!lowered_stat);
 }
 
 /**
  * Invert the lowered/raised  status of a widget.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::ToggleWidgetLoweredState(byte widget_index)
+inline void BaseWindow::ToggleWidgetLoweredState(byte widget_index)
 {
 	assert(widget_index < widget_count);
-	TOGGLEBIT(widget[widget_index].display_flags, WIDG_LOWERED);
+	TOGGLEBIT(widget[widget_index].m_display_flags, WIDG_LOWERED);
 }
 
 /**
  * Marks a widget as lowered.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::LowerWidget(byte widget_index)
+inline void BaseWindow::LowerWidget(byte widget_index)
 {
 	SetWidgetLoweredState(widget_index, true);
 }
 
 /**
  * Marks a widget as raised.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  */
-inline void Window::RaiseWidget(byte widget_index)
+inline void BaseWindow::RaiseWidget(byte widget_index)
 {
 	SetWidgetLoweredState(widget_index, false);
 }
 
 /**
  * Gets the lowered state of a widget.
- * @param w : Window on which the widget is located
+ * @param w : BaseWindow on which the widget is located
  * @param widget_index : index of this widget in the window
  * @return status of the widget ie: lowered = true, raised= false
  */
-inline bool Window::IsWidgetLowered(byte widget_index) const
+inline bool BaseWindow::IsWidgetLowered(byte widget_index) const
 {
 	assert(widget_index < widget_count);
-	return HASBIT(widget[widget_index].display_flags, WIDG_LOWERED);
+	return HASBIT(widget[widget_index].m_display_flags, WIDG_LOWERED);
 }
 
 void InitWindowSystem(void);
 void UnInitWindowSystem(void);
 void ResetWindowSystem(void);
 void InputLoop(void);
-//void InvalidateThisWindowData(Window *w);
+//void InvalidateThisWindowData(BaseWindow *w);
 void InvalidateWindowData(WindowClass cls, WindowNumber number);
-//void RaiseWindowButtons(Window *w);
+//void RaiseWindowButtons(BaseWindow *w);
 void RelocateAllWindows(int neww, int newh);
-int PositionMainToolbar(Window *w);
-//void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...);
-//void CDECL SetWindowWidgetsHiddenState(Window *w, bool hidden_stat, int widgets, ...);
-//void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...);
+int PositionMainToolbar(BaseWindow *w);
+//void CDECL SetWindowWidgetsDisabledState(BaseWindow *w, bool disab_stat, int widgets, ...);
+//void CDECL SetWindowWidgetsHiddenState(BaseWindow *w, bool hidden_stat, int widgets, ...);
+//void CDECL SetWindowWidgetsLoweredState(BaseWindow *w, bool lowered_stat, int widgets, ...);
 
 /* misc_gui.c*/
 void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint params[]);
@@ -942,14 +1053,14 @@
 	GuiShowTooltipsWithArgs(str, 0, NULL);
 }
 
-//void HandleButtonClick(Window *w, byte widget);
+//void HandleButtonClick(BaseWindow *w, byte widget);
 
-Window *GetCallbackWnd(void);
-//WindowList::Iterator FindWindowZPosition(const Window *w);
+BaseWindow *GetCallbackWnd(void);
+//WindowList::Iterator FindWindowZPosition(const BaseWindow *w);
 
 /* window.c */
-//extern Window *_z_windows[];
-//extern Window **_last_z_window;
+//extern BaseWindow *_z_windows[];
+//extern BaseWindow **_last_z_window;
 
 VARDEF Point _cursorpos_drag_start;
 
@@ -976,6 +1087,6 @@
  * @param left The leftmost widget to resize
  * @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
  */
-//void ResizeButtons(Window *w, byte left, byte right);
+//void ResizeButtons(BaseWindow *w, byte left, byte right);
 
 #endif /* WINDOW_H */