OpenTTD Source  1.11.2
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. */
95 
96  /* Pushable window widget types. */
97  WWT_MASK = 0x7F,
98 
99  WWB_PUSHBUTTON = 1 << 7,
100 
101  WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON,
102  WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON,
103  WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON,
104  WWT_PUSHARROWBTN = WWT_ARROWBTN | WWB_PUSHBUTTON,
105  NWID_PUSHBUTTON_DROPDOWN = NWID_BUTTON_DROPDOWN | WWB_PUSHBUTTON,
106 };
107 
112 };
113 
114 /* Forward declarations. */
115 class NWidgetCore;
116 class Scrollbar;
117 
125 public:
127 
128  virtual void SetupSmallestSize(Window *w, bool init_array) = 0;
129  virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0;
130 
131  virtual void FillNestedArray(NWidgetBase **array, uint length) = 0;
132 
133  virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
135 
136  virtual bool IsHighlighted() const { return false; }
137  virtual TextColour GetHighlightColour() const { return TC_INVALID; }
138  virtual void SetHighlighted(TextColour highlight_colour) {}
139 
147  inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
148  {
149  this->padding_top = top;
150  this->padding_right = right;
151  this->padding_bottom = bottom;
152  this->padding_left = left;
153  }
154 
155  inline uint GetHorizontalStepSize(SizingType sizing) const;
156  inline uint GetVerticalStepSize(SizingType sizing) const;
157 
158  virtual void Draw(const Window *w) = 0;
159  virtual void SetDirty(const Window *w) const;
160 
161  Rect GetCurrentRect() const
162  {
163  Rect r;
164  r.left = this->pos_x;
165  r.top = this->pos_y;
166  r.right = this->pos_x + this->current_x;
167  r.bottom = this->pos_y + this->current_y;
168  return r;
169  }
170 
172  uint fill_x;
173  uint fill_y;
174  uint resize_x;
175  uint resize_y;
176  /* Size of the widget in the smallest window possible.
177  * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
178  */
179  uint smallest_x;
180  uint smallest_y;
181  /* Current widget size (that is, after resizing). */
182  uint current_x;
183  uint current_y;
184 
185  int pos_x;
186  int pos_y;
187 
190 
191  uint8 padding_top;
194  uint8 padding_left;
195 
196 protected:
197  inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
198 };
199 
205 {
206  return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
207 }
208 
214 {
215  return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
216 }
217 
226 inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
227 {
228  this->pos_x = x;
229  this->pos_y = y;
230  if (sizing == ST_SMALLEST) {
231  this->smallest_x = given_width;
232  this->smallest_y = given_height;
233  }
234  this->current_x = given_width;
235  this->current_y = given_height;
236 }
237 
238 
244 public:
245  NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
246 
247  void SetMinimalSize(uint min_x, uint min_y);
248  void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
249  void SetFill(uint fill_x, uint fill_y);
250  void SetResize(uint resize_x, uint resize_y);
251 
252  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
253 
254  uint min_x;
255  uint min_y;
256 };
257 
260  /* Generic. */
263  /* Viewport widget. */
267  /* Button dropdown widget. */
269  /* Scrollbar widget. */
272  /* Generic. */
274 
285 };
287 
288 
293 public:
294  NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
295 
296  void SetIndex(int index);
297  void SetDataTip(uint32 widget_data, StringID tool_tip);
298  void SetToolTip(StringID tool_tip);
299 
300  inline void SetLowered(bool lowered);
301  inline bool IsLowered() const;
302  inline void SetDisabled(bool disabled);
303  inline bool IsDisabled() const;
304 
305  void FillNestedArray(NWidgetBase **array, uint length) override;
306  NWidgetCore *GetWidgetFromPos(int x, int y) override;
307  bool IsHighlighted() const override;
308  TextColour GetHighlightColour() const override;
309  void SetHighlighted(TextColour highlight_colour) override;
310 
312  Colours colour;
313  int index;
314  uint32 widget_data;
318 };
319 
324 inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
325 {
326  this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
327  this->highlight_colour = highlight_colour;
328 }
329 
331 inline bool NWidgetCore::IsHighlighted() const
332 {
333  return HasBit(this->disp_flags, NDB_HIGHLIGHT);
334 }
335 
338 {
339  return this->highlight_colour;
340 }
341 
346 inline void NWidgetCore::SetLowered(bool lowered)
347 {
348  this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
349 }
350 
352 inline bool NWidgetCore::IsLowered() const
353 {
354  return HasBit(this->disp_flags, NDB_LOWERED);
355 }
356 
361 inline void NWidgetCore::SetDisabled(bool disabled)
362 {
363  this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
364 }
365 
367 inline bool NWidgetCore::IsDisabled() const
368 {
369  return HasBit(this->disp_flags, NDB_DISABLED);
370 }
371 
372 
378 public:
380  ~NWidgetContainer();
381 
382  void Add(NWidgetBase *wid);
383  void FillNestedArray(NWidgetBase **array, uint length) override;
384 
386  inline bool IsEmpty() { return head == nullptr; }
387 
388  NWidgetBase *GetWidgetOfType(WidgetType tp) override;
389 
390 protected:
393 };
394 
397  SZSP_VERTICAL = INT_MAX / 2,
400 
402 };
403 
415 public:
416  NWidgetStacked();
417 
418  void SetIndex(int index);
419 
420  void SetupSmallestSize(Window *w, bool init_array) override;
421  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
422  void FillNestedArray(NWidgetBase **array, uint length) override;
423 
424  void Draw(const Window *w) override;
425  NWidgetCore *GetWidgetFromPos(int x, int y) override;
426 
427  void SetDisplayedPlane(int plane);
428 
430  int index;
431 };
432 
436 
437  NC_NONE = 0,
439 };
441 
442 
444 public:
446 
447  void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
448 
449  void Draw(const Window *w) override;
450  NWidgetCore *GetWidgetFromPos(int x, int y) override;
451 
452 protected:
454  uint8 pip_pre;
455  uint8 pip_inter;
456  uint8 pip_post;
457 };
458 
464 public:
466 
467  void SetupSmallestSize(Window *w, bool init_array);
468  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
469 };
470 
476 public:
478 
479  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
480 };
481 
487 public:
489 
490  void SetupSmallestSize(Window *w, bool init_array);
491  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
492 };
493 
503 public:
504  NWidgetMatrix();
505 
506  void SetIndex(int index);
507  void SetColour(Colours colour);
508  void SetClicked(int clicked);
509  void SetCount(int count);
510  void SetScrollbar(Scrollbar *sb);
511 
512  void SetupSmallestSize(Window *w, bool init_array) override;
513  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
514  void FillNestedArray(NWidgetBase **array, uint length) override;
515 
516  NWidgetCore *GetWidgetFromPos(int x, int y) override;
517  void Draw(const Window *w) override;
518 protected:
519  int index;
520  Colours colour;
521  int clicked;
522  int count;
524 private:
525  int widget_w;
526  int widget_h;
527  int widgets_x;
528  int widgets_y;
529 
530  void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
531 };
532 
533 
539 public:
540  NWidgetSpacer(int length, int height);
541 
542  void SetupSmallestSize(Window *w, bool init_array) override;
543  void FillNestedArray(NWidgetBase **array, uint length) override;
544 
545  void Draw(const Window *w) override;
546  void SetDirty(const Window *w) const override;
547  NWidgetCore *GetWidgetFromPos(int x, int y) override;
548 };
549 
555 public:
556  NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr);
558 
559  void Add(NWidgetBase *nwid);
560  void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
561 
562  void SetupSmallestSize(Window *w, bool init_array) override;
563  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
564 
565  void FillNestedArray(NWidgetBase **array, uint length) override;
566 
567  void Draw(const Window *w) override;
568  NWidgetCore *GetWidgetFromPos(int x, int y) override;
569  NWidgetBase *GetWidgetOfType(WidgetType tp) override;
570 
571 private:
573 };
574 
584 class NWidgetViewport : public NWidgetCore {
585 public:
586  NWidgetViewport(int index);
587 
588  void SetupSmallestSize(Window *w, bool init_array) override;
589  void Draw(const Window *w) override;
590 
591  void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
593 };
594 
598 class Scrollbar {
599 private:
600  const bool is_vertical;
601  uint16 count;
602  uint16 cap;
603  uint16 pos;
604  uint16 stepsize;
605 
606 public:
612  };
613 
615  {
616  }
617 
622  inline uint16 GetCount() const
623  {
624  return this->count;
625  }
626 
631  inline uint16 GetCapacity() const
632  {
633  return this->cap;
634  }
635 
640  inline uint16 GetPosition() const
641  {
642  return this->pos;
643  }
644 
650  inline bool IsVisible(uint16 item) const
651  {
652  return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
653  }
654 
659  inline bool IsVertical() const
660  {
661  return this->is_vertical;
662  }
663 
668  void SetStepSize(uint16 stepsize)
669  {
670  assert(stepsize > 0);
671  this->stepsize = stepsize;
672  }
673 
679  void SetCount(int num)
680  {
681  assert(num >= 0);
682  assert(num <= MAX_UVALUE(uint16));
683 
684  this->count = num;
685  num -= this->cap;
686  if (num < 0) num = 0;
687  if (num < this->pos) this->pos = num;
688  }
689 
695  void SetCapacity(int capacity)
696  {
697  assert(capacity > 0);
698  assert(capacity <= MAX_UVALUE(uint16));
699 
700  this->cap = capacity;
701  if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
702  }
703 
704  void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
705 
710  void SetPosition(int position)
711  {
712  assert(position >= 0);
713  assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
714  this->pos = position;
715  }
716 
723  void UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
724  {
725  if (difference == 0) return;
726  switch (unit) {
727  case SS_SMALL: difference *= this->stepsize; break;
728  case SS_BIG: difference *= this->cap; break;
729  default: break;
730  }
731  this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
732  }
733 
740  void ScrollTowards(int position)
741  {
742  if (position < this->GetPosition()) {
743  /* scroll up to the item */
744  this->SetPosition(position);
745  } else if (position >= this->GetPosition() + this->GetCapacity()) {
746  /* scroll down so that the item is at the bottom */
747  this->SetPosition(position - this->GetCapacity() + 1);
748  }
749  }
750 
751  int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const;
752 };
753 
759 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
760 public:
761  NWidgetScrollbar(WidgetType tp, Colours colour, int index);
762 
763  void SetupSmallestSize(Window *w, bool init_array) override;
764  void Draw(const Window *w) override;
765 
766  static void InvalidateDimensionCache();
767  static Dimension GetVerticalDimension();
768  static Dimension GetHorizontalDimension();
769 
770 private:
773 };
774 
779 class NWidgetLeaf : public NWidgetCore {
780 public:
781  NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
782 
783  void SetupSmallestSize(Window *w, bool init_array) override;
784  void Draw(const Window *w) override;
785 
786  bool ButtonHit(const Point &pt);
787 
788  static void InvalidateDimensionCache();
789 
793 private:
798 };
799 
807 static inline uint ComputeMaxSize(uint base, uint max_space, uint step)
808 {
809  if (base >= max_space || step == 0) return base;
810  if (step == 1) return max_space;
811  uint increment = max_space - base;
812  increment -= increment % step;
813  return base + increment;
814 }
815 
868  uint32 data;
870 };
871 
877  Colours colour;
878  int16 index;
879 };
880 
886  uint8 top, right, bottom, left;
887 };
888 
894  uint8 pre, inter, post;
895 };
896 
902  uint8 lines;
903  uint8 spacing;
905 };
906 
913 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
914 
919 struct NWidgetPart {
921  union {
930  } u;
931 };
932 
939 static inline NWidgetPart SetResize(int16 dx, int16 dy)
940 {
941  NWidgetPart part;
942 
943  part.type = WPT_RESIZE;
944  part.u.xy.x = dx;
945  part.u.xy.y = dy;
946 
947  return part;
948 }
949 
956 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
957 {
958  NWidgetPart part;
959 
960  part.type = WPT_MINSIZE;
961  part.u.xy.x = x;
962  part.u.xy.y = y;
963 
964  return part;
965 }
966 
974 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
975 {
976  NWidgetPart part;
977 
978  part.type = WPT_MINTEXTLINES;
979  part.u.text_lines.lines = lines;
980  part.u.text_lines.spacing = spacing;
981  part.u.text_lines.size = size;
982 
983  return part;
984 }
985 
992 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
993 {
994  NWidgetPart part;
995 
996  part.type = WPT_FILL;
997  part.u.xy.x = fill_x;
998  part.u.xy.y = fill_y;
999 
1000  return part;
1001 }
1002 
1008 static inline NWidgetPart EndContainer()
1009 {
1010  NWidgetPart part;
1011 
1012  part.type = WPT_ENDCONTAINER;
1013 
1014  return part;
1015 }
1016 
1023 static inline NWidgetPart SetDataTip(uint32 data, StringID tip)
1024 {
1025  NWidgetPart part;
1026 
1027  part.type = WPT_DATATIP;
1028  part.u.data_tip.data = data;
1029  part.u.data_tip.tooltip = tip;
1030 
1031  return part;
1032 }
1033 
1041 static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
1042 {
1043  return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip);
1044 }
1045 
1055 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
1056 {
1057  NWidgetPart part;
1058 
1059  part.type = WPT_PADDING;
1060  part.u.padding.top = top;
1061  part.u.padding.right = right;
1062  part.u.padding.bottom = bottom;
1063  part.u.padding.left = left;
1064 
1065  return part;
1066 }
1067 
1073 static inline NWidgetPart SetPadding(uint8 padding)
1074 {
1075  return SetPadding(padding, padding, padding, padding);
1076 }
1077 
1085 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
1086 {
1087  NWidgetPart part;
1088 
1089  part.type = WPT_PIPSPACE;
1090  part.u.pip.pre = pre;
1091  part.u.pip.inter = inter;
1092  part.u.pip.post = post;
1093 
1094  return part;
1095 }
1096 
1104 static inline NWidgetPart SetScrollbar(int index)
1105 {
1106  NWidgetPart part;
1107 
1108  part.type = WPT_SCROLLBAR;
1109  part.u.widget.index = index;
1110 
1111  return part;
1112 }
1113 
1123 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
1124 {
1125  NWidgetPart part;
1126 
1127  part.type = tp;
1128  part.u.widget.colour = col;
1129  part.u.widget.index = idx;
1130 
1131  return part;
1132 }
1133 
1141 {
1142  NWidgetPart part;
1143 
1144  part.type = tp;
1145  part.u.cont_flags = cont_flags;
1146 
1147  return part;
1148 }
1149 
1156 {
1157  NWidgetPart part;
1158 
1159  part.type = WPT_FUNCTION;
1160  part.u.func_ptr = func_ptr;
1161 
1162  return part;
1163 }
1164 
1165 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
1166 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
1167 
1168 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);
1169 
1170 #endif /* WIDGET_TYPE_H */
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:399
NWidgetBackground::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1768
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:243
NWidgetPartTextLines::lines
uint8 lines
Number of text lines.
Definition: widget_type.h:902
NWidgetMatrix::clicked
int clicked
The currently clicked widget.
Definition: widget_type.h:521
NWidgetScrollbar::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2008
NWidgetStacked::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1032
NWidgetMatrix::widgets_y
int widgets_y
The number of visible widgets in vertical direction.
Definition: widget_type.h:528
NDB_LOWERED
@ NDB_LOWERED
Widget is lowered (pressed down) bit.
Definition: widget_type.h:261
NWidgetStacked::NWidgetStacked
NWidgetStacked()
Widgets stacked on top of each other.
Definition: widget.cpp:978
NWidgetCore::IsDisabled
bool IsDisabled() const
Return whether the widget is disabled.
Definition: widget_type.h:367
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:1155
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:807
NWidgetCore::GetHighlightColour
TextColour GetHighlightColour() const override
Return the colour of the highlight.
Definition: widget_type.h:337
NWidgetCore::IsHighlighted
bool IsHighlighted() const override
Return whether the widget is highlighted.
Definition: widget_type.h:331
NWidgetPart::pip
NWidgetPartPIP pip
Part with pre/inter/post spaces.
Definition: widget_type.h:926
NWidgetSpacer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1475
Scrollbar::SS_SMALL
@ SS_SMALL
Step in stepsize units.
Definition: widget_type.h:610
NWidgetPartPIP::post
uint8 post
Amount of space before/between/after child widgets.
Definition: widget_type.h:894
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1104
NWidgetPIPContainer::pip_inter
uint8 pip_inter
Amount of space between widgets.
Definition: widget_type.h:455
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:631
NWidgetStacked::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:430
NWidgetLeaf::resizebox_dimension
static Dimension resizebox_dimension
Cached size of a resizebox widget.
Definition: widget_type.h:791
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:1055
Scrollbar::is_vertical
const bool is_vertical
Scrollbar has vertical orientation.
Definition: widget_type.h:600
NWidgetCore::SetHighlighted
void SetHighlighted(TextColour highlight_colour) override
Highlight the widget or not.
Definition: widget_type.h:324
SZSP_BEGIN
@ SZSP_BEGIN
First zero-size plane.
Definition: widget_type.h:401
NWidgetBase::GetVerticalStepSize
uint GetVerticalStepSize(SizingType sizing) const
Get the vertical sizing step.
Definition: widget_type.h:213
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:951
ND_SCROLLBAR_DOWN
@ ND_SCROLLBAR_DOWN
Bit value of the 'scrollbar down' flag.
Definition: widget_type.h:283
NWID_HSCROLLBAR
@ NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:81
Scrollbar::ScrollbarStepping
ScrollbarStepping
Stepping sizes when scrolling.
Definition: widget_type.h:608
NWidgetViewport
Nested widget to display a viewport in a window.
Definition: widget_type.h:584
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:740
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:603
NWidgetPartPaddings
Widget part for storing padding.
Definition: widget_type.h:885
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:502
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1972
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:204
ND_SHADE_DIMMED
@ ND_SHADE_DIMMED
Bit value of the 'dimmed colours' flag.
Definition: widget_type.h:280
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
math_func.hpp
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:827
NWidgetStacked::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1058
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NWidgetMatrix::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1637
NWidgetLeaf::stickybox_dimension
static Dimension stickybox_dimension
Cached size of a stickybox widget.
Definition: widget_type.h:797
NDB_SCROLLBAR_DOWN
@ NDB_SCROLLBAR_DOWN
Down-button is lowered bit.
Definition: widget_type.h:271
NDB_SHADE_DIMMED
@ NDB_SHADE_DIMMED
Display dimmed colours in the viewport.
Definition: widget_type.h:266
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:538
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:719
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:679
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:250
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:939
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:779
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1539
NWidgetMatrix::count
int count
Amount of valid widgets.
Definition: widget_type.h:522
NWidgetPart::xy
Point xy
Part with an x/y size.
Definition: widget_type.h:922
NWidgetSpacer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1461
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:398
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:104
NWidgetBase::FillNestedArray
virtual void FillNestedArray(NWidgetBase **array, uint length)=0
NWidgetCore::tool_tip
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:315
NWidgetContainer::GetWidgetOfType
NWidgetBase * GetWidgetOfType(WidgetType tp) override
Retrieve a widget by its type.
Definition: widget.cpp:937
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:346
strings_type.h
NWidgetLeaf::shadebox_dimension
static Dimension shadebox_dimension
Cached size of a shadebox widget.
Definition: widget_type.h:794
NWidgetBase::SetPadding
void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Set additional space (padding) around the widget.
Definition: widget_type.h:147
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:180
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:598
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:2805
NWidgetBase::padding_top
uint8 padding_top
Paddings added to the top of the widget. Managed by parent container widget.
Definition: widget_type.h:191
NWidgetMatrix::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1544
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:919
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1023
NWidgetMatrix::sb
Scrollbar * sb
The scrollbar we're associated with.
Definition: widget_type.h:523
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:314
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:1515
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:189
NWidgetStacked::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1052
NWidgetLeaf::InvalidateDimensionCache
static void InvalidateDimensionCache()
Reset the cached dimensions.
Definition: widget.cpp:2099
NWidgetResizeBase::NWidgetResizeBase
NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y)
Constructor for resizable nested widgets.
Definition: widget.cpp:804
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:438
ND_DROPDOWN_ACTIVE
@ ND_DROPDOWN_ACTIVE
Bit value of the 'dropdown active' flag.
Definition: widget_type.h:281
bitmath_func.hpp
AWV_LEFT
@ AWV_LEFT
Force the arrow to the left.
Definition: widget_type.h:37
WPT_FILL
@ WPT_FILL
Widget part for specifying fill.
Definition: widget_type.h:88
NWidgetBase::padding_left
uint8 padding_left
Paddings added to the left of the widget. Managed by parent container widget. (parent container may s...
Definition: widget_type.h:194
NDB_HIGHLIGHT
@ NDB_HIGHLIGHT
Highlight of widget is on.
Definition: widget_type.h:273
NWidgetLeaf::NWidgetLeaf
NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip)
Nested leaf widget.
Definition: widget.cpp:2126
NWidgetBackground::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1822
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:101
NWidgetLeaf::dropdown_dimension
static Dimension dropdown_dimension
Cached size of a dropdown widget.
Definition: widget_type.h:790
ST_SMALLEST
@ ST_SMALLEST
Initialize nested widget tree to smallest size. Also updates current_x and current_y.
Definition: widget_type.h:110
NWidgetPartPIP
Widget part for storing pre/inter/post spaces.
Definition: widget_type.h:893
ND_HIGHLIGHT
@ ND_HIGHLIGHT
Bit value of the highlight flag.
Definition: widget_type.h:277
NWidgetViewport::UpdateViewportCoordinates
void UpdateViewportCoordinates(Window *w)
Update the position and size of the viewport (after eg a resize).
Definition: widget.cpp:1949
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:622
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:392
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:1904
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:171
NWidgetResizeBase::SetResize
void SetResize(uint resize_x, uint resize_y)
Set resize step of the widget.
Definition: widget.cpp:848
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:179
NWidgetHorizontal::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1209
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array)
Definition: widget.cpp:1307
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:795
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:793
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:102
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
NWidgetBackground::GetWidgetOfType
NWidgetBase * GetWidgetOfType(WidgetType tp) override
Retrieve a widget by its type.
Definition: widget.cpp:1891
Scrollbar::IsVertical
bool IsVertical() const
Is the scrollbar vertical or not?
Definition: widget_type.h:659
NWidgetMatrix::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1605
NWidgetVertical::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1376
GetWidgetFromPos
int GetWidgetFromPos(const Window *w, int x, int y)
Returns the index for the widget located at the given position relative to the window.
Definition: widget.cpp:160
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:1041
NWidgetPart::widget
NWidgetPartWidget widget
Part with a start of a widget.
Definition: widget_type.h:924
NWidgetPartWidget::index
int16 index
Widget index in the widget array.
Definition: widget_type.h:878
WPT_SCROLLBAR
@ WPT_SCROLLBAR
Widget part for attaching a scrollbar.
Definition: widget_type.h:94
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:454
NWidgetDisplay
NWidgetDisplay
Nested widget flags that affect display and interaction with 'real' widgets.
Definition: widget_type.h:259
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:1760
NWidgetLeaf::defsizebox_dimension
static Dimension defsizebox_dimension
Cached size of a defsizebox widget.
Definition: widget_type.h:796
ND_LOWERED
@ ND_LOWERED
Bit value of the lowered flag.
Definition: widget_type.h:275
NWidgetPartTextLines
Widget part for storing minimal text line data.
Definition: widget_type.h:901
WWT_LAST
@ WWT_LAST
Last Item. use WIDGETS_END to fill up padding!!
Definition: widget_type.h:70
NWidgetContainer::NWidgetContainer
NWidgetContainer(WidgetType tp)
Constructor container baseclass.
Definition: widget.cpp:921
ND_DISABLED
@ ND_DISABLED
Bit value of the disabled flag.
Definition: widget_type.h:276
Scrollbar::SS_RAW
@ SS_RAW
Step in single units.
Definition: widget_type.h:609
NWidgetPart::func_ptr
NWidgetFunctionType * func_ptr
Part with a function call.
Definition: widget_type.h:928
NDB_SCROLLBAR_UP
@ NDB_SCROLLBAR_UP
Up-button is lowered bit.
Definition: widget_type.h:270
Scrollbar::count
uint16 count
Number of elements in the list.
Definition: widget_type.h:601
NWidgetPart::padding
NWidgetPartPaddings padding
Part with paddings.
Definition: widget_type.h:925
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:352
NWidgetPartWidget
Widget part for storing basic widget information.
Definition: widget_type.h:876
NWidgetPartTextLines::spacing
uint8 spacing
Extra spacing around lines.
Definition: widget_type.h:903
NDB_NO_TRANSPARENCY
@ NDB_NO_TRANSPARENCY
Viewport is never transparent.
Definition: widget_type.h:264
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
NWidgetStacked::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1073
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:391
NWidgetMatrix::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:519
NWidgetPartDataTip
Widget part for storing data and tooltip information.
Definition: widget_type.h:867
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1091
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:183
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:414
NWidgetScrollbar::vertical_dimension
static Dimension vertical_dimension
Cached size of vertical scrollbar button.
Definition: widget_type.h:771
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:188
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:837
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:1470
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
NWidgetHorizontal::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array)
Definition: widget.cpp:1140
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:386
Scrollbar::cap
uint16 cap
Number of visible elements of the scroll bar.
Definition: widget_type.h:602
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:695
NWidgetSpacer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1455
NWidgetBackground::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1881
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:1692
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:1465
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:103
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:173
NWidgetPart::cont_flags
NWidContainerFlags cont_flags
Part with container flags.
Definition: widget_type.h:929
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1008
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:311
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:185
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:463
ST_RESIZE
@ ST_RESIZE
Resize the nested widget tree.
Definition: widget_type.h:111
NWidgetBackground::NWidgetBackground
NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child=nullptr)
Constructor parent nested widgets.
Definition: widget.cpp:1723
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:1599
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
NWidgetPIPContainer
Container with pre/inter/post child space.
Definition: widget_type.h:443
Scrollbar::SetPosition
void SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:710
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1123
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:172
NWidgetScrollbar
Nested widget to display and control a scrollbar in a window.
Definition: widget_type.h:759
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:650
NWidgetBackground::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1840
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:956
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:1940
NWidgetPIPContainer::flags
NWidContainerFlags flags
Flags of the container.
Definition: widget_type.h:453
NDB_SHADE_GREY
@ NDB_SHADE_GREY
Shade viewport to grey-scale.
Definition: widget_type.h:265
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:456
NWidgetStacked::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:988
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:175
NWidgetBase::StoreSizePosition
void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
Store size and position.
Definition: widget_type.h:226
NWidgetVertical
Vertical container.
Definition: widget_type.h:486
NWidgetBackground::child
NWidgetPIPContainer * child
Child widget.
Definition: widget_type.h:572
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:640
NWidgetPart::data_tip
NWidgetPartDataTip data_tip
Part with a data/tooltip.
Definition: widget_type.h:923
NWidgetContainer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:968
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:465
NWidgetHorizontalLTR::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1297
NWidgetCore::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:312
NWidgetMatrix::widget_h
int widget_h
The height of the child widget including inter spacing.
Definition: widget_type.h:526
NWidgetCore::highlight_colour
TextColour highlight_colour
Colour of highlight.
Definition: widget_type.h:317
NCB_EQUALSIZE
@ NCB_EQUALSIZE
Containers should keep all their (resizing) children equally large.
Definition: widget_type.h:435
Scrollbar::stepsize
uint16 stepsize
Distance to scroll, when pressing the buttons or using the wheel.
Definition: widget_type.h:604
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
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:377
NWidgetBase::padding_right
uint8 padding_right
Paddings added to the right of the widget. Managed by parent container widget. (parent container may ...
Definition: widget_type.h:192
NC_NONE
@ NC_NONE
All flags cleared.
Definition: widget_type.h:437
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:316
NWidgetBase::SetDirty
virtual void SetDirty(const Window *w) const
Mark the widget as 'dirty' (in need of repaint).
Definition: widget.cpp:773
NWidgetSpacer::NWidgetSpacer
NWidgetSpacer(int length, int height)
Generic spacer widget.
Definition: widget.cpp:1449
NWidgetResizeBase::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:854
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:1986
StackedZeroSizePlanes
StackedZeroSizePlanes
Display planes with zero size for NWidgetStacked.
Definition: widget_type.h:396
NWidgetHorizontalLTR::NWidgetHorizontalLTR
NWidgetHorizontalLTR(NWidContainerFlags flags=NC_NONE)
Horizontal left-to-right container widget.
Definition: widget.cpp:1292
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1085
NWidgetResizeBase::min_x
uint min_x
Minimal horizontal size of only this widget.
Definition: widget_type.h:254
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:186
ND_SCROLLBAR_UP
@ ND_SCROLLBAR_UP
Bit value of the 'scrollbar up' flag.
Definition: widget_type.h:282
Scrollbar::SS_BIG
@ SS_BIG
Step in cap units.
Definition: widget_type.h:611
Scrollbar::SetStepSize
void SetStepSize(uint16 stepsize)
Set the distance to scroll when using the buttons or the wheel.
Definition: widget_type.h:668
NWidgetScrollbar::NWidgetScrollbar
NWidgetScrollbar(WidgetType tp, Colours colour, int index)
Scrollbar widget.
Definition: widget.cpp:2002
ND_SHADE_GREY
@ ND_SHADE_GREY
Bit value of the 'shade to grey' flag.
Definition: widget_type.h:279
WPT_PADDING
@ WPT_PADDING
Widget part for specifying a padding.
Definition: widget_type.h:90
Scrollbar::UpdatePosition
void UpdatePosition(int difference, ScrollbarStepping unit=SS_SMALL)
Updates the position of the first visible element by the given amount.
Definition: widget_type.h:723
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:992
NWidgetPart::type
WidgetType type
Type of the part.
Definition: widget_type.h:920
NWidgetResizeBase::min_y
uint min_y
Minimal vertical size of only this widget.
Definition: widget_type.h:255
NWidgetHorizontalLTR
Horizontal container that doesn't change the direction of the widgets for RTL languages.
Definition: widget_type.h:475
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:525
NWidgetBase::padding_bottom
uint8 padding_bottom
Paddings added to the bottom of the widget. Managed by parent container widget.
Definition: widget_type.h:193
NWidgetBackground::Add
void Add(NWidgetBase *nwid)
Add a child to the parent.
Definition: widget.cpp:1742
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:277
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:109
NWidContainerFlags
NWidContainerFlags
Nested widget container flags,.
Definition: widget_type.h:434
SZSP_VERTICAL
@ SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:397
MatrixWidgetValues
MatrixWidgetValues
Bits of the WWT_MATRIX widget data.
Definition: widget_type.h:23
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:554
NDB_DISABLED
@ NDB_DISABLED
Widget is disabled (greyed out) bit.
Definition: widget_type.h:262
NWidgetVertical::NWidgetVertical
NWidgetVertical(NWidContainerFlags flags=NC_NONE)
Vertical container widget.
Definition: widget.cpp:1303
NWidgetViewport::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1914
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:313
NWidgetMatrix::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:520
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:292
NWidgetLeaf::closebox_dimension
static Dimension closebox_dimension
Cached size of a closebox widget.
Definition: widget_type.h:792
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:47
NWidgetPartDataTip::tooltip
StringID tooltip
Tooltip of the widget.
Definition: widget_type.h:869
WPT_FUNCTION
@ WPT_FUNCTION
Widget part for calling a user function.
Definition: widget_type.h:93
NWidgetLeaf::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2406
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:174
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:877
NWidgetPartPaddings::left
uint8 left
Paddings for all directions.
Definition: widget_type.h:886
NWidgetPartTextLines::size
FontSize size
Font size of text lines.
Definition: widget_type.h:904
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:182
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:429
NWidgetMatrix::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1575
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:2878
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:815
NWidgetScrollbar::horizontal_dimension
static Dimension horizontal_dimension
Cached size of horizontal scrollbar button.
Definition: widget_type.h:772
NWidgetLeaf::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2212
NWidgetScrollbar::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2039
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:2547
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:2827
NWidgetHorizontal::NWidgetHorizontal
NWidgetHorizontal(NWidContainerFlags flags=NC_NONE)
Horizontal container widget.
Definition: widget.cpp:1136
NWidgetBackground::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1834
NWidgetCore::SetDisabled
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:361
ND_SCROLLBAR_BTN
@ ND_SCROLLBAR_BTN
Bit value of the 'scrollbar up' or 'scrollbar down' flag.
Definition: widget_type.h:284
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
NWidgetPartDataTip::data
uint32 data
Data value of the widget.
Definition: widget_type.h:868
NWidgetMatrix::widgets_x
int widgets_x
The number of visible widgets in horizontal direction.
Definition: widget_type.h:527
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:974
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:278
NWidgetPart::text_lines
NWidgetPartTextLines text_lines
Part with text line data.
Definition: widget_type.h:927
NDB_DROPDOWN_ACTIVE
@ NDB_DROPDOWN_ACTIVE
Dropdown menu of the button dropdown widget is active.
Definition: widget_type.h:268
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:913
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1498
WPT_ENDCONTAINER
@ WPT_ENDCONTAINER
Widget part to denote end of a container.
Definition: widget_type.h:92