OpenTTD Source  20241108-master-g80f628063a
Window Struct Reference

Data structure for an opened window. More...

#include <window_gui.h>

Inheritance diagram for Window:
ZeroedMemoryAllocator AIConfigWindow AboutWindow BaseGraphWindow BaseNetworkContentDownloadStatusWindow BaseVehicleListWindow BootstrapAskForDownloadWindow BootstrapBackground BootstrapErrorWindow BuildAirToolbarWindow BuildBridgeWindow BuildDocksToolbarWindow BuildIndustryWindow BuildRailToolbarWindow BuildRoadToolbarWindow BuildTreesWindow BuildVehicleWindow BuyCompanyWindow CheatWindow CompanyFinancesWindow CompanyInfrastructureWindow CompanyStationsWindow CompanyWindow CreateScenarioWindow CustomCurrencyWindow DepotWindow DropdownWindow EndGameHighScoreBaseWindow EnginePreviewWindow ErrmsgWindow ExtraViewportWindow FoundTownWindow FramerateWindow FrametimeGraphWindow GSConfigWindow GameOptionsWindow GameSettingsWindow GenerateLandscapeWindow GenerateProgressWindow GoalListWindow GoalQuestionWindow GraphLegendWindow HelpWindow IConsoleWindow IndustryCargoesWindow IndustryDirectoryWindow IndustryViewWindow LandInfoWindow LinkGraphLegendWindow MainToolbarWindow MainWindow MessageHistoryWindow MusicTrackSelectionWindow MusicWindow NetworkAskRelayWindow NetworkAskSurveyWindow NetworkChatWindow NetworkClientListWindow NetworkContentListWindow NetworkGameWindow NetworkJoinStatusWindow NetworkStartServerWindow NewGRFInspectWindow NewGRFParametersWindow NewGRFWindow NewsWindow OrdersWindow OskWindow PerformanceLeagueWindow PerformanceRatingDetailWindow PickerWindowBase QueryStringWindow QueryWindow RefitWindow ReplaceVehicleWindow SaveLoadWindow SavePresetWindow ScanProgressWindow ScenarioEditorLandscapeGenerationWindow ScenarioEditorToolbarWindow ScreenshotWindow ScriptDebugWindow ScriptLeagueWindow ScriptListWindow ScriptSettingsWindow SelectCompanyLiveryWindow SelectCompanyManagerFaceWindow SelectGameWindow SelectStationWindow< T > SetDateWindow SignListWindow SignWindow SmallMapWindow SpriteAlignerWindow StationViewWindow StatusBarWindow StoryBookWindow SubsidyListWindow TerraformToolbarWindow TextfileWindow TimetableWindow TooltipsWindow TownAuthorityWindow TownDirectoryWindow TownViewWindow TransparenciesWindow VehicleDetailsWindow VehicleViewWindow WaypointWindow

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 (WidgetID widnum) const
 Get the nested widget with number widnum from the nested widget tree. More...
 
template<class NWID >
NWID * GetWidget (WidgetID widnum)
 Get the nested widget with number widnum from the nested widget tree. More...
 
const ScrollbarGetScrollbar (WidgetID widnum) const
 Return the Scrollbar to a widget index. More...
 
ScrollbarGetScrollbar (WidgetID widnum)
 Return the Scrollbar to a widget index. More...
 
const QueryStringGetQueryString (WidgetID widnum) const
 Return the querystring associated to a editbox. More...
 
QueryStringGetQueryString (WidgetID widnum)
 Return the querystring associated to a editbox. More...
 
void UpdateQueryStringSize ()
 Update size of all QueryStrings of this window.
 
virtual const struct TextbufGetFocusedTextbuf () const
 Get the current input text buffer. 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 ptrdiff_t 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 ()
 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...
 
template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0>
void FinishInitNested (T number)
 
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 (WidgetID widget_index, TextColour highlighted_colour)
 Sets the highlighted status of a widget. More...
 
bool IsWidgetHighlighted (WidgetID widget_index) const
 Gets the highlighted status of a widget. More...
 
void SetWidgetDisabledState (WidgetID widget_index, bool disab_stat)
 Sets the enabled/disabled status of a widget. More...
 
void DisableWidget (WidgetID widget_index)
 Sets a widget to disabled. More...
 
void EnableWidget (WidgetID widget_index)
 Sets a widget to Enabled. More...
 
bool IsWidgetDisabled (WidgetID widget_index) const
 Gets the enabled/disabled status of a widget. More...
 
bool IsWidgetFocused (WidgetID widget_index) const
 Check if given widget is focused within this window. More...
 
bool IsWidgetGloballyFocused (WidgetID widget_index) const
 Check if given widget has user input focus. More...
 
void SetWidgetLoweredState (WidgetID widget_index, bool lowered_stat)
 Sets the lowered/raised status of a widget. More...
 
void ToggleWidgetLoweredState (WidgetID widget_index)
 Invert the lowered/raised status of a widget. More...
 
void LowerWidget (WidgetID widget_index)
 Marks a widget as lowered. More...
 
void RaiseWidget (WidgetID widget_index)
 Marks a widget as raised. More...
 
void RaiseWidgetWhenLowered (WidgetID widget_index)
 Marks a widget as raised and dirty (redraw), when it is marked as lowered. More...
 
bool IsWidgetLowered (WidgetID widget_index) const
 Gets the lowered state of a widget. More...
 
void UnfocusFocusedWidget ()
 Makes no widget on this window have focus. More...
 
bool SetFocusedWidget (WidgetID widget_index)
 Set focus within this window to the given widget. More...
 
EventState HandleEditBoxKey (WidgetID wid, char32_t key, uint16_t keycode)
 Process keypress for editbox widget. More...
 
virtual void InsertTextString (WidgetID 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 (WidgetID 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, WidgetID 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...
 
template<typename... Args>
void SetWidgetsDisabledState (bool disab_stat, Args... widgets)
 Sets the enabled/disabled status of a list of widgets. More...
 
template<typename... Args>
void SetWidgetsLoweredState (bool lowered_stat, Args... widgets)
 Sets the lowered/raised status of a list of widgets. More...
 
template<typename... Args>
void RaiseWidgetsWhenLowered (Args... widgets)
 Raises the widgets and sets widgets dirty that are lowered. More...
 
void SetWidgetDirty (WidgetID 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 (WidgetID widget, SortButtonState state) const
 Draw a sort button's up or down arrow symbol. More...
 
WindowFindChildWindow (WindowClass wc=WC_INVALID) const
 Find the Window whose parent pointer points to this window. More...
 
void CloseChildWindows (WindowClass wc=WC_INVALID) const
 Close all children a window might have in a head-recursive manner. More...
 
virtual void Close (int data=0)
 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, bool reposition=false)
 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 ScheduleResize ()
 Mark this window as resized and in need of OnResize() event.
 
void ProcessScheduledResize ()
 Process scheduled OnResize() event.
 
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_t sm_width, int16_t 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 ([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const
 Draw the contents of a nested widget. More...
 
virtual void UpdateWidgetSize ([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize)
 Update size and resize step of a widget in the window. More...
 
virtual void SetStringParameters ([[maybe_unused]] WidgetID widget) const
 Initialize string parameters for a widget. More...
 
virtual void OnFocus ()
 The window has gained focus. More...
 
virtual void OnFocusLost (bool closing)
 The window has lost focus. More...
 
virtual EventState OnKeyPress ([[maybe_unused]] char32_t key, [[maybe_unused]] uint16_t 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 ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count)
 A click with the left mouse button has been made on the window. More...
 
virtual bool OnRightClick ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
 A click with the right mouse button has been made on the window. More...
 
virtual void OnHover ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
 The mouse is hovering over a widget in the window, perform an action for it. More...
 
virtual bool OnTooltip ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond)
 Event to display a custom tooltip. More...
 
virtual void OnMouseDrag ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
 An 'object' is being dragged at the provided position, highlight the target if possible. More...
 
virtual void OnDragDrop ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
 A dragged 'object' has been released. More...
 
virtual void OnScroll ([[maybe_unused]] Point delta)
 Handle the request for (viewport) scrolling. More...
 
virtual void OnMouseOver ([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
 The mouse is currently moving over the window or has just moved outside of the window. More...
 
virtual void OnMouseWheel ([[maybe_unused]] 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 OnRealtimeTick ([[maybe_unused]] 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 ([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index)
 A dropdown option associated to this window has been selected. More...
 
virtual void OnDropdownClose (Point pt, WidgetID widget, int index, bool instant_close)
 A dropdown window associated to this window has been closed. More...
 
virtual void OnEditboxChanged ([[maybe_unused]] WidgetID widget)
 The text in an editbox has been edited. More...
 
virtual void OnQueryTextFinished ([[maybe_unused]] std::optional< std::string > str)
 The query window opened from this window has closed. More...
 
virtual void OnInvalidateData ([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true)
 Some data on this window has become invalid. More...
 
virtual void OnPlaceObject ([[maybe_unused]] Point pt, [[maybe_unused]] TileIndex tile)
 The user clicked some place on the map when a tile highlight mode has been set. More...
 
virtual bool OnVehicleSelect ([[maybe_unused]] const struct Vehicle *v)
 The user clicked on a vehicle while HT_VEHICLE has been set. More...
 
virtual bool OnVehicleSelect ([[maybe_unused]] VehicleList::const_iterator begin, [[maybe_unused]] 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 ([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt)
 The user is dragging over the map when the tile highlight mode has been set. More...
 
virtual void OnPlaceMouseUp ([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile)
 The user has dragged over the map when the tile highlight mode has been set. More...
 
virtual void OnPlacePresize ([[maybe_unused]] Point pt, [[maybe_unused]] 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 NWidgetBaseGetWidget (WidgetID 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

WindowDescwindow_desc
 Window description.
 
WindowFlags flags
 Window flags.
 
WindowClass window_class
 Window class.
 
WindowNumber window_number
 Window number within the window class.
 
int scale
 Scale of this window – used to determine how to resize.
 
uint8_t timeout_timer
 Timer value of the WF_TIMEOUT for flags.
 
uint8_t 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.
 
ViewportDataviewport
 Pointer to viewport data, if present.
 
const NWidgetCorenested_focus
 Currently focused nested widget, or nullptr if no nested widget has focus.
 
std::map< WidgetID, QueryString * > querystrings
 QueryString associated to WWT_EDITBOX widgets.
 
std::unique_ptr< NWidgetBasenested_root
 Root of the nested tree.
 
WidgetLookup widget_lookup
 Indexed access to the nested widget tree. Do not access directly, use Window::GetWidget() instead.
 
NWidgetStackedshade_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).
 
WidgetID mouse_capture_widget
 ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
 
Windowparent
 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.
 
bool scheduled_resize
 Set if window has been resized.
 

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 273 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
descThe description of the window.

Definition at line 1756 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
wcWindow class of the window to remove; WC_INVALID if class does not matter

Definition at line 1035 of file window.cpp.

References Close(), and FindChildWindow().

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

◆ CreateNestedTree()

void Window::CreateNestedTree ( )

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

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

Parameters
fill_nestedFill the widget_lookup (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 1723 of file window.cpp.

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

Referenced by InitNested(), NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), SavePresetWindow::SavePresetWindow(), ScriptDebugWindow::ScriptDebugWindow(), ScriptListWindow::ScriptListWindow(), ScriptSettingsWindow::ScriptSettingsWindow(), VehicleDetailsWindow::VehicleDetailsWindow(), and WaypointWindow::WaypointWindow().

◆ DisableWidget()

void Window::DisableWidget ( WidgetID  widget_index)
inline

Sets a widget to disabled.

Parameters
widget_indexindex of this widget in the window

Definition at line 397 of file window_gui.h.

References SetWidgetDisabledState().

Referenced by TextfileWindow::AppendHistory(), and BuildRailToolbarWindow::OnPlaceObjectAbort().

◆ DrawSortButtonState()

void Window::DrawSortButtonState ( WidgetID  widget,
SortButtonState  state 
) const

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

Parameters
widgetSort button widget
stateState of sort button

Definition at line 763 of file widget.cpp.

References SBS_OFF, and widget_lookup.

Referenced by NetworkContentListWindow::OnPaint(), and StationViewWindow::OnPaint().

◆ DrawWidget()

virtual void Window::DrawWidget ( [[maybe_unused] ] const Rect r,
[[maybe_unused] ] WidgetID  widget 
) const
inlinevirtual

Draw the contents of a nested widget.

Parameters
rRectangle occupied by the widget.
widgetNumber of the widget to draw.
Note
This method may not change any state, it may only use drawing functions.

Definition at line 610 of file window_gui.h.

◆ EnableWidget()

void Window::EnableWidget ( WidgetID  widget_index)
inline

Sets a widget to Enabled.

Parameters
widget_indexindex of this widget in the window

Definition at line 406 of file window_gui.h.

References SetWidgetDisabledState().

Referenced by TextfileWindow::AppendHistory().

◆ FindChildWindow()

Window * Window::FindChildWindow ( WindowClass  wc = WC_INVALID) const

Find the Window whose parent pointer points to this window.

Parameters
wparent Window to find child of
wcWindow class of the window to remove; WC_INVALID if class does not matter
Returns
a Window pointer that is the child of w, or nullptr otherwise

Definition at line 1022 of file window.cpp.

References WC_INVALID.

Referenced by CloseChildWindows().

◆ 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_widthdefault width in pixels of the window
def_heightdefault height in pixels of the window
See also
Window::Window(), Window::InitializeData(), Window::InitializePositionSize()

Definition at line 1420 of file window.cpp.

References height, and width.

Referenced by FinishInitNested(), and ReInit().

◆ FinishInitNested()

◆ 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 378 of file window.cpp.

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

◆ GetFocusedTextbuf()

const Textbuf * Window::GetFocusedTextbuf ( ) const
virtual

Get the current input text buffer.

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

Reimplemented in IConsoleWindow.

Definition at line 365 of file window.cpp.

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

◆ GetQueryString() [1/2]

QueryString * Window::GetQueryString ( WidgetID  widnum)

Return the querystring associated to a editbox.

Parameters
widnumEditbox widget index
Returns
QueryString or nullptr.

Definition at line 345 of file window.cpp.

References querystrings.

◆ GetQueryString() [2/2]

const QueryString * Window::GetQueryString ( WidgetID  widnum) const

Return the querystring associated to a editbox.

Parameters
widnumEditbox widget index
Returns
QueryString or nullptr.

Definition at line 334 of file window.cpp.

References querystrings.

Referenced by GetCaretPosition(), GetFocusedTextbuf(), GetTextBoundingRect(), GetTextCharacterAtPosition(), and InsertTextString().

◆ GetRowFromWidget()

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

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

Parameters
clickposVertical position of the mouse click.
widgetWidget number of the widget clicked in.
paddingAmount of empty space between the widget edge and the top of the first row.
line_heightHeight 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 213 of file window.cpp.

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

Referenced by TextfileWindow::CheckHyperlinkClick(), and Scrollbar::GetScrolledRowFromWidget().

◆ GetScrollbar() [1/2]

Scrollbar * Window::GetScrollbar ( WidgetID  widnum)

Return the Scrollbar to a widget index.

Parameters
widnumScrollbar widget index
Returns
Scrollbar to the widget

Definition at line 324 of file window.cpp.

◆ GetScrollbar() [2/2]

◆ 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
fromStart of the string range.
toEnd of the string range.
Returns
Rectangle encompassing the string range, relative to the window.

Reimplemented in IConsoleWindow.

Definition at line 394 of file window.cpp.

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

◆ GetTextCharacterAtPosition()

ptrdiff_t Window::GetTextCharacterAtPosition ( const Point pt) const
virtual

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

Parameters
ptThe position to test.
Returns
Index of the character position or -1 if no character is at the position.

Reimplemented in IConsoleWindow.

Definition at line 409 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 ( WidgetID  widnum)
inline

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

Template Parameters
NWIDType of the nested widget.
Parameters
widnumWidget number of the widget to retrieve.
Returns
The requested widget if it is instantiated, nullptr otherwise.

Definition at line 952 of file window_gui.h.

References widget_lookup.

◆ GetWidget() [2/2]

template<class NWID >
const NWID * Window::GetWidget ( WidgetID  widnum) const
inline

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

Template Parameters
NWIDType of the nested widget.
Parameters
widnumWidget number of the widget to retrieve.
Returns
The requested widget if it is instantiated, nullptr otherwise.

Definition at line 977 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 ( WidgetID  widget)

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

Parameters
widgetthe widget to "click"

Definition at line 590 of file window.cpp.

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

◆ HandleEditBoxKey()

EventState Window::HandleEditBoxKey ( WidgetID  wid,
char32_t  key,
uint16_t  keycode 
)

Process keypress for editbox widget.

Parameters
widEditbox widget.
keythe Unicode value of the key.
keycodethe 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 2473 of file window.cpp.

◆ InitializeData()

void Window::InitializeData ( WindowNumber  window_number)
protected

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

Parameters
window_numberNumber 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, widget_lookup is either nullptr, or already initialized.

Definition at line 1364 of file window.cpp.

References _current_text_dir, WindowDesc::cls, WindowDesc::default_pos, flags, INVALID_OWNER, nested_focus, nested_root, OnInit(), owner, resize, SetWhiteBorder(), ST_SMALLEST, ResizeInfo::step_height, ResizeInfo::step_width, TD_RTL, WDP_CENTER, WF_CENTERED, window_class, window_desc, and window_number.

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
xOffset in pixels from the left of the screen of the new window.
yOffset in pixels from the top of the screen of the new window.
sm_widthSmallest width in pixels of the window.
sm_heightSmallest height in pixels of the window.

Definition at line 1402 of file window.cpp.

Referenced by FinishInitNested(), and ReInit().

◆ InitNested()

void Window::InitNested ( WindowNumber  window_number = 0)

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

Parameters
window_numberNumber of the new window.

Definition at line 1746 of file window.cpp.

References CreateNestedTree(), and FinishInitNested().

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

◆ InsertTextString()

void Window::InsertTextString ( WidgetID  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
widEdit box widget.
strText string to insert.

Reimplemented in IConsoleWindow.

Definition at line 2631 of file window.cpp.

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

◆ InvalidateData()

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

◆ 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, LandInfoWindow, and IndustryViewWindow.

Definition at line 853 of file window_gui.h.

◆ IsWidgetDisabled()

bool Window::IsWidgetDisabled ( WidgetID  widget_index) const
inline

Gets the enabled/disabled status of a widget.

Parameters
widget_indexindex of this widget in the window
Returns
status of the widget ie: disabled = true, enabled = false

Definition at line 416 of file window_gui.h.

Referenced by BuildRailClick_Remove(), ScriptDebugWindow::DrawWidgetCompanyButton(), HandlePlacePushButton(), DepotWindow::OnTimeout(), RailToolbar_CtrlChanged(), RoadToolbar_CtrlChanged(), LinkGraphLegendWindow::SetOverlay(), and LinkGraphLegendWindow::UpdateOverlayCompanies().

◆ IsWidgetFocused()

bool Window::IsWidgetFocused ( WidgetID  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 426 of file window_gui.h.

References NWidgetCore::index.

◆ IsWidgetGloballyFocused()

bool Window::IsWidgetGloballyFocused ( WidgetID  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 437 of file window_gui.h.

◆ IsWidgetHighlighted()

bool Window::IsWidgetHighlighted ( WidgetID  widget_index) const

Gets the highlighted status of a widget.

Parameters
widget_indexindex of this widget in the window
Returns
status of the widget ie: highlighted = true, not highlighted = false

Definition at line 272 of file window.cpp.

◆ IsWidgetLowered()

◆ LowerWidget()

void Window::LowerWidget ( WidgetID  widget_index)
inline

◆ OnClick()

virtual void Window::OnClick ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget,
[[maybe_unused] ] int  click_count 
)
inlinevirtual

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

Parameters
ptthe point inside the window that has been clicked.
widgetthe clicked widget.
click_countNumber of fast consecutive clicks at same position

Reimplemented in EndGameHighScoreBaseWindow.

Definition at line 670 of file window_gui.h.

Referenced by 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 BuildRoadToolbarWindow, BuildRailToolbarWindow, and DepotWindow.

Definition at line 661 of file window_gui.h.

References ES_NOT_HANDLED.

Referenced by HandleCtrlChanged().

◆ OnDragDrop()

virtual void Window::OnDragDrop ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget 
)
inlinevirtual

A dragged 'object' has been released.

Parameters
ptthe point inside the window where the release took place.
widgetthe widget where the release took place.

Definition at line 708 of file window_gui.h.

◆ OnDropdownClose()

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

A dropdown window associated to this window has been closed.

Parameters
ptthe point inside the window the mouse resides on after closure.
widgetthe widget (button) that the dropdown is associated with.
indexthe element in the dropdown that is selected.
instant_closewhether the dropdown was configured to close on mouse up.

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

Definition at line 287 of file window.cpp.

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

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

◆ OnDropdownSelect()

virtual void Window::OnDropdownSelect ( [[maybe_unused] ] WidgetID  widget,
[[maybe_unused] ] int  index 
)
inlinevirtual

A dropdown option associated to this window has been selected.

Parameters
widgetthe widget (button) that the dropdown is associated with.
indexthe element in the dropdown that is selected.

Definition at line 763 of file window_gui.h.

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

◆ OnEditboxChanged()

virtual void Window::OnEditboxChanged ( [[maybe_unused] ] WidgetID  widget)
inlinevirtual

The text in an editbox has been edited.

Parameters
widgetThe widget of the editbox.

Definition at line 771 of file window_gui.h.

Referenced by InsertTextString().

◆ OnFocus()

void Window::OnFocus ( )
virtual

The window has gained focus.

Called when window gains focus.

Reimplemented in IConsoleWindow.

Definition at line 508 of file window.cpp.

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

◆ OnFocusLost()

void Window::OnFocusLost ( bool  closing)
virtual

The window has lost focus.

Called when window loses focus.

Parameters
closingTrue iff the window has lost focus in the process of closing.

Reimplemented in IConsoleWindow, OskWindow, and DropdownWindow.

Definition at line 516 of file window.cpp.

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

◆ OnHotkey()

EventState Window::OnHotkey ( int  hotkey)
virtual

A hotkey has been pressed.

Parameters
hotkeyHotkey 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, TownDirectoryWindow, ScenarioEditorToolbarWindow, MainToolbarWindow, SignListWindow, BuildRoadToolbarWindow, BuildRailToolbarWindow, PickerWindow, OrdersWindow, MainWindow, IndustryDirectoryWindow, and BuildVehicleWindow.

Definition at line 565 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 ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget 
)
inlinevirtual

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

Parameters
ptThe point where the mouse is hovering.
widgetThe widget where the mouse is hovering.

Definition at line 686 of file window_gui.h.

◆ OnInit()

◆ OnInitialPosition()

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

Compute the initial position of the window.

Parameters
sm_widthSmallest width of the window.
sm_heightSmallest height of the window.
window_numberThe window number of the new window.
Returns
Initial position of the top-left corner of the window.

Definition at line 1711 of file window.cpp.

References LocalGetWindowPlacement(), window_desc, and window_number.

Referenced by FinishInitNested(), and ReInit().

◆ OnInvalidateData()

virtual void Window::OnInvalidateData ( [[maybe_unused] ] int  data = 0,
[[maybe_unused] ] bool  gui_scope = true 
)
inlinevirtual

Some data on this window has become invalid.

Parameters
datainformation about the changed data.
gui_scopeWhether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

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

Definition at line 786 of file window_gui.h.

Referenced by InvalidateData(), and ProcessScheduledInvalidations().

◆ OnKeyPress()

virtual EventState Window::OnKeyPress ( [[maybe_unused] ] char32_t  key,
[[maybe_unused] ] uint16_t  keycode 
)
inlinevirtual

A key has been pressed.

Parameters
keythe Unicode value of the key.
keycodethe 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 652 of file window_gui.h.

◆ OnMouseDrag()

virtual void Window::OnMouseDrag ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget 
)
inlinevirtual

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

Parameters
ptThe point inside the window that the mouse hovers over.
widgetThe widget the mouse hovers over.

Definition at line 701 of file window_gui.h.

◆ OnMouseOver()

virtual void Window::OnMouseOver ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  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
ptthe point inside the window that the mouse hovers over.
widgetthe widget the mouse hovers over.

Definition at line 722 of file window_gui.h.

◆ OnMouseWheel()

virtual void Window::OnMouseWheel ( [[maybe_unused] ] int  wheel)
inlinevirtual

The mouse wheel has been turned.

Parameters
wheelthe amount of movement of the mouse wheel.

Definition at line 728 of file window_gui.h.

◆ OnPaint()

◆ OnPlaceDrag()

virtual void Window::OnPlaceDrag ( [[maybe_unused] ] ViewportPlaceMethod  select_method,
[[maybe_unused] ] ViewportDragDropSelectionProcess  select_proc,
[[maybe_unused] ] Point  pt 
)
inlinevirtual

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

Parameters
select_methodthe method of selection (allowed directions)
select_procwhat will be created when the drag is over.
ptthe exact point on the map where the mouse is.

Definition at line 825 of file window_gui.h.

◆ OnPlaceMouseUp()

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

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

Parameters
select_methodthe method of selection (allowed directions)
select_procwhat should be created.
ptthe exact point on the map where the mouse was released.
start_tilethe begin tile of the drag.
end_tilethe end tile of the drag.

Definition at line 836 of file window_gui.h.

Referenced by PlaceRail_Bridge(), and PlaceRoad_Bridge().

◆ OnPlaceObject()

virtual void Window::OnPlaceObject ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] TileIndex  tile 
)
inlinevirtual

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

Parameters
ptthe exact point on the map that has been clicked.
tilethe tile on the map that has been clicked.

Definition at line 794 of file window_gui.h.

◆ OnPlacePresize()

virtual void Window::OnPlacePresize ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] 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
ptthe exact point on the map where the mouse is.
tilethe tile on the map where the mouse is.

Definition at line 845 of file window_gui.h.

◆ OnQueryTextFinished()

virtual void Window::OnQueryTextFinished ( [[maybe_unused] ] std::optional< std::string >  str)
inlinevirtual

The query window opened from this window has closed.

Parameters
strthe new value of the string, std::nullopt if the window was cancelled or an empty string when the default button was pressed, i.e. str->empty().

Definition at line 779 of file window_gui.h.

◆ OnResize()

◆ OnRightClick()

virtual bool Window::OnRightClick ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget 
)
inlinevirtual

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

Parameters
ptthe point inside the window that has been clicked.
widgetthe clicked widget.
Returns
true if the click was actually handled, i.e. do not show a tooltip if tooltip-on-right-click is enabled.

Definition at line 679 of file window_gui.h.

◆ OnScroll()

virtual void Window::OnScroll ( [[maybe_unused] ] Point  delta)
inlinevirtual

Handle the request for (viewport) scrolling.

Parameters
deltathe amount the viewport must be scrolled.

Definition at line 714 of file window_gui.h.

◆ OnTooltip()

virtual bool Window::OnTooltip ( [[maybe_unused] ] Point  pt,
[[maybe_unused] ] WidgetID  widget,
[[maybe_unused] ] TooltipCloseCondition  close_cond 
)
inlinevirtual

Event to display a custom tooltip.

Parameters
ptThe point where the mouse is located.
widgetThe widget where the mouse is located.
Returns
True if the event is handled, false if it is ignored.

Definition at line 694 of file window_gui.h.

◆ OnVehicleSelect() [1/2]

virtual bool Window::OnVehicleSelect ( [[maybe_unused] ] const struct Vehicle v)
inlinevirtual

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

Parameters
vclicked vehicle
Returns
true if the click is handled, false if it is ignored
Precondition
v->IsPrimaryVehicle() == true

Definition at line 802 of file window_gui.h.

◆ OnVehicleSelect() [2/2]

virtual bool Window::OnVehicleSelect ( [[maybe_unused] ] VehicleList::const_iterator  begin,
[[maybe_unused] ] VehicleList::const_iterator  end 
)
inlinevirtual

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

Parameters
vclicked vehicle
Returns
True if the click is handled, false if it is ignored
Precondition
v->IsPrimaryVehicle() == true

Definition at line 810 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
sizethe amount of space not to allocate

◆ RaiseButtons()

◆ RaiseWidget()

void Window::RaiseWidget ( WidgetID  widget_index)
inline

◆ RaiseWidgetsWhenLowered()

template<typename... Args>
void Window::RaiseWidgetsWhenLowered ( Args...  widgets)
inline

Raises the widgets and sets widgets dirty that are lowered.

Parameters
widgetslist of widgets

Definition at line 542 of file window_gui.h.

References RaiseWidgetWhenLowered().

Referenced by GenerateLandscapeWindow::OnTimeout(), CreateScenarioWindow::OnTimeout(), and NetworkStartServerWindow::OnTimeout().

◆ RaiseWidgetWhenLowered()

void Window::RaiseWidgetWhenLowered ( WidgetID  widget_index)
inline

Marks a widget as raised and dirty (redraw), when it is marked as lowered.

Parameters
widget_indexindex of this widget in the window

Definition at line 484 of file window_gui.h.

References IsWidgetLowered(), RaiseWidget(), and SetWidgetDirty().

Referenced by IndustryCargoesWindow::OnInvalidateData(), ScenarioEditorLandscapeGenerationWindow::OnTimeout(), MainToolbarWindow::OnTimeout(), and RaiseWidgetsWhenLowered().

◆ ReInit()

void Window::ReInit ( int  rx = 0,
int  ry = 0,
bool  reposition = false 
)

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

Parameters
rxHorizontal resize of the window.
ryVertical resize of the window.
repositionIf set, reposition the window to default location.
Note
For just resizing the window, use ResizeWindow instead.

Definition at line 952 of file window.cpp.

References _current_text_dir, _gui_scale, FindWindowPlacementAndResize(), WindowDesc::GetDefaultWidth(), height, InitializePositionSize(), nested_root, OnInit(), OnInitialPosition(), resize, ResizeWindow(), scale, SetDirty(), ST_SMALLEST, ResizeInfo::step_height, ResizeInfo::step_width, TD_RTL, width, window_desc, and window_number.

Referenced by TextfileWindow::AfterLoadText(), TextfileWindow::LoadText(), TextfileWindow::LoadTextfile(), BuildRailToolbarWindow::ModifyRailType(), BuildRoadToolbarWindow::ModifyRoadType(), CompanyInfrastructureWindow::OnInvalidateData(), ScriptLeagueWindow::OnInvalidateData(), LandInfoWindow::OnInvalidateData(), MusicTrackSelectionWindow::OnInvalidateData(), MusicWindow::OnInvalidateData(), ScriptDebugWindow::OnInvalidateData(), StationViewWindow::OnInvalidateData(), TimetableWindow::OnInvalidateData(), RefitWindow::OnInvalidateData(), VehicleDetailsWindow::OnInvalidateData(), ReplaceVehicleWindow::OnPaint(), BuildVehicleWindow::OnPaint(), CompanyFinancesWindow::OnPaint(), CompanyWindow::OnPaint(), DepotWindow::OnPaint(), IndustryViewWindow::OnPaint(), NetworkGameWindow::OnPaint(), StationViewWindow::OnPaint(), SelectGameWindow::OnResize(), and SetShaded().

◆ SetFocusedWidget()

bool Window::SetFocusedWidget ( WidgetID  widget_index)

Set focus within this window to the given widget.

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

Parameters
widget_indexIndex of the widget in the window to set the focus to.
Returns
Focus has changed.

Definition at line 486 of file window.cpp.

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

Referenced by NetworkChatWindow::NetworkChatWindow(), NetworkContentListWindow::NetworkContentListWindow(), OnHotkey(), BuildVehicleWindow::OnHotkey(), IndustryDirectoryWindow::OnHotkey(), PickerWindow::OnHotkey(), SignListWindow::OnHotkey(), TownDirectoryWindow::OnHotkey(), and SavePresetWindow::SavePresetWindow().

◆ SetShaded()

void Window::SetShaded ( bool  make_shaded)

Set the shaded state of the window to make_shaded.

Parameters
make_shadedIf 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 995 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(), and DispatchMouseWheelEvent().

◆ SetStringParameters()

virtual void Window::SetStringParameters ( [[maybe_unused] ] WidgetID  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
widgetWidget number.

Definition at line 632 of file window_gui.h.

Referenced by NWidgetBackground::SetupSmallestSize().

◆ SetWidgetDirty()

◆ SetWidgetDisabledState()

void Window::SetWidgetDisabledState ( WidgetID  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_indexindex of this widget in the window
disab_statstatus to use ie: disabled = true, enabled = false

Definition at line 387 of file window_gui.h.

References NWidgetCore::SetDisabled().

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

◆ SetWidgetHighlight()

void Window::SetWidgetHighlight ( WidgetID  widget_index,
TextColour  highlighted_colour 
)

Sets the highlighted status of a widget.

Parameters
widget_indexindex of this widget in the window
highlighted_colourColour of highlight, or TC_INVALID to disable.

Definition at line 242 of file window.cpp.

References NWidgetBase::SetDirty().

◆ SetWidgetLoweredState()

◆ SetWidgetsDisabledState()

template<typename... Args>
void Window::SetWidgetsDisabledState ( bool  disab_stat,
Args...  widgets 
)
inline

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_statstatus to use ie: disabled = true, enabled = false
widgetslist of widgets

Definition at line 521 of file window_gui.h.

References SetWidgetDisabledState().

Referenced by ScriptDebugWindow::OnInit(), BuildDocksToolbarWindow::OnInvalidateData(), SpriteAlignerWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), BuildVehicleWindow::OnPaint(), SelectCompanyManagerFaceWindow::OnPaint(), VehicleGroupWindow::OnPaint(), MainToolbarWindow::OnPaint(), VehicleDetailsWindow::OnPaint(), and ScriptDebugWindow::UpdateLogScroll().

◆ SetWidgetsLoweredState()

template<typename... Args>
void Window::SetWidgetsLoweredState ( bool  lowered_stat,
Args...  widgets 
)
inline

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

Parameters
lowered_statstatus to use ie: lowered = true, raised = false
widgetslist of widgets

Definition at line 532 of file window_gui.h.

References SetWidgetLoweredState().

Referenced by SpriteAlignerWindow::OnInvalidateData(), 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, LandInfoWindow, and IndustryViewWindow.

Definition at line 861 of file window_gui.h.

◆ 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 780 of file widget.cpp.

◆ ToggleWidgetLoweredState()

void Window::ToggleWidgetLoweredState ( WidgetID  widget_index)
inline

Invert the lowered/raised status of a widget.

Parameters
widget_indexindex of this widget in the window

Definition at line 456 of file window_gui.h.

Referenced by 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 470 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 ( [[maybe_unused] ] WidgetID  widget,
[[maybe_unused] ] Dimension size,
[[maybe_unused] ] const Dimension padding,
[[maybe_unused] ] Dimension fill,
[[maybe_unused] ] 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
widgetWidget number.
[in,out]sizeSize of the widget.
paddingRecommended amount of space between the widget content and the widget edge.
[in,out]fillFill step of the widget.
[in,out]resizeResize step of the widget.

Definition at line 624 of file window_gui.h.

Referenced by NWidgetStacked::SetupSmallestSize().


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