(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
authorrubidium
Thu, 08 May 2008 11:31:41 +0000
changeset 10461 48556aee54da
parent 10460 a834c2e45ae1
child 10462 416b62f5ee6f
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
src/airport_gui.cpp
src/bridge_gui.cpp
src/cheat_gui.cpp
src/console.cpp
src/dock_gui.cpp
src/intro_gui.cpp
src/main_gui.cpp
src/misc_gui.cpp
src/network/network_gui.cpp
src/newgrf_gui.cpp
src/news_gui.cpp
src/osk_gui.cpp
src/player_gui.cpp
src/rail_gui.cpp
src/road_gui.cpp
src/settings_gui.cpp
src/signs_gui.cpp
src/statusbar_gui.cpp
src/toolbar_gui.cpp
src/widgets/dropdown.cpp
src/window.cpp
src/window_gui.h
--- a/src/airport_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/airport_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -282,7 +282,7 @@
 
 static void ShowBuildAirportPicker()
 {
-	AllocateWindowDesc(&_build_airport_desc);
+	new Window(&_build_airport_desc);
 }
 
 void InitializeAirportGui()
--- a/src/bridge_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/bridge_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -184,7 +184,7 @@
 	}
 
 	if (j != 0) {
-		Window *w = AllocateWindowDesc(&_build_bridge_desc);
+		Window *w = new Window(&_build_bridge_desc);
 		/* Change the data, or the caption of the gui. Set it to road or rail, accordingly */
 		w->widget[BBSW_CAPTION].data = (transport_type == TRANSPORT_ROAD) ? STR_1803_SELECT_ROAD_BRIDGE : STR_100D_SELECT_RAIL_BRIDGE;
 	} else {
--- a/src/cheat_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/cheat_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -229,5 +229,5 @@
 void ShowCheatWindow()
 {
 	DeleteWindowById(WC_CHEATS, 0);
-	AllocateWindowDesc(&_cheats_desc);
+	new Window(&_cheats_desc);
 }
--- a/src/console.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/console.cpp	Thu May 08 11:31:41 2008 +0000
@@ -318,7 +318,7 @@
 {
 	switch (_iconsole_mode) {
 		case ICONSOLE_CLOSED: {
-			Window *w = AllocateWindowDesc(&_iconsole_window_desc);
+			Window *w = new Window(&_iconsole_window_desc);
 			w->height = _screen.height / 3;
 			w->width = _screen.width;
 			_iconsole_mode = ICONSOLE_OPENED;
--- a/src/dock_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/dock_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -309,7 +309,7 @@
 
 static void ShowBuildDockStationPicker()
 {
-	AllocateWindowDesc(&_build_dock_station_desc);
+	new Window(&_build_dock_station_desc);
 }
 
 static void UpdateDocksDirection()
@@ -379,7 +379,7 @@
 
 static void ShowBuildDocksDepotPicker()
 {
-	AllocateWindowDesc(&_build_docks_depot_desc);
+	new Window(&_build_docks_depot_desc);
 	UpdateDocksDirection();
 }
 
--- a/src/intro_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/intro_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -133,7 +133,7 @@
 
 void ShowSelectGameWindow()
 {
-	AllocateWindowDesc(&_select_game_desc);
+	new Window(&_select_game_desc);
 }
 
 static void AskExitGameCallback(Window *w, bool confirmed)
--- a/src/main_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/main_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -412,7 +412,7 @@
 	int width = _screen.width;
 	int height = _screen.height;
 
-	Window *w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
+	Window *w = new Window(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
 	InitializeWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
 
 	/* XXX: these are not done */
--- a/src/misc_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/misc_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -98,7 +98,7 @@
 {
 	DeleteWindowById(WC_LAND_INFO, 0);
 
-	Window *w = AllocateWindowDesc(&_land_info_desc);
+	Window *w = new Window(&_land_info_desc);
 	WP(w, void_d).data = &_landinfo_data;
 
 	Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
@@ -318,7 +318,7 @@
 void ShowAboutWindow()
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_about_desc);
+	new Window(&_about_desc);
 }
 
 static int _tree_to_plant;
@@ -615,7 +615,7 @@
 			pt.x = (_screen.width - 240) >> 1;
 			pt.y = (_screen.height - 46) >> 1;
 		}
-		w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
+		w = new Window(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
 	} else {
 		if ((x | y) != 0) {
 			pt = RemapCoords2(x, y);
@@ -626,7 +626,7 @@
 			pt.x = (_screen.width - 334) >> 1;
 			pt.y = (_screen.height - 137) >> 1;
 		}
-		w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
+		w = new Window(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
 	}
 
 	w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
@@ -753,7 +753,7 @@
 	if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
 	int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
 
-	Window *w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
+	Window *w = new Window(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]));
@@ -1241,7 +1241,7 @@
 	DeleteWindowById(WC_QUERY_STRING, 0);
 	DeleteWindowById(WC_SAVELOAD, 0);
 
-	Window *w = AllocateWindowDesc(&_query_string_desc);
+	Window *w = new Window(&_query_string_desc);
 	w->parent = parent;
 
 	GetString(_edit_str_buf, str, lastof(_edit_str_buf));
@@ -1353,7 +1353,7 @@
  * @param callback callback function pointer to set in the window descriptor*/
 void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool))
 {
-	Window *w = AllocateWindowDesc(&_query_desc);
+	Window *w = new Window(&_query_desc);
 	if (w == NULL) return;
 
 	if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
@@ -1741,7 +1741,7 @@
 
 	assert((uint)mode < lengthof(saveload_captions));
 
-	Window *w = AllocateWindowDesc(sld);
+	Window *w = new Window(sld);
 	w->widget[1].data = saveload_captions[mode];
 	w->LowerWidget(7);
 
--- a/src/network/network_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/network/network_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -675,7 +675,7 @@
 		_ng_sorting.order = 0;    // sort ascending by default
 	}
 
-	Window *w = AllocateWindowDesc(&_network_game_window_desc);
+	Window *w = new Window(&_network_game_window_desc);
 	if (w != NULL) {
 		querystr_d *querystr = &WP(w, network_ql_d).q;
 
@@ -992,7 +992,7 @@
 {
 	DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
-	Window *w = AllocateWindowDesc(&_network_start_server_window_desc);
+	Window *w = new Window(&_network_start_server_window_desc);
 	ttd_strlcpy(_edit_str_net_buf, _network_server_name, lengthof(_edit_str_net_buf));
 
 	_saveload_mode = SLD_NEW_GAME;
@@ -1228,7 +1228,7 @@
 	NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
 	NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
 
-	Window *w = AllocateWindowDesc(&_network_lobby_window_desc);
+	Window *w = new Window(&_network_lobby_window_desc);
 	if (w != NULL) {
 		WP(w, network_ql_d).n.server = ngl;
 		strcpy(_edit_str_net_buf, "");
@@ -1471,7 +1471,7 @@
 	int h = ClientListPopupHeight();
 
 	/* Allocate the popup */
-	w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
+	w = new Window(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;
 
@@ -1708,7 +1708,7 @@
 void ShowJoinStatusWindow()
 {
 	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
-	Window *w = AllocateWindowDesc(&_network_join_status_window_desc);
+	Window *w = new Window(&_network_join_status_window_desc);
 	/* Parent the status window to the lobby */
 	if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
 }
@@ -1943,7 +1943,7 @@
 	_edit_str_net_buf[0] = '\0';
 	_chat_tab_completion_active = false;
 
-	Window *w = AllocateWindowDesc(&_chat_window_desc);
+	Window *w = new Window(&_chat_window_desc);
 
 	w->LowerWidget(2);
 	WP(w, chatquerystr_d).dtype   = type;
@@ -2045,7 +2045,7 @@
 	DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
 
 	_edit_str_net_buf[0] = '\0';
-	Window *w = AllocateWindowDesc(&_ncp_window_desc);
+	Window *w = new Window(&_ncp_window_desc);
 	WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL;
 	InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_net_buf, min(lengthof(_network_default_company_pass), lengthof(_edit_str_net_buf)), 0);
 }
--- a/src/newgrf_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/newgrf_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -408,7 +408,7 @@
 					Window *w;
 
 					DeleteWindowByClass(WC_SAVELOAD);
-					w = AllocateWindowDesc(&_newgrf_add_dlg_desc);
+					w = new Window(&_newgrf_add_dlg_desc);
 					w->resize.step_height = 10;
 
 					WP(w, newgrf_add_d).list = list;
@@ -582,7 +582,7 @@
 	Window *w;
 
 	DeleteWindowByClass(WC_GAME_OPTIONS);
-	w = AllocateWindowDesc(&_newgrf_desc);
+	w = new Window(&_newgrf_desc);
 	if (w == NULL) return;
 
 	w->resize.step_height = 14;
--- a/src/news_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/news_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -432,7 +432,7 @@
 		case NM_NORMAL:
 		case NM_CALLBACK:
 			_news_type13_desc.top = top;
-			w = AllocateWindowDesc(&_news_type13_desc);
+			w = new Window(&_news_type13_desc);
 			if (ni->flags & NF_VIEWPORT) {
 				InitializeWindowViewport(w, 2, 58, 426, 110,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
@@ -441,7 +441,7 @@
 
 		case NM_THIN:
 			_news_type2_desc.top = top;
-			w = AllocateWindowDesc(&_news_type2_desc);
+			w = new Window(&_news_type2_desc);
 			if (ni->flags & NF_VIEWPORT) {
 				InitializeWindowViewport(w, 2, 58, 426, 70,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
@@ -450,7 +450,7 @@
 
 		default:
 			_news_type0_desc.top = top;
-			w = AllocateWindowDesc(&_news_type0_desc);
+			w = new Window(&_news_type0_desc);
 			if (ni->flags & NF_VIEWPORT) {
 				InitializeWindowViewport(w, 3, 17, 274, 47,
 					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
@@ -711,7 +711,7 @@
 void ShowMessageHistory()
 {
 	DeleteWindowById(WC_MESSAGE_HISTORY, 0);
-	Window *w = AllocateWindowDesc(&_message_history_desc);
+	Window *w = new Window(&_message_history_desc);
 
 	if (w == NULL) return;
 
@@ -933,7 +933,7 @@
 void ShowMessageOptions()
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_message_options_desc);
+	new Window(&_message_options_desc);
 }
 
 
--- a/src/osk_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/osk_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -349,7 +349,7 @@
 {
 	DeleteWindowById(WC_OSK, 0);
 
-	Window *w = AllocateWindowDesc(&_osk_desc);
+	Window *w = new Window(&_osk_desc);
 
 	w->parent = parent;
 	assert(parent != NULL);
--- a/src/player_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/player_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -1552,7 +1552,7 @@
 	if (_game_mode != GM_MENU) HideVitalWindows();
 
 	DeleteWindowByClass(WC_HIGHSCORE);
-	w = AllocateWindowDesc(&_highscore_desc);
+	w = new Window(&_highscore_desc);
 
 	if (w != NULL) {
 		MarkWholeScreenDirty();
@@ -1575,7 +1575,7 @@
 
 	HideVitalWindows();
 	DeleteWindowByClass(WC_ENDSCREEN);
-	w = AllocateWindowDesc(&_endgame_desc);
+	w = new Window(&_endgame_desc);
 
 	if (w != NULL) {
 		MarkWholeScreenDirty();
--- a/src/rail_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/rail_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -1226,10 +1226,10 @@
 {
 	Window *w;
 	if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
-		w = AllocateWindowDesc(&_station_builder_desc);
+		w = new Window(&_station_builder_desc);
 		_railstation.newstations = false;
 	} else {
-		w = AllocateWindowDesc(&_newstation_builder_desc);
+		w = new Window(&_newstation_builder_desc);
 		_railstation.newstations = true;
 		_railstation.station_count = GetNumCustomStations(_railstation.station_class);
 
@@ -1397,7 +1397,7 @@
  */
 static void ShowSignalBuilder()
 {
-	AllocateWindowDesc(&_signal_builder_desc);
+	new Window(&_signal_builder_desc);
 }
 
 /** Enum referring to the widgets of the build rail depot window */
@@ -1473,7 +1473,7 @@
 
 static void ShowBuildTrainDepotPicker()
 {
-	AllocateWindowDesc(&_build_depot_desc);
+	new Window(&_build_depot_desc);
 }
 
 /** Enum referring to the widgets of the build NewGRF rail waypoint window */
@@ -1576,7 +1576,7 @@
 
 static void ShowBuildWaypointPicker()
 {
-	Window *w = AllocateWindowDesc(&_build_waypoint_desc);
+	Window *w = new Window(&_build_waypoint_desc);
 	w->hscroll.cap = 5;
 	w->hscroll.count = _waypoint_count;
 }
--- a/src/road_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/road_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -817,7 +817,7 @@
 
 static void ShowRoadDepotPicker()
 {
-	AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
+	new Window(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
 }
 
 /** Enum referring to the widgets of the build road station window */
@@ -966,7 +966,7 @@
 
 static void ShowRVStationPicker(RoadStopType rs)
 {
-	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
+	Window *w = new Window(&_rv_station_picker_desc);
 	if (w == NULL) return;
 
 	w->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
--- a/src/settings_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/settings_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -389,7 +389,7 @@
 void ShowGameOptions()
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_game_options_desc);
+	new Window(&_game_options_desc);
 }
 
 struct GameSettingData {
@@ -698,7 +698,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);
+	new Window(&_game_difficulty_desc);
 }
 
 static const char *_patches_ui[] = {
@@ -1104,7 +1104,7 @@
 void ShowPatchesSelection()
 {
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
-	AllocateWindowDesc(&_patches_selection_desc);
+	new Window(&_patches_selection_desc);
 }
 
 
@@ -1334,5 +1334,5 @@
 	_str_separator[1] = '\0';
 
 	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
-	AllocateWindowDesc(&_cust_currency_desc);
+	new Window(&_cust_currency_desc);
 }
--- a/src/signs_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/signs_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -301,7 +301,7 @@
 	DeleteWindowById(WC_QUERY_STRING, 0);
 	DeleteWindowById(WC_SAVELOAD, 0);
 
-	Window *w = AllocateWindowDesc(&_query_sign_edit_desc);
+	Window *w = new Window(&_query_sign_edit_desc);
 
 	WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT;
 	WP(w, editsign_d).afilter = CS_ALPHANUMERAL;
--- a/src/statusbar_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/statusbar_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -163,7 +163,7 @@
 void ShowStatusBar()
 {
 	_main_status_desc.top = _screen.height - 12;
-	Window *w = AllocateWindowDesc(&_main_status_desc);
+	Window *w = new Window(&_main_status_desc);
 	if (w != NULL) {
 		CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 		WP(w, def_d).data_1 = -1280;
--- a/src/toolbar_gui.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/toolbar_gui.cpp	Thu May 08 11:31:41 2008 +0000
@@ -1230,7 +1230,7 @@
 
 	Point pos = GetToolbarDropdownPos(parent_button, width, height);
 
-	w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
+	w = new Window(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
 	w->widget[0].bottom = item_count * 10 + 1;
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 
@@ -1390,7 +1390,7 @@
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 	Point pos = GetToolbarDropdownPos(main_button, 241, 82);
-	w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
+	w = new Window(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 	WP(w, menu_d).item_count = 0;
 	WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
@@ -1418,7 +1418,7 @@
 	/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
 	_last_built_roadtype = ROADTYPE_ROAD;
 
-	Window *w = AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
+	Window *w = new Window((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
 	if (w == NULL) return NULL;
 
 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
--- a/src/widgets/dropdown.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/widgets/dropdown.cpp	Thu May 08 11:31:41 2008 +0000
@@ -282,7 +282,7 @@
 
 	if (width == 0) width = wi->right - wi->left + 1;
 
-	Window *dw = AllocateWindow(
+	Window *dw = new Window(
 		w->left + wi->left,
 		top,
 		width,
--- a/src/window.cpp	Wed May 07 23:00:11 2008 +0000
+++ b/src/window.cpp	Thu May 08 11:31:41 2008 +0000
@@ -677,10 +677,10 @@
 	}
 }
 
-/** Open a new window.
- * This function is called from AllocateWindow() or AllocateWindowDesc()
+/**
+ * Initializes a new Window.
+ * This function is called the constructors.
  * 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
  * @param x offset in pixels from the left of the screen
  * @param y offset in pixels from the top of the screen
@@ -694,71 +694,65 @@
  * @param window_number number being assigned to the new window
  * @param data the data to be given during the WE_CREATE message
  * @return Window pointer of the newly created window */
-static Window *LocalAllocateWindow(int x, int y, int min_width, int min_height, int def_width, int def_height,
+void Window::Initialize(int x, int y, int min_width, int min_height, int def_width, int def_height,
 				WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data)
 {
-	Window *w;
-
 	/* We have run out of windows, close one and use that as the place for our new one */
 	if (_last_z_window == endof(_z_windows)) {
-		w = FindDeletableWindow();
+		Window *w = FindDeletableWindow();
 		if (w == NULL) w = ForceFindDeletableWindow();
 		delete w;
 	}
 
-	w = new Window(proc);
-
 	/* Set up window properties */
-	w->window_class = cls;
-	w->flags4 = WF_WHITE_BORDER_MASK; // just opened windows have a white border
-	w->caption_color = 0xFF;
-	w->left = x;
-	w->top = y;
-	w->width = min_width;
-	w->height = min_height;
-	AssignWidgetToWindow(w, widget);
-	w->resize.width = min_width;
-	w->resize.height = min_height;
-	w->resize.step_width = 1;
-	w->resize.step_height = 1;
-	w->window_number = window_number;
-
-	{
-		Window **wz = _last_z_window;
+	this->window_class = cls;
+	this->flags4 = WF_WHITE_BORDER_MASK; // just opened windows have a white border
+	this->caption_color = 0xFF;
+	this->left = x;
+	this->top = y;
+	this->width = min_width;
+	this->height = min_height;
+	this->wndproc = proc;
+	AssignWidgetToWindow(this, widget);
+	this->resize.width = min_width;
+	this->resize.height = min_height;
+	this->resize.step_width = 1;
+	this->resize.step_height = 1;
+	this->window_number = window_number;
 
-		/* 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 && w->window_class != WC_HIGHSCORE && w->window_class != WC_ENDSCREEN) {
-			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--;
+	/* 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 */
+	Window **wz = _last_z_window;
+	if (wz != _z_windows && this->window_class != WC_SEND_NETWORK_MSG && this->window_class != WC_HIGHSCORE && this->window_class != WC_ENDSCREEN) {
+		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);
-		}
+		assert(wz >= _z_windows);
+		if (wz != _last_z_window) memmove(wz + 1, wz, (byte*)_last_z_window - (byte*)wz);
+	}
 
-		*wz = w;
-		_last_z_window++;
-	}
+	*wz = this;
+	_last_z_window++;
 
 	WindowEvent e;
 	e.event = WE_CREATE;
 	e.we.create.data = data;
-	w->HandleWindowEvent(&e);
+	this->HandleWindowEvent(&e);
 
 	/* Try to make windows smaller when our window is too small.
 	 * w->(width|height) is normally the same as min_(width|height),
 	 * but this way the GUIs can be made a little more dynamic;
 	 * one can use the same spec for multiple windows and those
 	 * can then determine the real minimum size of the window. */
-	if (w->width != def_width || w->height != def_height) {
+	if (this->width != def_width || this->height != def_height) {
 		/* Think about the overlapping toolbars when determining the minimum window size */
 		int free_height = _screen.height;
 		const Window *wt = FindWindowById(WC_STATUS_BAR, 0);
@@ -766,45 +760,43 @@
 		wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
 		if (wt != NULL) free_height -= wt->height;
 
-		int enlarge_x = max(min(def_width  - w->width,  _screen.width - w->width),  0);
-		int enlarge_y = max(min(def_height - w->height, free_height   - w->height), 0);
+		int enlarge_x = max(min(def_width  - this->width,  _screen.width - this->width),  0);
+		int enlarge_y = max(min(def_height - this->height, free_height   - this->height), 0);
 
 		/* X and Y has to go by step.. calculate it.
 		 * The cast to int is necessary else x/y are implicitly casted to
 		 * unsigned int, which won't work. */
-		if (w->resize.step_width  > 1) enlarge_x -= enlarge_x % (int)w->resize.step_width;
-		if (w->resize.step_height > 1) enlarge_y -= enlarge_y % (int)w->resize.step_height;
+		if (this->resize.step_width  > 1) enlarge_x -= enlarge_x % (int)this->resize.step_width;
+		if (this->resize.step_height > 1) enlarge_y -= enlarge_y % (int)this->resize.step_height;
 
-		ResizeWindow(w, enlarge_x, enlarge_y);
+		ResizeWindow(this, enlarge_x, enlarge_y);
 
 		WindowEvent e;
 		e.event = WE_RESIZE;
-		e.we.sizing.size.x = w->width;
-		e.we.sizing.size.y = w->height;
+		e.we.sizing.size.x = this->width;
+		e.we.sizing.size.y = this->height;
 		e.we.sizing.diff.x = enlarge_x;
 		e.we.sizing.diff.y = enlarge_y;
-		w->HandleWindowEvent(&e);
+		this->HandleWindowEvent(&e);
 	}
 
-	int nx = w->left;
-	int ny = w->top;
+	int nx = this->left;
+	int ny = this->top;
 
-	if (nx + w->width > _screen.width) nx -= (nx + w->width - _screen.width);
+	if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width);
 
 	const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
-	ny = max(ny, (wt == NULL || w == wt || y == 0) ? 0 : wt->height);
+	ny = max(ny, (wt == NULL || this == wt || y == 0) ? 0 : wt->height);
 	nx = max(nx, 0);
 
-	if (w->viewport != NULL) {
-		w->viewport->left += nx - w->left;
-		w->viewport->top  += ny - w->top;
+	if (this->viewport != NULL) {
+		this->viewport->left += nx - this->left;
+		this->viewport->top  += ny - this->top;
 	}
-	w->left = nx;
-	w->top = ny;
+	this->left = nx;
+	this->top = ny;
 
-	w->SetDirty();
-
-	return w;
+	this->SetDirty();
 }
 
 /**
@@ -821,10 +813,9 @@
  * @param *widget see Widget pointer to the window layout and various elements
  * @return Window pointer of the newly created window
  */
-Window *AllocateWindow(int x, int y, int width, int height,
-			WindowProc *proc, WindowClass cls, const Widget *widget, void *data)
+Window::Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data)
 {
-	return LocalAllocateWindow(x, y, width, height, width, height, proc, cls, widget, 0, data);
+	this->Initialize(x, y, width, height, width, height, proc, cls, widget, 0, data);
 }
 
 
@@ -1014,24 +1005,11 @@
  *
  * @return Window pointer of the newly created window
  */
-static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number, void *data)
+Window::Window(const WindowDesc *desc, void *data, WindowNumber window_number)
 {
 	Point pt = LocalGetWindowPlacement(desc, window_number);
-	Window *w = LocalAllocateWindow(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->default_width, desc->default_height, desc->proc, desc->cls, desc->widgets, window_number, data);
-	w->desc_flags = desc->flags;
-
-	return w;
-}
-
-/**
- * Open a new window.
- * @param *desc The pointer to the WindowDesc to be created
- * @param data arbitrary data that is send with the WE_CREATE message
- * @return Window pointer of the newly created window
- */
-Window *AllocateWindowDesc(const WindowDesc *desc, void *data)
-{
-	return LocalAllocateWindowDesc(desc, 0, data);
+	this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->default_width, desc->default_height, desc->proc, desc->cls, desc->widgets, window_number, data);
+	this->desc_flags = desc->flags;
 }
 
 /**
@@ -1044,7 +1022,7 @@
 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data)
 {
 	if (BringWindowToFrontById(desc->cls, window_number)) return NULL;
-	return LocalAllocateWindowDesc(desc, window_number, data);
+	return new Window(desc, data, window_number);
 }
 
 /** Do a search for a window at specific coordinates. For this we start
--- a/src/window_gui.h	Wed May 07 23:00:11 2008 +0000
+++ b/src/window_gui.h	Thu May 08 11:31:41 2008 +0000
@@ -297,8 +297,14 @@
 private:
 	WindowProc *wndproc;   ///< Event handler function for the window. Do not use directly, call HandleWindowEvent() instead.
 
+protected:
+	void Initialize(int x, int y, int min_width, int min_height, int def_width, int def_height,
+			WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data);
+
 public:
-	Window(WindowProc *proc) : wndproc(proc) {}
+	Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data = NULL);
+	Window(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0);
+
 	virtual ~Window();
 
 	uint16 flags4;              ///< Window flags, @see WindowFlags
@@ -554,11 +560,7 @@
 
 bool IsWindowOfPrototype(const Window *w, const Widget *widget);
 void AssignWidgetToWindow(Window *w, const Widget *widget);
-Window *AllocateWindow(int x, int y, int width, int height,
-			WindowProc *proc, WindowClass cls, const Widget *widget,
-			void *data = NULL);
 
-Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL);
 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
 
 void DrawWindowViewport(const Window *w);