OpenTTD Source  20241124-master-g9399a92a4f
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 "vehiclelist.h"
14 #include "vehicle_type.h"
15 #include "viewport_type.h"
16 #include "company_type.h"
17 #include "tile_type.h"
18 #include "widget_type.h"
19 #include "string_type.h"
20 
24 enum FrameFlags {
25  FR_NONE = 0,
26  FR_TRANSPARENT = 1 << 0,
27  FR_BORDERONLY = 1 << 4,
28  FR_LOWERED = 1 << 5,
29  FR_DARKENED = 1 << 6,
30 };
31 
33 
35 public:
58 
62  int vsep_wide;
64  int hsep_wide;
66 
67  static const WidgetDimensions unscaled;
69 
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;
78 
79 private:
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;
92 
93  friend NWidgetLeaf;
94 };
95 
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},
119  .vsep_picker = 1,
120  .vsep_normal = 2,
121  .vsep_sparse = 4,
122  .vsep_wide = 8,
123  .hsep_normal = 2,
124  .hsep_wide = 6,
125  .hsep_indent = 10,
126 };
127 
128 /* widget.cpp */
129 void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
130 
131 inline void DrawFrameRect(const Rect &r, Colours colour, FrameFlags flags)
132 {
133  DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, flags);
134 }
135 
136 void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs);
137 
138 /* window.cpp */
139 using WindowList = std::list<Window *>;
140 extern WindowList _z_windows;
141 extern Window *_focused_window;
142 
143 
150 };
151 
152 Point GetToolbarAlignedWindowPosition(int window_width);
153 
154 struct HotkeyList;
155 
160 
161  WindowDesc(WindowPosition default_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad,
162  WindowClass window_class, WindowClass parent_class, uint32_t flags,
163  const std::span<const NWidgetPart> nwid_parts, HotkeyList *hotkeys = nullptr,
164  const std::source_location location = std::source_location::current());
165 
166  ~WindowDesc();
167 
168  const std::source_location source_location;
172  const char *ini_key;
173  uint32_t flags;
174  const std::span<const NWidgetPart> nwid_parts;
176 
177  bool pref_sticky;
178  int16_t pref_width;
179  int16_t pref_height;
180 
181  int16_t GetDefaultWidth() const;
182  int16_t GetDefaultHeight() const;
183 
184  static void LoadFromConfig();
185  static void SaveToConfig();
186 
187 private:
190 
195  WindowDesc(const WindowDesc &) = delete;
196  WindowDesc& operator=(const WindowDesc &) = delete;
197 };
198 
203  WDF_CONSTRUCTION = 1 << 0,
204  WDF_MODAL = 1 << 1,
205  WDF_NO_FOCUS = 1 << 2,
206  WDF_NO_CLOSE = 1 << 3,
207 };
208 
212 struct ResizeInfo {
213  uint step_width;
214  uint step_height;
215 };
216 
222 };
223 
228  WF_TIMEOUT = 1 << 0,
229 
230  WF_DRAGGING = 1 << 3,
231  WF_SIZING_RIGHT = 1 << 4,
232  WF_SIZING_LEFT = 1 << 5,
234  WF_STICKY = 1 << 6,
236  WF_WHITE_BORDER = 1 << 8,
237  WF_HIGHLIGHTED = 1 << 9,
238  WF_CENTERED = 1 << 10,
239 };
241 
242 static const int TIMEOUT_DURATION = 7;
243 static const int WHITE_BORDER_DURATION = 3;
244 
254  int32_t scrollpos_x;
255  int32_t scrollpos_y;
258 };
259 
260 struct QueryString;
261 
262 /* misc_gui.cpp */
263 enum TooltipCloseCondition {
264  TCC_RIGHT_CLICK,
265  TCC_HOVER,
266  TCC_NONE,
267  TCC_EXIT_VIEWPORT,
268 };
269 
274 private:
275  static std::vector<Window *> closed_windows;
276 
277 protected:
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;
284 
285  /* Protected to prevent deletion anywhere outside Window::DeleteClosedWindows(). */
286  virtual ~Window();
287 
288 public:
289  Window(WindowDesc &desc);
290 
297  inline void *operator new[](size_t size) = delete;
298 
303 
304  int scale;
305 
306  uint8_t timeout_timer;
308 
309  int left;
310  int top;
311  int width;
312  int height;
313 
315 
317 
320  std::map<WidgetID, QueryString*> querystrings;
321  std::unique_ptr<NWidgetBase> nested_root;
325 
327 
329  WindowList::iterator z_position;
330 
331  template <class NWID>
332  inline const NWID *GetWidget(WidgetID widnum) const;
333  template <class NWID>
334  inline NWID *GetWidget(WidgetID widnum);
335 
336  const Scrollbar *GetScrollbar(WidgetID widnum) const;
338 
339  const QueryString *GetQueryString(WidgetID widnum) const;
341  void UpdateQueryStringSize();
342 
343  virtual const struct Textbuf *GetFocusedTextbuf() const;
344  virtual Point GetCaretPosition() const;
345  virtual Rect GetTextBoundingRect(const char *from, const char *to) const;
346  virtual ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const;
347 
348  void InitNested(WindowNumber number = 0);
349  void CreateNestedTree();
351 
352  template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
353  void FinishInitNested(T number)
354  {
355  this->FinishInitNested(number.base());
356  }
357 
361  inline void SetTimeout()
362  {
363  this->flags |= WF_TIMEOUT;
364  this->timeout_timer = TIMEOUT_DURATION;
365  }
366 
370  inline void SetWhiteBorder()
371  {
372  this->flags |= WF_WHITE_BORDER;
373  this->white_border_timer = WHITE_BORDER_DURATION;
374  }
375 
377  void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour);
378  bool IsWidgetHighlighted(WidgetID widget_index) const;
379 
387  inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
388  {
389  NWidgetCore *nwid = this->GetWidget<NWidgetCore>(widget_index);
390  if (nwid != nullptr) nwid->SetDisabled(disab_stat);
391  }
392 
397  inline void DisableWidget(WidgetID widget_index)
398  {
399  SetWidgetDisabledState(widget_index, true);
400  }
401 
406  inline void EnableWidget(WidgetID widget_index)
407  {
408  SetWidgetDisabledState(widget_index, false);
409  }
410 
416  inline bool IsWidgetDisabled(WidgetID widget_index) const
417  {
418  return this->GetWidget<NWidgetCore>(widget_index)->IsDisabled();
419  }
420 
426  inline bool IsWidgetFocused(WidgetID widget_index) const
427  {
428  return this->nested_focus != nullptr && this->nested_focus->index == widget_index;
429  }
430 
437  inline bool IsWidgetGloballyFocused(WidgetID widget_index) const
438  {
439  return _focused_window == this && IsWidgetFocused(widget_index);
440  }
441 
447  inline void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
448  {
449  this->GetWidget<NWidgetCore>(widget_index)->SetLowered(lowered_stat);
450  }
451 
456  inline void ToggleWidgetLoweredState(WidgetID widget_index)
457  {
458  bool lowered_state = this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
459  this->GetWidget<NWidgetCore>(widget_index)->SetLowered(!lowered_state);
460  }
461 
466  inline void LowerWidget(WidgetID widget_index)
467  {
468  SetWidgetLoweredState(widget_index, true);
469  }
470 
475  inline void RaiseWidget(WidgetID widget_index)
476  {
477  SetWidgetLoweredState(widget_index, false);
478  }
479 
484  inline void RaiseWidgetWhenLowered(WidgetID widget_index)
485  {
486  if (this->IsWidgetLowered(widget_index)) {
487  this->RaiseWidget(widget_index);
488  this->SetWidgetDirty(widget_index);
489  }
490  }
491 
497  inline bool IsWidgetLowered(WidgetID widget_index) const
498  {
499  return this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
500  }
501 
502  void UnfocusFocusedWidget();
503  bool SetFocusedWidget(WidgetID widget_index);
504 
505  EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode);
506  virtual void InsertTextString(WidgetID wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end);
507 
508  void HandleButtonClick(WidgetID widget);
509  int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const;
510 
511  void RaiseButtons(bool autoraise = false);
512 
520  template<typename... Args>
521  void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
522  {
523  (SetWidgetDisabledState(widgets, disab_stat), ...);
524  }
525 
531  template<typename... Args>
532  void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
533  {
534  (SetWidgetLoweredState(widgets, lowered_stat), ...);
535  }
536 
541  template<typename... Args>
542  void RaiseWidgetsWhenLowered(Args... widgets)
543  {
544  (this->RaiseWidgetWhenLowered(widgets), ...);
545  }
546 
547  void SetWidgetDirty(WidgetID widget_index) const;
548 
549  void DrawWidgets() const;
550  void DrawViewport() const;
551  void DrawSortButtonState(WidgetID widget, SortButtonState state) const;
552  static int SortButtonWidth();
553 
555  void CloseChildWindows(WindowClass wc = WC_INVALID) const;
556  virtual void Close(int data = 0);
557  static void DeleteClosedWindows();
558 
559  void SetDirty() const;
560  void ReInit(int rx = 0, int ry = 0, bool reposition = false);
561 
563  inline bool IsShaded() const
564  {
565  return this->shade_select != nullptr && this->shade_select->shown_plane == SZSP_HORIZONTAL;
566  }
567 
568  void SetShaded(bool make_shaded);
569 
570  void ScheduleResize();
571  void ProcessScheduledResize();
572  void InvalidateData(int data = 0, bool gui_scope = true);
575 
576  /*** Event handling ***/
577 
582  virtual void OnInit() { }
583 
584  virtual void ApplyDefaults();
585 
593  virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number);
594 
599  virtual void OnPaint()
600  {
601  this->DrawWidgets();
602  }
603 
610  virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const {}
611 
624  virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) {}
625 
632  virtual void SetStringParameters([[maybe_unused]] WidgetID widget) const {}
633 
637  virtual void OnFocus();
638 
643  virtual void OnFocusLost(bool closing);
644 
652  virtual EventState OnKeyPress([[maybe_unused]] char32_t key, [[maybe_unused]] uint16_t keycode) { return ES_NOT_HANDLED; }
653 
654  virtual EventState OnHotkey(int hotkey);
655 
662 
663 
670  virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) {}
671 
679  virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) { return false; }
680 
686  virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
687 
694  virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; }
695 
701  virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
702 
708  virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
709 
714  virtual void OnScroll([[maybe_unused]] Point delta) {}
715 
722  virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
723 
728  virtual void OnMouseWheel([[maybe_unused]] int wheel) {}
729 
730 
734  virtual void OnMouseLoop() {}
735 
739  virtual void OnGameTick() {}
740 
744  virtual void OnRealtimeTick([[maybe_unused]] uint delta_ms) {}
745 
749  virtual void OnTimeout() {}
750 
751 
756  virtual void OnResize() {}
757 
763  virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index) {}
764 
765  virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close);
766 
771  virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget) {}
772 
779  virtual void OnQueryTextFinished([[maybe_unused]] std::optional<std::string> str) {}
780 
786  virtual void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) {}
787 
794  virtual void OnPlaceObject([[maybe_unused]] Point pt, [[maybe_unused]] TileIndex tile) {}
795 
802  virtual bool OnVehicleSelect([[maybe_unused]] const struct Vehicle *v) { return false; }
803 
810  virtual bool OnVehicleSelect([[maybe_unused]] VehicleList::const_iterator begin, [[maybe_unused]] VehicleList::const_iterator end) { return false; }
811 
815  virtual void OnPlaceObjectAbort() {}
816 
817 
825  virtual void OnPlaceDrag([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) {}
826 
836  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) {}
837 
845  virtual void OnPlacePresize([[maybe_unused]] Point pt, [[maybe_unused]] TileIndex tile) {}
846 
847  /*** End of the event handling ***/
848 
853  virtual bool IsNewGRFInspectable() const { return false; }
854 
861  virtual void ShowNewGRFInspectWindow() const { NOT_REACHED(); }
862 
867  template <bool TtoBack>
868  struct WindowIterator {
869  typedef Window *value_type;
870  typedef value_type *pointer;
871  typedef value_type &reference;
872  typedef size_t difference_type;
873  typedef std::forward_iterator_tag iterator_category;
874 
875  explicit WindowIterator(WindowList::iterator start) : it(start)
876  {
877  this->Validate();
878  }
879  explicit WindowIterator(const Window *w) : it(w->z_position) {}
880 
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; }
885 
886  bool IsEnd() const { return this->it == _z_windows.end(); }
887 
888  private:
889  WindowList::iterator it;
890  void Validate()
891  {
892  while (!this->IsEnd() && *this->it == nullptr) this->Next();
893  }
894  void Next()
895  {
896  if constexpr (!TtoBack) {
897  ++this->it;
898  } else if (this->it == _z_windows.begin()) {
899  this->it = _z_windows.end();
900  } else {
901  --this->it;
902  }
903  }
904  };
907 
912  template <bool Tfront>
913  struct AllWindows {
914  AllWindows() {}
915  WindowIterator<Tfront> begin()
916  {
917  if constexpr (Tfront) {
918  auto back = _z_windows.end();
919  if (back != _z_windows.begin()) --back;
920  return WindowIterator<Tfront>(back);
921  } else {
922  return WindowIterator<Tfront>(_z_windows.begin());
923  }
924  }
926  };
930 };
931 
939 template <class It, class Pred>
940 inline bool AllEqual(It begin, It end, Pred pred)
941 {
942  return std::adjacent_find(begin, end, std::not_fn(pred)) == end;
943 }
944 
951 template <class NWID>
952 inline NWID *Window::GetWidget(WidgetID widnum)
953 {
954  auto it = this->widget_lookup.find(widnum);
955  if (it == std::end(this->widget_lookup)) return nullptr;
956  NWID *nwid = dynamic_cast<NWID *>(it->second);
957  assert(nwid != nullptr);
958  return nwid;
959 }
960 
962 template <>
963 inline const NWidgetBase *Window::GetWidget<NWidgetBase>(WidgetID widnum) const
964 {
965  auto it = this->widget_lookup.find(widnum);
966  if (it == std::end(this->widget_lookup)) return nullptr;
967  return it->second;
968 }
969 
976 template <class NWID>
977 inline const NWID *Window::GetWidget(WidgetID widnum) const
978 {
979  return const_cast<Window *>(this)->GetWidget<NWID>(widnum);
980 }
981 
982 
986 class PickerWindowBase : public Window {
987 
988 public:
990  {
991  this->parent = parent;
992  }
993 
994  void Close([[maybe_unused]] int data = 0) override;
995 };
996 
998 Window *FindWindowFromPt(int x, int y);
999 
1000 template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
1002 {
1003  return BringWindowToFrontById(cls, number.base());
1004 }
1005 
1014 template <typename Wcls>
1015 Wcls *AllocateWindowDescFront(WindowDesc &desc, int window_number, bool return_existing = false)
1016 {
1017  Wcls *w = static_cast<Wcls *>(BringWindowToFrontById(desc.cls, window_number));
1018  if (w != nullptr) return return_existing ? w : nullptr;
1019  return new Wcls(desc, window_number);
1020 }
1021 
1022 void RelocateAllWindows(int neww, int newh);
1023 
1024 void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount = 0);
1025 
1026 /* widget.cpp */
1027 WidgetID GetWidgetFromPos(const Window *w, int x, int y);
1028 
1029 extern Point _cursorpos_drag_start;
1030 
1031 extern int _scrollbar_start_pos;
1032 extern int _scrollbar_size;
1033 extern uint8_t _scroller_click_timeout;
1034 
1035 extern bool _scrolling_viewport;
1036 extern bool _mouse_hovering;
1037 
1045 };
1047 
1048 void SetFocusedWindow(Window *w);
1049 
1050 void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);
1051 Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step = 1);
1052 
1053 #endif /* WINDOW_GUI_H */
Baseclass for nested widgets.
Definition: widget_type.h:144
Base class for a 'real' widget.
Definition: widget_type.h:370
const WidgetID index
Index of the nested widget (-1 means 'not used').
Definition: widget_type.h:392
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:443
Leaf widget.
Definition: widget_type.h:916
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:498
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:512
Base class for windows opened from a toolbar.
Definition: window_gui.h:986
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3516
Scrollbar data structure.
Definition: widget_type.h:694
RectPadding defsizebox
Padding around image in defsizebox widget.
Definition: window_gui.h:48
RectPadding closebox
Padding around image in closebox widget.
Definition: window_gui.h:50
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
RectPadding captiontext
Padding for text within caption widget.
Definition: window_gui.h:51
RectPadding sparse_resize
Padding used for a resizeable 'sparse' widget window, usually containing multiple frames.
Definition: window_gui.h:57
RectPadding debugbox
Padding around image in debugbox widget.
Definition: window_gui.h:47
int vsep_sparse
Normal vertical spacing for 'sparse' widget window.
Definition: window_gui.h:61
RectPadding sparse
Padding used for 'sparse' widget window, usually containing multiple frames.
Definition: window_gui.h:56
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
RectPadding modalpopup
Spacing for popup warning/information windows.
Definition: window_gui.h:54
RectPadding hscrollbar
Padding inside horizontal scrollbar buttons.
Definition: window_gui.h:39
RectPadding shadebox
Padding around image in shadebox widget.
Definition: window_gui.h:45
RectPadding resizebox
Padding around image in resizebox widget.
Definition: window_gui.h:49
RectPadding vscrollbar
Padding inside vertical scrollbar buttons.
Definition: window_gui.h:38
RectPadding imgbtn
Padding around image button image.
Definition: window_gui.h:36
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
int vsep_picker
Vertical spacing of picker-window widgets.
Definition: window_gui.h:59
int vsep_wide
Wide vertical spacing.
Definition: window_gui.h:62
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
RectPadding inset
Padding inside inset container.
Definition: window_gui.h:37
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
RectPadding picker
Padding for a picker (dock, station, etc) window.
Definition: window_gui.h:55
RectPadding matrix
Padding of WWT_MATRIX items.
Definition: window_gui.h:44
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
RectPadding dropdownlist
Padding of complete drop down list.
Definition: window_gui.h:53
RectPadding stickybox
Padding around image in stickybox widget.
Definition: window_gui.h:46
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition: window_gui.h:40
RectPadding dropdowntext
Padding of drop down list item.
Definition: window_gui.h:52
int hsep_indent
Width of identation for tree layouts.
Definition: window_gui.h:65
Base class that provides memory initialization on dynamically created objects.
Definition: alloc_type.hpp:86
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Types related to companies.
Owner
Enum for all companies/owners.
Definition: company_type.h:18
StringAlignment
How to align the to-be drawn text.
Definition: gfx_type.h:342
FontSize
Available font sizes.
Definition: gfx_type.h:208
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:260
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:940
Types for strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
Dimensions (a width and height) of a rectangle in 2D.
List of hotkeys for a window.
Definition: hotkeys.h:37
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.
Definition: window_gui.h:212
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:214
uint step_width
Step-size of width resize changes.
Definition: window_gui.h:213
Helper/buffer for input fields.
Definition: textbuf_type.h:30
bool caret
is the caret ("_") visible or not
Definition: textbuf_type.h:38
Vehicle data structure.
Definition: vehicle_base.h:244
Data structure for a window viewport.
Definition: window_gui.h:252
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:257
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:255
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition: window_gui.h:256
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
Definition: window_gui.h:253
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition: window_gui.h:254
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
High level window description.
Definition: window_gui.h:159
uint32_t flags
Flags.
Definition: window_gui.h:173
int16_t GetDefaultWidth() const
Determine default width of window.
Definition: window.cpp:137
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
Definition: window.cpp:177
int16_t pref_width
User-preferred width of the window. Zero if unset.
Definition: window_gui.h:178
bool pref_sticky
Preferred stickyness.
Definition: window_gui.h:177
HotkeyList * hotkeys
Hotkeys for the window.
Definition: window_gui.h:175
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.
Definition: window_gui.h:179
int16_t GetDefaultHeight() const
Determine default height of window.
Definition: window.cpp:147
WindowClass cls
Class of the window,.
Definition: window_gui.h:170
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.
Definition: window.cpp:105
WindowPosition default_pos
Preferred position of the window.
Definition: window_gui.h:169
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
Definition: window_gui.h:172
int16_t default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
Definition: window_gui.h:189
WindowClass parent_cls
Class of the parent window.
Definition: window_gui.h:171
int16_t default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
Definition: window_gui.h:188
const std::source_location source_location
Source location of this definition.
Definition: window_gui.h:168
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
Definition: window.cpp:155
const std::span< const NWidgetPart > nwid_parts
Span of nested widget parts describing the window.
Definition: window_gui.h:174
Iterable ensemble of all valid Windows.
Definition: window_gui.h:913
Iterator to iterate all valid Windows.
Definition: window_gui.h:868
Data structure for an opened window.
Definition: window_gui.h:273
virtual const struct Textbuf * GetFocusedTextbuf() const
Get the current input text buffer.
Definition: window.cpp:365
void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
Definition: window.cpp:242
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:952
virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
A dragged 'object' has been released.
Definition: window_gui.h:708
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1047
bool IsWidgetGloballyFocused(WidgetID widget_index) const
Check if given widget has user input focus.
Definition: window_gui.h:437
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:780
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1733
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:320
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
Definition: window.cpp:194
uint8_t white_border_timer
Timer value of the WF_WHITE_BORDER for flags.
Definition: window_gui.h:307
NWidgetStacked * shade_select
Selection widget (NWID_SELECTION) to use for shading the window. If nullptr, window cannot shade.
Definition: window_gui.h:323
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
Definition: window.cpp:1402
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
Definition: window_gui.h:324
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3151
Window * parent
Parent window.
Definition: window_gui.h:328
virtual ~Window()
Remove window and all its child windows from the window stack.
Definition: window.cpp:1084
virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond)
Event to display a custom tooltip.
Definition: window_gui.h:694
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:475
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.
Definition: window_gui.h:794
virtual bool OnVehicleSelect([[maybe_unused]] const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
Definition: window_gui.h:802
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:551
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:306
virtual EventState OnKeyPress([[maybe_unused]] char32_t key, [[maybe_unused]] uint16_t keycode)
A key has been pressed.
Definition: window_gui.h:652
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.
Definition: window_gui.h:624
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
Definition: window_gui.h:326
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.
Definition: window_gui.h:722
virtual void OnGameTick()
Called once per (game) tick.
Definition: window_gui.h:739
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
Definition: window_gui.h:861
void RaiseWidgetWhenLowered(WidgetID widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
Definition: window_gui.h:484
virtual void SetStringParameters([[maybe_unused]] WidgetID widget) const
Initialize string parameters for a widget.
Definition: window_gui.h:632
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:763
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
Definition: window.cpp:3164
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.
Definition: window_gui.h:686
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition: window.cpp:1035
ResizeInfo resize
Resize information.
Definition: window_gui.h:314
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
Definition: window.cpp:470
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:397
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
Definition: window_gui.h:734
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
Definition: window.cpp:995
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition: window_gui.h:815
int scale
Scale of this window – used to determine how to resize.
Definition: window_gui.h:304
void ScheduleResize()
Mark this window as resized and in need of OnResize() event.
Definition: window.cpp:3129
bool IsWidgetFocused(WidgetID widget_index) const
Check if given widget is focused within this window.
Definition: window_gui.h:426
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:521
virtual void OnPaint()
The window must be repainted.
Definition: window_gui.h:599
virtual bool IsNewGRFInspectable() const
Is the data related to this window NewGRF inspectable?
Definition: window_gui.h:853
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1723
WindowDesc & window_desc
Window description.
Definition: window_gui.h:299
WindowClass window_class
Window class.
Definition: window_gui.h:301
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:318
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.
Definition: window_gui.h:825
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:370
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:486
virtual void OnFocusLost(bool closing)
The window has lost focus.
Definition: window.cpp:516
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.
Definition: window_gui.h:670
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Definition: window.cpp:287
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:497
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:416
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.
Definition: window_gui.h:836
void DrawViewport() const
Draw the viewport of this window.
Definition: viewport.cpp:1832
static std::vector< Window * > closed_windows
List of closed windows to delete.
Definition: window_gui.h:275
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...
Definition: window_gui.h:845
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:525
virtual void OnMouseWheel([[maybe_unused]] int wheel)
The mouse wheel has been turned.
Definition: window_gui.h:728
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition: window_gui.h:532
virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number)
Compute the initial position of the window.
Definition: window.cpp:1711
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:316
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:447
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:406
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
Definition: window.cpp:378
virtual void OnQueryTextFinished([[maybe_unused]] std::optional< std::string > str)
The query window opened from this window has closed.
Definition: window_gui.h:779
int left
x position of left edge of the window
Definition: window_gui.h:309
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:563
Window * FindChildWindow(WindowClass wc=WC_INVALID) const
Find the Window whose parent pointer points to this window.
Definition: window.cpp:1022
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:361
const NWidgetCore * nested_focus
Currently focused nested widget, or nullptr if no nested widget has focus.
Definition: window_gui.h:319
void UpdateQueryStringSize()
Update size of all QueryStrings of this window.
Definition: window.cpp:354
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition: window_gui.h:542
int top
y position of top edge of the window
Definition: window_gui.h:310
const QueryString * GetQueryString(WidgetID widnum) const
Return the querystring associated to a editbox.
Definition: window.cpp:334
virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const
Draw the contents of a nested widget.
Definition: window_gui.h:610
WidgetLookup widget_lookup
Indexed access to the nested widget tree. Do not access directly, use Window::GetWidget() instead.
Definition: window_gui.h:322
virtual ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const
Get the character that is rendered at a position by the focused edit box.
Definition: window.cpp:409
std::vector< int > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
Definition: window_gui.h:282
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
Definition: window.cpp:1364
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1756
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Definition: window.cpp:213
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition: window_gui.h:977
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:466
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
Definition: window_gui.h:661
void ProcessScheduledResize()
Process scheduled OnResize() event.
Definition: window.cpp:3137
EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode)
Process keypress for editbox widget.
Definition: window.cpp:2473
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.
Definition: window.cpp:2631
virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget)
The text in an editbox has been edited.
Definition: window_gui.h:771
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:590
virtual void OnResize()
Called after the window got resized.
Definition: window_gui.h:756
virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget)
A click with the right mouse button has been made on the window.
Definition: window_gui.h:679
virtual void OnFocus()
The window has gained focus.
Definition: window.cpp:508
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1746
virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index)
A dropdown option associated to this window has been selected.
Definition: window_gui.h:763
virtual void OnTimeout()
Called when this window's timeout has been reached.
Definition: window_gui.h:749
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.
Definition: window_gui.h:701
WindowFlags flags
Window flags.
Definition: window_gui.h:300
virtual void OnRealtimeTick([[maybe_unused]] uint delta_ms)
Called periodically.
Definition: window_gui.h:744
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:314
virtual void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true)
Some data on this window has become invalid.
Definition: window_gui.h:786
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.
Definition: window_gui.h:810
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
Definition: window.cpp:3176
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:394
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:565
static void DeleteClosedWindows()
Delete all closed windows.
Definition: window.cpp:65
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:387
std::unique_ptr< NWidgetBase > nested_root
Root of the nested tree.
Definition: window_gui.h:321
bool scheduled_resize
Set if window has been resized.
Definition: window_gui.h:283
bool IsWidgetHighlighted(WidgetID widget_index) const
Gets the highlighted status of a widget.
Definition: window.cpp:272
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
Definition: window.cpp:224
virtual void OnScroll([[maybe_unused]] Point delta)
Handle the request for (viewport) scrolling.
Definition: window_gui.h:714
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:312
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:311
virtual void OnInit()
Notification that the nested widget tree gets initialized.
Definition: window_gui.h:582
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:456
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Definition: window.cpp:1420
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:302
Types related to tiles.
Types related to vehicles.
uint32_t VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
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)
Definition: viewport_type.h:92
Definitions about widgets.
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:482
std::map< WidgetID, class NWidgetBase * > WidgetLookup
Lookup between widget IDs and NWidget objects.
Definition: widget_type.h:136
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:281
SpecialMouseMode
Mouse modes.
Definition: window_gui.h:1039
@ WSM_DRAGDROP
Drag&drop an object.
Definition: window_gui.h:1041
@ WSM_DRAGGING
Dragging mode (trees).
Definition: window_gui.h:1044
@ WSM_PRESIZE
Presizing mode (docks, tunnels).
Definition: window_gui.h:1043
@ WSM_NONE
No special mouse mode.
Definition: window_gui.h:1040
@ WSM_SIZING
Sizing mode.
Definition: window_gui.h:1042
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1223
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
Definition: window.cpp:90
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 ...
Definition: window_gui.h:940
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
Draw a caption bar.
Definition: widget.cpp:679
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:422
SortButtonState
State of a sort direction button.
Definition: window_gui.h:218
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:220
@ SBS_UP
Sort descending.
Definition: window_gui.h:221
@ SBS_OFF
Do not sort (with this button).
Definition: window_gui.h:219
static const int TIMEOUT_DURATION
The initial timeout value for WF_TIMEOUT.
Definition: window_gui.h:242
WidgetID 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:266
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:1627
WindowFlags
Window flags.
Definition: window_gui.h:227
@ WF_DRAGGING
Window is being dragged.
Definition: window_gui.h:230
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:236
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:228
@ WF_SIZING_LEFT
Window is being resized towards the left.
Definition: window_gui.h:232
@ WF_DISABLE_VP_SCROLL
Window does not do autoscroll,.
Definition: window_gui.h:235
@ WF_SIZING
Window is being resized.
Definition: window_gui.h:233
@ WF_HIGHLIGHTED
Window has a widget that has a highlight.
Definition: window_gui.h:237
@ WF_STICKY
Window is made sticky by user.
Definition: window_gui.h:234
@ WF_SIZING_RIGHT
Window is being resized towards the right.
Definition: window_gui.h:231
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
Definition: window_gui.h:238
FrameFlags
Flags to describe the look of the frame.
Definition: window_gui.h:24
@ FR_DARKENED
If set the background is darker, allows for lowered frames with normal background colour when used wi...
Definition: window_gui.h:29
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:27
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:28
@ FR_TRANSPARENT
Makes the background transparent if set.
Definition: window_gui.h:26
Wcls * AllocateWindowDescFront(WindowDesc &desc, int window_number, bool return_existing=false)
Open a new window.
Definition: window_gui.h:1015
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
Definition: window.cpp:3443
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y)
Special handling for the scrollbar widget type.
Definition: widget.cpp:242
bool _mouse_hovering
The mouse is hovering over the same point.
Definition: window.cpp:91
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
Definition: window.cpp:1768
WindowDefaultFlag
Window default widget/window handling flags.
Definition: window_gui.h:202
@ WDF_NO_CLOSE
This window can't be interactively closed.
Definition: window_gui.h:206
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:203
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Definition: window_gui.h:204
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
Definition: window_gui.h:205
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount=0)
Shows a tooltip.
Definition: misc_gui.cpp:760
WindowList _z_windows
List of windows opened at the screen sorted from the front to back.
Definition: window.cpp:57
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Definition: window.cpp:93
static const int WHITE_BORDER_DURATION
The initial timeout value for WF_WHITE_BORDER.
Definition: window_gui.h:243
Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step=1)
Apply 'scroll' to a rect to be drawn in.
Definition: widget.cpp:2411
WindowPosition
How do we the window to be placed?
Definition: window_gui.h:145
@ WDP_CENTER
Center the window.
Definition: window_gui.h:148
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:147
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:149
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:146
int WidgetID
Widget ID.
Definition: window_type.h:18
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:737
EventState
State of handling an event.
Definition: window_type.h:743
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:745
WindowClass
Window classes.
Definition: window_type.h:44
@ WC_INVALID
Invalid window.
Definition: window_type.h:724