OpenTTD Source: Window Struct Reference

OpenTTD Source 13.2.1

Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Static Private Attributes
Window Struct Reference

Data structure for an opened window. More...

`#include <window_gui.h>`

Inheritance diagram for Window:

## Data Structures
struct | AllWindows
| Iterable ensemble of all valid Windows. More...
struct | WindowIterator
| Iterator to iterate all valid Windows. More...

## Public Types
using | IteratorToFront = WindowIterator< false >
| Iterate in Z order towards front.
using | IteratorToBack = WindowIterator< true >
| Iterate in Z order towards back.
using | Iterate = AllWindows< false >
| Iterate all windows in whatever order is easiest.
using | IterateFromBack = AllWindows< false >
| Iterate all windows in Z order from back to front.
using | IterateFromFront = AllWindows< true >
| Iterate all windows in Z order from front to back.

## Public Member Functions
| Window (WindowDesc *desc)
| Empty constructor, initialization has been moved to InitNested() called from the constructor of the derived class. More...
void * | operator new[] (size_t size)=delete
| Helper allocation function to disallow something. More...
template<class NWID >
const NWID * | GetWidget (uint widnum) const
| Get the nested widget with number widnum from the nested widget tree. More...
template<class NWID >
NWID * | GetWidget (uint widnum)
| Get the nested widget with number widnum from the nested widget tree. More...
const Scrollbar * | GetScrollbar (uint widnum) const
| Return the Scrollbar to a widget index. More...
Scrollbar * | GetScrollbar (uint widnum)
| Return the Scrollbar to a widget index. More...
const QueryString * | GetQueryString (uint widnum) const
| Return the querystring associated to a editbox. More...
QueryString * | GetQueryString (uint widnum)
| Return the querystring associated to a editbox. More...
void | UpdateQueryStringSize ()
| Update size of all QueryStrings of this window.
virtual const char * | GetFocusedText () const
| Get the current input text if an edit box has the focus. More...
virtual const char * | GetCaret () const
| Get the string at the caret if an edit box has the focus. More...
virtual const char * | GetMarkedText (size_t *length) const
| Get the range of the currently marked input text. More...
virtual Point | GetCaretPosition () const
| Get the current caret position if an edit box has the focus. More...
virtual Rect | GetTextBoundingRect (const char *from, const char *to) const
| Get the bounding rectangle for a text range if an edit box has the focus. More...
virtual const char * | GetTextCharacterAtPosition (const Point &pt) const
| Get the character that is rendered at a position by the focused edit box. More...
void | InitNested (WindowNumber number=0)
| Perform complete initialization of the Window with nested widgets, to allow use. More...
void | CreateNestedTree (bool fill_nested=true)
| Perform the first part of the initialization of a nested widget tree. More...
void | FinishInitNested (WindowNumber window_number=0)
| Perform the second part of the initialization of a nested widget tree. More...
void | SetTimeout ()
| Set the timeout flag of the window and initiate the timer.
void | SetWhiteBorder ()
| Set the timeout flag of the window and initiate the timer.
void | DisableAllWidgetHighlight ()
| Disable the highlighted status of all widgets.
void | SetWidgetHighlight (byte widget_index, TextColour highlighted_colour)
| Sets the highlighted status of a widget. More...
bool | IsWidgetHighlighted (byte widget_index) const
| Gets the highlighted status of a widget. More...
void | SetWidgetDisabledState (byte widget_index, bool disab_stat)
| Sets the enabled/disabled status of a widget. More...
void | DisableWidget (byte widget_index)
| Sets a widget to disabled. More...
void | EnableWidget (byte widget_index)
| Sets a widget to Enabled. More...
bool | IsWidgetDisabled (byte widget_index) const
| Gets the enabled/disabled status of a widget. More...
bool | IsWidgetFocused (byte widget_index) const
| Check if given widget is focused within this window. More...
bool | IsWidgetGloballyFocused (byte widget_index) const
| Check if given widget has user input focus. More...
void | SetWidgetLoweredState (byte widget_index, bool lowered_stat)
| Sets the lowered/raised status of a widget. More...
void | ToggleWidgetLoweredState (byte widget_index)
| Invert the lowered/raised status of a widget. More...
void | LowerWidget (byte widget_index)
| Marks a widget as lowered. More...
void | RaiseWidget (byte widget_index)
| Marks a widget as raised. More...
bool | IsWidgetLowered (byte widget_index) const
| Gets the lowered state of a widget. More...
void | UnfocusFocusedWidget ()
| Makes no widget on this window have focus. More...
bool | SetFocusedWidget (int widget_index)
| Set focus within this window to the given widget. More...
EventState | HandleEditBoxKey (int wid, WChar key, uint16 keycode)
| Process keypress for editbox widget. More...
virtual void | InsertTextString (int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
| Insert a text string at the cursor position into the edit box widget. More...
void | HandleButtonClick (byte widget)
| Do all things to make a button look clicked and mark it to be unclicked in a few ticks. More...
int | GetRowFromWidget (int clickpos, int widget, int padding, int line_height=-1) const
| Compute the row of a widget that a user clicked in. More...
void | RaiseButtons (bool autoraise=false)
| Raise the buttons of the window. More...
void CDECL | SetWidgetsDisabledState (bool disab_stat, int widgets,...)
| Sets the enabled/disabled status of a list of widgets. More...
void CDECL | SetWidgetsLoweredState (bool lowered_stat, int widgets,...)
| Sets the lowered/raised status of a list of widgets. More...
void | SetWidgetDirty (byte widget_index) const
| Invalidate a widget, i.e. More...
void | DrawWidgets () const
| Paint all widgets of a window.
void | DrawViewport () const
| Draw the viewport of this window.
void | DrawSortButtonState (int widget, SortButtonState state) const
| Draw a sort button's up or down arrow symbol. More...
void | CloseChildWindows (WindowClass wc=WC_INVALID) const
| Close all children a window might have in a head-recursive manner. More...
virtual void | Close ()
| Hide the window and all its child windows, and mark them for a later deletion.
void | SetDirty () const
| Mark entire window as dirty (in need of re-paint)
void | ReInit (int rx=0, int ry=0)
| Re-initialize a window, and optionally change its size. More...
bool | IsShaded () const
| Is window shaded currently?
void | SetShaded (bool make_shaded)
| Set the shaded state of the window to make_shaded. More...
void | InvalidateData (int data=0, bool gui_scope=true)
| Mark this window's data as invalid (in need of re-computing) More...
void | ProcessScheduledInvalidations ()
| Process all scheduled invalidations.
void | ProcessHighlightedInvalidations ()
| Process all invalidation of highlighted widgets.
virtual void | OnInit ()
| Notification that the nested widget tree gets initialized. More...
virtual void | ApplyDefaults ()
| Read default values from WindowDesc configuration an apply them to the window.
virtual Point | OnInitialPosition (int16 sm_width, int16 sm_height, int window_number)
| Compute the initial position of the window. More...
virtual void | OnPaint ()
| The window must be repainted. More...
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget. More...
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
| Update size and resize step of a widget in the window. More...
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget. More...
virtual void | OnFocus ()
| Called when window gains focus.
virtual void | OnFocusLost ()
| Called when window loses focus.
virtual EventState | OnKeyPress (WChar key, uint16 keycode)
| A key has been pressed. More...
virtual EventState | OnHotkey (int hotkey)
| A hotkey has been pressed. More...
virtual EventState | OnCTRLStateChange ()
| The state of the control key has changed. More...
virtual void | OnClick (Point pt, int widget, int click_count)
| A click with the left mouse button has been made on the window. More...
virtual bool | OnRightClick (Point pt, int widget)
| A click with the right mouse button has been made on the window. More...
virtual void | OnHover (Point pt, int widget)
| The mouse is hovering over a widget in the window, perform an action for it. More...
virtual bool | OnTooltip (Point pt, int widget, TooltipCloseCondition close_cond)
| Event to display a custom tooltip. More...
virtual void | OnMouseDrag (Point pt, int widget)
| An 'object' is being dragged at the provided position, highlight the target if possible. More...
virtual void | OnDragDrop (Point pt, int widget)
| A dragged 'object' has been released. More...
virtual void | OnScroll (Point delta)
| Handle the request for (viewport) scrolling. More...
virtual void | OnMouseOver (Point pt, int widget)
| The mouse is currently moving over the window or has just moved outside of the window. More...
virtual void | OnMouseWheel (int wheel)
| The mouse wheel has been turned. More...
virtual void | OnMouseLoop ()
| Called for every mouse loop run, which is at least once per (game) tick.
virtual void | OnGameTick ()
| Called once per (game) tick.
virtual void | OnHundredthTick ()
| Called once every 100 (game) ticks, or once every 3s, whichever comes last. More...
virtual void | OnRealtimeTick (uint delta_ms)
| Called periodically.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnResize ()
| Called after the window got resized. More...
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected. More...
virtual void | OnDropdownClose (Point pt, int widget, int index, bool instant_close)
| A dropdown window associated to this window has been closed. More...
virtual void | OnEditboxChanged (int widget)
| The text in an editbox has been edited. More...
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed. More...
virtual void | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid. More...
virtual void | OnPlaceObject (Point pt, TileIndex tile)
| The user clicked some place on the map when a tile highlight mode has been set. More...
virtual bool | OnVehicleSelect (const struct Vehicle *v)
| The user clicked on a vehicle while HT_VEHICLE has been set. More...
virtual bool | OnVehicleSelect (VehicleList::const_iterator begin, VehicleList::const_iterator end)
| The user clicked on a vehicle while HT_VEHICLE has been set. More...
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
virtual void | OnPlaceDrag (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
| The user is dragging over the map when the tile highlight mode has been set. More...
virtual void | OnPlaceMouseUp (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
| The user has dragged over the map when the tile highlight mode has been set. More...
virtual void | OnPlacePresize (Point pt, TileIndex tile)
| The user moves over the map when a tile highlight mode has been set when the special mouse mode has been set to 'PRESIZE' mode. More...
virtual bool | IsNewGRFInspectable () const
| Is the data related to this window NewGRF inspectable? More...
virtual void | ShowNewGRFInspectWindow () const
| Show the NewGRF inspection window. More...
template<>
const NWidgetBase * | GetWidget (uint widnum) const
| Specialized case of Window::GetWidget for the nested widget base class.
Public Member Functions inherited from ZeroedMemoryAllocator
void * | operator new (size_t size)
| Memory allocator for a single class instance. More...
void * | operator new[] (size_t size)
| Memory allocator for an array of class instances. More...
void | operator delete (void *ptr)
| Memory release for a single class instance. More...
void | operator delete[] (void *ptr)
| Memory release for an array of class instances. More...

## Static Public Member Functions
static int | SortButtonWidth ()
| Get width of up/down arrow of sort button state. More...
static void | DeleteClosedWindows ()
| Delete all closed windows.

## Data Fields
WindowDesc * | window_desc
| Window description.
WindowFlags | flags
| Window flags.
WindowClass | window_class
| Window class.
WindowNumber | window_number
| Window number within the window class.
uint8 | timeout_timer
| Timer value of the WF_TIMEOUT for flags.
uint8 | white_border_timer
| Timer value of the WF_WHITE_BORDER for flags.
int | left
| x position of left edge of the window
int | top
| y position of top edge of the window
int | width
| width of the window (number of pixels to the right in x direction)
int | height
| Height of the window (number of pixels down in y direction)
ResizeInfo | resize
| Resize information.
Owner | owner
| The owner of the content shown in this window. Company colour is acquired from this variable.
ViewportData * | viewport
| Pointer to viewport data, if present.
const NWidgetCore * | nested_focus
| Currently focused nested widget, or `nullptr` if no nested widget has focus.
SmallMap< int, QueryString * > | querystrings
| QueryString associated to WWT_EDITBOX widgets.
NWidgetBase * | nested_root
| Root of the nested tree.
NWidgetBase ** | nested_array
| Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
uint | nested_array_size
| Size of the nested array.
NWidgetStacked * | shade_select
| Selection widget (NWID_SELECTION) to use for shading the window. If `nullptr`, window cannot shade.
Dimension | unshaded_size
| Last known unshaded size (only valid while shaded).
int | mouse_capture_widget
| Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
Window * | parent
| Parent window.
WindowList::iterator | z_position

## Protected Member Functions
void | InitializeData (WindowNumber window_number)
| Initializes the data (except the position and initial size) of a new Window. More...
void | InitializePositionSize (int x, int y, int min_width, int min_height)
| Set the position and smallest size of the window. More...
virtual void | FindWindowPlacementAndResize (int def_width, int def_height)
| Resize window towards the default size. More...
virtual | ~Window ()
| Remove window and all its child windows from the window stack.

## Protected Attributes
std::vector< int > | scheduled_invalidation_data
| Data of scheduled OnInvalidateData() calls.

## Static Private Attributes
static std::vector< Window * > | closed_windows
| List of closed windows to delete.

## Detailed Description

Data structure for an opened window.

Definition at line 213 of file window_gui.h.

## Constructor & Destructor Documentation

## ◆ Window()

Window::Window | ( | WindowDesc * | desc | ) |

Empty constructor, initialization has been moved to InitNested() called from the constructor of the derived class.

Parameters

  desc | The description of the window.

Definition at line 1814 of file window.cpp.

References _z_windows.

## Member Function Documentation

## ◆ CloseChildWindows()

void Window::CloseChildWindows | ( | WindowClass | wc = `WC_INVALID` | ) | const

Close all children a window might have in a head-recursive manner.

Parameters

  wc | Window class of the window to remove; WC_INVALID if class does not matter

Definition at line 1095 of file window.cpp.

References Close(), and FindChildWindow().

Referenced by NewGRFParametersWindow::OnClick(), AISettingsWindow::OnClick(), TimetableWindow::OnInvalidateData(), NewGRFParametersWindow::OnInvalidateData(), AISettingsWindow::OnInvalidateData(), OrdersWindow::OnInvalidateData(), NewGRFWindow::OnNewGRFsScanned(), VehicleGroupWindow::OnPaint(), and VehicleListWindow::OnPaint().

## ◆ CreateNestedTree()

void Window::CreateNestedTree | ( | bool | fill_nested = `true` | ) |

Perform the first part of the initialization of a nested widget tree.

Construct a nested widget tree in nested_root, and optionally fill the nested_array array to provide quick access to the uninitialized widgets. This is mainly useful for setting very basic properties.

Parameters

  fill_nested | Fill the nested_array (enabling is expensive!).

Note
  Filling the nested array requires an additional traversal through the nested widget tree, and is best performed by FinishInitNested rather than here.

Definition at line 1775 of file window.cpp.

References MakeWindowNWidgetTree(), nested_array_size, nested_root, WindowDesc::nwid_parts, and window_desc.

Referenced by AIDebugWindow::AIDebugWindow(), AIListWindow::AIListWindow(), InitNested(), NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), SavePresetWindow::SavePresetWindow(), VehicleDetailsWindow::VehicleDetailsWindow(), and WaypointWindow::WaypointWindow().

## ◆ DisableWidget()

void Window::DisableWidget | ( | byte | widget_index | ) |
| inline

Sets a widget to disabled.

Parameters

  widget_index | index of this widget in the window

Definition at line 331 of file window_gui.h.

References SetWidgetDisabledState().

Referenced by BuildRailToolbarWindow::OnPlaceObjectAbort().

## ◆ DrawSortButtonState()

void Window::DrawSortButtonState | ( | int | widget,
|  | SortButtonState | state
| ) |  | const

Draw a sort button's up or down arrow symbol.

Parameters

  widget | Sort button widget
  state | State of sort button

Definition at line 890 of file widget.cpp.

References nested_array, and SBS_OFF.

Referenced by BuildBridgeWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), BuildVehicleWindow::DrawWidget(), VehicleListWindow::DrawWidget(), NetworkContentListWindow::OnPaint(), and StationViewWindow::OnPaint().

## ◆ DrawWidget()

virtual void Window::DrawWidget | ( | const Rect & | r,
|  | int | widget
| ) |  | const
| inlinevirtual

Draw the contents of a nested widget.

Parameters

  r | Rectangle occupied by the widget.
  widget | Number of the widget to draw.

Note
  This method may not change any state, it may only use drawing functions.

Reimplemented in VehicleViewWindow, IndustryCargoesWindow, BuyCompanyWindow, VehicleDetailsWindow, CompanyWindow, NetworkAskRelayWindow, ScenarioEditorToolbarWindow, NetworkCompanyPasswordWindow, SelectStationWindow< T >, ScanProgressWindow, NetworkJoinStatusWindow, GameSettingsWindow, SavePresetWindow, NetworkClientListWindow, BuildRailWaypointWindow, CompanyInfrastructureWindow, VehicleListWindow, BuildRailDepotWindow, BuildSignalWindow, BuildVehicleWindow, IndustryDirectoryWindow, SelectCompanyManagerFaceWindow, GenerateProgressWindow, BuildRailStationWindow, PerformanceRatingDetailWindow, QueryWindow, MessageHistoryWindow, AIDebugWindow, BuildRoadStationWindow, NetworkStartServerWindow, OrdersWindow, QueryStringWindow, BuildRoadDepotWindow, PaymentRatesGraphWindow, RefitWindow, SelectCompanyLiveryWindow, FrametimeGraphWindow, SpriteAlignerWindow, NewGRFWindow, TownDirectoryWindow, AIConfigWindow, TooltipsWindow, MusicWindow, StoryBookWindow, FramerateWindow, NetworkContentListWindow, ScenarioEditorLandscapeGenerationWindow, NetworkGameWindow, VehicleGroupWindow, BuildDocksDepotWindow, BaseGraphWindow, MusicTrackSelectionWindow, BuildIndustryWindow, AboutWindow, ReplaceVehicleWindow, NewsWindow, CompanyStationsWindow, CompanyFinancesWindow, SaveLoadWindow, NewGRFInspectWindow, GoalQuestionWindow, BuildAirportWindow, TownViewWindow, DepotWindow, TimetableWindow, AISettingsWindow, BuildObjectWindow, GameOptionsWindow, ScriptLeagueWindow, SelectGameWindow, ErrmsgWindow, NewGRFParametersWindow, DropdownWindow, BootstrapAskForDownloadWindow, CheatWindow, BuildBridgeWindow, TownAuthorityWindow, SmallMapWindow, SignListWindow, GSConfigWindow, BuildTreesWindow, SubsidyListWindow, StatusBarWindow, AIListWindow, LinkGraphLegendWindow, BootstrapErrorWindow, EnginePreviewWindow, PerformanceLeagueWindow, OskWindow, LandInfoWindow, BootstrapBackground, GraphLegendWindow, TextfileWindow, TransparenciesWindow, and BaseNetworkContentDownloadStatusWindow.

Definition at line 500 of file window_gui.h.

## ◆ EnableWidget()

void Window::EnableWidget | ( | byte | widget_index | ) |
| inline

Sets a widget to Enabled.

Parameters

  widget_index | index of this widget in the window

Definition at line 340 of file window_gui.h.

References SetWidgetDisabledState().

## ◆ FindWindowPlacementAndResize()

void Window::FindWindowPlacementAndResize | ( | int | def_width,
|  | int | def_height
| ) |  |
| protectedvirtual

Resize window towards the default size.

Prior to construction, a position for the new window (for its default size) has been found with LocalGetWindowPlacement(). Initially, the window is constructed with minimal size. Resizing the window to its default size is done here.

Parameters

  def_width | default width in pixels of the window
  def_height | default height in pixels of the window

See also
  Window::Window(), Window::InitializeData(), Window::InitializePositionSize()

Reimplemented in NetworkAskRelayWindow, ScenarioEditorToolbarWindow, MainToolbarWindow, QueryWindow, NetworkChatWindow, and StatusBarWindow.

Definition at line 1472 of file window.cpp.

References height, and width.

Referenced by StatusBarWindow::FindWindowPlacementAndResize(), NetworkChatWindow::FindWindowPlacementAndResize(), MainToolbarWindow::FindWindowPlacementAndResize(), ScenarioEditorToolbarWindow::FindWindowPlacementAndResize(), and FinishInitNested().

## ◆ FinishInitNested()

void Window::FinishInitNested | ( | WindowNumber | window_number = `0` | ) |

Perform the second part of the initialization of a nested widget tree.

Parameters

  window_number | Number of the new window.

Definition at line 1791 of file window.cpp.

References ApplyDefaults(), FindWindowPlacementAndResize(), WindowDesc::GetDefaultWidth(), InitializeData(), InitializePositionSize(), nested_root, OnInitialPosition(), NWidgetBase::smallest_x, window_desc, and window_number.

Referenced by AIDebugWindow::AIDebugWindow(), AIListWindow::AIListWindow(), InitNested(), NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), SavePresetWindow::SavePresetWindow(), VehicleDetailsWindow::VehicleDetailsWindow(), and WaypointWindow::WaypointWindow().

## ◆ GetCaret()

const char * Window::GetCaret | ( |  | ) | const
| virtual

Get the string at the caret if an edit box has the focus.

Returns
  The text at the caret or nullptr if no edit box is focused.

Reimplemented in IConsoleWindow.

Definition at line 384 of file window.cpp.

References QueryString::GetCaret(), GetQueryString(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetCaretPosition()

Point Window::GetCaretPosition | ( |  | ) | const
| virtual

Get the current caret position if an edit box has the focus.

Returns
  Top-left location of the caret, relative to the window.

Reimplemented in IConsoleWindow.

Definition at line 411 of file window.cpp.

References QueryString::GetCaretPosition(), GetQueryString(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetFocusedText()

const char * Window::GetFocusedText | ( |  | ) | const
| virtual

Get the current input text if an edit box has the focus.

Returns
  The currently focused input text or nullptr if no input focused.

Reimplemented in IConsoleWindow.

Definition at line 371 of file window.cpp.

References GetQueryString(), QueryString::GetText(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetMarkedText()

const char * Window::GetMarkedText | ( | size_t * | length | ) | const
| virtual

Get the range of the currently marked input text.

Parameters

  [out] | length | Length of the marked text.

Returns
  Pointer to the start of the marked text or nullptr if no text is marked.

Reimplemented in IConsoleWindow.

Definition at line 398 of file window.cpp.

References QueryString::GetMarkedText(), GetQueryString(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetQueryString() [1/2]

QueryString * Window::GetQueryString | ( | uint | widnum | ) |

Return the querystring associated to a editbox.

Parameters

  widnum | Editbox widget index

Returns
  QueryString or nullptr.

Definition at line 350 of file window.cpp.

References SmallMap< T, U >::Find(), and querystrings.

## ◆ GetQueryString() [2/2]

const QueryString * Window::GetQueryString | ( | uint | widnum | ) | const

Return the querystring associated to a editbox.

Parameters

  widnum | Editbox widget index

Returns
  QueryString or nullptr.

Definition at line 339 of file window.cpp.

References SmallMap< T, U >::Find(), and querystrings.

Referenced by GetCaret(), GetCaretPosition(), GetFocusedText(), GetMarkedText(), GetTextBoundingRect(), GetTextCharacterAtPosition(), HandleEditBoxKey(), and InsertTextString().

## ◆ GetRowFromWidget()

int Window::GetRowFromWidget | ( | int | clickpos,
|  | int | widget,
|  | int | padding,
|  | int | line_height = `-1`
| ) |  | const

Compute the row of a widget that a user clicked in.

Parameters

  clickpos | Vertical position of the mouse click.
  widget | Widget number of the widget clicked in.
  padding | Amount of empty space between the widget edge and the top of the first row.
  line_height | Height of a single row. A negative value means using the vertical resize step of the widget.

Returns
  Row number clicked at. If clicked at a wrong position, #INT_MAX is returned.

Note
  The widget does not know where a list printed at the widget ends, so below a list is not a wrong position.

Definition at line 211 of file window.cpp.

References NWidgetBase::pos_y, and NWidgetBase::resize_y.

Referenced by Scrollbar::GetScrolledRowFromWidget(), and NetworkClientListWindow::OnMouseOver().

## ◆ GetScrollbar() [1/2]

Scrollbar * Window::GetScrollbar | ( | uint | widnum | ) |

Return the Scrollbar to a widget index.

Parameters

  widnum | Scrollbar widget index

Returns
  Scrollbar to the widget

Definition at line 329 of file window.cpp.

## ◆ GetScrollbar() [2/2]

const Scrollbar * Window::GetScrollbar | ( | uint | widnum | ) | const

Return the Scrollbar to a widget index.

Parameters

  widnum | Scrollbar widget index

Returns
  Scrollbar to the widget

Definition at line 319 of file window.cpp.

Referenced by AIDebugWindow::AIDebugWindow(), AIListWindow::AIListWindow(), DispatchMouseWheelEvent(), FramerateWindow::DrawElementTimesColumn(), NetworkContentListWindow::NetworkContentListWindow(), SavePresetWindow::SavePresetWindow(), and VehicleDetailsWindow::VehicleDetailsWindow().

## ◆ GetTextBoundingRect()

Rect Window::GetTextBoundingRect | ( | const char * | from,
|  | const char * | to
| ) |  | const
| virtual

Get the bounding rectangle for a text range if an edit box has the focus.

Parameters

  from | Start of the string range.
  to | End of the string range.

Returns
  Rectangle encompassing the string range, relative to the window.

Reimplemented in IConsoleWindow.

Definition at line 427 of file window.cpp.

References QueryString::GetBoundingRect(), GetQueryString(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetTextCharacterAtPosition()

const char * Window::GetTextCharacterAtPosition | ( | const Point & | pt | ) | const
| virtual

Get the character that is rendered at a position by the focused edit box.

Parameters

  pt | The position to test.

Returns
  Pointer to the character at the position or nullptr if no character is at the position.

Reimplemented in IConsoleWindow.

Definition at line 442 of file window.cpp.

References QueryString::GetCharAtPosition(), GetQueryString(), NWidgetCore::index, nested_focus, NWidgetBase::type, and WWT_EDITBOX.

## ◆ GetWidget() [1/2]

template<class NWID >

NWID * Window::GetWidget | ( | uint | widnum | ) |
| inline

Get the nested widget with number widnum from the nested widget tree.

Template Parameters

  NWID | Type of the nested widget.

Parameters

  widnum | Widget number of the widget to retrieve.

Returns
  The requested widget if it is instantiated, `nullptr` otherwise.

Definition at line 842 of file window_gui.h.

References nested_array, and nested_array_size.

## ◆ GetWidget() [2/2]

template<class NWID >

const NWID * Window::GetWidget | ( | uint | widnum | ) | const
| inline

Get the nested widget with number widnum from the nested widget tree.

Template Parameters

  NWID | Type of the nested widget.

Parameters

  widnum | Widget number of the widget to retrieve.

Returns
  The requested widget if it is instantiated, `nullptr` otherwise.

Definition at line 865 of file window_gui.h.

Referenced by QueryString::GetBoundingRect(), QueryString::GetCaretPosition(), QueryString::GetCharAtPosition(), LinkGraphOverlay::GetWidgetDpi(), HandleActiveWidget(), HandleScrollbarScrolling(), Scrollbar::SetCapacityFromWidget(), LinkGraphOverlay::SetCargoMask(), LinkGraphOverlay::SetCompanyMask(), and ShowDropDownList().

## ◆ HandleButtonClick()

void Window::HandleButtonClick | ( | byte | widget | ) |

Do all things to make a button look clicked and mark it to be unclicked in a few ticks.

Parameters

  widget | the widget to "click"

Definition at line 659 of file window.cpp.

References LowerWidget(), SetTimeout(), and SetWidgetDirty().

## ◆ HandleEditBoxKey()

EventState Window::HandleEditBoxKey | ( | int | wid,
|  | WChar | key,
|  | uint16 | keycode
| ) |  |

Process keypress for editbox widget.

Parameters

  wid | Editbox widget.
  key | the Unicode value of the key.
  keycode | the untranslated key code including shift state.

Returns
  ES_HANDLED if the key press has been handled and no other window should receive the event.

Definition at line 2538 of file window.cpp.

References QueryString::ACTION_NOTHING, ES_NOT_HANDLED, GetQueryString(), HKPR_CONFIRM, HKPR_CURSOR, HKPR_EDITING, InvalidateData(), OnClick(), OnEditboxChanged(), SetWidgetDirty(), WC_OSK, and window_class.

## ◆ InitializeData()

void Window::InitializeData | ( | WindowNumber | window_number | ) |
| protected

Initializes the data (except the position and initial size) of a new Window.

Parameters

  window_number | Number being assigned to the new window

Returns
  Window pointer of the newly created window

Precondition
  If nested widgets are used (widget is `nullptr`), nested_root and nested_array_size must be initialized. In addition, nested_array is either `nullptr`, or already initialized.

Definition at line 1412 of file window.cpp.

References _current_text_dir, NWidgetBase::AssignSizePosition(), BringWindowToFront(), WindowDesc::cls, WindowDesc::default_pos, EditBoxInGlobalFocus(), flags, NWidgetBase::GetWidgetOfType(), INVALID_OWNER, nested_array, nested_array_size, nested_focus, nested_root, OnInit(), owner, resize, NWidgetBase::resize_x, NWidgetBase::resize_y, SetFocusedWindow(), NWidgetBase::SetupSmallestSize(), SetWhiteBorder(), NWidgetBase::smallest_x, ST_SMALLEST, ResizeInfo::step_height, ResizeInfo::step_width, TD_RTL, WDP_CENTER, WF_CENTERED, window_class, window_desc, window_number, and WWT_EDITBOX.

Referenced by FinishInitNested().

## ◆ InitializePositionSize()

void Window::InitializePositionSize | ( | int | x,
|  | int | y,
|  | int | sm_width,
|  | int | sm_height
| ) |  |
| protected

Set the position and smallest size of the window.

Parameters

  x | Offset in pixels from the left of the screen of the new window.
  y | Offset in pixels from the top of the screen of the new window.
  sm_width | Smallest width in pixels of the window.
  sm_height | Smallest height in pixels of the window.

Definition at line 1454 of file window.cpp.

Referenced by FinishInitNested().

## ◆ InitNested()

void Window::InitNested | ( | WindowNumber | window_number = `0` | ) |

Perform complete initialization of the Window with nested widgets, to allow use.

Parameters

  window_number | Number of the new window.

Definition at line 1804 of file window.cpp.

References CreateNestedTree(), and FinishInitNested().

Referenced by BootstrapAskForDownloadWindow::BootstrapAskForDownloadWindow(), ScanProgressWindow::ScanProgressWindow(), and SetDateWindow::SetDateWindow().

## ◆ InsertTextString()

void Window::InsertTextString | ( | int | wid,
|  | const char * | str,
|  | bool | marked,
|  | const char * | caret,
|  | const char * | insert_location,
|  | const char * | replacement_end
| ) |  |
| virtual

Insert a text string at the cursor position into the edit box widget.

Parameters

  wid | Edit box widget.
  str | Text string to insert.

Reimplemented in IConsoleWindow.

Definition at line 2696 of file window.cpp.

References GetQueryString(), Textbuf::InsertString(), OnEditboxChanged(), and SetWidgetDirty().

## ◆ InvalidateData()

void Window::InvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true`
| ) |  |

Mark this window's data as invalid (in need of re-computing)

Parameters

  data | The data to invalidate with
  gui_scope | Whether the function is called from GUI scope.

Definition at line 3194 of file window.cpp.

References OnInvalidateData(), scheduled_invalidation_data, and SetDirty().

Referenced by NewGRFWindow::AddGRFToActive(), AIDebugWindow::AIDebugWindow(), AIDebugWindow::ChangeToAI(), DoZoomInOutWindow(), HandleEditBoxKey(), InvalidateWindowClassesData(), InvalidateWindowData(), NetworkContentListWindow::NetworkContentListWindow(), NewGRFConfirmationCallback(), TextfileWindow::OnClick(), SignListWindow::OnClick(), NewGRFParametersWindow::OnClick(), NewGRFInspectWindow::OnClick(), AIDebugWindow::OnClick(), GameSettingsWindow::OnClick(), NetworkContentListWindow::OnConnect(), NetworkContentListWindow::OnDownloadComplete(), RefitWindow::OnDragDrop(), NewGRFWindow::OnDragDrop(), NewGRFWindow::OnDropdownSelect(), GameSettingsWindow::OnDropdownSelect(), BuildObjectWindow::OnEditboxChanged(), SaveLoadWindow::OnEditboxChanged(), NetworkContentListWindow::OnEditboxChanged(), TownDirectoryWindow::OnEditboxChanged(), BuildRailStationWindow::OnEditboxChanged(), NewGRFWindow::OnEditboxChanged(), GameSettingsWindow::OnEditboxChanged(), NewGRFWindow::OnKeyPress(), AIDebugWindow::OnPaint(), CompanyWindow::OnPaint(), NewGRFWindow::OnQueryTextFinished(), NetworkContentListWindow::OnReceiveContentInfo(), SaveLoadWindow::OnTimeout(), ResetAllSettingsConfirmationCallback(), SignListWindow::SetFilterString(), and ShowIndustryCargoesWindow().

## ◆ IsNewGRFInspectable()

virtual bool Window::IsNewGRFInspectable | ( |  | ) | const
| inlinevirtual

Is the data related to this window NewGRF inspectable?

Returns
  true iff it is inspectable.

Reimplemented in VehicleViewWindow, IndustryViewWindow, and LandInfoWindow.

Definition at line 743 of file window_gui.h.

## ◆ IsWidgetDisabled()

bool Window::IsWidgetDisabled | ( | byte | widget_index | ) | const
| inline

Gets the enabled/disabled status of a widget.

Parameters

  widget_index | index of this widget in the window

Returns
  status of the widget ie: disabled = true, enabled = false

Definition at line 350 of file window_gui.h.

References nested_array_size.

Referenced by BuildRailClick_Remove(), PerformanceRatingDetailWindow::DrawWidget(), HandlePlacePushButton(), AIDebugWindow::OnClick(), PerformanceRatingDetailWindow::OnClick(), DepotWindow::OnTimeout(), RailToolbar_CtrlChanged(), RoadToolbar_CtrlChanged(), LinkGraphLegendWindow::SetOverlay(), LinkGraphLegendWindow::UpdateOverlayCargoes(), and LinkGraphLegendWindow::UpdateOverlayCompanies().

## ◆ IsWidgetFocused()

bool Window::IsWidgetFocused | ( | byte | widget_index | ) | const
| inline

Check if given widget is focused within this window.

Parameters

  widget_index | : index of the widget in the window to check

Returns
  true if given widget is the focused window in this window

Definition at line 361 of file window_gui.h.

References NWidgetCore::index.

## ◆ IsWidgetGloballyFocused()

bool Window::IsWidgetGloballyFocused | ( | byte | widget_index | ) | const
| inline

Check if given widget has user input focus.

This means that both the window has focus and that the given widget has focus within the window.

Parameters

  widget_index | : index of the widget in the window to check

Returns
  true if given widget is the focused window in this window and this window has focus

Definition at line 372 of file window_gui.h.

## ◆ IsWidgetHighlighted()

bool Window::IsWidgetHighlighted | ( | byte | widget_index | ) | const

Gets the highlighted status of a widget.

Parameters

  widget_index | index of this widget in the window

Returns
  status of the widget ie: highlighted = true, not highlighted = false

Definition at line 275 of file window.cpp.

References nested_array_size.

Referenced by ProcessHighlightedInvalidations().

## ◆ IsWidgetLowered()

bool Window::IsWidgetLowered | ( | byte | widget_index | ) | const
| inline

Gets the lowered state of a widget.

Parameters

  widget_index | index of this widget in the window

Returns
  status of the widget ie: lowered = true, raised= false

Definition at line 422 of file window_gui.h.

References nested_array_size.

Referenced by BuildAirToolbarWindow::Close(), BuildRailToolbarWindow::Close(), LinkGraphLegendWindow::DrawWidget(), IndustryCargoesWindow::NotifySmallmap(), StationViewWindow::OnClick(), BuildRailToolbarWindow::OnCTRLStateChange(), IndustryCargoesWindow::OnInvalidateData(), ScenarioEditorLandscapeGenerationWindow::OnPaint(), BuildRailToolbarWindow::OnPlaceDrag(), BuildRoadToolbarWindow::OnPlaceObject(), BuildAirToolbarWindow::OnPlaceObjectAbort(), BuildRailToolbarWindow::OnPlaceObjectAbort(), MainToolbarWindow::OnRealtimeTick(), ScenarioEditorToolbarWindow::OnRealtimeTick(), ScenarioEditorLandscapeGenerationWindow::OnTimeout(), SaveLoadWindow::OnTimeout(), GenerateLandscapeWindow::OnTimeout(), NetworkStartServerWindow::OnTimeout(), CreateScenarioWindow::OnTimeout(), MainToolbarWindow::OnTimeout(), RailToolbar_CtrlChanged(), TextfileWindow::ReflowContent(), RoadToolbar_CtrlChanged(), TextfileWindow::SetupScrollbars(), ToggleRailButton_Remove(), and ToggleRoadButton_Remove().

## ◆ LowerWidget()

void Window::LowerWidget | ( | byte | widget_index | ) |
| inline

Marks a widget as lowered.

Parameters

  widget_index | index of this widget in the window

Definition at line 403 of file window_gui.h.

References SetWidgetLoweredState().

Referenced by HandleButtonClick(), BuildDocksStationWindow::OnClick(), CompanyStationsWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildRailDepotWindow::OnClick(), PerformanceRatingDetailWindow::OnInvalidateData(), BuildSignalWindow::OnInvalidateData(), VehicleDetailsWindow::OnPaint(), and SmallMapWindow::SwitchMapType().

## ◆ OnClick()

virtual void Window::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count
| ) |  |
| inlinevirtual

A click with the left mouse button has been made on the window.

Parameters

  pt | the point inside the window that has been clicked.
  widget | the clicked widget.
  click_count | Number of fast consecutive clicks at same position

Reimplemented in VehicleViewWindow, IndustryCargoesWindow, BuyCompanyWindow, CustomCurrencyWindow, VehicleDetailsWindow, CompanyWindow, NetworkAskRelayWindow, ScenarioEditorToolbarWindow, NetworkCompanyPasswordWindow, SelectStationWindow< T >, NetworkJoinStatusWindow, GameSettingsWindow, SavePresetWindow, BuildRailWaypointWindow, MainToolbarWindow, VehicleListWindow, BuildRailDepotWindow, StationViewWindow, NetworkClientListWindow, BuildSignalWindow, IndustryDirectoryWindow, SelectCompanyManagerFaceWindow, BuildVehicleWindow, GenerateProgressWindow, BuildRailStationWindow, PerformanceRatingDetailWindow, MessageHistoryWindow, AIDebugWindow, FoundTownWindow, QueryWindow, CreateScenarioWindow, OrdersWindow, BuildRoadStationWindow, RefitWindow, NetworkStartServerWindow, QueryStringWindow, IndustryViewWindow, BuildRoadDepotWindow, SelectCompanyLiveryWindow, PaymentRatesGraphWindow, SpriteAlignerWindow, NewGRFWindow, TownDirectoryWindow, StoryBookWindow, AIConfigWindow, NetworkContentListWindow, PerformanceHistoryGraphWindow, MusicWindow, DepotWindow, NetworkGameWindow, FramerateWindow, GenerateLandscapeWindow, VehicleGroupWindow, BuildIndustryWindow, SaveLoadWindow, ScenarioEditorLandscapeGenerationWindow, BuildDocksDepotWindow, MusicTrackSelectionWindow, NewGRFInspectWindow, ReplaceVehicleWindow, BaseGraphWindow, BuildObjectWindow, TimetableWindow, CompanyStationsWindow, BuildRailToolbarWindow, BuildAirportWindow, CompanyFinancesWindow, SignWindow, NewsWindow, TownViewWindow, NetworkChatWindow, BuildDocksStationWindow, AISettingsWindow, BuildRoadToolbarWindow, GameOptionsWindow, ScriptLeagueWindow, GoalQuestionWindow, CheatWindow, LandInfoWindow, SelectGameWindow, NewGRFParametersWindow, NetworkContentDownloadStatusWindow, TownAuthorityWindow, DropdownWindow, GSConfigWindow, BuildBridgeWindow, BootstrapAskForDownloadWindow, SignListWindow, StatusBarWindow, SmallMapWindow, AIListWindow, TerraformToolbarWindow, BuildTreesWindow, BuildDocksToolbarWindow, SetDateWindow, EnginePreviewWindow, BuildAirToolbarWindow, LinkGraphLegendWindow, BootstrapErrorWindow, OskWindow, ExtraViewportWindow, WaypointWindow, GraphLegendWindow, TransparenciesWindow, GoalListWindow, EndGameHighScoreBaseWindow, TextfileWindow, SubsidyListWindow, and ScreenshotWindow.

Definition at line 553 of file window_gui.h.

Referenced by HandleEditBoxKey(), and OnHotkey().

## ◆ OnCTRLStateChange()

virtual EventState Window::OnCTRLStateChange | ( |  | ) |
| inlinevirtual

The state of the control key has changed.

Returns
  ES_HANDLED if the change has been handled and no other window should receive the event.

Reimplemented in DepotWindow, BuildRailToolbarWindow, and BuildRoadToolbarWindow.

Definition at line 544 of file window_gui.h.

References ES_NOT_HANDLED.

Referenced by HandleCtrlChanged().

## ◆ OnDragDrop()

virtual void Window::OnDragDrop | ( | Point | pt,
|  | int | widget
| ) |  |
| inlinevirtual

A dragged 'object' has been released.

Parameters

  pt | the point inside the window where the release took place.
  widget | the widget where the release took place.

Reimplemented in OrdersWindow, NewGRFWindow, RefitWindow, DepotWindow, and VehicleGroupWindow.

Definition at line 591 of file window_gui.h.

## ◆ OnDropdownClose()

void Window::OnDropdownClose | ( | Point | pt,
|  | int | widget,
|  | int | index,
|  | bool | instant_close
| ) |  |
| virtual

A dropdown window associated to this window has been closed.

Parameters

  pt | the point inside the window the mouse resides on after closure.
  widget | the widget (button) that the dropdown is associated with.
  index | the element in the dropdown that is selected.
  instant_close | whether the dropdown was configured to close on mouse up.

Reimplemented in GameSettingsWindow, NetworkClientListWindow, AISettingsWindow, NewGRFParametersWindow, and GSConfigWindow.

Definition at line 292 of file window.cpp.

References GetWidgetFromPos(), OnDropdownSelect(), and NWidgetBase::type.

Referenced by NetworkClientListWindow::OnDropdownClose(), and GameSettingsWindow::OnDropdownClose().

## ◆ OnDropdownSelect()

virtual void Window::OnDropdownSelect | ( | int | widget,
|  | int | index
| ) |  |
| inlinevirtual

A dropdown option associated to this window has been selected.

Parameters

  widget | the widget (button) that the dropdown is associated with.
  index | the element in the dropdown that is selected.

Reimplemented in IndustryCargoesWindow, VehicleDetailsWindow, ScenarioEditorToolbarWindow, GameSettingsWindow, VehicleListWindow, StationViewWindow, MainToolbarWindow, NetworkClientListWindow, IndustryDirectoryWindow, BuildVehicleWindow, OrdersWindow, CreateScenarioWindow, NetworkStartServerWindow, NewGRFWindow, SelectCompanyLiveryWindow, TownDirectoryWindow, VehicleGroupWindow, GenerateLandscapeWindow, StoryBookWindow, ReplaceVehicleWindow, CompanyStationsWindow, MusicTrackSelectionWindow, BuildAirportWindow, GameOptionsWindow, AISettingsWindow, NewGRFParametersWindow, GSConfigWindow, BuildBridgeWindow, and SetDateWindow.

Definition at line 653 of file window_gui.h.

Referenced by OnDropdownClose(), and DropdownWindow::OnMouseLoop().

## ◆ OnEditboxChanged()

virtual void Window::OnEditboxChanged | ( | int | widget | ) |
| inlinevirtual

The text in an editbox has been edited.

Parameters

  widget | The widget of the editbox.

Reimplemented in SignListWindow, OskWindow, GameSettingsWindow, NewGRFWindow, AIDebugWindow, BuildRailStationWindow, TownDirectoryWindow, NetworkContentListWindow, SaveLoadWindow, NetworkGameWindow, BuildObjectWindow, and NetworkChatWindow.

Definition at line 661 of file window_gui.h.

Referenced by HandleEditBoxKey(), InsertTextString(), and OskWindow::OnEditboxChanged().

## ◆ OnHotkey()

EventState Window::OnHotkey | ( | int | hotkey | ) |
| virtual

A hotkey has been pressed.

Parameters

  hotkey | Hotkey index, by default a widget index of a button or editbox.

Returns
  ES_HANDLED if the key press has been handled, and the hotkey is not unavailable for some reason.

Reimplemented in VehicleViewWindow, ScenarioEditorToolbarWindow, MainToolbarWindow, OrdersWindow, BuildRailStationWindow, BuildRailToolbarWindow, BuildObjectWindow, BuildRoadToolbarWindow, SignListWindow, and MainWindow.

Definition at line 634 of file window.cpp.

References ES_NOT_HANDLED, NWidgetCore::IsDisabled(), IsShaded(), OnClick(), SetFocusedWidget(), SetFocusedWindow(), NWidgetBase::type, and WWT_EDITBOX.

Referenced by HandleToolbarHotkey(), and VehicleViewWindow::OnHotkey().

## ◆ OnHover()

virtual void Window::OnHover | ( | Point | pt,
|  | int | widget
| ) |  |
| inlinevirtual

The mouse is hovering over a widget in the window, perform an action for it.

Parameters

  pt | The point where the mouse is hovering.
  widget | The widget where the mouse is hovering.

Definition at line 569 of file window_gui.h.

## ◆ OnHundredthTick()

virtual void Window::OnHundredthTick | ( |  | ) |
| inlinevirtual

Called once every 100 (game) ticks, or once every 3s, whichever comes last.

In normal game speed the frequency is 1 call every 100 ticks (can be more than 3s). In fast-forward the frequency is 1 call every ~3s (can be more than 100 ticks).

Reimplemented in CompanyWindow, IndustryDirectoryWindow, PaymentRatesGraphWindow, TownDirectoryWindow, BuildIndustryWindow, CompanyFinancesWindow, SignListWindow, and TownAuthorityWindow.

Definition at line 629 of file window_gui.h.

## ◆ OnInit()

virtual void Window::OnInit | ( |  | ) |
| inlinevirtual

Notification that the nested widget tree gets initialized.

The event can be used to perform general computations.

Note
  nested_root and/or nested_array (normally accessed via GetWidget()) may not exist during this call.

Reimplemented in IndustryCargoesWindow, GameSettingsWindow, NetworkClientListWindow, BuildSignalWindow, IndustryDirectoryWindow, SelectCompanyManagerFaceWindow, BuildVehicleWindow, PaymentRatesGraphWindow, IndustryViewWindow, RefitWindow, DepotWindow, NetworkContentListWindow, NetworkGameWindow, BuildIndustryWindow, NewsWindow, SelectGameWindow, BuildObjectWindow, CheatWindow, SmallMapWindow, TerraformToolbarWindow, SignListWindow, LandInfoWindow, IConsoleWindow, TownAuthorityWindow, and BaseVehicleListWindow.

Definition at line 472 of file window_gui.h.

Referenced by InitializeData(), and ReInit().

## ◆ OnInitialPosition()

Point Window::OnInitialPosition | ( | int16 | sm_width,
|  | int16 | sm_height,
|  | int | window_number
| ) |  |
| virtual

Compute the initial position of the window.

Parameters

  sm_width | Smallest width of the window.
  sm_height | Smallest height of the window.
  window_number | The window number of the new window.

Returns
  Initial position of the top-left corner of the window.

Reimplemented in TooltipsWindow, NetworkChatWindow, NewsWindow, TerraformToolbarWindow, ErrmsgWindow, BuildBridgeWindow, DropdownWindow, TransparenciesWindow, StatusBarWindow, and SetDateWindow.

Definition at line 1763 of file window.cpp.

References LocalGetWindowPlacement(), window_desc, and window_number.

Referenced by FinishInitNested().

## ◆ OnInvalidateData()

virtual void Window::OnInvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true`
| ) |  |
| inlinevirtual

Some data on this window has become invalid.

Parameters

  data | information about the changed data.
  gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Reimplemented in VehicleViewWindow, IndustryCargoesWindow, CompanyWindow, ScenarioEditorToolbarWindow, GameSettingsWindow, SelectStationWindow< T >, VehicleDetailsWindow, MainToolbarWindow, VehicleListWindow, CompanyInfrastructureWindow, StationViewWindow, BuildSignalWindow, IndustryDirectoryWindow, NetworkClientListWindow, BuildVehicleWindow, PerformanceRatingDetailWindow, AIDebugWindow, FoundTownWindow, NewGRFWindow, MessageHistoryWindow, IndustryViewWindow, BuildRailStationWindow, SelectCompanyLiveryWindow, SpriteAlignerWindow, PaymentRatesGraphWindow, RefitWindow, TownDirectoryWindow, NetworkContentListWindow, AIConfigWindow, StoryBookWindow, OrdersWindow, NetworkGameWindow, SaveLoadWindow, MusicWindow, BuildIndustryWindow, ReplaceVehicleWindow, DepotWindow, CompanyStationsWindow, ScriptTextfileWindow, GameOptionsWindow, NewGRFInspectWindow, TownViewWindow, AISettingsWindow, BaseGraphWindow, NewsWindow, GenerateLandscapeWindow, BuildObjectWindow, NetworkChatWindow, MusicTrackSelectionWindow, NewGRFParametersWindow, MainWindow, VehicleGroupWindow, GSConfigWindow, ScriptLeagueWindow, LandInfoWindow, SignListWindow, TownAuthorityWindow, BuildRoadToolbarWindow, GoalListWindow, SelectGameWindow, ErrmsgWindow, TimetableWindow, AIListWindow, SubsidyListWindow, StatusBarWindow, OskWindow, SmallMapWindow, PerformanceLeagueWindow, ExtraViewportWindow, EnginePreviewWindow, BuildDocksToolbarWindow, TransparenciesWindow, LinkGraphLegendWindow, WaypointWindow, BuildAirToolbarWindow, GraphLegendWindow, and TextfileWindow.

Definition at line 676 of file window_gui.h.

Referenced by InvalidateData(), and ProcessScheduledInvalidations().

## ◆ OnKeyPress()

virtual EventState Window::OnKeyPress | ( | WChar | key,
|  | uint16 | keycode
| ) |  |
| inlinevirtual

A key has been pressed.

Parameters

  key | the Unicode value of the key.
  keycode | the untranslated key code including shift state.

Returns
  ES_HANDLED if the key press has been handled and no other window should receive the event.

Reimplemented in NewGRFWindow, QueryWindow, NetworkContentListWindow, NetworkGameWindow, SaveLoadWindow, NetworkChatWindow, BuildBridgeWindow, IConsoleWindow, and EndGameHighScoreBaseWindow.

Definition at line 535 of file window_gui.h.

References ES_NOT_HANDLED.

## ◆ OnMouseDrag()

virtual void Window::OnMouseDrag | ( | Point | pt,
|  | int | widget
| ) |  |
| inlinevirtual

An 'object' is being dragged at the provided position, highlight the target if possible.

Parameters

  pt | The point inside the window that the mouse hovers over.
  widget | The widget the mouse hovers over.

Reimplemented in OrdersWindow, NewGRFWindow, RefitWindow, VehicleGroupWindow, and DepotWindow.

Definition at line 584 of file window_gui.h.

## ◆ OnMouseOver()

virtual void Window::OnMouseOver | ( | Point | pt,
|  | int | widget
| ) |  |
| inlinevirtual

The mouse is currently moving over the window or has just moved outside of the window.

In the latter case pt is (-1, -1).

Parameters

  pt | the point inside the window that the mouse hovers over.
  widget | the widget the mouse hovers over.

Reimplemented in VehicleViewWindow, SelectStationWindow< T >, NetworkClientListWindow, SaveLoadWindow, and SmallMapWindow.

Definition at line 605 of file window_gui.h.

## ◆ OnMouseWheel()

virtual void Window::OnMouseWheel | ( | int | wheel | ) |
| inlinevirtual

The mouse wheel has been turned.

Parameters

  wheel | the amount of movement of the mouse wheel.

Reimplemented in MainWindow, IConsoleWindow, SmallMapWindow, and ExtraViewportWindow.

Definition at line 611 of file window_gui.h.

## ◆ OnPaint()

virtual void Window::OnPaint | ( |  | ) |
| inlinevirtual

The window must be repainted.

Note
  This method should not change any state, it should only use drawing functions.

Reimplemented in VehicleViewWindow, VehicleDetailsWindow, ScenarioEditorToolbarWindow, CompanyWindow, GameSettingsWindow, MainToolbarWindow, VehicleListWindow, IndustryDirectoryWindow, BuildVehicleWindow, SelectCompanyManagerFaceWindow, StationViewWindow, MessageHistoryWindow, BuildRailStationWindow, CreateScenarioWindow, BuildRoadStationWindow, OrdersWindow, AIDebugWindow, TownDirectoryWindow, SelectCompanyLiveryWindow, RefitWindow, IndustryViewWindow, DepotWindow, StoryBookWindow, NetworkContentListWindow, NetworkGameWindow, SaveLoadWindow, ScenarioEditorLandscapeGenerationWindow, VehicleGroupWindow, ReplaceVehicleWindow, CompanyFinancesWindow, BuildDocksStationWindow, BuildAirportWindow, CompanyStationsWindow, AISettingsWindow, TownViewWindow, ScriptLeagueWindow, NewGRFParametersWindow, TimetableWindow, GSConfigWindow, MainWindow, GoalListWindow, SmallMapWindow, SignListWindow, HighScoreWindow, IConsoleWindow, EndGameWindow, TownAuthorityWindow, PerformanceLeagueWindow, TransparenciesWindow, and ScreenshotWindow.

Definition at line 489 of file window_gui.h.

References DrawWidgets().

## ◆ OnPlaceDrag()

virtual void Window::OnPlaceDrag | ( | ViewportPlaceMethod | select_method,
|  | ViewportDragDropSelectionProcess | select_proc,
|  | Point | pt
| ) |  |
| inlinevirtual

The user is dragging over the map when the tile highlight mode has been set.

Parameters

  select_method | the method of selection (allowed directions)
  select_proc | what will be created when the drag is over.
  pt | the exact point on the map where the mouse is.

Reimplemented in ScenarioEditorLandscapeGenerationWindow, BuildRailToolbarWindow, BuildRoadToolbarWindow, BuildObjectWindow, TerraformToolbarWindow, BuildDocksToolbarWindow, BuildTreesWindow, and BuildAirToolbarWindow.

Definition at line 715 of file window_gui.h.

## ◆ OnPlaceMouseUp()

virtual void Window::OnPlaceMouseUp | ( | ViewportPlaceMethod | select_method,
|  | ViewportDragDropSelectionProcess | select_proc,
|  | Point | pt,
|  | TileIndex | start_tile,
|  | TileIndex | end_tile
| ) |  |
| inlinevirtual

The user has dragged over the map when the tile highlight mode has been set.

Parameters

  select_method | the method of selection (allowed directions)
  select_proc | what should be created.
  pt | the exact point on the map where the mouse was released.
  start_tile | the begin tile of the drag.
  end_tile | the end tile of the drag.

Reimplemented in ScenarioEditorLandscapeGenerationWindow, BuildRailToolbarWindow, BuildRoadToolbarWindow, BuildObjectWindow, TerraformToolbarWindow, BuildDocksToolbarWindow, BuildTreesWindow, and BuildAirToolbarWindow.

Definition at line 726 of file window_gui.h.

Referenced by PlaceRail_Bridge(), and PlaceRoad_Bridge().

## ◆ OnPlaceObject()

virtual void Window::OnPlaceObject | ( | Point | pt,
|  | TileIndex | tile
| ) |  |
| inlinevirtual

The user clicked some place on the map when a tile highlight mode has been set.

Parameters

  pt | the exact point on the map that has been clicked.
  tile | the tile on the map that has been clicked.

Reimplemented in CompanyWindow, ScenarioEditorToolbarWindow, MainToolbarWindow, OrdersWindow, FoundTownWindow, StoryBookWindow, BuildIndustryWindow, ScenarioEditorLandscapeGenerationWindow, BuildRailToolbarWindow, BuildObjectWindow, BuildRoadToolbarWindow, TerraformToolbarWindow, BuildTreesWindow, BuildDocksToolbarWindow, and BuildAirToolbarWindow.

Definition at line 684 of file window_gui.h.

## ◆ OnPlacePresize()

virtual void Window::OnPlacePresize | ( | Point | pt,
|  | TileIndex | tile
| ) |  |
| inlinevirtual

The user moves over the map when a tile highlight mode has been set when the special mouse mode has been set to 'PRESIZE' mode.

An example of this is the tile highlight for dock building.

Parameters

  pt | the exact point on the map where the mouse is.
  tile | the tile on the map where the mouse is.

Reimplemented in BuildDocksToolbarWindow, BuildRailToolbarWindow, and BuildRoadToolbarWindow.

Definition at line 735 of file window_gui.h.

## ◆ OnQueryTextFinished()

virtual void Window::OnQueryTextFinished | ( | char * | str | ) |
| inlinevirtual

The query window opened from this window has closed.

Parameters

  str | the new value of the string, nullptr if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str).

Reimplemented in VehicleViewWindow, CustomCurrencyWindow, CompanyWindow, ScenarioEditorToolbarWindow, GameSettingsWindow, NetworkJoinStatusWindow, StationViewWindow, NetworkClientListWindow, BuildVehicleWindow, SelectCompanyManagerFaceWindow, OrdersWindow, CreateScenarioWindow, NetworkStartServerWindow, NewGRFWindow, IndustryViewWindow, SpriteAlignerWindow, GenerateLandscapeWindow, VehicleGroupWindow, NetworkGameWindow, DepotWindow, TimetableWindow, NewGRFInspectWindow, TownViewWindow, AISettingsWindow, NewGRFParametersWindow, CheatWindow, GSConfigWindow, and WaypointWindow.

Definition at line 669 of file window_gui.h.

Referenced by QueryStringWindow::Close(), and SavePresetWindow::OnClick().

## ◆ OnResize()

virtual void Window::OnResize | ( |  | ) |
| inlinevirtual

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented in VehicleViewWindow, IndustryCargoesWindow, VehicleDetailsWindow, GameSettingsWindow, SelectStationWindow< T >, SavePresetWindow, VehicleListWindow, StationViewWindow, IndustryDirectoryWindow, BuildVehicleWindow, NetworkClientListWindow, OrdersWindow, AIDebugWindow, BuildRailStationWindow, MessageHistoryWindow, RefitWindow, IndustryViewWindow, DepotWindow, SpriteAlignerWindow, SelectCompanyLiveryWindow, PaymentRatesGraphWindow, TownDirectoryWindow, VehicleGroupWindow, NetworkContentListWindow, NetworkGameWindow, SaveLoadWindow, StoryBookWindow, NewGRFWindow, ReplaceVehicleWindow, FramerateWindow, BuildIndustryWindow, TimetableWindow, CompanyStationsWindow, NewGRFInspectWindow, TownViewWindow, AISettingsWindow, NewsWindow, BuildObjectWindow, NewGRFParametersWindow, MainWindow, GSConfigWindow, BuildBridgeWindow, GoalListWindow, SignListWindow, AIListWindow, SubsidyListWindow, WaypointWindow, ExtraViewportWindow, and TextfileWindow.

Definition at line 646 of file window_gui.h.

## ◆ OnRightClick()

virtual bool Window::OnRightClick | ( | Point | pt,
|  | int | widget
| ) |  |
| inlinevirtual

A click with the right mouse button has been made on the window.

Parameters

  pt | the point inside the window that has been clicked.
  widget | the clicked widget.

Returns
  true if the click was actually handled, i.e. do not show a tooltip if tooltip-on-right-click is enabled.

Reimplemented in DepotWindow, and SmallMapWindow.

Definition at line 562 of file window_gui.h.

## ◆ OnScroll()

virtual void Window::OnScroll | ( | Point | delta | ) |
| inlinevirtual

Handle the request for (viewport) scrolling.

Parameters

  delta | the amount the viewport must be scrolled.

Reimplemented in MainWindow, SmallMapWindow, and ExtraViewportWindow.

Definition at line 597 of file window_gui.h.

## ◆ OnTooltip()

virtual bool Window::OnTooltip | ( | Point | pt,
|  | int | widget,
|  | TooltipCloseCondition | close_cond
| ) |  |
| inlinevirtual

Event to display a custom tooltip.

Parameters

  pt | The point where the mouse is located.
  widget | The widget where the mouse is located.

Returns
  True if the event is handled, false if it is ignored.

Reimplemented in IndustryCargoesWindow, NetworkClientListWindow, ReplaceVehicleWindow, MainWindow, and LinkGraphLegendWindow.

Definition at line 577 of file window_gui.h.

## ◆ OnVehicleSelect() [1/2]

virtual bool Window::OnVehicleSelect | ( | const struct Vehicle * | v | ) |
| inlinevirtual

The user clicked on a vehicle while HT_VEHICLE has been set.

Parameters

  v | clicked vehicle

Returns
  true if the click is handled, false if it is ignored

Precondition
  v->IsPrimaryVehicle() == true

Definition at line 692 of file window_gui.h.

## ◆ OnVehicleSelect() [2/2]

virtual bool Window::OnVehicleSelect | ( | VehicleList::const_iterator | begin,
|  | VehicleList::const_iterator | end
| ) |  |
| inlinevirtual

The user clicked on a vehicle while HT_VEHICLE has been set.

Parameters

  v | clicked vehicle

Returns
  True if the click is handled, false if it is ignored

Precondition
  v->IsPrimaryVehicle() == true

Reimplemented in OrdersWindow, and DepotWindow.

Definition at line 700 of file window_gui.h.

## ◆ operator new[]()

void* Window::operator new[] | ( | size_t | size | ) |
| inlinedelete

Helper allocation function to disallow something.

Don't allow arrays; arrays of Windows are pointless as you need to destruct them all at the same time too, which is kinda hard.

Parameters

  size | the amount of space not to allocate

## ◆ RaiseButtons()

void Window::RaiseButtons | ( | bool | autoraise = `false` | ) |

Raise the buttons of the window.

Parameters

  autoraise | Raise only the push buttons of the window.

Definition at line 597 of file window.cpp.

References nested_array, nested_array_size, and NWidgetBase::type.

Referenced by CompanyWindow::OnPlaceObject(), BuildAirToolbarWindow::OnPlaceObjectAbort(), TerraformToolbarWindow::OnPlaceObjectAbort(), ScenarioEditorLandscapeGenerationWindow::OnPlaceObjectAbort(), BuildRailToolbarWindow::OnPlaceObjectAbort(), BuildIndustryWindow::OnPlaceObjectAbort(), FoundTownWindow::OnPlaceObjectAbort(), CompanyWindow::OnPlaceObjectAbort(), BuildIndustryWindow::OnTimeout(), and BuildTreesWindow::UpdateMode().

## ◆ RaiseWidget()

void Window::RaiseWidget | ( | byte | widget_index | ) |
| inline

Marks a widget as raised.

Parameters

  widget_index | index of this widget in the window

Definition at line 412 of file window_gui.h.

References SetWidgetLoweredState().

Referenced by BuildRailStationWindow::CheckSelectedSize(), BuildDocksStationWindow::OnClick(), CompanyStationsWindow::OnClick(), BuildDocksDepotWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), BuildRoadDepotWindow::OnClick(), BuildRoadStationWindow::OnClick(), CreateScenarioWindow::OnClick(), PerformanceRatingDetailWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildSignalWindow::OnClick(), BuildRailDepotWindow::OnClick(), SpriteAlignerWindow::OnInvalidateData(), PerformanceRatingDetailWindow::OnInvalidateData(), IndustryCargoesWindow::OnInvalidateData(), VehicleGroupWindow::OnPaint(), DepotWindow::OnPlaceObjectAbort(), ScenarioEditorLandscapeGenerationWindow::OnTimeout(), GenerateLandscapeWindow::OnTimeout(), DepotWindow::OnTimeout(), NetworkStartServerWindow::OnTimeout(), CreateScenarioWindow::OnTimeout(), MainToolbarWindow::OnTimeout(), ResetSignalVariant(), and SmallMapWindow::SwitchMapType().

## ◆ ReInit()

void Window::ReInit | ( | int | rx = `0`,
|  | int | ry = `0`
| ) |  |

Re-initialize a window, and optionally change its size.

Parameters

  rx | Horizontal resize of the window.
  ry | Vertical resize of the window.

Note
  For just resizing the window, use ResizeWindow instead.

Definition at line 1019 of file window.cpp.

References _current_text_dir, NWidgetBase::AssignSizePosition(), height, nested_root, OnInit(), resize, NWidgetBase::resize_x, NWidgetBase::resize_y, ResizeWindow(), SetDirty(), NWidgetBase::SetupSmallestSize(), NWidgetBase::smallest_x, NWidgetBase::smallest_y, ST_SMALLEST, ResizeInfo::step_height, ResizeInfo::step_width, TD_RTL, and width.

Referenced by BuildRailToolbarWindow::ModifyRailType(), BuildRoadToolbarWindow::ModifyRoadType(), CompanyFinancesWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), StationViewWindow::OnClick(), CompanyFinancesWindow::OnHundredthTick(), SmallMapWindow::OnInvalidateData(), TimetableWindow::OnInvalidateData(), LandInfoWindow::OnInvalidateData(), ScriptLeagueWindow::OnInvalidateData(), StationViewWindow::OnInvalidateData(), CompanyInfrastructureWindow::OnInvalidateData(), VehicleDetailsWindow::OnInvalidateData(), CompanyFinancesWindow::OnPaint(), IndustryViewWindow::OnPaint(), StationViewWindow::OnPaint(), BuildVehicleWindow::OnPaint(), CompanyWindow::OnPaint(), BuildObjectWindow::SelectOtherObject(), and SetShaded().

## ◆ SetFocusedWidget()

bool Window::SetFocusedWidget | ( | int | widget_index | ) |

Set focus within this window to the given widget.

The function however doesn't change which window has focus.

Parameters

  widget_index | Index of the widget in the window to set the focus to.

Returns
  Focus has changed.

Definition at line 519 of file window.cpp.

References VideoDriver::EditBoxGainedFocus(), VideoDriver::EditBoxLostFocus(), VideoDriver::GetInstance(), nested_array, nested_array_size, nested_focus, NWidgetBase::SetDirty(), NWidgetBase::type, and WWT_EDITBOX.

Referenced by NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), SignListWindow::OnHotkey(), OnHotkey(), BuildObjectWindow::OnHotkey(), BuildRailStationWindow::OnHotkey(), and SavePresetWindow::SavePresetWindow().

## ◆ SetShaded()

void Window::SetShaded | ( | bool | make_shaded | ) |

Set the shaded state of the window to make_shaded.

Parameters

  make_shaded | If `true`, shade the window (roll up until just the title bar is visible), else unshade/unroll the window to its original size.

Note
  The method uses Window::ReInit(), thus after the call, the whole window should be considered changed.

Definition at line 1055 of file window.cpp.

References height, nested_focus, ReInit(), NWidgetStacked::SetDisplayedPlane(), shade_select, NWidgetStacked::shown_plane, SZSP_HORIZONTAL, UnfocusFocusedWidget(), unshaded_size, and width.

Referenced by BringWindowToFrontById(), DispatchMouseWheelEvent(), and CompanyFinancesWindow::OnClick().

## ◆ SetStringParameters()

virtual void Window::SetStringParameters | ( | int | widget | ) | const
| inlinevirtual

Initialize string parameters for a widget.

Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.

Parameters

  widget | Widget number.

Reimplemented in VehicleViewWindow, BuyCompanyWindow, CustomCurrencyWindow, IndustryCargoesWindow, CompanyWindow, VehicleDetailsWindow, NetworkAskRelayWindow, ScenarioEditorToolbarWindow, GameSettingsWindow, VehicleListWindow, CompanyInfrastructureWindow, NetworkClientListWindow, BuildSignalWindow, IndustryDirectoryWindow, BuildVehicleWindow, SelectCompanyManagerFaceWindow, StationViewWindow, BuildRailStationWindow, QueryWindow, OrdersWindow, AIDebugWindow, CreateScenarioWindow, NetworkStartServerWindow, QueryStringWindow, IndustryViewWindow, RefitWindow, SelectCompanyLiveryWindow, SpriteAlignerWindow, TownDirectoryWindow, NewGRFWindow, FrametimeGraphWindow, AIConfigWindow, StoryBookWindow, ScriptTextfileWindow, NewGRFTextfileWindow, FramerateWindow, CompanyStationsWindow, BuildIndustryWindow, BuildRailToolbarWindow, AboutWindow, SignWindow, VehicleGroupWindow, MusicTrackSelectionWindow, NetworkChatWindow, GenerateLandscapeWindow, DepotWindow, NewsWindow, ReplaceVehicleWindow, TownViewWindow, GoalQuestionWindow, NewGRFInspectWindow, CompanyFinancesWindow, BuildRoadToolbarWindow, TimetableWindow, ScriptLeagueWindow, BuildAirportWindow, GameOptionsWindow, ErrmsgWindow, NewGRFParametersWindow, SignListWindow, TownAuthorityWindow, BuildObjectWindow, SmallMapWindow, SetDateWindow, BaseSetTextfileWindow< TBaseSet >, AIListWindow, OskWindow, WaypointWindow, ExtraViewportWindow, ContentTextfileWindow, and GoalListWindow.

Definition at line 522 of file window_gui.h.

Referenced by NWidgetBackground::SetupSmallestSize().

## ◆ SetWidgetDirty()

void Window::SetWidgetDirty | ( | byte | widget_index | ) | const

Invalidate a widget, i.e.

mark it as being changed and in need of redraw.

Parameters

  widget_index | the widget to redraw.

Definition at line 621 of file window.cpp.

References nested_array, and NWidgetBase::SetDirty().

Referenced by VehicleGroupWindow::DirtyHighlightedGroupWidget(), HandleActiveWidget(), HandleButtonClick(), StationViewWindow::HandleCargoWaitingClick(), HandleEditBoxKey(), HandleZoomMessage(), InsertTextString(), RefitWindow::OnClick(), SavePresetWindow::OnClick(), IndustryCargoesWindow::OnClick(), NewGRFWindow::OnDragDrop(), OrdersWindow::OnDragDrop(), OskWindow::OnEditboxChanged(), OskWindow::OnInvalidateData(), GoalListWindow::OnInvalidateData(), IndustryCargoesWindow::OnInvalidateData(), DepotWindow::OnMouseDrag(), RefitWindow::OnMouseDrag(), NewGRFWindow::OnMouseDrag(), OrdersWindow::OnMouseDrag(), NetworkClientListWindow::OnMouseOver(), VehicleViewWindow::OnMouseOver(), StoryBookWindow::OnPageElementClick(), StoryBookWindow::OnPaint(), AIDebugWindow::OnPaint(), StoryBookWindow::OnPlaceObject(), BuildRailToolbarWindow::OnPlaceObjectAbort(), StoryBookWindow::OnPlaceObjectAbort(), DepotWindow::OnPlaceObjectAbort(), VehicleGroupWindow::OnPlaceObjectAbort(), OrdersWindow::OnPlaceObjectAbort(), NetworkStartServerWindow::OnQueryTextFinished(), CreateScenarioWindow::OnQueryTextFinished(), StatusBarWindow::OnRealtimeTick(), MainToolbarWindow::OnRealtimeTick(), ScenarioEditorLandscapeGenerationWindow::OnTimeout(), GenerateLandscapeWindow::OnTimeout(), StoryBookWindow::OnTimeout(), DepotWindow::OnTimeout(), NetworkStartServerWindow::OnTimeout(), CreateScenarioWindow::OnTimeout(), MainToolbarWindow::OnTimeout(), ScenarioEditorToolbarWindow::OnTimeout(), OrdersWindow::OrderClick_Nonstop(), OrdersWindow::OrderClick_Unload(), ProcessHighlightedInvalidations(), SetWidgetHighlight(), SetWindowWidgetDirty(), BuildBridgeWindow::SortBridgeList(), CompanyStationsWindow::SortStationsList(), ToggleRailButton_Remove(), ToggleRoadButton_Remove(), and StoryBookWindow::UpdatePrevNextDisabledState().

## ◆ SetWidgetDisabledState()

void Window::SetWidgetDisabledState | ( | byte | widget_index,
|  | bool | disab_stat
| ) |  |
| inline

Sets the enabled/disabled status of a widget.

By default, widgets are enabled. On certain conditions, they have to be disabled.

Parameters

  widget_index | index of this widget in the window
  disab_stat | status to use ie: disabled = true, enabled = false

Definition at line 321 of file window_gui.h.

References nested_array_size.

Referenced by NetworkContentListWindow::BuildContentList(), DisableWidget(), EnableWidget(), HandleZoomMessage(), NetworkContentListWindow::NetworkContentListWindow(), RefitWindow::OnInit(), WaypointWindow::OnInvalidateData(), LinkGraphLegendWindow::OnInvalidateData(), GoalListWindow::OnInvalidateData(), GSConfigWindow::OnInvalidateData(), NewGRFParametersWindow::OnInvalidateData(), MusicTrackSelectionWindow::OnInvalidateData(), NewGRFInspectWindow::OnInvalidateData(), AIConfigWindow::OnInvalidateData(), NetworkContentListWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), AIDebugWindow::OnInvalidateData(), PerformanceRatingDetailWindow::OnInvalidateData(), NetworkClientListWindow::OnInvalidateData(), BuildSignalWindow::OnInvalidateData(), GameSettingsWindow::OnInvalidateData(), CompanyWindow::OnInvalidateData(), TownAuthorityWindow::OnPaint(), NetworkGameWindow::OnPaint(), CreateScenarioWindow::OnPaint(), StationViewWindow::OnPaint(), BuildVehicleWindow::OnPaint(), VehicleListWindow::OnPaint(), MainToolbarWindow::OnPaint(), CompanyWindow::OnPaint(), ScenarioEditorToolbarWindow::OnPaint(), VehicleViewWindow::OnPaint(), BuildIndustryWindow::SetButtons(), SetWidgetsDisabledState(), and StoryBookWindow::UpdatePrevNextDisabledState().

## ◆ SetWidgetHighlight()

void Window::SetWidgetHighlight | ( | byte | widget_index,
|  | TextColour | highlighted_colour
| ) |  |

Sets the highlighted status of a widget.

Parameters

  widget_index | index of this widget in the window
  highlighted_colour | Colour of highlight, or TC_INVALID to disable.

Definition at line 242 of file window.cpp.

References nested_array_size, and SetWidgetDirty().

## ◆ SetWidgetLoweredState()

void Window::SetWidgetLoweredState | ( | byte | widget_index,
|  | bool | lowered_stat
| ) |  |
| inline

Sets the lowered/raised status of a widget.

Parameters

  widget_index | index of this widget in the window
  lowered_stat | status to use ie: lowered = true, raised = false

Definition at line 382 of file window_gui.h.

References nested_array_size.

Referenced by LowerWidget(), SignListWindow::OnClick(), BuildAirportWindow::OnClick(), BuildVehicleWindow::OnClick(), TransparenciesWindow::OnInvalidateData(), SelectGameWindow::OnInvalidateData(), MusicTrackSelectionWindow::OnInvalidateData(), GenerateLandscapeWindow::OnInvalidateData(), GameOptionsWindow::OnInvalidateData(), MusicWindow::OnInvalidateData(), AIDebugWindow::OnInvalidateData(), BuildSignalWindow::OnInvalidateData(), DepotWindow::OnMouseDrag(), GameOptionsWindow::OnMouseLoop(), TownAuthorityWindow::OnPaint(), TownViewWindow::OnPaint(), NetworkGameWindow::OnPaint(), OrdersWindow::OnPaint(), CreateScenarioWindow::OnPaint(), StationViewWindow::OnPaint(), SelectCompanyManagerFaceWindow::OnPaint(), VehicleViewWindow::OnPaint(), DepotWindow::OnPlaceObjectAbort(), RaiseWidget(), and SetWidgetsLoweredState().

## ◆ SetWidgetsDisabledState()

void CDECL Window::SetWidgetsDisabledState | ( | bool | disab_stat,
|  | int | widgets,
|  |  | ...
| ) |  |

Sets the enabled/disabled status of a list of widgets.

By default, widgets are enabled. On certain conditions, they have to be disabled.

Parameters

  disab_stat | status to use ie: disabled = true, enabled = false
  widgets | list of widgets ended by WIDGET_LIST_END

Definition at line 560 of file window.cpp.

References SetWidgetDisabledState(), and WIDGET_LIST_END.

Referenced by AIDebugWindow::AIDebugWindow(), BuildAirToolbarWindow::OnInvalidateData(), BuildDocksToolbarWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), VehicleGroupWindow::OnPaint(), SelectCompanyManagerFaceWindow::OnPaint(), BuildVehicleWindow::OnPaint(), MainToolbarWindow::OnPaint(), and VehicleDetailsWindow::OnPaint().

## ◆ SetWidgetsLoweredState()

void CDECL Window::SetWidgetsLoweredState | ( | bool | lowered_stat,
|  | int | widgets,
|  |  | ...
| ) |  |

Sets the lowered/raised status of a list of widgets.

Parameters

  lowered_stat | status to use ie: lowered = true, raised = false
  widgets | list of widgets ended by WIDGET_LIST_END

Definition at line 579 of file window.cpp.

References SetWidgetLoweredState(), and WIDGET_LIST_END.

Referenced by SelectCompanyManagerFaceWindow::OnPaint(), and ScenarioEditorToolbarWindow::OnTimeout().

## ◆ ShowNewGRFInspectWindow()

virtual void Window::ShowNewGRFInspectWindow | ( |  | ) | const
| inlinevirtual

Show the NewGRF inspection window.

When this function is called it is up to the window to call and pass the right parameters to the ShowInspectWindow function.

Precondition
  this->IsNewGRFInspectable()

Reimplemented in VehicleViewWindow, IndustryViewWindow, and LandInfoWindow.

Definition at line 751 of file window_gui.h.

Referenced by NewGRFInspectWindow::OnClick().

## ◆ SortButtonWidth()

int Window::SortButtonWidth | ( |  | ) |
| static

Get width of up/down arrow of sort button state.

Returns
  Width of space required by sort button arrow.

Definition at line 907 of file widget.cpp.

Referenced by BuildBridgeWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), and IndustryDirectoryWindow::UpdateWidgetSize().

## ◆ ToggleWidgetLoweredState()

void Window::ToggleWidgetLoweredState | ( | byte | widget_index | ) |
| inline

Invert the lowered/raised status of a widget.

Parameters

  widget_index | index of this widget in the window

Definition at line 392 of file window_gui.h.

References nested_array_size.

Referenced by TextfileWindow::OnClick(), CompanyStationsWindow::OnClick(), NetworkCompanyPasswordWindow::OnClick(), IndustryCargoesWindow::OnClick(), MainToolbarWindow::OnRealtimeTick(), ScenarioEditorToolbarWindow::OnRealtimeTick(), ToggleRailButton_Remove(), and ToggleRoadButton_Remove().

## ◆ UnfocusFocusedWidget()

void Window::UnfocusFocusedWidget | ( |  | ) |

Makes no widget on this window have focus.

The function however doesn't change which window has focus.

Definition at line 503 of file window.cpp.

References VideoDriver::EditBoxLostFocus(), VideoDriver::GetInstance(), nested_focus, NWidgetBase::SetDirty(), NWidgetBase::type, and WWT_EDITBOX.

Referenced by SetShaded().

## ◆ UpdateWidgetSize()

virtual void Window::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize
| ) |  |
| inlinevirtual

Update size and resize step of a widget in the window.

After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.

Parameters

  widget | Widget number.
  size | Size of the widget.
  padding | Recommended amount of space between the widget content and the widget edge.
  fill | Fill step of the widget.
  resize | Resize step of the widget.

Reimplemented in VehicleViewWindow, BuyCompanyWindow, CustomCurrencyWindow, IndustryCargoesWindow, NetworkAskRelayWindow, ScenarioEditorToolbarWindow, CompanyWindow, VehicleDetailsWindow, NetworkCompanyPasswordWindow, SelectStationWindow< T >, NetworkJoinStatusWindow, ScanProgressWindow, SavePresetWindow, BuildRailWaypointWindow, GameSettingsWindow, BuildRailDepotWindow, CompanyInfrastructureWindow, VehicleListWindow, NetworkClientListWindow, BuildSignalWindow, IndustryDirectoryWindow, BuildVehicleWindow, SelectCompanyManagerFaceWindow, GenerateProgressWindow, StationViewWindow, BuildRailStationWindow, QueryWindow, CreateScenarioWindow, MessageHistoryWindow, PerformanceRatingDetailWindow, BuildRoadStationWindow, NetworkStartServerWindow, AIDebugWindow, QueryStringWindow, IndustryViewWindow, BuildRoadDepotWindow, PaymentRatesGraphWindow, TownDirectoryWindow, RefitWindow, SpriteAlignerWindow, SelectCompanyLiveryWindow, OrdersWindow, FrametimeGraphWindow, StoryBookWindow, AIConfigWindow, NewGRFWindow, TooltipsWindow, MusicWindow, DepotWindow, GenerateLandscapeWindow, NetworkContentListWindow, SaveLoadWindow, ScenarioEditorLandscapeGenerationWindow, FramerateWindow, BuildDocksDepotWindow, NetworkGameWindow, TownViewWindow, BaseGraphWindow, AboutWindow, MusicTrackSelectionWindow, BuildIndustryWindow, GoalQuestionWindow, CompanyFinancesWindow, VehicleGroupWindow, CompanyStationsWindow, NewGRFInspectWindow, ScriptLeagueWindow, GameOptionsWindow, NewsWindow, AISettingsWindow, BuildAirportWindow, ReplaceVehicleWindow, CheatWindow, SelectGameWindow, SignListWindow, TownAuthorityWindow, BuildObjectWindow, BootstrapAskForDownloadWindow, ErrmsgWindow, NewGRFParametersWindow, TimetableWindow, BuildBridgeWindow, GoalListWindow, BuildTreesWindow, GSConfigWindow, PerformanceLeagueWindow, SubsidyListWindow, LinkGraphLegendWindow, AIListWindow, StatusBarWindow, SetDateWindow, BootstrapErrorWindow, LandInfoWindow, EnginePreviewWindow, TextfileWindow, and BaseNetworkContentDownloadStatusWindow.

Definition at line 514 of file window_gui.h.

Referenced by NWidgetStacked::SetupSmallestSize().

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

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