OpenTTD Source: WindowDesc Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes
WindowDesc Struct Reference

High level window description. More...

`#include <window_gui.h>`

## Public Member Functions
| WindowDesc (WindowPosition default_pos, std::string_view ini_key, int16_t def_width_trad, int16_t def_height_trad, WindowClass window_class, WindowClass parent_class, WindowDefaultFlags flags, const std::span< const NWidgetPart > nwid_parts, HotkeyList *hotkeys=nullptr, const std::source_location location=std::source_location::current())
| Window description constructor.
int16_t | GetDefaultWidth () const
| Determine default width of window.
int16_t | GetDefaultHeight () const
| Determine default height of window.

## Static Public Member Functions
static void | LoadFromConfig ()
| Load all WindowDesc settings from _windows_file.
static void | SaveToConfig ()
| Save all WindowDesc settings to _windows_file.

## Data Fields
const std::source_location | source_location
| Source location of this definition.
const WindowPosition | default_pos
| Preferred position of the window.
const WindowClass | cls
| Class of the window,.
const WindowClass | parent_cls
| Class of the parent window.
const std::string_view | ini_key
| Key to store window defaults in openttd.cfg. An empty string if nothing shall be stored.
const WindowDefaultFlags | flags
| Flags.
const std::span< const NWidgetPart > | nwid_parts
| Span of nested widget parts describing the window.
const HotkeyList * | hotkeys
| Hotkeys for the window.
bool | pref_sticky = false
| Preferred stickyness.
int16_t | pref_width = 0
| User-preferred width of the window. Zero if unset.
int16_t | pref_height = 0
| User-preferred height of the window. Zero if unset.

## Private Member Functions
| WindowDesc (const WindowDesc &)=delete
| Delete copy constructor to prevent compilers from copying the structure, which fails due to _window_descs.
WindowDesc & | operator= (const WindowDesc &)=delete

## Private Attributes
const int16_t | default_width_trad
| Preferred initial width of the window (pixels at 1x zoom).
const int16_t | default_height_trad
| Preferred initial height of the window (pixels at 1x zoom).

## Detailed Description

High level window description.

Definition at line 168 of file window_gui.h.

## Constructor & Destructor Documentation

## ◆ WindowDesc()

WindowDesc::WindowDesc | ( | WindowPosition | default_pos,
|  | std::string_view | ini_key,
|  | int16_t | def_width_trad,
|  | int16_t | def_height_trad,
|  | WindowClass | window_class,
|  | WindowClass | parent_class,
|  | WindowDefaultFlags | flags,
|  | const std::span< const NWidgetPart > | nwid_parts,
|  | HotkeyList * | hotkeys = `nullptr`,
|  | const std::source_location | location = `std::source_location::current()`
| ) |  |

Window description constructor.

Definition at line 108 of file window.cpp.

References _window_descs.

## ◆ ~WindowDesc()

WindowDesc::~WindowDesc | ( |  | ) |

Definition at line 127 of file window.cpp.

## Member Function Documentation

## ◆ GetDefaultHeight()

int16_t WindowDesc::GetDefaultHeight | ( |  | ) | const

Determine default height of window.

This is either a stored user preferred size, or the built-in default.

Returns
  Height in pixels.

Definition at line 147 of file window.cpp.

References default_height_trad, pref_height, and ScaleGUITrad().

Referenced by DispatchLeftClickEvent(), and LocalGetWindowPlacement().

## ◆ GetDefaultWidth()

int16_t WindowDesc::GetDefaultWidth | ( |  | ) | const

Determine default width of window.

This is either a stored user preferred size, or the built-in default.

Returns
  Width in pixels.

Definition at line 137 of file window.cpp.

References default_width_trad, pref_width, and ScaleGUITrad().

Referenced by DispatchLeftClickEvent(), Window::FinishInitNested(), LocalGetWindowPlacement(), and Window::ReInit().

## ◆ LoadFromConfig()

void WindowDesc::LoadFromConfig | ( |  | ) |
| static

Load all WindowDesc settings from _windows_file.

Definition at line 155 of file window.cpp.

References _window_descs, _windows_file, IniLoadWindowSettings(), IniLoadFile::LoadFromDisk(), and NO_DIRECTORY.

Referenced by AfterNewGRFScan::OnNewGRFsScanned().

## ◆ SaveToConfig()

void WindowDesc::SaveToConfig | ( |  | ) |
| static

Save all WindowDesc settings to _windows_file.

Definition at line 176 of file window.cpp.

References _window_descs, _windows_file, DescSorter(), IniSaveWindowSettings(), IniLoadFile::LoadFromDisk(), NO_DIRECTORY, and IniFile::SaveToDisk().

## Field Documentation

## ◆ cls

const WindowClass WindowDesc::cls

Class of the window,.

See also
  WindowClass.

Definition at line 179 of file window_gui.h.

Referenced by AllocateWindowDescFront(), and Window::InitializeData().

## ◆ default_height_trad

const int16_t WindowDesc::default_height_trad
| private

Preferred initial height of the window (pixels at 1x zoom).

Definition at line 198 of file window_gui.h.

Referenced by GetDefaultHeight().

## ◆ default_pos

const WindowPosition WindowDesc::default_pos

Preferred position of the window.

See also
  WindowPosition()

Definition at line 178 of file window_gui.h.

Referenced by Window::InitializeData(), and LocalGetWindowPlacement().

## ◆ default_width_trad

const int16_t WindowDesc::default_width_trad
| private

Preferred initial width of the window (pixels at 1x zoom).

Definition at line 197 of file window_gui.h.

Referenced by GetDefaultWidth().

## ◆ flags

const WindowDefaultFlags WindowDesc::flags

Flags.

See also
  WindowDefaultFlag

Definition at line 182 of file window_gui.h.

Referenced by CloseAllNonVitalWindows(), CloseConstructionWindows(), CloseNonVitalWindows(), DispatchLeftClickEvent(), DispatchRightClickEvent(), and MaybeBringWindowToFront().

## ◆ hotkeys

const HotkeyList* WindowDesc::hotkeys

Hotkeys for the window.

Definition at line 184 of file window_gui.h.

Referenced by HandleKeypress(), and HandleToolbarHotkey().

## ◆ ini_key

const std::string_view WindowDesc::ini_key

Key to store window defaults in openttd.cfg. An empty string if nothing shall be stored.

Definition at line 181 of file window_gui.h.

Referenced by DescSorter().

## ◆ nwid_parts

const std::span<const NWidgetPart> WindowDesc::nwid_parts

Span of nested widget parts describing the window.

Definition at line 183 of file window_gui.h.

Referenced by Window::CreateNestedTree().

## ◆ parent_cls

const WindowClass WindowDesc::parent_cls

Class of the parent window.

See also
  WindowClass

Definition at line 180 of file window_gui.h.

Referenced by LocalGetWindowPlacement().

## ◆ pref_height

int16_t WindowDesc::pref_height = 0

User-preferred height of the window. Zero if unset.

Definition at line 188 of file window_gui.h.

Referenced by DispatchLeftClickEvent(), and GetDefaultHeight().

## ◆ pref_sticky

bool WindowDesc::pref_sticky = false

Preferred stickyness.

Definition at line 186 of file window_gui.h.

Referenced by Window::ApplyDefaults(), and DispatchLeftClickEvent().

## ◆ pref_width

int16_t WindowDesc::pref_width = 0

User-preferred width of the window. Zero if unset.

Definition at line 187 of file window_gui.h.

Referenced by DispatchLeftClickEvent(), and GetDefaultWidth().

## ◆ source_location

const std::source_location WindowDesc::source_location

Source location of this definition.

Definition at line 177 of file window_gui.h.

The documentation for this struct was generated from the following files:

- src/window_gui.h
- src/window.cpp