# window_func.h File Reference

Window functions not directly related to making/drawing windows. More...

`#include "window_type.h"`
`#include "company_type.h"`

Go to the source code of this file.

## Functions
void | SetWindowDirty (const Window *w)
| Mark entire window as dirty (in need of re-paint).
Window * | FindWindowById (WindowClass cls, WindowNumber number)
| Find a window by its class and window number.
void | ChangeWindowOwner (Owner old_owner, Owner new_owner)
| Change the owner of all the windows one company can take over from another company in the case of a company merger.
void | ResizeWindow (Window *w, int x, int y)
| Resize the window.
int | PositionMainToolbar (Window *w)
| (Re)position main toolbar window at the screen
void | InitWindowSystem ()
| (re)initialize the windowing system
void | UnInitWindowSystem ()
| Close down the windowing system.
void | ResetWindowSystem ()
| Reset the windowing system, by means of shutting it down followed by re-initialization.
void | SetupColoursAndInitialWindow ()
void | InputLoop ()
| Regular call from the global game loop.
void | InvalidateThisWindowData (Window *w, int data=0)
| Mark window data as invalid (in need of re-computing).
void | InvalidateWindowData (WindowClass cls, WindowNumber number, int data=0)
| Mark window data of the window of a given class and specific window number as invalid (in need of re-computing).
void | InvalidateWindowClassesData (WindowClass cls, int data=0)
| Mark window data of all windows of a given class as invalid (in need of re-computing).
void | DeleteNonVitalWindows ()
| Try to delete a non-vital window.
void | DeleteAllNonVitalWindows ()
| It is possible that a stickied window gets to a position where the 'close' button is outside the gaming area.
void | DeleteConstructionWindows ()
| Delete all windows that are used for construction of vehicle etc.
void | HideVitalWindows ()
| Delete all always on-top windows to get an empty screen.
void | ShowVitalWindows ()
void | InvalidateWindowWidget (WindowClass cls, WindowNumber number, byte widget_index)
| Mark a particular widget in a particular window as dirty (in need of repainting).
void | InvalidateWindow (WindowClass cls, WindowNumber number)
| Mark window as dirty (in need of repainting).
void | InvalidateWindowClasses (WindowClass cls)
| Mark all windows of a particular class as dirty (in need of repainting).
void | DeleteWindowById (WindowClass cls, WindowNumber number, bool force=true)
| Delete a window by its class and window number (if it is open).
void | DeleteWindowByClass (WindowClass cls)
| Delete all windows of a given class.

## Detailed Description

Window functions not directly related to making/drawing windows.

Definition in file window_func.h.

## Function Documentation

void ChangeWindowOwner | ( | Owner | old_owner,
|  | Owner | new_owner |
| ) |  |  |

Change the owner of all the windows one company can take over from another company in the case of a company merger.

Do not change ownership of windows that need to be deleted once takeover is complete

Parameters:

  | old_owner | original owner of the window
  | new_owner | the new owner of the window

Definition at line 626 of file window.cpp.

References Window::owner, and Window::window_class.

void DeleteAllNonVitalWindows | ( |  | ) |

It is possible that a stickied window gets to a position where the 'close' button is outside the gaming area.

You cannot close it then; except 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

Definition at line 2260 of file window.cpp.

References DeleteNonVitalWindows(), Window::flags4, and WF_STICKY.

Referenced by GenerateWorld().

void DeleteConstructionWindows | ( |  | ) |

Delete all windows that are used for construction of vehicle etc.

Once done with that invalidate the others to ensure they get refreshed too.

Definition at line 2283 of file window.cpp.

References Window::desc_flags, Window::SetDirty(), and WDF_CONSTRUCTION.

Referenced by SetLocalCompany().

void DeleteNonVitalWindows | ( |  | ) |

Try to delete a non-vital window.

Non-vital windows are windows other than the game selection, main toolbar, status bar, toolbar menu, and tooltip windows. Stickied windows are also considered vital.

Definition at line 2232 of file window.cpp.

References Window::flags4, WF_STICKY, and Window::window_class.

Referenced by DeleteAllNonVitalWindows().

void DeleteWindowByClass | ( | WindowClass | cls | ) |

Delete all windows of a given class.

Parameters:

  | cls | Window class of windows to delete

Definition at line 582 of file window.cpp.

References Window::window_class.

Referenced by NewGRFWindow::OnClick(), NewGRFAddWindow::OnClick(), ShowBuildRailToolbar(), ShowEndGameChart(), ShowHighscoreTable(), and ShowNewGRFSettings().

void DeleteWindowById | ( | WindowClass | cls,
|  | WindowNumber | number,
|  | bool | force |
| ) |  |  |

Delete a window by its class and window number (if it is open).

Parameters:

  | cls | Window class
  | number | Number of the window within the window class
  | force | force deletion; if false don't delete when stickied

Definition at line 568 of file window.cpp.

References Window::desc_flags, FindWindowById(), Window::flags4, WDF_STICKY_BUTTON, and WF_STICKY.

Referenced by _GenerateWorld(), CmdCompanyCtrl(), CmdDeleteGroup(), CmdMoveRailVehicle(), CmdSellRailWagon(), DeleteCompanyWindows(), DispatchLeftClickEvent(), GuiShowTooltips(), HandleGeneratingWorldAbortion(), HideVitalWindows(), MoveToNextItem(), BuildRailToolbarWindow::OnPlaceObjectAbort(), ShowBuildBridgeWindow(), ShowDropDownList(), ShowMessageHistory(), ShowNewsMessage(), ShowOnScreenKeyboard(), ShowQueryString(), ShowVehicleDetailsWindow(), ShowVehicleRefitWindow(), StartWindowDrag(), StartWindowSizing(), ToggleRailButton_Remove(), and Station::~Station().

Window* FindWindowById | ( | WindowClass | cls,
|  | WindowNumber | number |
| ) |  |  |

Find a window by its class and window number.

Parameters:

  | cls | Window class
  | number | Number of the window within the window class

Returns:
  Pointer to the found window, or `NULL` if not available

Definition at line 552 of file window.cpp.

References Window::window_class, and Window::window_number.

Referenced by BringWindowToFrontById(), ChangeVehicleWindow(), ClickChangeDateCheat(), DeleteDepotHighlightOfVehicle(), DeleteGroupHighlightOfVehicle(), DeleteWindowById(), Window::FindWindowPlacementAndResize(), GenerateWorld(), GenericPlaceSignals(), HandleAutoSignalPlacement(), HandleKeypress(), IConsoleGUIPrint(), Window::Initialize(), IsNewsTickerShown(), LocalGetWindowPlacement(), BuildRailToolbarWindow::OnPlaceDrag(), PositionMainToolbar(), ReadyForNextItem(), ReinitGuiAfterToggleElrail(), RelocateAllWindows(), ResetSignalVariant(), SetDefaultRailGui(), ShowBuildRailToolbar(), ShowDropDownList(), ShowLastNewsMessage(), StationJoinerNeeded(), and VpHandlePlaceSizingDrag().

void InvalidateThisWindowData | ( | Window * | w,
|  | int | data |
| ) |  |  |

Mark window data as invalid (in need of re-computing).

Parameters:

  | w | Window with invalid data

Definition at line 2177 of file window.cpp.

References Window::OnInvalidateData(), and Window::SetDirty().

Referenced by ChangeVehicleWindow(), InvalidateWindowClassesData(), and InvalidateWindowData().

void InvalidateWindow | ( | WindowClass | cls,
|  | WindowNumber | number |
| ) |  |  |

Mark window as dirty (in need of repainting).

Parameters:

  | cls | Window class
  | number | Window number in that class

Definition at line 2137 of file window.cpp.

References Window::SetDirty(), Window::window_class, and Window::window_number.

Referenced by AddNewsItem(), AircraftEventHandler_AtTerminal(), ChangePopulation(), ChangeTownRating(), CmdAddVehicleGroup(), CmdAutofillTimetable(), CmdBuildAircraft(), CmdBuildAirport(), CmdBuildCompanyHQ(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuyShareInCompany(), CmdChangeServiceInt(), CmdChangeSetting(), CmdDoTownAction(), CmdMoveRailVehicle(), CmdPause(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), CmdReverseTrainDirection(), CmdSellRailWagon(), CmdSellShareInCompany(), CmdSetAutoReplace(), CmdStartStopVehicle(), DeleteLastWagon(), DeleteNewsItem(), DeliverGoodsToIndustry(), DestroyCompanyHQ(), DoStartupNewCompany(), IndustryProductionCallback(), InvalidateVehicleOrder(), LoadUnloadVehicle(), RemoveOrderFromAllVehicles(), SetLocalCompany(), SetSettingValue(), SetTrainGroupID(), TrainConsistChanged(), TrainPowerChanged(), TriggerIndustryProduction(), UpdateCompanyRatingAndValue(), UpdateTownGrowRate(), and UpdateTrainGroupID().

void InvalidateWindowClasses | ( | WindowClass | cls | ) |

Mark all windows of a particular class as dirty (in need of repainting).

Parameters:

  | cls | Window class

Definition at line 2165 of file window.cpp.

References Window::SetDirty(), and Window::window_class.

Referenced by ClickSetProdCheat(), CmdSkipToOrder(), CmdStartStopVehicle(), and ProcessOrders().

void InvalidateWindowClassesData | ( | WindowClass | cls,
|  | int | data |
| ) |  |  |

Mark window data of all windows of a given class as invalid (in need of re-computing).

Parameters:

  | cls | Window class

Definition at line 2200 of file window.cpp.

References InvalidateThisWindowData(), and Window::window_class.

Referenced by AddRemoveEngineFromAutoreplaceAndBuildWindows(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRoadVeh(), CmdBuildShip(), CmdCloneOrder(), CmdDeleteOrder(), CmdInsertOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), CmdRenameVehicle(), CmdSellRailWagon(), and DecloneOrder().

void InvalidateWindowData | ( | WindowClass | cls,
|  | WindowNumber | number,
|  | int | data |
| ) |  |  |

Mark window data of the window of a given class and specific window number as invalid (in need of re-computing).

Parameters:

  | cls | Window class
  | number | Window number within the class

Definition at line 2188 of file window.cpp.

References InvalidateThisWindowData(), Window::window_class, and Window::window_number.

Referenced by AddRemoveEngineFromAutoreplaceAndBuildWindows(), ChangePopulation(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdBuildAircraft(), CmdBuildAirport(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRailroadStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadStop(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuildTrainWaypoint(), CmdCompanyCtrl(), CmdConvertRail(), CmdCreateGroup(), CmdDeleteGroup(), CmdMoveRailVehicle(), CmdPlaceSign(), CmdRemoveAllVehiclesGroup(), CmdRenameGroup(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdSetGroupReplaceProtection(), DeleteStationIfEmpty(), DoCreateTown(), IndustryDailyLoop(), InvalidateAutoreplaceWindow(), InvalidateVehicleOrder(), AILog::Log(), MoveToNextItem(), NewGRFAddWindow::OnClick(), ReloadNewGRFData(), SaveFileDone(), SaveFileStart(), ShowTicker(), VehicleEnter_Track(), and Station::~Station().

void InvalidateWindowWidget | ( | WindowClass | cls,
|  | WindowNumber | number,
|  | byte | widget_index |
| ) |  |  |

Mark a particular widget in a particular window as dirty (in need of repainting).

Parameters:

  | cls | Window class
  | number | Window number in that class
  | widget_index | Index number of the widget that needs repainting

Definition at line 2151 of file window.cpp.

References Window::InvalidateWidget(), Window::window_class, and Window::window_number.

Referenced by CmdBuildAirport(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRailroadStation(), CmdBuildRoadStop(), CmdMoveRailVehicle(), CmdRemoveFromRailroadStation(), CmdStartStopVehicle(), Station::MarkDirty(), MarkTrainAsStuck(), RemoveRoadStop(), TrainPowerChanged(), TryPathReserve(), UpdateAircraftSpeed(), and UpdateStationAcceptance().

int PositionMainToolbar | ( | Window * | w | ) |

(Re)position main toolbar window at the screen

Parameters:

  | w | Window structure of the main toolbar window, may also be `NULL`

Returns:
  X coordinate of left edge of the repositioned toolbar window

Definition at line 2314 of file window.cpp.

References _settings_client, FindWindowById(), ClientSettings::gui, Window::height, Window::left, SetDirtyBlocks(), GUISettings::toolbar_pos, Window::width, and Window::window_class.

Referenced by RelocateAllWindows().

void ResizeWindow | ( | Window * | w,
|  | int | x,
|  | int | y |
| ) |  |  |

Resize the window.

Update all the widgets of a window based on their resize flags Both the areas of the old window and the new sized window are set dirty ensuring proper redrawal.

Parameters:

  | w | Window to resize
  | x | delta x-size of changed window (positive if larger, etc.)
  | y | delta y-size of changed window

Definition at line 1307 of file window.cpp.

References GB(), Window::height, RESIZE_BOTTOM, RESIZE_LEFT, RESIZE_NONE, RESIZE_RIGHT, RESIZE_TOP, Window::SetDirty(), Widget::type, Window::widget, Window::width, and WWT_LAST.

Referenced by Window::FindWindowPlacementAndResize(), and RelocateAllWindows().