70 static constexpr
float ASPECT_LOCATION = 12.f / 14.f;
71 static constexpr
float ASPECT_RENAME = 12.f / 14.f;
72 static constexpr
float ASPECT_SETTINGS_BUTTON = 21.f / 12.f;
73 static constexpr
float ASPECT_TOGGLE_SIZE = 12.f / 14.f;
74 static constexpr
float ASPECT_LEFT_RIGHT_BUTTON = 8.f / 12.f;
75 static constexpr
float ASPECT_UP_DOWN_BUTTON = 11.f / 12.f;
76 static constexpr
float ASPECT_VEHICLE_ICON = 15.f / 12.f;
77 static constexpr
float ASPECT_VEHICLE_FLAG = 11.f / 12.f;
84 static constexpr uint WD_SHADEBOX_WIDTH = 12;
85 static constexpr uint WD_STICKYBOX_WIDTH = 12;
86 static constexpr uint WD_DEBUGBOX_WIDTH = 12;
87 static constexpr uint WD_DEFSIZEBOX_WIDTH = 12;
88 static constexpr uint WD_RESIZEBOX_WIDTH = 12;
89 static constexpr uint WD_CLOSEBOX_WIDTH = 11;
90 static constexpr uint WD_CAPTION_HEIGHT = 14;
91 static constexpr uint WD_DROPDOWN_HEIGHT = 12;
97 .
imgbtn = { .left = 1, .top = 1, .right = 1, .bottom = 1},
98 .inset = { .left = 2, .top = 1, .right = 2, .bottom = 1},
99 .vscrollbar = { .left = 2, .top = 3, .right = 2, .bottom = 3},
100 .hscrollbar = { .left = 3, .top = 2, .right = 3, .bottom = 2},
101 .bevel = { .left = 1, .top = 1, .right = 1, .bottom = 1},
102 .fullbevel = { .left = 1, .top = 1, .right = 1, .bottom = 1},
103 .framerect = { .left = 2, .top = 1, .right = 2, .bottom = 1},
104 .frametext = { .left = 6, .top = 6, .right = 6, .bottom = 6},
105 .matrix = { .left = 2, .top = 3, .right = 2, .bottom = 1},
106 .shadebox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
107 .stickybox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
108 .debugbox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
109 .defsizebox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
110 .resizebox = { .left = 2, .top = 2, .right = 2, .bottom = 2},
111 .closebox = { .left = 2, .top = 2, .right = 1, .bottom = 2},
112 .captiontext = { .left = 2, .top = 2, .right = 2, .bottom = 2},
113 .dropdowntext = { .left = 2, .top = 1, .right = 2, .bottom = 1},
114 .dropdownlist = { .left = 1, .top = 2, .right = 1, .bottom = 2},
115 .modalpopup = { .left = 20, .top = 10, .right = 20, .bottom = 10},
116 .picker = { .left = 3, .top = 3, .right = 3, .bottom = 3},
117 .sparse = { .left = 10, .top = 8, .right = 10, .bottom = 8},
118 .sparse_resize = { .left = 10, .top = 8, .right = 10, .bottom = 0},
133 DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, flags);
139 using WindowList = std::list<Window *>;
141 extern Window *_focused_window;
164 const std::source_location location = std::source_location::current());
263 enum TooltipCloseCondition {
297 inline void *
operator new[](
size_t size) =
delete;
329 WindowList::iterator z_position;
331 template <
class NWID>
333 template <
class NWID>
352 template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value,
int> = 0>
389 NWidgetCore *nwid = this->GetWidget<NWidgetCore>(widget_index);
390 if (nwid !=
nullptr) nwid->
SetDisabled(disab_stat);
418 return this->GetWidget<NWidgetCore>(widget_index)->IsDisabled();
428 return this->nested_focus !=
nullptr && this->nested_focus->
index == widget_index;
449 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(lowered_stat);
458 bool lowered_state = this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
459 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(!lowered_state);
499 return this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
506 virtual void InsertTextString(
WidgetID wid,
const char *str,
bool marked,
const char *
caret,
const char *insert_location,
const char *replacement_end);
520 template<
typename... Args>
531 template<
typename... Args>
541 template<
typename... Args>
556 virtual void Close(
int data = 0);
560 void ReInit(
int rx = 0,
int ry = 0,
bool reposition =
false);
670 virtual void OnClick([[maybe_unused]]
Point pt, [[maybe_unused]]
WidgetID widget, [[maybe_unused]]
int click_count) {}
694 virtual bool OnTooltip([[maybe_unused]]
Point pt, [[maybe_unused]]
WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond) {
return false; }
786 virtual void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true) {}
810 virtual bool OnVehicleSelect([[maybe_unused]] VehicleList::const_iterator begin, [[maybe_unused]] VehicleList::const_iterator end) {
return false; }
867 template <
bool TtoBack>
872 typedef size_t difference_type;
873 typedef std::forward_iterator_tag iterator_category;
881 bool operator==(
const WindowIterator &other)
const {
return this->it == other.it; }
882 bool operator!=(
const WindowIterator &other)
const {
return !(*
this == other); }
883 Window * operator*()
const {
return *this->it; }
884 WindowIterator & operator++() { this->Next(); this->Validate();
return *
this; }
886 bool IsEnd()
const {
return this->it ==
_z_windows.end(); }
889 WindowList::iterator it;
892 while (!this->IsEnd() && *this->it ==
nullptr) this->Next();
896 if constexpr (!TtoBack) {
912 template <
bool Tfront>
917 if constexpr (Tfront) {
939 template <
class It,
class Pred>
942 return std::adjacent_find(begin, end, std::not_fn(pred)) == end;
951 template <
class NWID>
956 NWID *nwid =
dynamic_cast<NWID *
>(it->second);
957 assert(nwid !=
nullptr);
976 template <
class NWID>
979 return const_cast<Window *
>(
this)->GetWidget<NWID>(widnum);
994 void Close([[maybe_unused]]
int data = 0)
override;
1000 template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value,
int> = 0>
1014 template <
typename Wcls>
1018 if (w !=
nullptr)
return return_existing ? w :
nullptr;
1019 return new Wcls(desc, window_number);
1029 extern Point _cursorpos_drag_start;
1031 extern int _scrollbar_start_pos;
1032 extern int _scrollbar_size;
1033 extern uint8_t _scroller_click_timeout;
Base class for windows opened from a toolbar.
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Base class that provides memory initialization on dynamically created objects.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Types related to companies.
Owner
Enum for all companies/owners.
StringAlignment
How to align the to-be drawn text.
FontSize
Available font sizes.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Dimensions (a width and height) of a rectangle in 2D.
List of hotkeys for a window.
Coordinates of a point in 2D.
Data stored about a string that can be modified in the GUI.
Padding dimensions to apply to each side of a Rect.
Specification of a rectangle with absolute coordinates of all edges.
Data structure for resizing a window.
uint step_height
Step-size of height resize changes.
uint step_width
Step-size of width resize changes.
Helper/buffer for input fields.
bool caret
is the caret ("_") visible or not
Data structure for a window viewport.
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Data structure for viewport, display of a part of the world.
High level window description.
int16_t GetDefaultWidth() const
Determine default width of window.
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
int16_t pref_width
User-preferred width of the window. Zero if unset.
bool pref_sticky
Preferred stickyness.
HotkeyList * hotkeys
Hotkeys for the window.
WindowDesc(const WindowDesc &)=delete
Delete copy constructor to prevent compilers from copying the structure, which fails due to _window_d...
int16_t pref_height
User-preferred height of the window. Zero if unset.
int16_t GetDefaultHeight() const
Determine default height of window.
WindowClass cls
Class of the window,.
WindowDesc(WindowPosition default_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad, WindowClass window_class, WindowClass parent_class, uint32_t flags, const std::span< const NWidgetPart > nwid_parts, HotkeyList *hotkeys=nullptr, const std::source_location location=std::source_location::current())
Window description constructor.
WindowPosition default_pos
Preferred position of the window.
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
int16_t default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
WindowClass parent_cls
Class of the parent window.
int16_t default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
const std::source_location source_location
Source location of this definition.
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
const std::span< const NWidgetPart > nwid_parts
Span of nested widget parts describing the window.
Iterable ensemble of all valid Windows.
Iterator to iterate all valid Windows.
Data structure for an opened window.
virtual const struct Textbuf * GetFocusedTextbuf() const
Get the current input text buffer.
void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
A dragged 'object' has been released.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
bool IsWidgetGloballyFocused(WidgetID widget_index) const
Check if given widget has user input focus.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
uint8_t white_border_timer
Timer value of the WF_WHITE_BORDER for flags.
NWidgetStacked * shade_select
Selection widget (NWID_SELECTION) to use for shading the window. If nullptr, window cannot shade.
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
void DrawWidgets() const
Paint all widgets of a window.
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Window * parent
Parent window.
virtual ~Window()
Remove window and all its child windows from the window stack.
virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond)
Event to display a custom tooltip.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
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.
virtual bool OnVehicleSelect([[maybe_unused]] const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
virtual EventState OnKeyPress([[maybe_unused]] char32_t key, [[maybe_unused]] uint16_t keycode)
A key has been pressed.
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.
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
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.
virtual void OnGameTick()
Called once per (game) tick.
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
void RaiseWidgetWhenLowered(WidgetID widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
virtual void SetStringParameters([[maybe_unused]] WidgetID widget) const
Initialize string parameters for a widget.
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
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.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
ResizeInfo resize
Resize information.
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
int scale
Scale of this window – used to determine how to resize.
void ScheduleResize()
Mark this window as resized and in need of OnResize() event.
bool IsWidgetFocused(WidgetID widget_index) const
Check if given widget is focused within this window.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
virtual void OnPaint()
The window must be repainted.
virtual bool IsNewGRFInspectable() const
Is the data related to this window NewGRF inspectable?
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
WindowDesc & window_desc
Window description.
WindowClass window_class
Window class.
ViewportData * viewport
Pointer to viewport data, if present.
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.
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
virtual void OnFocusLost(bool closing)
The window has lost focus.
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.
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
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.
void DrawViewport() const
Draw the viewport of this window.
static std::vector< Window * > closed_windows
List of closed windows to delete.
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 b...
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
virtual void OnMouseWheel([[maybe_unused]] int wheel)
The mouse wheel has been turned.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number)
Compute the initial position of the window.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
virtual void OnQueryTextFinished([[maybe_unused]] std::optional< std::string > str)
The query window opened from this window has closed.
int left
x position of left edge of the window
bool IsShaded() const
Is window shaded currently?
Window * FindChildWindow(WindowClass wc=WC_INVALID) const
Find the Window whose parent pointer points to this window.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
const NWidgetCore * nested_focus
Currently focused nested widget, or nullptr if no nested widget has focus.
void UpdateQueryStringSize()
Update size of all QueryStrings of this window.
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
int top
y position of top edge of the window
const QueryString * GetQueryString(WidgetID widnum) const
Return the querystring associated to a editbox.
virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const
Draw the contents of a nested widget.
WidgetLookup widget_lookup
Indexed access to the nested widget tree. Do not access directly, use Window::GetWidget() instead.
virtual ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const
Get the character that is rendered at a position by the focused edit box.
std::vector< int > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
void ProcessScheduledResize()
Process scheduled OnResize() event.
EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode)
Process keypress for editbox widget.
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.
virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget)
The text in an editbox has been edited.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
virtual void OnResize()
Called after the window got resized.
virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
A click with the right mouse button has been made on the window.
virtual void OnFocus()
The window has gained focus.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index)
A dropdown option associated to this window has been selected.
virtual void OnTimeout()
Called when this window's timeout has been reached.
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.
WindowFlags flags
Window flags.
virtual void OnRealtimeTick([[maybe_unused]] uint delta_ms)
Called periodically.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
virtual void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true)
Some data on this window has become invalid.
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.
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
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.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static void DeleteClosedWindows()
Delete all closed windows.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
std::unique_ptr< NWidgetBase > nested_root
Root of the nested tree.
bool scheduled_resize
Set if window has been resized.
bool IsWidgetHighlighted(WidgetID widget_index) const
Gets the highlighted status of a widget.
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
virtual void OnScroll([[maybe_unused]] Point delta)
Handle the request for (viewport) scrolling.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
virtual void OnInit()
Notification that the nested widget tree gets initialized.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
WindowNumber window_number
Window number within the window class.
Types related to vehicles.
uint32_t VehicleID
The type all our vehicle IDs have.
Functions and type for generating vehicle lists.
Types related to viewports.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
SpecialMouseMode
Mouse modes.
@ WSM_DRAGDROP
Drag&drop an object.
@ WSM_DRAGGING
Dragging mode (trees).
@ WSM_PRESIZE
Presizing mode (docks, tunnels).
@ WSM_NONE
No special mouse mode.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
bool AllEqual(It begin, It end, Pred pred)
Generic helper function that checks if all elements of the range are equal with respect to the given ...
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
Draw a caption bar.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
SortButtonState
State of a sort direction button.
@ SBS_DOWN
Sort ascending.
@ SBS_OFF
Do not sort (with this button).
static const int TIMEOUT_DURATION
The initial timeout value for WF_TIMEOUT.
WidgetID GetWidgetFromPos(const Window *w, int x, int y)
Returns the index for the widget located at the given position relative to the window.
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar.
@ WF_DRAGGING
Window is being dragged.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ WF_TIMEOUT
Window timeout counter.
@ WF_SIZING_LEFT
Window is being resized towards the left.
@ WF_DISABLE_VP_SCROLL
Window does not do autoscroll,.
@ WF_SIZING
Window is being resized.
@ WF_HIGHLIGHTED
Window has a widget that has a highlight.
@ WF_STICKY
Window is made sticky by user.
@ WF_SIZING_RIGHT
Window is being resized towards the right.
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
FrameFlags
Flags to describe the look of the frame.
@ FR_DARKENED
If set the background is darker, allows for lowered frames with normal background colour when used wi...
@ FR_BORDERONLY
Draw border only, no background.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ FR_TRANSPARENT
Makes the background transparent if set.
Wcls * AllocateWindowDescFront(WindowDesc &desc, int window_number, bool return_existing=false)
Open a new window.
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y)
Special handling for the scrollbar widget type.
bool _mouse_hovering
The mouse is hovering over the same point.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
WindowDefaultFlag
Window default widget/window handling flags.
@ WDF_NO_CLOSE
This window can't be interactively closed.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount=0)
Shows a tooltip.
WindowList _z_windows
List of windows opened at the screen sorted from the front to back.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
static const int WHITE_BORDER_DURATION
The initial timeout value for WF_WHITE_BORDER.
Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step=1)
Apply 'scroll' to a rect to be drawn in.
WindowPosition
How do we the window to be placed?
@ WDP_CENTER
Center the window.
@ WDP_AUTO
Find a place automatically.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
int32_t WindowNumber
Number to differentiate different windows of the same class.
EventState
State of handling an event.
@ ES_NOT_HANDLED
The passed event is not handled.
WindowClass
Window classes.
@ WC_INVALID
Invalid window.