OpenTTD Source  13.1
widget_type.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 WIDGET_TYPE_H
11 #define WIDGET_TYPE_H
12 
13 #include "core/alloc_type.hpp"
14 #include "core/bitmath_func.hpp"
15 #include "core/math_func.hpp"
16 #include "strings_type.h"
17 #include "gfx_type.h"
18 #include "window_type.h"
19 
20 static const int WIDGET_LIST_END = -1;
21 
24  /* Number of column bits of the WWT_MATRIX widget data. */
27 
28  /* Number of row bits of the WWT_MATRIX widget data. */
31 };
32 
39 };
40 
44 enum WidgetType {
45  /* Window widget types. */
47 
60 
65 
71 
72  /* Nested widget types. */
83 
84  /* Nested widget part types. */
97 
98  /* Pushable window widget types. */
99  WWT_MASK = 0x7F,
100 
101  WWB_PUSHBUTTON = 1 << 7,
102 
103  WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON,
104  WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON,
105  WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON,
106  WWT_PUSHARROWBTN = WWT_ARROWBTN | WWB_PUSHBUTTON,
107  NWID_PUSHBUTTON_DROPDOWN = NWID_BUTTON_DROPDOWN | WWB_PUSHBUTTON,
108 };
109 
114 };
115 
116 /* Forward declarations. */
117 class NWidgetCore;
118 class Scrollbar;
119 
127 public:
129 
130  virtual void AdjustPaddingForZoom();
131  virtual void SetupSmallestSize(Window *w, bool init_array) = 0;
132  virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0;
133 
134  virtual void FillNestedArray(NWidgetBase **array, uint length) = 0;
135 
136  virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
138 
139  virtual bool IsHighlighted() const { return false; }
140  virtual TextColour GetHighlightColour() const { return TC_INVALID; }
141  virtual void SetHighlighted(TextColour highlight_colour) {}
142 
150  inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
151  {
152  this->uz_padding.top = top;
153  this->uz_padding.right = right;
154  this->uz_padding.bottom = bottom;
155  this->uz_padding.left = left;
156  this->AdjustPaddingForZoom();
157  }
158 
163  inline void SetPadding(const RectPadding &padding)
164  {
165  this->uz_padding = padding;
166  this->AdjustPaddingForZoom();
167  }
168 
169  inline uint GetHorizontalStepSize(SizingType sizing) const;
170  inline uint GetVerticalStepSize(SizingType sizing) const;
171 
172  virtual void Draw(const Window *w) = 0;
173  virtual void SetDirty(const Window *w) const;
174 
175  Rect GetCurrentRect() const
176  {
177  Rect r;
178  r.left = this->pos_x;
179  r.top = this->pos_y;
180  r.right = this->pos_x + this->current_x - 1;
181  r.bottom = this->pos_y + this->current_y - 1;
182  return r;
183  }
184 
186  uint fill_x;
187  uint fill_y;
188  uint resize_x;
189  uint resize_y;
190  /* Size of the widget in the smallest window possible.
191  * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
192  */
193  uint smallest_x;
194  uint smallest_y;
195  /* Current widget size (that is, after resizing). */
196  uint current_x;
197  uint current_y;
198 
199  int pos_x;
200  int pos_y;
201 
204 
207 
208 protected:
209  inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
210 };
211 
217 {
218  return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
219 }
220 
226 {
227  return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
228 }
229 
238 inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
239 {
240  this->pos_x = x;
241  this->pos_y = y;
242  if (sizing == ST_SMALLEST) {
243  this->smallest_x = given_width;
244  this->smallest_y = given_height;
245  }
246  this->current_x = given_width;
247  this->current_y = given_height;
248 }
249 
250 
256 public:
257  NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
258 
259  void AdjustPaddingForZoom() override;
260  void SetMinimalSize(uint min_x, uint min_y);
261  void SetMinimalSizeAbsolute(uint min_x, uint min_y);
262  void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
263  void SetFill(uint fill_x, uint fill_y);
264  void SetResize(uint resize_x, uint resize_y);
265 
266  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
267 
268  uint min_x;
269  uint min_y;
270 
271  bool absolute;
272  uint uz_min_x;
273  uint uz_min_y;
274 
278 };
279 
282  /* Generic. */
285  /* Viewport widget. */
289  /* Button dropdown widget. */
291  /* Scrollbar widget. */
294  /* Generic. */
296 
307 };
309 
310 
315 public:
316  NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
317 
318  void SetIndex(int index);
319  void SetDataTip(uint32 widget_data, StringID tool_tip);
320  void SetToolTip(StringID tool_tip);
321  void SetTextColour(TextColour colour);
322  void SetAlignment(StringAlignment align);
323 
324  inline void SetLowered(bool lowered);
325  inline bool IsLowered() const;
326  inline void SetDisabled(bool disabled);
327  inline bool IsDisabled() const;
328 
329  void FillNestedArray(NWidgetBase **array, uint length) override;
330  NWidgetCore *GetWidgetFromPos(int x, int y) override;
331  bool IsHighlighted() const override;
332  TextColour GetHighlightColour() const override;
333  void SetHighlighted(TextColour highlight_colour) override;
334 
336  Colours colour;
337  int index;
338  uint32 widget_data;
344 };
345 
350 inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
351 {
352  this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
353  this->highlight_colour = highlight_colour;
354 }
355 
357 inline bool NWidgetCore::IsHighlighted() const
358 {
359  return HasBit(this->disp_flags, NDB_HIGHLIGHT);
360 }
361 
364 {
365  return this->highlight_colour;
366 }
367 
372 inline void NWidgetCore::SetLowered(bool lowered)
373 {
374  this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
375 }
376 
378 inline bool NWidgetCore::IsLowered() const
379 {
380  return HasBit(this->disp_flags, NDB_LOWERED);
381 }
382 
387 inline void NWidgetCore::SetDisabled(bool disabled)
388 {
389  this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
390 }
391 
393 inline bool NWidgetCore::IsDisabled() const
394 {
395  return HasBit(this->disp_flags, NDB_DISABLED);
396 }
397 
398 
404 public:
406  ~NWidgetContainer();
407 
408  void AdjustPaddingForZoom() override;
409  void Add(NWidgetBase *wid);
410  void FillNestedArray(NWidgetBase **array, uint length) override;
411 
413  inline bool IsEmpty() { return head == nullptr; }
414 
415  NWidgetBase *GetWidgetOfType(WidgetType tp) override;
416 
417 protected:
420 };
421 
424  SZSP_VERTICAL = INT_MAX / 2,
427 
429 };
430 
442 public:
443  NWidgetStacked();
444 
445  void SetIndex(int index);
446 
447  void AdjustPaddingForZoom() override;
448  void SetupSmallestSize(Window *w, bool init_array) override;
449  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
450  void FillNestedArray(NWidgetBase **array, uint length) override;
451 
452  void Draw(const Window *w) override;
453  NWidgetCore *GetWidgetFromPos(int x, int y) override;
454 
455  void SetDisplayedPlane(int plane);
456 
458  int index;
459 };
460 
465 
466  NC_NONE = 0,
469 };
471 
472 
474 public:
476 
477  void AdjustPaddingForZoom() override;
478  void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
479 
480  void Draw(const Window *w) override;
481  NWidgetCore *GetWidgetFromPos(int x, int y) override;
482 
483 protected:
485  uint8 pip_pre;
486  uint8 pip_inter;
487  uint8 pip_post;
488 
489  uint8 uz_pip_pre;
490  uint8 uz_pip_inter;
491  uint8 uz_pip_post;
492 };
493 
499 public:
501 
502  void SetupSmallestSize(Window *w, bool init_array) override;
503  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
504 };
505 
511 public:
513 
514  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
515 };
516 
522 public:
524 
525  void SetupSmallestSize(Window *w, bool init_array) override;
526  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
527 };
528 
538 public:
539  NWidgetMatrix();
540 
541  void SetIndex(int index);
542  void SetColour(Colours colour);
543  void SetClicked(int clicked);
544  void SetCount(int count);
545  void SetScrollbar(Scrollbar *sb);
546 
547  void SetupSmallestSize(Window *w, bool init_array) override;
548  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
549  void FillNestedArray(NWidgetBase **array, uint length) override;
550 
551  NWidgetCore *GetWidgetFromPos(int x, int y) override;
552  void Draw(const Window *w) override;
553 protected:
554  int index;
555  Colours colour;
556  int clicked;
557  int count;
559 private:
560  int widget_w;
561  int widget_h;
562  int widgets_x;
563  int widgets_y;
564 
565  void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
566 };
567 
568 
574 public:
575  NWidgetSpacer(int width, int height);
576 
577  void SetupSmallestSize(Window *w, bool init_array) override;
578  void FillNestedArray(NWidgetBase **array, uint length) override;
579 
580  void Draw(const Window *w) override;
581  void SetDirty(const Window *w) const override;
582  NWidgetCore *GetWidgetFromPos(int x, int y) override;
583 };
584 
590 public:
591  NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr);
593 
594  void Add(NWidgetBase *nwid);
595  void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
596 
597  void AdjustPaddingForZoom() override;
598  void SetupSmallestSize(Window *w, bool init_array) override;
599  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
600 
601  void FillNestedArray(NWidgetBase **array, uint length) override;
602 
603  void Draw(const Window *w) override;
604  NWidgetCore *GetWidgetFromPos(int x, int y) override;
605  NWidgetBase *GetWidgetOfType(WidgetType tp) override;
606 
607 private:
609 };
610 
620 class NWidgetViewport : public NWidgetCore {
621 public:
622  NWidgetViewport(int index);
623 
624  void SetupSmallestSize(Window *w, bool init_array) override;
625  void Draw(const Window *w) override;
626 
627  void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
629 };
630 
634 class Scrollbar {
635 private:
636  const bool is_vertical;
637  uint16 count;
638  uint16 cap;
639  uint16 pos;
640  uint16 stepsize;
641 
642 public:
648  };
649 
651  {
652  }
653 
658  inline uint16 GetCount() const
659  {
660  return this->count;
661  }
662 
667  inline uint16 GetCapacity() const
668  {
669  return this->cap;
670  }
671 
676  inline uint16 GetPosition() const
677  {
678  return this->pos;
679  }
680 
686  inline bool IsVisible(uint16 item) const
687  {
688  return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
689  }
690 
695  inline bool IsVertical() const
696  {
697  return this->is_vertical;
698  }
699 
704  void SetStepSize(uint16 stepsize)
705  {
706  assert(stepsize > 0);
707  this->stepsize = stepsize;
708  }
709 
715  void SetCount(int num)
716  {
717  assert(num >= 0);
718  assert(num <= MAX_UVALUE(uint16));
719 
720  this->count = num;
721  num -= this->cap;
722  if (num < 0) num = 0;
723  if (num < this->pos) this->pos = num;
724  }
725 
731  void SetCapacity(int capacity)
732  {
733  assert(capacity > 0);
734  assert(capacity <= MAX_UVALUE(uint16));
735 
736  this->cap = capacity;
737  if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
738  }
739 
740  void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
741 
747  bool SetPosition(int position)
748  {
749  uint16 old_pos = this->pos;
750  this->pos = Clamp(position, 0, std::max(this->count - this->cap, 0));
751  return this->pos != old_pos;
752  }
753 
761  bool UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
762  {
763  if (difference == 0) return false;
764  switch (unit) {
765  case SS_SMALL: difference *= this->stepsize; break;
766  case SS_BIG: difference *= this->cap; break;
767  default: break;
768  }
769  return this->SetPosition(this->pos + difference);
770  }
771 
778  void ScrollTowards(int position)
779  {
780  if (position < this->GetPosition()) {
781  /* scroll up to the item */
782  this->SetPosition(position);
783  } else if (position >= this->GetPosition() + this->GetCapacity()) {
784  /* scroll down so that the item is at the bottom */
785  this->SetPosition(position - this->GetCapacity() + 1);
786  }
787  }
788 
789  int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0) const;
790  EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const;
791 };
792 
798 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
799 public:
800  NWidgetScrollbar(WidgetType tp, Colours colour, int index);
801 
802  void SetupSmallestSize(Window *w, bool init_array) override;
803  void Draw(const Window *w) override;
804 
805  static void InvalidateDimensionCache();
806  static Dimension GetVerticalDimension();
807  static Dimension GetHorizontalDimension();
808 
809 private:
812 };
813 
818 class NWidgetLeaf : public NWidgetCore {
819 public:
820  NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
821 
822  void SetupSmallestSize(Window *w, bool init_array) override;
823  void Draw(const Window *w) override;
824 
825  bool ButtonHit(const Point &pt);
826 
827  static void InvalidateDimensionCache();
828 
832 private:
837 };
838 
846 static inline uint ComputeMaxSize(uint base, uint max_space, uint step)
847 {
848  if (base >= max_space || step == 0) return base;
849  if (step == 1) return max_space;
850  uint increment = max_space - base;
851  increment -= increment % step;
852  return base + increment;
853 }
854 
907  uint32 data;
909 };
910 
916  Colours colour;
917  int16 index;
918 };
919 
925 };
926 
932  uint8 pre, inter, post;
933 };
934 
940  uint8 lines;
941  uint8 spacing;
943 };
944 
951 };
952 
959 };
960 
967 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
968 
973 struct NWidgetPart {
975  union {
986  } u;
987 };
988 
995 static inline NWidgetPart SetResize(int16 dx, int16 dy)
996 {
997  NWidgetPart part;
998 
999  part.type = WPT_RESIZE;
1000  part.u.xy.x = dx;
1001  part.u.xy.y = dy;
1002 
1003  return part;
1004 }
1005 
1012 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
1013 {
1014  NWidgetPart part;
1015 
1016  part.type = WPT_MINSIZE;
1017  part.u.xy.x = x;
1018  part.u.xy.y = y;
1019 
1020  return part;
1021 }
1022 
1030 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
1031 {
1032  NWidgetPart part;
1033 
1034  part.type = WPT_MINTEXTLINES;
1035  part.u.text_lines.lines = lines;
1036  part.u.text_lines.spacing = spacing;
1037  part.u.text_lines.size = size;
1038 
1039  return part;
1040 }
1041 
1047 static inline NWidgetPart SetTextColour(TextColour colour)
1048 {
1049  NWidgetPart part;
1050 
1051  part.type = WPT_TEXTCOLOUR;
1052  part.u.colour.colour = colour;
1053 
1054  return part;
1055 }
1056 
1063 {
1064  NWidgetPart part;
1065 
1066  part.type = WPT_ALIGNMENT;
1067  part.u.align.align = align;
1068 
1069  return part;
1070 }
1071 
1078 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
1079 {
1080  NWidgetPart part;
1081 
1082  part.type = WPT_FILL;
1083  part.u.xy.x = fill_x;
1084  part.u.xy.y = fill_y;
1085 
1086  return part;
1087 }
1088 
1094 static inline NWidgetPart EndContainer()
1095 {
1096  NWidgetPart part;
1097 
1098  part.type = WPT_ENDCONTAINER;
1099 
1100  return part;
1101 }
1102 
1109 static inline NWidgetPart SetDataTip(uint32 data, StringID tip)
1110 {
1111  NWidgetPart part;
1112 
1113  part.type = WPT_DATATIP;
1114  part.u.data_tip.data = data;
1115  part.u.data_tip.tooltip = tip;
1116 
1117  return part;
1118 }
1119 
1127 static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
1128 {
1129  return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip);
1130 }
1131 
1141 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
1142 {
1143  NWidgetPart part;
1144 
1145  part.type = WPT_PADDING;
1146  part.u.padding.top = top;
1147  part.u.padding.right = right;
1148  part.u.padding.bottom = bottom;
1149  part.u.padding.left = left;
1150 
1151  return part;
1152 }
1153 
1159 static inline NWidgetPart SetPadding(const RectPadding &padding)
1160 {
1161  NWidgetPart part;
1162 
1163  part.type = WPT_PADDING;
1164  part.u.padding.left = padding.left;
1165  part.u.padding.top = padding.top;
1166  part.u.padding.right = padding.right;
1167  part.u.padding.bottom = padding.bottom;
1168 
1169  return part;
1170 }
1171 
1177 static inline NWidgetPart SetPadding(uint8 padding)
1178 {
1179  return SetPadding(padding, padding, padding, padding);
1180 }
1181 
1189 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
1190 {
1191  NWidgetPart part;
1192 
1193  part.type = WPT_PIPSPACE;
1194  part.u.pip.pre = pre;
1195  part.u.pip.inter = inter;
1196  part.u.pip.post = post;
1197 
1198  return part;
1199 }
1200 
1208 static inline NWidgetPart SetScrollbar(int index)
1209 {
1210  NWidgetPart part;
1211 
1212  part.type = WPT_SCROLLBAR;
1213  part.u.widget.index = index;
1214 
1215  return part;
1216 }
1217 
1227 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
1228 {
1229  NWidgetPart part;
1230 
1231  part.type = tp;
1232  part.u.widget.colour = col;
1233  part.u.widget.index = idx;
1234 
1235  return part;
1236 }
1237 
1245 {
1246  NWidgetPart part;
1247 
1248  part.type = tp;
1249  part.u.cont_flags = cont_flags;
1250 
1251  return part;
1252 }
1253 
1260 {
1261  NWidgetPart part;
1262 
1263  part.type = WPT_FUNCTION;
1264  part.u.func_ptr = func_ptr;
1265 
1266  return part;
1267 }
1268 
1269 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
1270 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
1271 
1272 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);
1273 
1274 void SetupWidgetDimensions();
1275 
1276 #endif /* WIDGET_TYPE_H */
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:426
NWidgetBackground::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2141
NWidgetSpacer::NWidgetSpacer
NWidgetSpacer(int width, int height)
Generic spacer widget.
Definition: widget.cpp:1815
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:255
NWidgetPartTextLines::lines
uint8 lines
Number of text lines.
Definition: widget_type.h:940
NWidgetMatrix::clicked
int clicked
The currently clicked widget.
Definition: widget_type.h:556
NWidgetScrollbar::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2465
NWidgetStacked::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1350
NWidgetMatrix::widgets_y
int widgets_y
The number of visible widgets in vertical direction.
Definition: widget_type.h:563
NDB_LOWERED
@ NDB_LOWERED
Widget is lowered (pressed down) bit.
Definition: widget_type.h:283
NWidgetStacked::NWidgetStacked
NWidgetStacked()
Widgets stacked on top of each other.
Definition: widget.cpp:1288
NWidgetResizeBase::uz_min_x
uint uz_min_x
Unscaled Minimal horizontal size of only this widget.
Definition: widget_type.h:272
NWidgetPart::colour
NWidgetPartTextColour colour
Part with text colour data.
Definition: widget_type.h:982
NWidgetCore::IsDisabled
bool IsDisabled() const
Return whether the widget is disabled.
Definition: widget_type.h:393
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:51
WPT_DATATIP
@ WPT_DATATIP
Widget part for specifying data and tooltip.
Definition: widget_type.h:89
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1259
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:846
NWidgetCore::GetHighlightColour
TextColour GetHighlightColour() const override
Return the colour of the highlight.
Definition: widget_type.h:363
NWidgetCore::IsHighlighted
bool IsHighlighted() const override
Return whether the widget is highlighted.
Definition: widget_type.h:357
NWidgetPart::pip
NWidgetPartPIP pip
Part with pre/inter/post spaces.
Definition: widget_type.h:980
NWidgetSpacer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1841
Scrollbar::SS_SMALL
@ SS_SMALL
Step in stepsize units.
Definition: widget_type.h:646
NWidgetPartPIP::post
uint8 post
Amount of space before/between/after child widgets.
Definition: widget_type.h:932
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1208
NWidgetPIPContainer::pip_inter
uint8 pip_inter
Amount of space between widgets.
Definition: widget_type.h:486
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
NWidgetPart::align
NWidgetPartAlignment align
Part with internal alignment.
Definition: widget_type.h:983
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:667
NWidgetStacked::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:458
NWidgetLeaf::resizebox_dimension
static Dimension resizebox_dimension
Cached size of a resizebox widget.
Definition: widget_type.h:830
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1141
Scrollbar::is_vertical
const bool is_vertical
Scrollbar has vertical orientation.
Definition: widget_type.h:636
NWidgetCore::SetHighlighted
void SetHighlighted(TextColour highlight_colour) override
Highlight the widget or not.
Definition: widget_type.h:350
SZSP_BEGIN
@ SZSP_BEGIN
First zero-size plane.
Definition: widget_type.h:428
NWidgetBase::GetVerticalStepSize
uint GetVerticalStepSize(SizingType sizing) const
Get the vertical sizing step.
Definition: widget_type.h:225
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1261
ND_SCROLLBAR_DOWN
@ ND_SCROLLBAR_DOWN
Bit value of the 'scrollbar down' flag.
Definition: widget_type.h:305
NWID_HSCROLLBAR
@ NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:81
Scrollbar::ScrollbarStepping
ScrollbarStepping
Stepping sizes when scrolling.
Definition: widget_type.h:644
NWidgetViewport
Nested widget to display a viewport in a window.
Definition: widget_type.h:620
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:778
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
Scrollbar::pos
uint16 pos
Index of first visible item of the list.
Definition: widget_type.h:639
NWidgetPartPaddings
Widget part for storing padding.
Definition: widget_type.h:924
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:537
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
NWidgetBase::GetHorizontalStepSize
uint GetHorizontalStepSize(SizingType sizing) const
Get the horizontal sizing step.
Definition: widget_type.h:216
NWidgetPIPContainer::uz_pip_post
uint8 uz_pip_post
Unscaled space after last widget.
Definition: widget_type.h:491
ND_SHADE_DIMMED
@ ND_SHADE_DIMMED
Bit value of the 'dimmed colours' flag.
Definition: widget_type.h:302
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
math_func.hpp
NWidgetBase::uz_padding
RectPadding uz_padding
Unscaled padding, for resize calculation.
Definition: widget_type.h:206
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
NWidgetResizeBase::SetMinimalTextLines
void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size)
Set minimal text lines for the widget.
Definition: widget.cpp:1106
NWidgetStacked::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1376
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NWidgetMatrix::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2003
NWidgetLeaf::stickybox_dimension
static Dimension stickybox_dimension
Cached size of a stickybox widget.
Definition: widget_type.h:836
NDB_SCROLLBAR_DOWN
@ NDB_SCROLLBAR_DOWN
Down-button is lowered bit.
Definition: widget_type.h:293
NDB_SHADE_DIMMED
@ NDB_SHADE_DIMMED
Display dimmed colours in the viewport.
Definition: widget_type.h:288
window_type.h
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
ArrowWidgetValues
ArrowWidgetValues
Values for an arrow widget.
Definition: widget_type.h:34
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:74
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
NWidgetSpacer
Spacer widget.
Definition: widget_type.h:573
WWT_ARROWBTN
@ WWT_ARROWBTN
(Toggle) Button with an arrow
Definition: widget_type.h:52
NWidgetBase::NWidgetBase
NWidgetBase(WidgetType tp)
Base class constructor.
Definition: widget.cpp:970
NWidgetResizeBase::uz_min_y
uint uz_min_y
Unscaled Minimal vertical size of only this widget.
Definition: widget_type.h:273
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:715
MAT_ROW_START
@ MAT_ROW_START
Lowest bit of the number of rows.
Definition: widget_type.h:29
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:257
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:995
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:818
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1905
StringAlignment
StringAlignment
How to align the to-be drawn text.
Definition: gfx_type.h:334
NWidgetMatrix::count
int count
Amount of valid widgets.
Definition: widget_type.h:557
NWidgetPart::xy
Point xy
Part with an x/y size.
Definition: widget_type.h:976
NWidgetSpacer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1827
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:425
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
NWidgetBase::FillNestedArray
virtual void FillNestedArray(NWidgetBase **array, uint length)=0
NWidgetCore::tool_tip
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:339
NWidgetContainer::GetWidgetOfType
NWidgetBase * GetWidgetOfType(WidgetType tp) override
Retrieve a widget by its type.
Definition: widget.cpp:1239
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:372
strings_type.h
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2353
NWidgetLeaf::shadebox_dimension
static Dimension shadebox_dimension
Cached size of a shadebox widget.
Definition: widget_type.h:833
NWidgetBase::SetPadding
void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Set additional space (padding) around the widget.
Definition: widget_type.h:150
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:76
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:194
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:634
NCB_BIGFIRST
@ NCB_BIGFIRST
Allocate space to biggest resize first.
Definition: widget_type.h:464
MakeNWidgets
NWidgetContainer * MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:3250
NWidgetMatrix::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1910
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:973
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1655
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1109
NWidgetPIPContainer::uz_pip_inter
uint8 uz_pip_inter
Unscaled space between widgets.
Definition: widget_type.h:490
NWidgetMatrix::sb
Scrollbar * sb
The scrollbar we're associated with.
Definition: widget_type.h:558
MAT_COL_START
@ MAT_COL_START
Lowest bit of the number of columns.
Definition: widget_type.h:25
NWidgetCore::widget_data
uint32 widget_data
Data of the widget.
Definition: widget_type.h:338
SETBITS
#define SETBITS(x, y)
Sets several bits in a variable.
Definition: bitmath_func.hpp:136
alloc_type.hpp
NWidgetBase::Draw
virtual void Draw(const Window *w)=0
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1881
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:203
NWidgetStacked::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1370
NWidgetLeaf::InvalidateDimensionCache
static void InvalidateDimensionCache()
Reset the cached dimensions.
Definition: widget.cpp:2544
NWidgetResizeBase::NWidgetResizeBase
NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y)
Constructor for resizable nested widgets.
Definition: widget.cpp:1060
RectPadding
Padding dimensions to apply to each side of a Rect.
Definition: geometry_type.hpp:47
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:467
ND_DROPDOWN_ACTIVE
@ ND_DROPDOWN_ACTIVE
Bit value of the 'dropdown active' flag.
Definition: widget_type.h:303
Scrollbar::UpdatePosition
bool UpdatePosition(int difference, ScrollbarStepping unit=SS_SMALL)
Updates the position of the first visible element by the given amount.
Definition: widget_type.h:761
bitmath_func.hpp
AWV_LEFT
@ AWV_LEFT
Force the arrow to the left.
Definition: widget_type.h:37
NWidgetResizeBase::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1136
WPT_FILL
@ WPT_FILL
Widget part for specifying fill.
Definition: widget_type.h:88
NDB_HIGHLIGHT
@ NDB_HIGHLIGHT
Highlight of widget is on.
Definition: widget_type.h:295
NWidgetLeaf::NWidgetLeaf
NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip)
Nested leaf widget.
Definition: widget.cpp:2571
NWidgetBackground::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:2208
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:103
NWidgetLeaf::dropdown_dimension
static Dimension dropdown_dimension
Cached size of a dropdown widget.
Definition: widget_type.h:829
ST_SMALLEST
@ ST_SMALLEST
Initialize nested widget tree to smallest size. Also updates current_x and current_y.
Definition: widget_type.h:112
NWidgetPartPIP
Widget part for storing pre/inter/post spaces.
Definition: widget_type.h:931
ND_HIGHLIGHT
@ ND_HIGHLIGHT
Bit value of the highlight flag.
Definition: widget_type.h:299
NWidgetViewport::UpdateViewportCoordinates
void UpdateViewportCoordinates(Window *w)
Update the position and size of the viewport (after eg a resize).
Definition: widget.cpp:2331
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:658
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:207
NWidgetContainer::tail
NWidgetBase * tail
Pointer to last widget in container.
Definition: widget_type.h:419
NWID_VIEWPORT
@ NWID_VIEWPORT
Nested widget containing a viewport.
Definition: widget_type.h:79
NWidgetViewport::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2286
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:185
NWidgetResizeBase::SetResize
void SetResize(uint resize_x, uint resize_y)
Set resize step of the widget.
Definition: widget.cpp:1130
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:193
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
NWidgetLeaf::debugbox_dimension
static Dimension debugbox_dimension
Cached size of a debugbox widget.
Definition: widget_type.h:834
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:188
NWidgetBase::GetWidgetOfType
virtual NWidgetBase * GetWidgetOfType(WidgetType tp)
Retrieve a widget by its type.
Definition: widget.cpp:1044
WPT_PIPSPACE
@ WPT_PIPSPACE
Widget part for specifying pre/inter/post space for containers.
Definition: widget_type.h:91
ZeroedMemoryAllocator
Base class that provides memory initialization on dynamically created objects.
Definition: alloc_type.hpp:85
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
NWidgetBackground::GetWidgetOfType
NWidgetBase * GetWidgetOfType(WidgetType tp) override
Retrieve a widget by its type.
Definition: widget.cpp:2273
Scrollbar::IsVertical
bool IsVertical() const
Is the scrollbar vertical or not?
Definition: widget_type.h:695
NWidgetMatrix::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1971
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:399
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1127
Scrollbar::UpdateListPositionOnKeyPress
EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const
Update the given list position as if it were on this scroll bar when the given keycode was pressed.
Definition: widget.cpp:2374
NWidgetPart::widget
NWidgetPartWidget widget
Part with a start of a widget.
Definition: widget_type.h:978
NWidgetPartWidget::index
int16 index
Widget index in the widget array.
Definition: widget_type.h:917
WPT_SCROLLBAR
@ WPT_SCROLLBAR
Widget part for attaching a scrollbar.
Definition: widget_type.h:96
MAT_COL_BITS
@ MAT_COL_BITS
Number of bits for the number of columns in the matrix.
Definition: widget_type.h:26
NWidgetPIPContainer::pip_pre
uint8 pip_pre
Amount of space before first widget.
Definition: widget_type.h:485
NWidgetResizeBase::uz_text_size
FontSize uz_text_size
'Unscaled' font size, stored for resize calculation.
Definition: widget_type.h:277
NWidgetDisplay
NWidgetDisplay
Nested widget flags that affect display and interaction with 'real' widgets.
Definition: widget_type.h:281
NWidgetBackground::SetPIP
void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post)
Set additional pre/inter/post space for the background widget.
Definition: widget.cpp:2127
NWidgetLeaf::defsizebox_dimension
static Dimension defsizebox_dimension
Cached size of a defsizebox widget.
Definition: widget_type.h:835
ND_LOWERED
@ ND_LOWERED
Bit value of the lowered flag.
Definition: widget_type.h:297
NWidgetPartTextLines
Widget part for storing minimal text line data.
Definition: widget_type.h:939
WWT_LAST
@ WWT_LAST
Last Item. use WIDGETS_END to fill up padding!!
Definition: widget_type.h:70
WPT_ALIGNMENT
@ WPT_ALIGNMENT
Widget part for specifying text/image alignment.
Definition: widget_type.h:93
NWidgetContainer::NWidgetContainer
NWidgetContainer(WidgetType tp)
Constructor container baseclass.
Definition: widget.cpp:1223
ND_DISABLED
@ ND_DISABLED
Bit value of the disabled flag.
Definition: widget_type.h:298
Scrollbar::SS_RAW
@ SS_RAW
Step in single units.
Definition: widget_type.h:645
NWidgetPart::func_ptr
NWidgetFunctionType * func_ptr
Part with a function call.
Definition: widget_type.h:984
NDB_SCROLLBAR_UP
@ NDB_SCROLLBAR_UP
Up-button is lowered bit.
Definition: widget_type.h:292
Scrollbar::count
uint16 count
Number of elements in the list.
Definition: widget_type.h:637
NWidgetPart::padding
NWidgetPartPaddings padding
Part with paddings.
Definition: widget_type.h:979
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
WPT_MINSIZE
@ WPT_MINSIZE
Widget part for specifying minimal size.
Definition: widget_type.h:86
NWidgetCore::IsLowered
bool IsLowered() const
Return whether the widget is lowered.
Definition: widget_type.h:378
NWidgetPartWidget
Widget part for storing basic widget information.
Definition: widget_type.h:915
NWidgetHorizontal::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1470
NWidgetPartTextLines::spacing
uint8 spacing
Extra spacing around lines.
Definition: widget_type.h:941
NDB_NO_TRANSPARENCY
@ NDB_NO_TRANSPARENCY
Viewport is never transparent.
Definition: widget_type.h:286
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
NWidgetStacked::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1391
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:418
NWidgetMatrix::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:554
NWidgetPartDataTip
Widget part for storing data and tooltip information.
Definition: widget_type.h:906
NWidgetHorizontal::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1537
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1409
NWidgetPIPContainer::uz_pip_pre
uint8 uz_pip_pre
Unscaled space before first widget.
Definition: widget_type.h:489
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:197
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:441
NWidgetScrollbar::vertical_dimension
static Dimension vertical_dimension
Cached size of vertical scrollbar button.
Definition: widget_type.h:810
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:202
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition: widget_type.h:44
NWidgetResizeBase::SetFill
void SetFill(uint fill_x, uint fill_y)
Set the filling of the widget from initial size.
Definition: widget.cpp:1119
WWT_TEXTBTN_2
@ WWT_TEXTBTN_2
(Toggle) Button with diff text when clicked
Definition: widget_type.h:54
NWidgetSpacer::SetDirty
void SetDirty(const Window *w) const override
Mark the widget as 'dirty' (in need of repaint).
Definition: widget.cpp:1836
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
WPT_MINTEXTLINES
@ WPT_MINTEXTLINES
Widget part for specifying minimal number of lines of text.
Definition: widget_type.h:87
NWidgetContainer::IsEmpty
bool IsEmpty()
Return whether the container is empty.
Definition: widget_type.h:413
Scrollbar::cap
uint16 cap
Number of visible elements of the scroll bar.
Definition: widget_type.h:638
NWidgetBase::GetWidgetFromPos
virtual NWidgetCore * GetWidgetFromPos(int x, int y)=0
Scrollbar::SetCapacity
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:731
NWidgetSpacer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1821
NWidgetBase::SetPadding
void SetPadding(const RectPadding &padding)
Set additional space (padding) around the widget.
Definition: widget_type.h:163
NWidgetBackground::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:2263
NWidgetMatrix::GetScrollOffsets
void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y)
Get the different offsets that are influenced by scrolling.
Definition: widget.cpp:2058
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
NWidgetSpacer::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1831
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:187
NWidgetPart::cont_flags
NWidContainerFlags cont_flags
Part with container flags.
Definition: widget_type.h:985
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1094
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
NWidgetCore::disp_flags
NWidgetDisplay disp_flags
Flags that affect display and interaction with the widget.
Definition: widget_type.h:335
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:199
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:498
ST_RESIZE
@ ST_RESIZE
Resize the nested widget tree.
Definition: widget_type.h:113
NWidgetBackground::NWidgetBackground
NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child=nullptr)
Constructor parent nested widgets.
Definition: widget.cpp:2089
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
NWidgetMatrix::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1965
NWidgetResizeBase::uz_text_spacing
uint8 uz_text_spacing
'Unscaled' text padding, stored for resize calculation.
Definition: widget_type.h:276
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
NWidgetPIPContainer
Container with pre/inter/post child space.
Definition: widget_type.h:473
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1227
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:186
NWidgetScrollbar
Nested widget to display and control a scrollbar in a window.
Definition: widget_type.h:798
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:686
NWidgetBackground::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2226
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1012
WPT_RESIZE
@ WPT_RESIZE
Widget part for specifying resizing.
Definition: widget_type.h:85
NWidgetViewport::InitializeViewport
void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom)
Initialize the viewport of the window.
Definition: widget.cpp:2322
NWidgetPIPContainer::flags
NWidContainerFlags flags
Flags of the container.
Definition: widget_type.h:484
NWidgetPartTextColour::colour
TextColour colour
TextColour for DrawString.
Definition: widget_type.h:950
NDB_SHADE_GREY
@ NDB_SHADE_GREY
Shade viewport to grey-scale.
Definition: widget_type.h:287
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
NWidgetPIPContainer::pip_post
uint8 pip_post
Amount of space after last widget.
Definition: widget_type.h:487
NWidgetStacked::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1306
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:189
WPT_TEXTCOLOUR
@ WPT_TEXTCOLOUR
Widget part for specifying text colour.
Definition: widget_type.h:92
NWidgetBase::StoreSizePosition
void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
Store size and position.
Definition: widget_type.h:238
NWidgetPartAlignment
Widget part for setting text/image alignment within a widget.
Definition: widget_type.h:957
EventState
EventState
State of handling an event.
Definition: window_type.h:719
NWidgetVertical
Vertical container.
Definition: widget_type.h:521
NWidgetBackground::child
NWidgetPIPContainer * child
Child widget.
Definition: widget_type.h:608
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:676
NWidgetPart::data_tip
NWidgetPartDataTip data_tip
Part with a data/tooltip.
Definition: widget_type.h:977
NWidgetContainer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1278
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:479
NWidgetCore::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:336
NWidgetMatrix::widget_h
int widget_h
The height of the child widget including inter spacing.
Definition: widget_type.h:561
NWidgetCore::highlight_colour
TextColour highlight_colour
Colour of highlight.
Definition: widget_type.h:341
NCB_EQUALSIZE
@ NCB_EQUALSIZE
Containers should keep all their (resizing) children equally large.
Definition: widget_type.h:463
NWidgetResizeBase::uz_text_lines
uint8 uz_text_lines
'Unscaled' text lines, stored for resize calculation.
Definition: widget_type.h:275
Scrollbar::stepsize
uint16 stepsize
Distance to scroll, when pressing the buttons or using the wheel.
Definition: widget_type.h:640
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WWT_INSET
@ WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition: widget_type.h:49
SetAlignment
static NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1062
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:403
NC_NONE
@ NC_NONE
All flags cleared.
Definition: widget_type.h:466
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
NWidgetCore::scrollbar_index
int scrollbar_index
Index of an attached scrollbar.
Definition: widget_type.h:340
NWidgetBase::SetDirty
virtual void SetDirty(const Window *w) const
Mark the widget as 'dirty' (in need of repaint).
Definition: widget.cpp:1024
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2427
StackedZeroSizePlanes
StackedZeroSizePlanes
Display planes with zero size for NWidgetStacked.
Definition: widget_type.h:423
NWidgetHorizontalLTR::NWidgetHorizontalLTR
NWidgetHorizontalLTR(NWidContainerFlags flags=NC_NONE)
Horizontal left-to-right container widget.
Definition: widget.cpp:1640
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1189
NWidgetPartTextColour
Widget part for storing text colour.
Definition: widget_type.h:949
NWidgetHorizontalLTR::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1645
NWidgetResizeBase::min_x
uint min_x
Minimal horizontal size of only this widget.
Definition: widget_type.h:268
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:200
ND_SCROLLBAR_UP
@ ND_SCROLLBAR_UP
Bit value of the 'scrollbar up' flag.
Definition: widget_type.h:304
NWidgetCore::align
StringAlignment align
Alignment of text/image within widget.
Definition: widget_type.h:343
Scrollbar::SS_BIG
@ SS_BIG
Step in cap units.
Definition: widget_type.h:647
Scrollbar::SetStepSize
void SetStepSize(uint16 stepsize)
Set the distance to scroll when using the buttons or the wheel.
Definition: widget_type.h:704
NWidgetScrollbar::NWidgetScrollbar
NWidgetScrollbar(WidgetType tp, Colours colour, int index)
Scrollbar widget.
Definition: widget.cpp:2443
ND_SHADE_GREY
@ ND_SHADE_GREY
Bit value of the 'shade to grey' flag.
Definition: widget_type.h:301
WPT_PADDING
@ WPT_PADDING
Widget part for specifying a padding.
Definition: widget_type.h:90
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1078
NWidgetCore::text_colour
TextColour text_colour
Colour of text within widget.
Definition: widget_type.h:342
NWidgetPart::type
WidgetType type
Type of the part.
Definition: widget_type.h:974
NWidgetResizeBase::min_y
uint min_y
Minimal vertical size of only this widget.
Definition: widget_type.h:269
NWidgetHorizontalLTR
Horizontal container that doesn't change the direction of the widgets for RTL languages.
Definition: widget_type.h:510
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:206
NWidgetMatrix::widget_w
int widget_w
The width of the child widget including inter spacing.
Definition: widget_type.h:560
NWidgetBackground::Add
void Add(NWidgetBase *nwid)
Add a child to the parent.
Definition: widget.cpp:2109
SetTextColour
static NWidgetPart SetTextColour(TextColour colour)
Widget part function for setting the text colour.
Definition: widget_type.h:1047
MAT_ROW_BITS
@ MAT_ROW_BITS
Number of bits for the number of rows in the matrix.
Definition: widget_type.h:30
Window
Data structure for an opened window.
Definition: window_gui.h:213
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:111
NWidContainerFlags
NWidContainerFlags
Nested widget container flags,.
Definition: widget_type.h:462
SZSP_VERTICAL
@ SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:424
NWidgetResizeBase::absolute
bool absolute
Set if minimum size is fixed and should not be resized.
Definition: widget_type.h:271
MatrixWidgetValues
MatrixWidgetValues
Bits of the WWT_MATRIX widget data.
Definition: widget_type.h:23
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:589
NDB_DISABLED
@ NDB_DISABLED
Widget is disabled (greyed out) bit.
Definition: widget_type.h:284
NWidgetVertical::NWidgetVertical
NWidgetVertical(NWidContainerFlags flags=NC_NONE)
Vertical container widget.
Definition: widget.cpp:1651
NWidgetViewport::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2296
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
NWidgetCore::index
int index
Index of the nested widget in the widget array of the window (-1 means 'not used').
Definition: widget_type.h:337
NWidgetMatrix::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:555
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:314
SetupWidgetDimensions
void SetupWidgetDimensions()
Set up pre-scaled versions of Widget Dimensions.
Definition: widget.cpp:199
NWidgetLeaf::closebox_dimension
static Dimension closebox_dimension
Cached size of a closebox widget.
Definition: widget_type.h:831
AWV_RIGHT
@ AWV_RIGHT
Force the arrow to the right.
Definition: widget_type.h:38
WWT_DEBUGBOX
@ WWT_DEBUGBOX
NewGRF debug box (at top-right of a window, between WWT_CAPTION and WWT_SHADEBOX)
Definition: widget_type.h:61
gfx_type.h
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
NWidgetPartDataTip::tooltip
StringID tooltip
Tooltip of the widget.
Definition: widget_type.h:908
WPT_FUNCTION
@ WPT_FUNCTION
Widget part for calling a user function.
Definition: widget_type.h:95
NWidgetLeaf::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2838
NWidgetVertical::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1722
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:188
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
NWidgetPartWidget::colour
Colours colour
Widget colour.
Definition: widget_type.h:916
NWidgetPartTextLines::size
FontSize size
Font size of text lines.
Definition: widget_type.h:942
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:196
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:457
NWidgetMatrix::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1941
MakeCompanyButtonRows
NWidgetBase * MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip)
Make a number of rows with button-like graphics, for enabling/disabling each company.
Definition: widget.cpp:3323
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:1080
NWidgetScrollbar::horizontal_dimension
static Dimension horizontal_dimension
Cached size of horizontal scrollbar button.
Definition: widget_type.h:811
NWidgetLeaf::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2663
NWidgetResizeBase::SetMinimalSizeAbsolute
void SetMinimalSizeAbsolute(uint min_x, uint min_y)
Set absolute (post-scaling) minimal size of the widget.
Definition: widget.cpp:1093
NWidgetScrollbar::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2490
NWidgetLeaf::ButtonHit
bool ButtonHit(const Point &pt)
For a NWID_BUTTON_DROPDOWN, test whether pt refers to the button or to the drop-down.
Definition: widget.cpp:2976
MakeWindowNWidgetTree
NWidgetContainer * MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select)
Make a nested widget tree for a window from a parts array.
Definition: widget.cpp:3272
NWidgetHorizontal::NWidgetHorizontal
NWidgetHorizontal(NWidContainerFlags flags=NC_NONE)
Horizontal container widget.
Definition: widget.cpp:1466
NWidgetBackground::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:2220
NWidgetCore::SetDisabled
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:387
NWidgetBase::padding
RectPadding padding
Padding added to the widget. Managed by parent container widget. (parent container may swap left and ...
Definition: widget_type.h:205
ND_SCROLLBAR_BTN
@ ND_SCROLLBAR_BTN
Bit value of the 'scrollbar up' or 'scrollbar down' flag.
Definition: widget_type.h:306
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
NWID_BUTTON_DROPDOWN
@ NWID_BUTTON_DROPDOWN
Button with a drop-down.
Definition: widget_type.h:80
Scrollbar::SetPosition
bool SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:747
NWidgetPartDataTip::data
uint32 data
Data value of the widget.
Definition: widget_type.h:907
NWidgetMatrix::widgets_x
int widgets_x
The number of visible widgets in horizontal direction.
Definition: widget_type.h:562
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1030
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
ND_NO_TRANSPARENCY
@ ND_NO_TRANSPARENCY
Bit value of the 'no transparency' flag.
Definition: widget_type.h:300
NC_BIGFIRST
@ NC_BIGFIRST
Value of the NCB_BIGFIRST flag.
Definition: widget_type.h:468
NWidgetPart::text_lines
NWidgetPartTextLines text_lines
Part with text line data.
Definition: widget_type.h:981
NDB_DROPDOWN_ACTIVE
@ NDB_DROPDOWN_ACTIVE
Dropdown menu of the button dropdown widget is active.
Definition: widget_type.h:290
NWidgetPartAlignment::align
StringAlignment align
Alignment of text/image.
Definition: widget_type.h:958
NWidgetBase::SetupSmallestSize
virtual void SetupSmallestSize(Window *w, bool init_array)=0
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
NWidgetFunctionType
NWidgetBase * NWidgetFunctionType(int *biggest_index)
Pointer to function returning a nested widget.
Definition: widget_type.h:967
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1864
WPT_ENDCONTAINER
@ WPT_ENDCONTAINER
Widget part to denote end of a container.
Definition: widget_type.h:94