OpenTTD Source 20260801-master-g0de95fb529
window_func.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef WINDOW_FUNC_H
11#define WINDOW_FUNC_H
12
13#include "window_type.h"
14#include "company_type.h"
16#include "strings_type.h"
17
18Window *FindWindowById(WindowClass cls, WindowNumber number);
19Window *FindWindowByClass(WindowClass cls);
21void ChangeWindowOwner(Owner old_owner, Owner new_owner);
22
23void ResizeWindow(Window *w, int x, int y, bool clamp_to_screen = true, bool schedule_resize = true);
28
29int GetMainViewTop();
31
32void InitWindowSystem();
36void InputLoop();
37
38void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0, bool gui_scope = false);
40void InvalidateWindowData(WindowClass cls, WindowNumber number, ConvertibleThroughBase auto data, bool gui_scope = false) { InvalidateWindowData(cls, number, data.base(), gui_scope); }
42template <typename T> requires is_scoped_enum_v<T>
43void InvalidateWindowData(WindowClass cls, WindowNumber number, T data, bool gui_scope = false) { InvalidateWindowData(cls, number, to_underlying(data), gui_scope); }
44void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope = false);
46void InvalidateWindowClassesData(WindowClass cls, ConvertibleThroughBase auto data, bool gui_scope = false) { InvalidateWindowClassesData(cls, data.base(), gui_scope); }
48template <typename T> requires is_scoped_enum_v<T>
49void InvalidateWindowClassesData(WindowClass cls, T data, bool gui_scope = false) { InvalidateWindowClassesData(cls, to_underlying(data), gui_scope); }
50
55void HideVitalWindows();
56void ShowVitalWindows();
57
62void ReInitAllWindows(bool zoom_changed);
63
64void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index);
65void SetWindowDirty(WindowClass cls, WindowNumber number);
66void SetWindowClassesDirty(WindowClass cls);
67
68void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true, int data = 0);
69void CloseWindowByClass(WindowClass cls, int data = 0);
70
73Point GetCaretPosition();
74
81constexpr StringID operator+(StringID string, WindowNumber window_number) noexcept { return string + static_cast<int32_t>(window_number); }
82
83#endif /* WINDOW_FUNC_H */
Types related to companies.
A type is considered 'convertible through base()' when it has a 'base()' function that returns someth...
#define T
Climate temperate.
Definition engines.h:91
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
constexpr bool is_scoped_enum_v
Implementation of std::is_scoped_enum_v (from C++23).
Definition enum_type.hpp:24
All geometry types in OpenTTD.
#define Point
Macro that prevents name conflicts between included headers.
Types related to strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:273
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
Definition window.cpp:3501
void CloseConstructionWindows()
Close all windows that are used for construction of vehicle etc.
Definition window.cpp:3405
void ShowVitalWindows()
Show the vital in-game windows.
Definition main_gui.cpp:583
Window * GetMainWindow()
Get the main window, i.e.
Definition window.cpp:1190
void InputLoop()
Regular call from the global game loop.
Definition window.cpp:3078
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition window.cpp:3490
void CloseNonVitalWindows()
Try to close a non-vital window.
Definition window.cpp:3361
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
Definition window.cpp:3523
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
Definition main_gui.cpp:554
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition window.cpp:1176
void InvalidateWindowClassesData(WindowClass cls, int data=0, bool gui_scope=false)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition window.cpp:3336
constexpr StringID operator+(StringID string, WindowNumber window_number) noexcept
Adding a window number to a string is a common occurence to get the caption for a vehicle type.
Definition window_func.h:81
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
Definition window.cpp:3393
int GetMainViewTop()
Return the top of the main view available for general use.
Definition window.cpp:2148
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition window.cpp:3435
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
Definition window.cpp:3512
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition window.cpp:2159
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 c...
Definition window.cpp:1253
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting).
Definition window.cpp:3226
bool FocusedWindowIsConsole()
Check if a console is focused.
Definition window.cpp:470
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
Definition window.cpp:1903
bool EditBoxInGlobalFocus()
Check if an edit box is in global focus.
Definition window.cpp:456
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data=0, bool gui_scope=false)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition window.cpp:3318
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
Definition window.cpp:3418
void ResizeWindow(Window *w, int x, int y, bool clamp_to_screen=true, bool schedule_resize=true)
Resize the window.
Definition window.cpp:2108
void CloseWindowByClass(WindowClass cls, int data=0)
Close all windows of a given class.
Definition window.cpp:1217
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition window.cpp:3380
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1161
void UnInitWindowSystem()
Close down the windowing system.
Definition window.cpp:1889
void CloseWindowById(WindowClass cls, WindowNumber number, bool force=true, int data=0)
Close a window by its class and window number (if it is open).
Definition window.cpp:1204
void InitWindowSystem()
(re)initialize the windowing system
Definition window.cpp:1867
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting).
Definition window.cpp:3212
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting).
Definition window.cpp:3196
Types related to windows.
int WidgetID
Widget ID.
Definition window_type.h:21