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 <http://www.gnu.org/licenses/>.
8 /** @file window_func.h %Window functions not directly related to making/drawing windows. */
13 #include "window_type.h"
14 #include "company_type.h"
15 #include "core/geometry_type.hpp"
16 #include "core/strong_typedef_type.hpp"
18 Window
*FindWindowById(WindowClass cls
, WindowNumber number
);
19 Window
*FindWindowByClass(WindowClass cls
);
20 Window
*GetMainWindow();
21 void ChangeWindowOwner(Owner old_owner
, Owner new_owner
);
23 template<typename T
, std::enable_if_t
<std::is_base_of
<StrongTypedefBase
, T
>::value
, int> = 0>
24 Window
*FindWindowById(WindowClass cls
, T number
)
26 return FindWindowById(cls
, number
.base());
29 void ResizeWindow(Window
*w
, int x
, int y
, bool clamp_to_screen
= true);
30 int PositionMainToolbar(Window
*w
);
31 int PositionStatusbar(Window
*w
);
32 int PositionNewsMessage(Window
*w
);
33 int PositionNetworkChatWindow(Window
*w
);
36 int GetMainViewBottom();
38 void InitWindowSystem();
39 void UnInitWindowSystem();
40 void ResetWindowSystem();
41 void SetupColoursAndInitialWindow();
44 void InvalidateWindowData(WindowClass cls
, WindowNumber number
, int data
= 0, bool gui_scope
= false);
45 void InvalidateWindowClassesData(WindowClass cls
, int data
= 0, bool gui_scope
= false);
47 template<typename T
, std::enable_if_t
<std::is_base_of
<StrongTypedefBase
, T
>::value
, int> = 0>
48 void InvalidateWindowData(WindowClass cls
, T number
, int data
= 0, bool gui_scope
= false)
50 InvalidateWindowData(cls
, number
.base(), data
, gui_scope
);
53 void CloseNonVitalWindows();
54 void CloseAllNonVitalWindows();
55 void DeleteAllMessages();
56 void CloseConstructionWindows();
57 void HideVitalWindows();
58 void ShowVitalWindows();
61 * Re-initialize all windows.
62 * @param zoom_changed Set if windows are being re-initialized due to a zoom level changed.
64 void ReInitAllWindows(bool zoom_changed
);
66 void SetWindowWidgetDirty(WindowClass cls
, WindowNumber number
, WidgetID widget_index
);
67 void SetWindowDirty(WindowClass cls
, WindowNumber number
);
68 void SetWindowClassesDirty(WindowClass cls
);
70 template<typename T
, std::enable_if_t
<std::is_base_of
<StrongTypedefBase
, T
>::value
, int> = 0>
71 void SetWindowDirty(WindowClass cls
, T number
)
73 SetWindowDirty(cls
, number
.base());
76 void CloseWindowById(WindowClass cls
, WindowNumber number
, bool force
= true, int data
= 0);
77 void CloseWindowByClass(WindowClass cls
, int data
= 0);
79 template<typename T
, std::enable_if_t
<std::is_base_of
<StrongTypedefBase
, T
>::value
, int> = 0>
80 void CloseWindowById(WindowClass cls
, T number
, bool force
= true, int data
= 0)
82 CloseWindowById(cls
, number
.base(), force
, data
);
85 bool EditBoxInGlobalFocus();
86 bool FocusedWindowIsConsole();
87 Point
GetCaretPosition();
89 #endif /* WINDOW_FUNC_H */