mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-01 03:48:43 +00:00
(svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
This commit is contained in:
parent
46a0ebe1d9
commit
e6c944a6c4
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -364,6 +364,16 @@ void CallWindowEventNP(Window *w, int event)
|
||||
w->HandleWindowEvent(&e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark entire window as dirty (in need of re-paint)
|
||||
* @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
|
||||
@ -371,8 +381,7 @@ void CallWindowEventNP(Window *w, int event)
|
||||
*/
|
||||
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);
|
||||
delete FindChildWindow(this);
|
||||
|
||||
CallWindowEventNP(w, WE_DESTROY);
|
||||
if (w->viewport != NULL) DeleteWindowViewport(w);
|
||||
CallWindowEventNP(this, WE_DESTROY);
|
||||
if (this->viewport != NULL) DeleteWindowViewport(this);
|
||||
|
||||
SetWindowDirty(w);
|
||||
free(w->widget);
|
||||
w->widget = NULL;
|
||||
w->widget_count = 0;
|
||||
w->parent = NULL;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user