summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-06 21:28:30 +0000
committerrubidium <rubidium@openttd.org>2008-05-06 21:28:30 +0000
commite6c944a6c4507ec00948391d1b0bdf300bbd879e (patch)
tree248a2b8909d0045aad2724ae25b5f9064e597dd1 /src
parent46a0ebe1d931bb49dcc10e811f8f85ea91e1dcb5 (diff)
downloadopenttd-e6c944a6c4507ec00948391d1b0bdf300bbd879e.tar.xz
(svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
Diffstat (limited to 'src')
-rw-r--r--src/airport_gui.cpp2
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/dock_gui.cpp4
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/misc_gui.cpp24
-rw-r--r--src/network/network_gui.cpp14
-rw-r--r--src/news_gui.cpp4
-rw-r--r--src/osk_gui.cpp4
-rw-r--r--src/player_gui.cpp14
-rw-r--r--src/rail_gui.cpp8
-rw-r--r--src/road_gui.cpp4
-rw-r--r--src/settings_gui.cpp4
-rw-r--r--src/signs_gui.cpp4
-rw-r--r--src/toolbar_gui.cpp4
-rw-r--r--src/train_cmd.cpp3
-rw-r--r--src/vehicle_gui.cpp4
-rw-r--r--src/widgets/dropdown.cpp6
-rw-r--r--src/window.cpp58
-rw-r--r--src/window_func.h1
-rw-r--r--src/window_gui.h4
21 files changed, 86 insertions, 86 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 1e5dbcb70..046ccb1af 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -236,7 +236,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP: {
if (WP(w, def_d).close) {
- DeleteWindow(w);
+ delete w;
return;
}
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index b18582e9b..f3d48b367 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -42,7 +42,7 @@ void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void BuildBridge(Window *w, int i)
{
- DeleteWindow(w);
+ delete w;
DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
_bridgedata.type | _bridgedata.indexes[i], CcBuildBridge,
CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 44b66b125..0d72eeb90 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -280,7 +280,7 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP:
if (WP(w, def_d).close) {
- DeleteWindow(w);
+ delete w;
return;
}
@@ -354,7 +354,7 @@ static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
} break;
case WE_MOUSELOOP:
- if (WP(w, def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) delete w;
break;
case WE_DESTROY:
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index f6d15e3ef..a91c0fb7d 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -96,7 +96,7 @@ static void EnginePreviewWndProc(Window *w, WindowEvent *e)
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
/* Fallthrough */
case 3:
- DeleteWindow(w);
+ delete w;
break;
}
break;
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 0d5f00704..59781f73b 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -342,7 +342,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch (e->we.click.widget) {
- case 0: DeleteWindow(w); break;
+ case 0: delete w; break;
case GLAND_TEMPERATE:
case GLAND_ARCTIC:
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 875de065b..abe07ab1a 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -558,11 +558,11 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- if (_right_button_down) DeleteWindow(w);
+ if (_right_button_down) delete w;
break;
case WE_4:
- if (--_errmsg_duration == 0) DeleteWindow(w);
+ if (--_errmsg_duration == 0) delete w;
break;
case WE_DESTROY:
@@ -575,7 +575,7 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
if (e->we.keypress.keycode == WKC_SPACE) {
/* Don't continue. */
e->we.keypress.cont = false;
- DeleteWindow(w);
+ delete w;
}
break;
}
@@ -711,9 +711,9 @@ static void TooltipsWndProc(Window *w, WindowEvent *e)
/* We can show tooltips while dragging tools. These are shown as long as
* we are dragging the tool. Normal tooltips work with rmb */
if (WP(w, tooltips_d).paramcount == 0 ) {
- if (!_right_button_down) DeleteWindow(w);
+ if (!_right_button_down) delete w;
} else {
- if (!_left_button_down) DeleteWindow(w);
+ if (!_left_button_down) delete w;
}
break;
@@ -1171,7 +1171,7 @@ static void QueryStringWndProc(Window *w, WindowEvent *e)
}
/* Fallthrough */
case QUERY_STR_WIDGET_CANCEL:
- DeleteWindow(w);
+ delete w;
break;
}
break;
@@ -1183,7 +1183,7 @@ static void QueryStringWndProc(Window *w, WindowEvent *e)
case WE_KEYPRESS:
switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) {
case 1: goto press_ok; // Enter pressed, confirms change
- case 2: DeleteWindow(w); break; // ESC pressed, closes window, abandons changes
+ case 2: delete w; break; // ESC pressed, closes window, abandons changes
}
break;
@@ -1296,7 +1296,7 @@ static void QueryWndProc(Window *w, WindowEvent *e)
if (q->proc != NULL) q->proc(w->parent, true);
/* Fallthrough */
case QUERY_WIDGET_NO:
- DeleteWindow(w);
+ delete w;
break;
}
break;
@@ -1310,7 +1310,7 @@ static void QueryWndProc(Window *w, WindowEvent *e)
/* Fallthrough */
case WKC_ESC:
e->we.keypress.cont = false;
- DeleteWindow(w);
+ delete w;
break;
}
break;
@@ -1581,13 +1581,13 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
- DeleteWindow(w);
+ delete w;
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
SetFiosType(file->type);
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
- DeleteWindow(w);
+ delete w;
ShowHeightmapLoad();
} else {
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
@@ -1620,7 +1620,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
case WE_KEYPRESS:
if (e->we.keypress.keycode == WKC_ESC) {
- DeleteWindow(w);
+ delete w;
return;
}
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index fdfe1f870..0629b5ede 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -869,7 +869,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
ttd_strlcpy(_file_to_saveload.title, nd->map->title, sizeof(_file_to_saveload.title));
- DeleteWindow(w);
+ delete w;
SwitchMode(SM_START_SCENARIO);
}
}
@@ -879,7 +879,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
_is_network_server = true;
/* XXX - WC_NETWORK_WINDOW (this window) should stay, but if it stays, it gets
* copied all the elements of 'load game' and upon closing that, it segfaults */
- DeleteWindow(w);
+ delete w;
ShowSaveLoadDialog(SLD_LOAD_GAME);
break;
}
@@ -1672,7 +1672,7 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
if (e->we.click.widget == 2) { //Disconnect button
NetworkDisconnect();
- DeleteWindow(w);
+ delete w;
SwitchMode(SM_MENU);
ShowNetworkGameWindow();
}
@@ -1891,7 +1891,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
case 3: /* Send */
SendChat(WP(w, chatquerystr_d).text.buf, WP(w, chatquerystr_d).dtype, WP(w, chatquerystr_d).dest);
/* FALLTHROUGH */
- case 0: /* Cancel */ DeleteWindow(w); break;
+ case 0: /* Cancel */ delete w; break;
}
break;
@@ -1908,7 +1908,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
case 1: /* Return */
SendChat(WP(w, chatquerystr_d).text.buf, WP(w, chatquerystr_d).dtype, WP(w, chatquerystr_d).dest);
/* FALLTHROUGH */
- case 2: /* Escape */ DeleteWindow(w); break;
+ case 2: /* Escape */ delete w; break;
}
}
break;
@@ -1987,7 +1987,7 @@ static void NetworkCompanyPasswordWindowWndProc(Window *w, WindowEvent *e)
/* FALL THROUGH */
case NCPWW_CANCEL:
- DeleteWindow(w);
+ delete w;
break;
case NCPWW_SAVE_AS_DEFAULT_PASSWORD:
@@ -2013,7 +2013,7 @@ static void NetworkCompanyPasswordWindowWndProc(Window *w, WindowEvent *e)
break;
case 2: // Escape
- DeleteWindow(w);
+ delete w;
break;
}
break;
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 7fbb4b147..5f1b9a86b 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -195,7 +195,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case 1: {
NewsItem *ni = WP(w, news_d).ni;
- DeleteWindow(w);
+ delete w;
ni->duration = 0;
_forced_news = INVALID_NEWS;
break;
@@ -227,7 +227,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
if (e->we.keypress.keycode == WKC_SPACE) {
/* Don't continue. */
e->we.keypress.cont = false;
- DeleteWindow(w);
+ delete w;
}
break;
diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp
index c2b3b3bbf..290e377b2 100644
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -164,7 +164,7 @@ static void OskWndProc(Window *w, WindowEvent *e)
parent->HandleWindowEvent(&e);
}
}
- DeleteWindow(w);
+ delete w;
break;
case OSK_WIDGET_CANCEL:
@@ -179,7 +179,7 @@ static void OskWndProc(Window *w, WindowEvent *e)
UpdateTextBufferSize(&qs->text);
MoveTextBufferPos(&qs->text, WKC_END);
}
- DeleteWindow(w);
+ delete w;
break;
}
/* make sure that the parent window's textbox also gets updated */
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 76670fbec..dd7c6298e 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -197,7 +197,7 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
int oldleft = w->left; ///< current left position of the window before closing it
PlayerID player = (PlayerID)w->window_number;
- DeleteWindow(w);
+ delete w;
/* Open up the (toggled size) Finance window at the same position as the previous */
DoShowPlayerFinances(player, !HasBit(mode, 0), stickied, oldtop, oldleft);
}
@@ -871,20 +871,20 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
int oldleft = w->left; ///< current top position of the window before closing it
DoCommandP(0, 0, *pf, NULL, CMD_SET_PLAYER_FACE);
- DeleteWindow(w);
+ delete w;
/* Open up the (toggled size) Face selection window at the same position as the previous */
DoSelectPlayerFace((PlayerID)w->window_number, !WP(w, facesel_d).advanced, oldtop, oldleft);
} break;
/* Cancel button */
case PFW_WIDGET_CANCEL:
- DeleteWindow(w);
+ delete w;
break;
/* OK button */
case PFW_WIDGET_ACCEPT:
DoCommandP(0, 0, *pf, NULL, CMD_SET_PLAYER_FACE);
- DeleteWindow(w);
+ delete w;
break;
/* Load button */
@@ -1379,7 +1379,7 @@ static void BuyCompanyWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch (e->we.click.widget) {
case 3:
- DeleteWindow(w);
+ delete w;
break;
case 4: {
DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
@@ -1464,7 +1464,7 @@ static void EndGameWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: /* Close the window (and show the highscore window) */
- DeleteWindow(w);
+ delete w;
break;
case WE_DESTROY: /* Show the highscore window when this one is closed */
@@ -1505,7 +1505,7 @@ static void HighScoreWndProc(Window *w, WindowEvent *e)
} break;
case WE_CLICK: /* Onclick to close window, and in destroy event handle the rest */
- DeleteWindow(w);
+ delete w;
break;
case WE_DESTROY: /* Get back all the hidden windows */
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 840bf8062..fab382325 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1128,7 +1128,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP:
if (WP(w, def_d).close) {
- DeleteWindow(w);
+ delete w;
return;
}
CheckRedrawStationCoverage(w);
@@ -1352,7 +1352,7 @@ static void SignalBuildWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- if (WP(w, def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) delete w;
return;
case WE_DESTROY:
@@ -1443,7 +1443,7 @@ static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- if (WP(w, def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) delete w;
return;
case WE_DESTROY:
@@ -1542,7 +1542,7 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e)
}
case WE_MOUSELOOP:
- if (WP(w, def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) delete w;
break;
case WE_DESTROY:
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 05a7fd55f..30400f606 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -767,7 +767,7 @@ static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- if (WP(w, def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) delete w;
break;
case WE_DESTROY:
@@ -925,7 +925,7 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP:
if (WP(w, def_d).close) {
- DeleteWindow(w);
+ delete w;
return;
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index fa829ce67..c20caa85f 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -642,7 +642,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
}
DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
- DeleteWindow(w);
+ delete w;
/* If we are in the editor, we should reload the economy.
* This way when you load a game, the max loan and interest rate
* are loaded correctly. */
@@ -651,7 +651,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
}
case GDW_CANCEL: // Cancel button - close window, abandon changes
- DeleteWindow(w);
+ delete w;
break;
} break;
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index f4cf33070..2f1da2419 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -246,7 +246,7 @@ static void QuerySignEditWndProc(Window *w, WindowEvent *e)
/* FALL THROUGH */
case QUERY_EDIT_SIGN_WIDGET_CANCEL:
- DeleteWindow(w);
+ delete w;
break;
}
break;
@@ -258,7 +258,7 @@ static void QuerySignEditWndProc(Window *w, WindowEvent *e)
/* FALL THROUGH */
case 2: // ESC pressed, closes window, abandons changes
- DeleteWindow(w);
+ delete w;
break;
}
break;
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 454e4a4d0..8323592d6 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1142,7 +1142,7 @@ static void MenuWndProc(Window *w, WindowEvent *e)
}
int action_id = WP(w, menu_d).action_id;
- DeleteWindow(w);
+ delete w;
if (index >= 0) {
assert((uint)index <= lengthof(_menu_clicked_procs));
@@ -1347,7 +1347,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
index = WP(w, menu_d).sel_index;
}
- DeleteWindow(w);
+ delete w;
if (index >= 0) {
assert(index >= 0 && index < 30);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 41844cae3..0ac6f657c 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1347,8 +1347,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
if (v == first && IsFrontEngine(first)) {
- w = FindWindowById(WC_VEHICLE_VIEW, first->index);
- if (w != NULL) DeleteWindow(w);
+ delete FindWindowById(WC_VEHICLE_VIEW, first->index);
}
InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
RebuildVehicleLists();
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index a99c8cf16..35456cbc4 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -398,9 +398,9 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
}
- if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
+ if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8, NULL, command)) delete w;
} else {
- if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w);
+ if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) delete w;
}
}
break;
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index ea2d3a5f5..5eb79e9f7 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -172,7 +172,7 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e)
case WE_MOUSELOOP: {
Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
if (w2 == NULL) {
- DeleteWindow(w);
+ delete w;
return;
}
@@ -182,7 +182,7 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e)
e.we.dropdown.button = WP(w, dropdown_d).parent_button;
e.we.dropdown.index = WP(w, dropdown_d).selected_index;
w2->HandleWindowEvent(&e);
- DeleteWindow(w);
+ delete w;
return;
}
@@ -362,7 +362,7 @@ void HideDropDownMenu(Window *pw)
if (pw->window_class == WP(*wz, dropdown_d).parent_wnd_class &&
pw->window_number == WP(*wz, dropdown_d).parent_wnd_num) {
- DeleteWindow(*wz);
+ delete *wz;
break;
}
}
diff --git a/src/window.cpp b/src/window.cpp
index 8737ba1e8..649f79100 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -170,7 +170,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
if (w->desc_flags & WDF_STD_BTN) {
if (e.we.click.widget == 0) { /* 'X' */
- DeleteWindow(w);
+ delete w;
return;
}
@@ -369,10 +369,19 @@ void CallWindowEventNP(Window *w, int event)
* @param w Window to redraw
* @ingroup dirty
*/
+void Window::SetDirty() const
+{
+ SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height);
+}
+
+/**
+ * Mark entire window as dirty (in need of re-paint)
+ * @param w Window to redraw
+ * @ingroup dirty
+ */
void SetWindowDirty(const Window *w)
{
- if (w == NULL) return;
- SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height);
+ if (w != NULL) w->SetDirty();
}
/** Find the Window whose parent pointer points to this window
@@ -410,44 +419,35 @@ Window **FindWindowZPosition(const Window *w)
/**
* Remove window and all its child windows from the window stack.
- * @param w Window to delete
*/
-void DeleteWindow(Window *w)
+Window::~Window()
{
- if (w == NULL) return;
-
if (_thd.place_mode != VHM_NONE &&
- _thd.window_class == w->window_class &&
- _thd.window_number == w->window_number) {
+ _thd.window_class == this->window_class &&
+ _thd.window_number == this->window_number) {
ResetObjectToPlace();
}
/* Prevent Mouseover() from resetting mouse-over coordinates on a non-existing window */
- if (_mouseover_last_w == w) _mouseover_last_w = NULL;
+ if (_mouseover_last_w == this) _mouseover_last_w = NULL;
/* Find the window in the z-array, and effectively remove it
* by moving all windows after it one to the left. This must be
* done before removing the child so we cannot cause recursion
* between the deletion of the parent and the child. */
- Window **wz = FindWindowZPosition(w);
+ Window **wz = FindWindowZPosition(this);
if (wz == NULL) return;
memmove(wz, wz + 1, (byte*)_last_z_window - (byte*)wz);
_last_z_window--;
/* Delete any children a window might have in a head-recursive manner */
- Window *v = FindChildWindow(w);
- if (v != NULL) DeleteWindow(v);
-
- CallWindowEventNP(w, WE_DESTROY);
- if (w->viewport != NULL) DeleteWindowViewport(w);
+ delete FindChildWindow(this);
- SetWindowDirty(w);
- free(w->widget);
- w->widget = NULL;
- w->widget_count = 0;
- w->parent = NULL;
+ CallWindowEventNP(this, WE_DESTROY);
+ if (this->viewport != NULL) DeleteWindowViewport(this);
- delete w;
+ this->SetDirty();
+ free(this->widget);
}
/**
@@ -475,7 +475,7 @@ Window *FindWindowById(WindowClass cls, WindowNumber number)
*/
void DeleteWindowById(WindowClass cls, WindowNumber number)
{
- DeleteWindow(FindWindowById(cls, number));
+ delete FindWindowById(cls, number);
}
/**
@@ -493,7 +493,7 @@ restart_search:
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
if (w->window_class == cls) {
- DeleteWindow(w);
+ delete w;
goto restart_search;
}
}
@@ -514,7 +514,7 @@ restart_search:
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
if (w->caption_color == id) {
- DeleteWindow(w);
+ delete w;
goto restart_search;
}
}
@@ -696,7 +696,7 @@ static Window *LocalAllocateWindow(int x, int y, int min_width, int min_height,
if (_last_z_window == endof(_z_windows)) {
w = FindDeletableWindow();
if (w == NULL) w = ForceFindDeletableWindow();
- DeleteWindow(w);
+ delete w;
}
w = new Window(proc);
@@ -1087,7 +1087,7 @@ restart_search:
* anywhere in the z-array. We call DeleteWindow() so that it can properly
* release own alloc'd memory, which otherwise could result in memleaks */
FOR_ALL_WINDOWS(wz) {
- DeleteWindow(*wz);
+ delete *wz;
goto restart_search;
}
@@ -2212,7 +2212,7 @@ restart_search:
w->window_class != WC_TOOLTIPS &&
(w->flags4 & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
- DeleteWindow(w);
+ delete w;
goto restart_search;
}
}
@@ -2236,7 +2236,7 @@ restart_search:
* anywhere in the z-array */
FOR_ALL_WINDOWS(wz) {
if ((*wz)->flags4 & WF_STICKY) {
- DeleteWindow(*wz);
+ delete *wz;
goto restart_search;
}
}
diff --git a/src/window_func.h b/src/window_func.h
index 10e0513df..851d207ce 100644
--- a/src/window_func.h
+++ b/src/window_func.h
@@ -13,7 +13,6 @@ void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int
void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
Window *FindWindowById(WindowClass cls, WindowNumber number);
-void DeleteWindow(Window *w);
void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
void ResizeWindow(Window *w, int x, int y);
diff --git a/src/window_gui.h b/src/window_gui.h
index c0b6d6efa..ae6edabec 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -296,6 +296,7 @@ private:
public:
Window(WindowProc *proc) : wndproc(proc) {}
+ virtual ~Window();
uint16 flags4; ///< Window flags, @see WindowFlags
WindowClass window_class; ///< Window class
@@ -345,6 +346,8 @@ public:
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
void InvalidateWidget(byte widget_index) const;
+ void SetDirty() const;
+
virtual void HandleWindowEvent(WindowEvent *e);
};
@@ -548,7 +551,6 @@ void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int
void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam);
Window *FindWindowById(WindowClass cls, WindowNumber number);
-void DeleteWindow(Window *w);
void DeletePlayerWindows(PlayerID pi);
void ChangeWindowOwner(PlayerID old_player, PlayerID new_player);
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);