OpenTTD Source: src/window_gui.h Source File

OpenTTD Source 1.11.0-RC1

window_gui.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef WINDOW_GUI_H
11 #define WINDOW_GUI_H
12
13 #include "vehicle_type.h"
14 #include "viewport_type.h"
15 #include "company_type.h"
16 #include "tile_type.h"
17 #include "widget_type.h"
18 #include "core/smallvec_type.hpp"
19 #include "core/smallmap_type.hpp"
20 #include "string_type.h"
21
25 enum FrameFlags {
26 FR_NONE = 0,
27 FR_TRANSPARENT = 1 << 0,
28 FR_BORDERONLY = 1 << 4,
29 FR_LOWERED = 1 << 5,
30 FR_DARKENED = 1 << 6,
31 };
32
33 DECLARE_ENUM_AS_BIT_SET(FrameFlags)
34
35
36 enum WidgetDrawDistances {
37 /* WWT_IMGBTN(_2) */
38 WD_IMGBTN_LEFT = 1,
39 WD_IMGBTN_RIGHT = 2,
40 WD_IMGBTN_TOP = 1,
41 WD_IMGBTN_BOTTOM = 2,
42
43 /* WWT_INSET */
44 WD_INSET_LEFT = 2,
45 WD_INSET_RIGHT = 2,
46 WD_INSET_TOP = 1,
47
48 WD_SCROLLBAR_LEFT = 2,
49 WD_SCROLLBAR_RIGHT = 2,
50 WD_SCROLLBAR_TOP = 2,
51 WD_SCROLLBAR_BOTTOM = 2,
52
53 /* Size of the pure frame bevel without any padding. */
54 WD_BEVEL_LEFT = 1,
55 WD_BEVEL_RIGHT = 1,
56 WD_BEVEL_TOP = 1,
57 WD_BEVEL_BOTTOM = 1,
58
59 /* FrameRect widgets, all text buttons, panel, editbox */
60 WD_FRAMERECT_LEFT = 2,
61 WD_FRAMERECT_RIGHT = 2,
62 WD_FRAMERECT_TOP = 1,
63 WD_FRAMERECT_BOTTOM = 1,
64
65 /* Extra space at top/bottom of text panels */
66 WD_TEXTPANEL_TOP = 6,
67 WD_TEXTPANEL_BOTTOM = 6,
68
69 /* WWT_FRAME */
70 WD_FRAMETEXT_LEFT = 6,
71 WD_FRAMETEXT_RIGHT = 6,
72 WD_FRAMETEXT_TOP = 6,
73 WD_FRAMETEXT_BOTTOM = 6,
74
75 /* WWT_MATRIX */
76 WD_MATRIX_LEFT = 2,
77 WD_MATRIX_RIGHT = 2,
78 WD_MATRIX_TOP = 3,
79 WD_MATRIX_BOTTOM = 1,
80
81 /* WWT_SHADEBOX */
82 WD_SHADEBOX_WIDTH = 12,
83 WD_SHADEBOX_LEFT = 2,
84 WD_SHADEBOX_RIGHT = 2,
85 WD_SHADEBOX_TOP = 3,
86 WD_SHADEBOX_BOTTOM = 3,
87
88 /* WWT_STICKYBOX */
89 WD_STICKYBOX_WIDTH = 12,
90 WD_STICKYBOX_LEFT = 2,
91 WD_STICKYBOX_RIGHT = 2,
92 WD_STICKYBOX_TOP = 3,
93 WD_STICKYBOX_BOTTOM = 3,
94
95 /* WWT_DEBUGBOX */
96 WD_DEBUGBOX_WIDTH = 12,
97 WD_DEBUGBOX_LEFT = 2,
98 WD_DEBUGBOX_RIGHT = 2,
99 WD_DEBUGBOX_TOP = 3,
100 WD_DEBUGBOX_BOTTOM = 3,
101
102 /* WWT_DEFSIZEBOX */
103 WD_DEFSIZEBOX_WIDTH = 12,
104 WD_DEFSIZEBOX_LEFT = 2,
105 WD_DEFSIZEBOX_RIGHT = 2,
106 WD_DEFSIZEBOX_TOP = 3,
107 WD_DEFSIZEBOX_BOTTOM = 3,
108
109 /* WWT_RESIZEBOX */
110 WD_RESIZEBOX_WIDTH = 12,
111 WD_RESIZEBOX_LEFT = 3,
112 WD_RESIZEBOX_RIGHT = 2,
113 WD_RESIZEBOX_TOP = 3,
114 WD_RESIZEBOX_BOTTOM = 2,
115
116 /* WWT_CLOSEBOX */
117 WD_CLOSEBOX_WIDTH = 11,
118 WD_CLOSEBOX_LEFT = 2,
119 WD_CLOSEBOX_RIGHT = 1,
120 WD_CLOSEBOX_TOP = 2,
121 WD_CLOSEBOX_BOTTOM = 2,
122
123 /* WWT_CAPTION */
124 WD_CAPTION_HEIGHT = 14,
125 WD_CAPTIONTEXT_LEFT = 2,
126 WD_CAPTIONTEXT_RIGHT = 2,
127 WD_CAPTIONTEXT_TOP = 2,
128 WD_CAPTIONTEXT_BOTTOM = 2,
129
130 /* Dropdown widget. */
131 WD_DROPDOWN_HEIGHT = 12,
132 WD_DROPDOWNTEXT_LEFT = 2,
133 WD_DROPDOWNTEXT_RIGHT = 2,
134 WD_DROPDOWNTEXT_TOP = 1,
135 WD_DROPDOWNTEXT_BOTTOM = 1,
136
137 WD_PAR_VSEP_NORMAL = 2,
138 WD_PAR_VSEP_WIDE = 8,
139 };
140
141 /* widget.cpp */
142 void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
143 void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str);
144
145 /* window.cpp */
146 extern Window *_z_front_window;
147 extern Window *_z_back_window;
148 extern Window *_focused_window;
149
150
152 enum WindowPosition {
153 WDP_MANUAL,
154 WDP_AUTO,
155 WDP_CENTER,
156 WDP_ALIGN_TOOLBAR,
157 };
158
159 Point GetToolbarAlignedWindowPosition(int window_width);
160
161 struct HotkeyList;
162
166 struct WindowDesc : ZeroedMemoryAllocator {
167
168 WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
169 WindowClass window_class, WindowClass parent_class, uint32 flags,
170 const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys = nullptr);
171
172 ~WindowDesc();
173
174 WindowPosition default_pos;
175 WindowClass cls;
176 WindowClass parent_cls;
177 const char *ini_key;
178 uint32 flags;
179 const NWidgetPart *nwid_parts;
180 int16 nwid_length;
181 HotkeyList *hotkeys;
182
183 bool pref_sticky;
184 int16 pref_width;
185 int16 pref_height;
186
187 int16 GetDefaultWidth() const;
188 int16 GetDefaultHeight() const;
189
190 static void LoadFromConfig();
191 static void SaveToConfig();
192
193 private:
194 int16 default_width_trad;
195 int16 default_height_trad;
196
201 WindowDesc(const WindowDesc &other);
202 };
203
207 enum WindowDefaultFlag {
208 WDF_CONSTRUCTION = 1 << 0,
209 WDF_MODAL = 1 << 1,
210 WDF_NO_FOCUS = 1 << 2,
211 };
212
216 struct ResizeInfo {
217 uint step_width;
218 uint step_height;
219 };
220
222 enum SortButtonState {
223 SBS_OFF,
224 SBS_DOWN,
225 SBS_UP,
226 };
227
231 enum WindowFlags {
232 WF_TIMEOUT = 1 << 0,
233
234 WF_DRAGGING = 1 << 3,
235 WF_SIZING_RIGHT = 1 << 4,
236 WF_SIZING_LEFT = 1 << 5,
237 WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT,
238 WF_STICKY = 1 << 6,
239 WF_DISABLE_VP_SCROLL = 1 << 7,
240 WF_WHITE_BORDER = 1 << 8,
241 WF_HIGHLIGHTED = 1 << 9,
242 WF_CENTERED = 1 << 10,
243 };
244 DECLARE_ENUM_AS_BIT_SET(WindowFlags)
245
246 static const int TIMEOUT_DURATION = 7;
247 static const int WHITE_BORDER_DURATION = 3;
248
256 struct ViewportData : Viewport {
257 VehicleID follow_vehicle;
258 int32 scrollpos_x;
259 int32 scrollpos_y;
260 int32 dest_scrollpos_x;
261 int32 dest_scrollpos_y;
262 };
263
264 struct QueryString;
265
266 /* misc_gui.cpp */
267 enum TooltipCloseCondition {
268 TCC_RIGHT_CLICK,
269 TCC_HOVER,
270 TCC_NONE,
271 };
272
276 struct Window : ZeroedMemoryAllocator {
277 protected:
278 void InitializeData(WindowNumber window_number);
279 void InitializePositionSize(int x, int y, int min_width, int min_height);
280 virtual void FindWindowPlacementAndResize(int def_width, int def_height);
281
282 std::vector<int> scheduled_invalidation_data;
283
284 public:
285 Window(WindowDesc *desc);
286
287 virtual ~Window();
288
295 inline void *operator new[](size_t size)
296 {
297 NOT_REACHED();
298 }
299
305 inline void operator delete(void *ptr)
306 {
307 }
308
309 WindowDesc *window_desc;
310 WindowFlags flags;
311 WindowClass window_class;
312 WindowNumber window_number;
313
314 uint8 timeout_timer;
315 uint8 white_border_timer;
316
317 int left;
318 int top;
319 int width;
320 int height;
321
322 ResizeInfo resize;
323
324 Owner owner;
325
326 ViewportData *viewport;
327 const NWidgetCore *nested_focus;
328 SmallMap<int, QueryString*> querystrings;
329 NWidgetBase *nested_root;
330 NWidgetBase **nested_array;
331 uint nested_array_size;
332 NWidgetStacked *shade_select;
333 Dimension unshaded_size;
334
335 int mouse_capture_widget;
336
337 Window *parent;
338 Window *z_front;
339 Window *z_back;
340
341 template <class NWID>
342 inline const NWID *GetWidget(uint widnum) const;
343 template <class NWID>
344 inline NWID *GetWidget(uint widnum);
345
346 const Scrollbar *GetScrollbar(uint widnum) const;
347 Scrollbar *GetScrollbar(uint widnum);
348
349 const QueryString *GetQueryString(uint widnum) const;
350 QueryString *GetQueryString(uint widnum);
351
352 virtual const char *GetFocusedText() const;
353 virtual const char *GetCaret() const;
354 virtual const char *GetMarkedText(size_t *length) const;
355 virtual Point GetCaretPosition() const;
356 virtual Rect GetTextBoundingRect(const char *from, const char *to) const;
357 virtual const char *GetTextCharacterAtPosition(const Point &pt) const;
358
359 void InitNested(WindowNumber number = 0);
360 void CreateNestedTree(bool fill_nested = true);
361 void FinishInitNested(WindowNumber window_number = 0);
362
366 inline void SetTimeout()
367 {
368 this->flags |= WF_TIMEOUT;
369 this->timeout_timer = TIMEOUT_DURATION;
370 }
371
375 inline void SetWhiteBorder()
376 {
377 this->flags |= WF_WHITE_BORDER;
378 this->white_border_timer = WHITE_BORDER_DURATION;
379 }
380
381 void DisableAllWidgetHighlight();
382 void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour);
383 bool IsWidgetHighlighted(byte widget_index) const;
384
392 inline void SetWidgetDisabledState(byte widget_index, bool disab_stat)
393 {
394 assert(widget_index < this->nested_array_size);
395 if (this->nested_array[widget_index] != nullptr) this->GetWidget<NWidgetCore>(widget_index)->SetDisabled(disab_stat);
396 }
397
402 inline void DisableWidget(byte widget_index)
403 {
404 SetWidgetDisabledState(widget_index, true);
405 }
406
411 inline void EnableWidget(byte widget_index)
412 {
413 SetWidgetDisabledState(widget_index, false);
414 }
415
421 inline bool IsWidgetDisabled(byte widget_index) const
422 {
423 assert(widget_index < this->nested_array_size);
424 return this->GetWidget<NWidgetCore>(widget_index)->IsDisabled();
425 }
426
432 inline bool IsWidgetFocused(byte widget_index) const
433 {
434 return this->nested_focus != nullptr && this->nested_focus->index == widget_index;
435 }
436
443 inline bool IsWidgetGloballyFocused(byte widget_index) const
444 {
445 return _focused_window == this && IsWidgetFocused(widget_index);
446 }
447
453 inline void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
454 {
455 assert(widget_index < this->nested_array_size);
456 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(lowered_stat);
457 }
458
463 inline void ToggleWidgetLoweredState(byte widget_index)
464 {
465 assert(widget_index < this->nested_array_size);
466 bool lowered_state = this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
467 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(!lowered_state);
468 }
469
474 inline void LowerWidget(byte widget_index)
475 {
476 SetWidgetLoweredState(widget_index, true);
477 }
478
483 inline void RaiseWidget(byte widget_index)
484 {
485 SetWidgetLoweredState(widget_index, false);
486 }
487
493 inline bool IsWidgetLowered(byte widget_index) const
494 {
495 assert(widget_index < this->nested_array_size);
496 return this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
497 }
498
499 void UnfocusFocusedWidget();
500 bool SetFocusedWidget(int widget_index);
501
502 EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode);
503 virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end);
504
505 void HandleButtonClick(byte widget);
506 int GetRowFromWidget(int clickpos, int widget, int padding, int line_height = -1) const;
507
508 void RaiseButtons(bool autoraise = false);
509 void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
510 void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
511 void SetWidgetDirty(byte widget_index) const;
512
513 void DrawWidgets() const;
514 void DrawViewport() const;
515 void DrawSortButtonState(int widget, SortButtonState state) const;
516 static int SortButtonWidth();
517
518 void DeleteChildWindows(WindowClass wc = WC_INVALID) const;
519
520 void SetDirty() const;
521 void ReInit(int rx = 0, int ry = 0);
522
524 inline bool IsShaded() const
525 {
526 return this->shade_select != nullptr && this->shade_select->shown_plane == SZSP_HORIZONTAL;
527 }
528
529 void SetShaded(bool make_shaded);
530
531 void InvalidateData(int data = 0, bool gui_scope = true);
532 void ProcessScheduledInvalidations();
533 void ProcessHighlightedInvalidations();
534
535 /*** Event handling ***/
536
541 virtual void OnInit() { }
542
543 virtual void ApplyDefaults();
544
552 virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number);
553
558 virtual void OnPaint()
559 {
560 this->DrawWidgets();
561 }
562
569 virtual void DrawWidget(const Rect &r, int widget) const {}
570
583 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) {}
584
591 virtual void SetStringParameters(int widget) const {}
592
593 virtual void OnFocus();
594
595 virtual void OnFocusLost();
596
604 virtual EventState OnKeyPress(WChar key, uint16 keycode) { return ES_NOT_HANDLED; }
605
606 virtual EventState OnHotkey(int hotkey);
607
613 virtual EventState OnCTRLStateChange() { return ES_NOT_HANDLED; }
614
615
622 virtual void OnClick(Point pt, int widget, int click_count) {}
623
631 virtual bool OnRightClick(Point pt, int widget) { return false; }
632
638 virtual void OnHover(Point pt, int widget) {}
639
646 virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) { return false; }
647
653 virtual void OnMouseDrag(Point pt, int widget) {}
654
660 virtual void OnDragDrop(Point pt, int widget) {}
661
666 virtual void OnScroll(Point delta) {}
667
674 virtual void OnMouseOver(Point pt, int widget) {}
675
680 virtual void OnMouseWheel(int wheel) {}
681
682
686 virtual void OnMouseLoop() {}
687
691 virtual void OnGameTick() {}
692
698 virtual void OnHundredthTick() {}
699
703 virtual void OnRealtimeTick(uint delta_ms) {}
704
708 virtual void OnTimeout() {}
709
710
715 virtual void OnResize() {}
716
722 virtual void OnDropdownSelect(int widget, int index) {}
723
724 virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close);
725
730 virtual void OnEditboxChanged(int widget) {}
731
738 virtual void OnQueryTextFinished(char *str) {}
739
745 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) {}
746
753 virtual void OnPlaceObject(Point pt, TileIndex tile) {}
754
760 virtual bool OnVehicleSelect(const struct Vehicle *v) { return false; }
761
765 virtual void OnPlaceObjectAbort() {}
766
767
775 virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) {}
776
786 virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) {}
787
795 virtual void OnPlacePresize(Point pt, TileIndex tile) {}
796
797 /*** End of the event handling ***/
798
803 virtual bool IsNewGRFInspectable() const { return false; }
804
811 virtual void ShowNewGRFInspectWindow() const { NOT_REACHED(); }
812 };
813
820 template <class NWID>
821 inline NWID *Window::GetWidget(uint widnum)
822 {
823 if (widnum >= this->nested_array_size || this->nested_array[widnum] == nullptr) return nullptr;
824 NWID *nwid = dynamic_cast<NWID *>(this->nested_array[widnum]);
825 assert(nwid != nullptr);
826 return nwid;
827 }
828
830 template <>
831 inline const NWidgetBase *Window::GetWidget<NWidgetBase>(uint widnum) const
832 {
833 if (widnum >= this->nested_array_size) return nullptr;
834 return this->nested_array[widnum];
835 }
836
843 template <class NWID>
844 inline const NWID *Window::GetWidget(uint widnum) const
845 {
846 return const_cast<Window *>(this)->GetWidget<NWID>(widnum);
847 }
848
849
853 class PickerWindowBase : public Window {
854
855 public:
856 PickerWindowBase(WindowDesc *desc, Window *parent) : Window(desc)
857 {
858 this->parent = parent;
859 }
860
861 virtual ~PickerWindowBase();
862 };
863
864 Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
865 Window *FindWindowFromPt(int x, int y);
866
875 template <typename Wcls>
876 Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_existing = false)
877 {
878 Wcls *w = static_cast<Wcls *>(BringWindowToFrontById(desc->cls, window_number));
879 if (w != nullptr) return return_existing ? w : nullptr;
880 return new Wcls(desc, window_number);
881 }
882
883 void RelocateAllWindows(int neww, int newh);
884
885 void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = nullptr, TooltipCloseCondition close_tooltip = TCC_HOVER);
886
887 /* widget.cpp */
888 int GetWidgetFromPos(const Window *w, int x, int y);
889
891 #define FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start) for (w = start; w != nullptr; w = w->z_front) if (w->window_class != WC_INVALID)
892 #define FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, start) for (w = start; w != nullptr; w = w->z_back) if (w->window_class != WC_INVALID)
893 #define FOR_ALL_WINDOWS_FROM_BACK(w) FOR_ALL_WINDOWS_FROM_BACK_FROM(w, _z_back_window)
894 #define FOR_ALL_WINDOWS_FROM_FRONT(w) FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, _z_front_window)
895
896 extern Point _cursorpos_drag_start;
897
898 extern int _scrollbar_start_pos;
899 extern int _scrollbar_size;
900 extern byte _scroller_click_timeout;
901
902 extern bool _scrolling_viewport;
903 extern bool _mouse_hovering;
904
906 enum SpecialMouseMode {
907 WSM_NONE,
908 WSM_DRAGDROP,
909 WSM_SIZING,
910 WSM_PRESIZE,
911 WSM_DRAGGING,
912 };
913 extern SpecialMouseMode _special_mouse_mode;
914
915 void SetFocusedWindow(Window *w);
916
917 void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);
918
919 #endif /* WINDOW_GUI_H */
ViewportData
Data structure for a window viewport.
Definition: window_gui.h:256
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:366
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
WD_DEFSIZEBOX_LEFT
@ WD_DEFSIZEBOX_LEFT
Left offset of defsize sprite.
Definition: window_gui.h:104
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
WC_INVALID
@ WC_INVALID
Invalid window.
Definition: window_type.h:700
WD_RESIZEBOX_BOTTOM
@ WD_RESIZEBOX_BOTTOM
Bottom offset of resize sprite.
Definition: window_gui.h:114
PickerWindowBase::~PickerWindowBase
virtual ~PickerWindowBase()
Destructor of the base class PickerWindowBase Main utility is to stop the base Window destructor from...
Definition: window.cpp:3640
Window::z_back
Window * z_back
The window behind us in z-order.
Definition: window_gui.h:339
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:314
Window::OnHundredthTick
virtual void OnHundredthTick()
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
Definition: window_gui.h:698
WD_MATRIX_RIGHT
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
Definition: window_gui.h:77
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
WF_SIZING
@ WF_SIZING
Window is being resized.
Definition: window_gui.h:237
Window::OnEditboxChanged
virtual void OnEditboxChanged(int widget)
The text in an editbox has been edited.
Definition: window_gui.h:730
Window::SetWhiteBorder
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:375
SortButtonState
SortButtonState
State of a sort direction button.
Definition: window_gui.h:222
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
WD_STICKYBOX_WIDTH
@ WD_STICKYBOX_WIDTH
Width of a standard sticky box widget.
Definition: window_gui.h:89
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Window::~Window
virtual ~Window()
Remove window and all its child windows from the window stack.
Definition: window.cpp:1084
AllocateWindowDescFront
Wcls * AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_existing=false)
Open a new window.
Definition: window_gui.h:876
Window::DrawSortButtonState
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:636
Window::nested_root
NWidgetBase * nested_root
Root of the nested tree.
Definition: window_gui.h:329
Window::DeleteChildWindows
void DeleteChildWindows(WindowClass wc=WC_INVALID) const
Delete all children a window might have in a head-recursive manner.
Definition: window.cpp:1072
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:208
_scrolling_viewport
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
Definition: window.cpp:77
Window::shade_select
NWidgetStacked * shade_select
Selection widget (NWID_SELECTION) to use for shading the window. If nullptr, window cannot shade.
Definition: window_gui.h:332
WD_SHADEBOX_BOTTOM
@ WD_SHADEBOX_BOTTOM
Bottom offset of shade sprite.
Definition: window_gui.h:86
WF_SIZING_RIGHT
@ WF_SIZING_RIGHT
Window is being resized towards the right.
Definition: window_gui.h:235
Window::OnHover
virtual void OnHover(Point pt, int widget)
The mouse is hovering over a widget in the window, perform an action for it.
Definition: window_gui.h:638
Window::ApplyDefaults
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
Definition: window.cpp:182
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:995
Window::DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: window_gui.h:569
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:115
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:78
ScrollbarClickHandler
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y)
Special handling for the scrollbar widget type.
Definition: widget.cpp:136
Window::InitializePositionSize
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
Definition: window.cpp:1508
widget_type.h
WF_DISABLE_VP_SCROLL
@ WF_DISABLE_VP_SCROLL
Window does not do autoscroll,.
Definition: window_gui.h:239
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:326
WD_STICKYBOX_TOP
@ WD_STICKYBOX_TOP
Top offset of sticky sprite.
Definition: window_gui.h:92
ViewportData::scrollpos_y
int32 scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:259
FrameFlags
FrameFlags
Flags to describe the look of the frame.
Definition: window_gui.h:25
smallvec_type.hpp
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:156
Window::OnGameTick
virtual void OnGameTick()
Called once per (game) tick.
Definition: window_gui.h:691
WD_CLOSEBOX_RIGHT
@ WD_CLOSEBOX_RIGHT
Right offset of closebox string.
Definition: window_gui.h:119
Window::IsNewGRFInspectable
virtual bool IsNewGRFInspectable() const
Is the data related to this window NewGRF inspectable?
Definition: window_gui.h:803
WF_STICKY
@ WF_STICKY
Window is made sticky by user.
Definition: window_gui.h:238
WidgetDrawDistances
WidgetDrawDistances
Distances used in drawing widgets.
Definition: window_gui.h:36
WDF_NO_FOCUS
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
Definition: window_gui.h:210
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
Window::OnInvalidateData
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: window_gui.h:745
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:573
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:72
WD_SCROLLBAR_RIGHT
@ WD_SCROLLBAR_RIGHT
Right offset of scrollbar.
Definition: window_gui.h:49
WD_DEFSIZEBOX_BOTTOM
@ WD_DEFSIZEBOX_BOTTOM
Bottom offset of defsize sprite.
Definition: window_gui.h:107
Window::SetWidgetHighlight
void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
Definition: window.cpp:232
WindowDesc::cls
WindowClass cls
Class of the window,.
Definition: window_gui.h:175
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:388
Window::OnTimeout
virtual void OnTimeout()
Called when this window's timeout has been reached.
Definition: window_gui.h:708
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:324
Window::OnDropdownClose
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Definition: window.cpp:282
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:29
smallmap_type.hpp
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
WD_DEBUGBOX_LEFT
@ WD_DEBUGBOX_LEFT
Left offset of debug sprite.
Definition: window_gui.h:97
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:635
Window::GetCaretPosition
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
Definition: window.cpp:390
_z_back_window
Window * _z_back_window
List of windows opened at the screen sorted from the back.
Definition: window.cpp:59
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
FR_TRANSPARENT
@ FR_TRANSPARENT
Makes the background transparent if set.
Definition: window_gui.h:27
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:610
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
Window::nested_focus
const NWidgetCore * nested_focus
Currently focused nested widget, or nullptr if no nested widget has focus.
Definition: window_gui.h:327
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
Window::scheduled_invalidation_data
std::vector< int > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
Definition: window_gui.h:282
Window::IsWidgetHighlighted
bool IsWidgetHighlighted(byte widget_index) const
Gets the highlighted status of a widget.
Definition: window.cpp:265
Window::GetCaret
virtual const char * GetCaret() const
Get the string at the caret if an edit box has the focus.
Definition: window.cpp:363
WD_IMGBTN_BOTTOM
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
Definition: window_gui.h:41
WD_INSET_TOP
@ WD_INSET_TOP
Top offset of string.
Definition: window_gui.h:46
Window::OnCTRLStateChange
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
Definition: window_gui.h:613
Window::GetTextCharacterAtPosition
virtual const char * GetTextCharacterAtPosition(const Point &pt) const
Get the character that is rendered at a position by the focused edit box.
Definition: window.cpp:421
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:328
SmallMap< int, QueryString * >
Window::OnPlaceMouseUp
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.
Definition: window_gui.h:786
Window::ProcessScheduledInvalidations
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
Definition: window.cpp:3274
WindowDesc::default_width_trad
int16 default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
Definition: window_gui.h:194
WindowDesc::default_pos
WindowPosition default_pos
Preferred position of the window.
Definition: window_gui.h:174
WindowDesc
High level window description.
Definition: window_gui.h:166
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:434
Window::SetStringParameters
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Definition: window_gui.h:591
WF_SIZING_LEFT
@ WF_SIZING_LEFT
Window is being resized towards the left.
Definition: window_gui.h:236
Window::SetShaded
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
Definition: window.cpp:1031
Window::GetWidget
const NWID * GetWidget(uint widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition: window_gui.h:844
Window::OnFocusLost
virtual void OnFocusLost()
Called when window loses focus.
Definition: window.cpp:524
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
_mouse_hovering
bool _mouse_hovering
The mouse is hovering over the same point.
Definition: window.cpp:78
Window::UnfocusFocusedWidget
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
Definition: window.cpp:479
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
WindowDesc::ini_key
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
Definition: window_gui.h:177
WD_RESIZEBOX_RIGHT
@ WD_RESIZEBOX_RIGHT
Right offset of resize sprite.
Definition: window_gui.h:112
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
WSM_PRESIZE
@ WSM_PRESIZE
Presizing mode (docks, tunnels).
Definition: window_gui.h:910
WD_SHADEBOX_RIGHT
@ WD_SHADEBOX_RIGHT
Right offset of shade sprite.
Definition: window_gui.h:84
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:411
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
Window::ProcessHighlightedInvalidations
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
Definition: window.cpp:3286
WD_CLOSEBOX_TOP
@ WD_CLOSEBOX_TOP
Top offset of closebox string.
Definition: window_gui.h:120
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
WF_CENTERED
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
Definition: window_gui.h:242
WF_WHITE_BORDER
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:240
SpecialMouseMode
SpecialMouseMode
Mouse modes.
Definition: window_gui.h:906
WD_INSET_RIGHT
@ WD_INSET_RIGHT
Right offset of string.
Definition: window_gui.h:45
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
GetToolbarAlignedWindowPosition
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar.
Definition: window.cpp:1736
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
Window::OnFocus
virtual void OnFocus()
Called when window gains focus.
Definition: window.cpp:516
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
ZeroedMemoryAllocator
Base class that provides memory initialization on dynamically created objects.
Definition: alloc_type.hpp:85
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WD_DEFSIZEBOX_RIGHT
@ WD_DEFSIZEBOX_RIGHT
Right offset of defsize sprite.
Definition: window_gui.h:105
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:73
Window::OnVehicleSelect
virtual bool OnVehicleSelect(const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
Definition: window_gui.h:760
Window::HandleEditBoxKey
EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode)
Process keypress for editbox widget.
Definition: window.cpp:2608
Window::DisableAllWidgetHighlight
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
Definition: window.cpp:212
Window::OnPlaceObject
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
Definition: window_gui.h:753
Window::OnDropdownSelect
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
Definition: window_gui.h:722
Window::GetQueryString
const QueryString * GetQueryString(uint widnum) const
Return the querystring associated to a editbox.
Definition: window.cpp:329
WindowDesc::GetDefaultWidth
int16 GetDefaultWidth() const
Determine default width of window.
Definition: window.cpp:123
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:337
WD_STICKYBOX_RIGHT
@ WD_STICKYBOX_RIGHT
Right offset of sticky sprite.
Definition: window_gui.h:91
Window::IsWidgetGloballyFocused
bool IsWidgetGloballyFocused(byte widget_index) const
Check if given widget has user input focus.
Definition: window_gui.h:443
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:317
Window::OnDragDrop
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
Definition: window_gui.h:660
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:310
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:232
WD_INSET_LEFT
@ WD_INSET_LEFT
Left offset of string.
Definition: window_gui.h:44
WindowClass
WindowClass
Window classes.
Definition: window_type.h:37
Window::ShowNewGRFInspectWindow
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
Definition: window_gui.h:811
WindowDesc::default_height_trad
int16 default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
Definition: window_gui.h:195
GetWidgetFromPos
int GetWidgetFromPos(const Window *w, int x, int y)
Returns the index for the widget located at the given position relative to the window.
Definition: widget.cpp:160
WD_DEBUGBOX_RIGHT
@ WD_DEBUGBOX_RIGHT
Right offset of debug sprite.
Definition: window_gui.h:98
WDF_MODAL
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Definition: window_gui.h:209
WindowDesc::GetDefaultHeight
int16 GetDefaultHeight() const
Determine default height of window.
Definition: window.cpp:133
TIMEOUT_DURATION
static const int TIMEOUT_DURATION
The initial timeout value for WF_TIMEOUT.
Definition: window_gui.h:246
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
WF_HIGHLIGHTED
@ WF_HIGHLIGHTED
Window has a widget that has a highlight.
Definition: window_gui.h:241
WindowDesc::nwid_parts
const NWidgetPart * nwid_parts
Nested widget parts describing the window.
Definition: window_gui.h:179
WindowDefaultFlag
WindowDefaultFlag
Window default widget/window handling flags.
Definition: window_gui.h:207
ViewportData::dest_scrollpos_y
int32 dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:261
Window::IsWidgetFocused
bool IsWidgetFocused(byte widget_index) const
Check if given widget is focused within this window.
Definition: window_gui.h:432
WSM_DRAGDROP
@ WSM_DRAGDROP
Drag&drop an object.
Definition: window_gui.h:908
Window::OnInit
virtual void OnInit()
Notification that the nested widget tree gets initialized.
Definition: window_gui.h:541
WSM_SIZING
@ WSM_SIZING
Sizing mode.
Definition: window_gui.h:909
Window::unshaded_size
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
Definition: window_gui.h:333
WindowDesc::SaveToConfig
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
Definition: window.cpp:164
string_type.h
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:495
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
WD_DROPDOWNTEXT_RIGHT
@ WD_DROPDOWNTEXT_RIGHT
Right offset of the dropdown widget string.
Definition: window_gui.h:133
WD_SCROLLBAR_LEFT
@ WD_SCROLLBAR_LEFT
Left offset of scrollbar.
Definition: window_gui.h:48
ResizeInfo::step_height
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:218
WindowDesc::WindowDesc
WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, WindowClass window_class, WindowClass parent_class, uint32 flags, const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys=nullptr)
Window description constructor.
Definition: window.cpp:92
WindowFlags
WindowFlags
Window flags.
Definition: window_gui.h:231
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3261
Window::mouse_capture_widget
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
Definition: window_gui.h:335
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:404
Window::nested_array
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
Definition: window_gui.h:330
Window::OnPlacePresize
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 b...
Definition: window_gui.h:795
WD_SHADEBOX_TOP
@ WD_SHADEBOX_TOP
Top offset of shade sprite.
Definition: window_gui.h:85
WD_SCROLLBAR_BOTTOM
@ WD_SCROLLBAR_BOTTOM
Bottom offset of scrollbar.
Definition: window_gui.h:51
WD_DROPDOWNTEXT_TOP
@ WD_DROPDOWNTEXT_TOP
Top offset of the dropdown widget string.
Definition: window_gui.h:134
WD_SHADEBOX_LEFT
@ WD_SHADEBOX_LEFT
Left offset of shade sprite.
Definition: window_gui.h:83
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
Window::OnClick
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: window_gui.h:622
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:224
ViewportData::scrollpos_x
int32 scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:258
vehicle_type.h
Window::OnMouseLoop
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
Definition: window_gui.h:686
WD_DROPDOWN_HEIGHT
@ WD_DROPDOWN_HEIGHT
Height of a drop down widget.
Definition: window_gui.h:131
WindowDesc::nwid_length
int16 nwid_length
Length of the nwid_parts array.
Definition: window_gui.h:180
ResizeInfo::step_width
uint step_width
Step-size of width resize changes.
Definition: window_gui.h:217
Window::OnMouseWheel
virtual void OnMouseWheel(int wheel)
The mouse wheel has been turned.
Definition: window_gui.h:680
WindowDesc::flags
uint32 flags
Flags.
Definition: window_gui.h:178
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:524
Window::OnPlaceObjectAbort
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition: window_gui.h:765
ResizeInfo
Data structure for resizing a window.
Definition: window_gui.h:216
WD_CLOSEBOX_WIDTH
@ WD_CLOSEBOX_WIDTH
Width of a close box widget.
Definition: window_gui.h:117
GuiShowTooltips
void GuiShowTooltips(Window *parent, StringID str, uint paramcount=0, const uint64 params[]=nullptr, TooltipCloseCondition close_tooltip=TCC_HOVER)
Shows a tooltip.
Definition: misc_gui.cpp:781
WD_BEVEL_RIGHT
@ WD_BEVEL_RIGHT
Width of right bevel border.
Definition: window_gui.h:55
tile_type.h
Window::SetWidgetsLoweredState
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
Definition: window.cpp:555
WD_CAPTIONTEXT_TOP
@ WD_CAPTIONTEXT_TOP
Offset of the caption text at the top.
Definition: window_gui.h:127
Window::OnTooltip
virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond)
Event to display a custom tooltip.
Definition: window_gui.h:646
WD_DEFSIZEBOX_WIDTH
@ WD_DEFSIZEBOX_WIDTH
Width of a standard defsize box widget.
Definition: window_gui.h:103
WD_SHADEBOX_WIDTH
@ WD_SHADEBOX_WIDTH
Width of a standard shade box widget.
Definition: window_gui.h:82
WD_DEBUGBOX_WIDTH
@ WD_DEBUGBOX_WIDTH
Width of a standard debug box widget.
Definition: window_gui.h:96
Window::GetTextBoundingRect
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.
Definition: window.cpp:406
WD_DEBUGBOX_BOTTOM
@ WD_DEBUGBOX_BOTTOM
Bottom offset of debug sprite.
Definition: window_gui.h:100
WD_SCROLLBAR_TOP
@ WD_SCROLLBAR_TOP
Top offset of scrollbar.
Definition: window_gui.h:50
Window::OnPaint
virtual void OnPaint()
The window must be repainted.
Definition: window_gui.h:558
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:536
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
Window::OnMouseOver
virtual void OnMouseOver(Point pt, int widget)
The mouse is currently moving over the window or has just moved outside of the window.
Definition: window_gui.h:674
EventState
EventState
State of handling an event.
Definition: window_type.h:717
WindowDesc::pref_sticky
bool pref_sticky
Preferred stickyness.
Definition: window_gui.h:183
WF_DRAGGING
@ WF_DRAGGING
Window is being dragged.
Definition: window_gui.h:234
Window::UpdateWidgetSize
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.
Definition: window_gui.h:583
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h:40
WD_RESIZEBOX_WIDTH
@ WD_RESIZEBOX_WIDTH
Width of a resize box widget.
Definition: window_gui.h:110
WSM_DRAGGING
@ WSM_DRAGGING
Dragging mode (trees).
Definition: window_gui.h:911
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:311
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
WD_STICKYBOX_BOTTOM
@ WD_STICKYBOX_BOTTOM
Bottom offset of sticky sprite.
Definition: window_gui.h:93
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:853
_special_mouse_mode
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Definition: window.cpp:80
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:318
Window::DrawViewport
void DrawViewport() const
Draw the viewport of this window.
Definition: viewport.cpp:1810
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
WHITE_BORDER_DURATION
static const int WHITE_BORDER_DURATION
The initial timeout value for WF_WHITE_BORDER.
Definition: window_gui.h:247
WD_BEVEL_TOP
@ WD_BEVEL_TOP
Height of top bevel border.
Definition: window_gui.h:56
Window::OnMouseDrag
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
Definition: window_gui.h:653
WD_BEVEL_LEFT
@ WD_BEVEL_LEFT
Width of left bevel border.
Definition: window_gui.h:54
ViewportData::follow_vehicle
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
Definition: window_gui.h:257
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:79
Window::OnInitialPosition
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
Definition: window.cpp:1820
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
WindowDesc::LoadFromConfig
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
Definition: window.cpp:141
RelocateAllWindows
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
Definition: window.cpp:3569
ViewportData::dest_scrollpos_x
int32 dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:260
WD_CAPTIONTEXT_BOTTOM
@ WD_CAPTIONTEXT_BOTTOM
Offset of the caption text at the bottom.
Definition: window_gui.h:128
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:153
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:656
FR_DARKENED
@ FR_DARKENED
If set the background is darker, allows for lowered frames with normal background colour when used wi...
Definition: window_gui.h:30
WD_RESIZEBOX_TOP
@ WD_RESIZEBOX_TOP
Top offset of resize sprite.
Definition: window_gui.h:113
Window::InsertTextString
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.
Definition: window.cpp:2752
Window::window_desc
WindowDesc * window_desc
Window description.
Definition: window_gui.h:309
Window::OnPlaceDrag
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.
Definition: window_gui.h:775
Window::OnRealtimeTick
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
Definition: window_gui.h:703
WD_DEBUGBOX_TOP
@ WD_DEBUGBOX_TOP
Top offset of debug sprite.
Definition: window_gui.h:99
WD_CAPTION_HEIGHT
@ WD_CAPTION_HEIGHT
Height of a title bar.
Definition: window_gui.h:124
WD_DROPDOWNTEXT_BOTTOM
@ WD_DROPDOWNTEXT_BOTTOM
Bottom offset of the dropdown widget string.
Definition: window_gui.h:135
Window::z_front
Window * z_front
The window in front of us in z-order.
Definition: window_gui.h:338
WindowDesc::parent_cls
WindowClass parent_cls
Class of the parent window.
Definition: window_gui.h:176
Window
Data structure for an opened window.
Definition: window_gui.h:276
WD_CAPTIONTEXT_LEFT
@ WD_CAPTIONTEXT_LEFT
Offset of the caption text at the left.
Definition: window_gui.h:125
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
WD_MATRIX_LEFT
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
Definition: window_gui.h:76
viewport_type.h
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
FindWindowFromPt
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
Definition: window.cpp:1882
Window::OnRightClick
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
Definition: window_gui.h:631
Window::OnQueryTextFinished
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Definition: window_gui.h:738
Window::OnScroll
virtual void OnScroll(Point delta)
Handle the request for (viewport) scrolling.
Definition: window_gui.h:666
WD_DROPDOWNTEXT_LEFT
@ WD_DROPDOWNTEXT_LEFT
Left offset of the dropdown widget string.
Definition: window_gui.h:132
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:225
WD_IMGBTN_LEFT
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
Definition: window_gui.h:38
SBS_OFF
@ SBS_OFF
Do not sort (with this button).
Definition: window_gui.h:223
Window::nested_array_size
uint nested_array_size
Size of the nested array.
Definition: window_gui.h:331
NWidgetCore::index
int index
Index of the nested widget in the widget array of the window (-1 means 'not used').
Definition: widget_type.h:303
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:421
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:282
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:474
WD_CLOSEBOX_BOTTOM
@ WD_CLOSEBOX_BOTTOM
Bottom offset of closebox string.
Definition: window_gui.h:121
Window::GetMarkedText
virtual const char * GetMarkedText(size_t *length) const
Get the range of the currently marked input text.
Definition: window.cpp:377
Window::GetRowFromWidget
int GetRowFromWidget(int clickpos, int widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Definition: window.cpp:201
Window::OnResize
virtual void OnResize()
Called after the window got resized.
Definition: window_gui.h:715
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:402
WD_BEVEL_BOTTOM
@ WD_BEVEL_BOTTOM
Height of bottom bevel border.
Definition: window_gui.h:57
WindowDesc::hotkeys
HotkeyList * hotkeys
Hotkeys for the window.
Definition: window_gui.h:181
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:419
WD_PAR_VSEP_WIDE
@ WD_PAR_VSEP_WIDE
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:138
WindowPosition
WindowPosition
How do we the window to be placed?
Definition: window_gui.h:152
WD_IMGBTN_RIGHT
@ WD_IMGBTN_RIGHT
Right offset of the image in the button.
Definition: window_gui.h:39
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
company_type.h
WindowDesc::pref_height
int16 pref_height
User-preferred height of the window. Zero if unset.
Definition: window_gui.h:185
DrawCaption
void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str)
Draw a caption bar.
Definition: widget.cpp:538
WD_CLOSEBOX_LEFT
@ WD_CLOSEBOX_LEFT
Left offset of closebox string.
Definition: window_gui.h:118
Window::white_border_timer
uint8 white_border_timer
Timer value of the WF_WHITE_BORDER for flags.
Definition: window_gui.h:315
WD_TEXTPANEL_BOTTOM
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
Definition: window_gui.h:67
WD_RESIZEBOX_LEFT
@ WD_RESIZEBOX_LEFT
Left offset of resize sprite.
Definition: window_gui.h:111
WSM_NONE
@ WSM_NONE
No special mouse mode.
Definition: window_gui.h:907
WD_STICKYBOX_LEFT
@ WD_STICKYBOX_LEFT
Left offset of sticky sprite.
Definition: window_gui.h:90
WindowDesc::pref_width
int16 pref_width
User-preferred width of the window. Zero if unset.
Definition: window_gui.h:184
Window::InitializeData
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
Definition: window.cpp:1466
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:28
Window::GetFocusedText
virtual const char * GetFocusedText() const
Get the current input text if an edit box has the focus.
Definition: window.cpp:350
WD_CAPTIONTEXT_RIGHT
@ WD_CAPTIONTEXT_RIGHT
Offset of the caption text at the right.
Definition: window_gui.h:126
_z_front_window
Window * _z_front_window
List of windows opened at the screen sorted from the front.
Definition: window.cpp:57
WD_TEXTPANEL_TOP
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
Definition: window_gui.h:66
Window::FindWindowPlacementAndResize
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Definition: window.cpp:1526
WD_DEFSIZEBOX_TOP
@ WD_DEFSIZEBOX_TOP
Top offset of defsize sprite.
Definition: window_gui.h:106
Window::OnKeyPress
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
Definition: window_gui.h:604
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1262