OpenTTD Source: src/window_func.h Source File

OpenTTD Source 15.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef WINDOW_FUNC_H
11#define WINDOW_FUNC_H
12
13#include "window_type.h"
14#include "company_type.h"
15#include "core/geometry_type.hpp"
16#include "core/strong_typedef_type.hpp"
17
18 Window *FindWindowById(WindowClass cls, WindowNumber number);
19 Window *FindWindowByClass(WindowClass cls);
20 Window *GetMainWindow();
21void ChangeWindowOwner(Owner old_owner, Owner new_owner);
22
23template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
24 Window *FindWindowById(WindowClass cls, T number)
25{
26 return FindWindowById(cls, number.base());
27}
28
29void ResizeWindow(Window *w, int x, int y, bool clamp_to_screen = true, bool schedule_resize = true);
30int PositionMainToolbar(Window *w);
31int PositionStatusbar(Window *w);
32int PositionNewsMessage(Window *w);
33int PositionNetworkChatWindow(Window *w);
34
35int GetMainViewTop();
36int GetMainViewBottom();
37
38void InitWindowSystem();
39void UnInitWindowSystem();
40void ResetWindowSystem();
41void SetupColoursAndInitialWindow();
42void InputLoop();
43
44void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0, bool gui_scope = false);
45void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope = false);
46
47template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
48void InvalidateWindowData(WindowClass cls, T number, int data = 0, bool gui_scope = false)
49{
50 InvalidateWindowData(cls, number.base(), data, gui_scope);
51}
52
53void CloseNonVitalWindows();
54void CloseAllNonVitalWindows();
55void DeleteAllMessages();
56void CloseConstructionWindows();
57void HideVitalWindows();
58void ShowVitalWindows();
59
64void ReInitAllWindows(bool zoom_changed);
65
66void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index);
67void SetWindowDirty(WindowClass cls, WindowNumber number);
68void SetWindowClassesDirty(WindowClass cls);
69
70template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
71void SetWindowDirty(WindowClass cls, T number)
72{
73 SetWindowDirty(cls, number.base());
74}
75
76void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true, int data = 0);
77void CloseWindowByClass(WindowClass cls, int data = 0);
78
79template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
80void CloseWindowById(WindowClass cls, T number, bool force = true, int data = 0)
81{
82 CloseWindowById(cls, number.base(), force, data);
83}
84
85bool EditBoxInGlobalFocus();
86bool FocusedWindowIsConsole();
87 Point GetCaretPosition();
88
89#endif /* WINDOW_FUNC_H */
company_type.h
Types related to companies.
Owner
Owner
Enum for all companies/owners.
Definition company_type.h:18
geometry_type.hpp
All geometry types in OpenTTD.
strong_typedef_type.hpp
Type (helpers) for making a strong typedef that is a distinct type.
Point
Coordinates of a point in 2D.
Definition geometry_type.hpp:21
Window
Data structure for an opened window.
Definition window_gui.h:273
PositionStatusbar
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
Definition window.cpp:3401
CloseConstructionWindows
void CloseConstructionWindows()
Close all windows that are used for construction of vehicle etc.
Definition window.cpp:3305
ShowVitalWindows
void ShowVitalWindows()
Show the vital in-game windows.
Definition main_gui.cpp:575
GetMainWindow
Window * GetMainWindow()
Get the main window, i.e.
Definition window.cpp:1127
InputLoop
void InputLoop()
Regular call from the global game loop.
Definition window.cpp:2993
PositionMainToolbar
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition window.cpp:3390
CloseNonVitalWindows
void CloseNonVitalWindows()
Try to close a non-vital window.
Definition window.cpp:3261
PositionNetworkChatWindow
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
Definition window.cpp:3423
SetupColoursAndInitialWindow
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
Definition main_gui.cpp:546
FindWindowByClass
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition window.cpp:1113
InvalidateWindowClassesData
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:3236
DeleteAllMessages
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
Definition window.cpp:3293
GetMainViewTop
int GetMainViewTop()
Return the top of the main view available for general use.
Definition window.cpp:2062
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition window.cpp:3335
PositionNewsMessage
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
Definition window.cpp:3412
GetMainViewBottom
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition window.cpp:2073
ChangeWindowOwner
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:1188
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition window.cpp:3127
FocusedWindowIsConsole
bool FocusedWindowIsConsole()
Check if a console is focused.
Definition window.cpp:462
ResetWindowSystem
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
Definition window.cpp:1818
EditBoxInGlobalFocus
bool EditBoxInGlobalFocus()
Check if an edit box is in global focus.
Definition window.cpp:448
InvalidateWindowData
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:3219
HideVitalWindows
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
Definition window.cpp:3318
ResizeWindow
void ResizeWindow(Window *w, int x, int y, bool clamp_to_screen=true, bool schedule_resize=true)
Resize the window.
Definition window.cpp:2022
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data=0)
Close all windows of a given class.
Definition window.cpp:1152
CloseAllNonVitalWindows
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition window.cpp:3280
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1098
UnInitWindowSystem
void UnInitWindowSystem()
Close down the windowing system.
Definition window.cpp:1804
CloseWindowById
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:1140
InitWindowSystem
void InitWindowSystem()
(re)initialize the windowing system
Definition window.cpp:1782
SetWindowWidgetDirty
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:3114
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition window.cpp:3101
window_type.h
Types related to windows.
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:18
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition window_type.h:740
WindowClass
WindowClass
Window classes.
Definition window_type.h:44