OpenTTD Source: src/widget_type.h Source File

OpenTTD Source 12.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
23 enum MatrixWidgetValues {
24 /* Number of column bits of the WWT_MATRIX widget data. */
25 MAT_COL_START = 0,
26 MAT_COL_BITS = 8,
27
28 /* Number of row bits of the WWT_MATRIX widget data. */
29 MAT_ROW_START = 8,
30 MAT_ROW_BITS = 8,
31 };
32
34 enum ArrowWidgetValues {
35 AWV_DECREASE,
36 AWV_INCREASE,
37 AWV_LEFT,
38 AWV_RIGHT,
39 };
40
44 enum WidgetType {
45 /* Window widget types. */
46 WWT_EMPTY,
47
48 WWT_PANEL,
49 WWT_INSET,
50 WWT_IMGBTN,
51 WWT_IMGBTN_2,
52 WWT_ARROWBTN,
53 WWT_TEXTBTN,
54 WWT_TEXTBTN_2,
55 WWT_LABEL,
56 WWT_TEXT,
57 WWT_MATRIX,
58 WWT_FRAME,
59 WWT_CAPTION,
60
61 WWT_DEBUGBOX,
62 WWT_SHADEBOX,
63 WWT_DEFSIZEBOX,
64 WWT_STICKYBOX,
65
66 WWT_RESIZEBOX,
67 WWT_CLOSEBOX,
68 WWT_DROPDOWN,
69 WWT_EDITBOX,
70 WWT_LAST,
71
72 /* Nested widget types. */
73 NWID_HORIZONTAL,
74 NWID_HORIZONTAL_LTR,
75 NWID_VERTICAL,
76 NWID_MATRIX,
77 NWID_SPACER,
78 NWID_SELECTION,
79 NWID_VIEWPORT,
80 NWID_BUTTON_DROPDOWN,
81 NWID_HSCROLLBAR,
82 NWID_VSCROLLBAR,
83
84 /* Nested widget part types. */
85 WPT_RESIZE,
86 WPT_MINSIZE,
87 WPT_MINTEXTLINES,
88 WPT_FILL,
89 WPT_DATATIP,
90 WPT_PADDING,
91 WPT_PIPSPACE,
92 WPT_TEXTCOLOUR,
93 WPT_ALIGNMENT,
94 WPT_ENDCONTAINER,
95 WPT_FUNCTION,
96 WPT_SCROLLBAR,
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
111 enum SizingType {
112 ST_SMALLEST,
113 ST_RESIZE,
114 };
115
116 /* Forward declarations. */
117 class NWidgetCore;
118 class Scrollbar;
119
126 class NWidgetBase : public ZeroedMemoryAllocator {
127 public:
128 NWidgetBase(WidgetType tp);
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;
137 virtual NWidgetBase *GetWidgetOfType(WidgetType tp);
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
159 inline uint GetHorizontalStepSize(SizingType sizing) const;
160 inline uint GetVerticalStepSize(SizingType sizing) const;
161
162 virtual void Draw(const Window *w) = 0;
163 virtual void SetDirty(const Window *w) const;
164
165 Rect GetCurrentRect() const
166 {
167 Rect r;
168 r.left = this->pos_x;
169 r.top = this->pos_y;
170 r.right = this->pos_x + this->current_x - 1;
171 r.bottom = this->pos_y + this->current_y - 1;
172 return r;
173 }
174
175 WidgetType type;
176 uint fill_x;
177 uint fill_y;
178 uint resize_x;
179 uint resize_y;
180 /* Size of the widget in the smallest window possible.
181 * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
182 */
183 uint smallest_x;
184 uint smallest_y;
185 /* Current widget size (that is, after resizing). */
186 uint current_x;
187 uint current_y;
188
189 int pos_x;
190 int pos_y;
191
192 NWidgetBase *next;
193 NWidgetBase *prev;
194
195 uint8 padding_top;
196 uint8 padding_right;
197 uint8 padding_bottom;
198 uint8 padding_left;
199
200 uint8 uz_padding_top;
201 uint8 uz_padding_right;
202 uint8 uz_padding_bottom;
203 uint8 uz_padding_left;
204
205 protected:
206 inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
207 };
208
213 inline uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const
214 {
215 return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
216 }
217
222 inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const
223 {
224 return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
225 }
226
235 inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
236 {
237 this->pos_x = x;
238 this->pos_y = y;
239 if (sizing == ST_SMALLEST) {
240 this->smallest_x = given_width;
241 this->smallest_y = given_height;
242 }
243 this->current_x = given_width;
244 this->current_y = given_height;
245 }
246
247
252 class NWidgetResizeBase : public NWidgetBase {
253 public:
254 NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
255
256 void AdjustPaddingForZoom() override;
257 void SetMinimalSize(uint min_x, uint min_y);
258 void SetMinimalSizeAbsolute(uint min_x, uint min_y);
259 void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
260 void SetFill(uint fill_x, uint fill_y);
261 void SetResize(uint resize_x, uint resize_y);
262
263 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
264
265 uint min_x;
266 uint min_y;
267
268 bool absolute;
269 uint uz_min_x;
270 uint uz_min_y;
271
272 uint8 uz_text_lines;
273 uint8 uz_text_spacing;
274 FontSize uz_text_size;
275 };
276
278 enum NWidgetDisplay {
279 /* Generic. */
280 NDB_LOWERED = 0,
281 NDB_DISABLED = 1,
282 /* Viewport widget. */
283 NDB_NO_TRANSPARENCY = 2,
284 NDB_SHADE_GREY = 3,
285 NDB_SHADE_DIMMED = 4,
286 /* Button dropdown widget. */
287 NDB_DROPDOWN_ACTIVE = 5,
288 /* Scrollbar widget. */
289 NDB_SCROLLBAR_UP = 6,
290 NDB_SCROLLBAR_DOWN = 7,
291 /* Generic. */
292 NDB_HIGHLIGHT = 8,
293
294 ND_LOWERED = 1 << NDB_LOWERED,
295 ND_DISABLED = 1 << NDB_DISABLED,
296 ND_HIGHLIGHT = 1 << NDB_HIGHLIGHT,
297 ND_NO_TRANSPARENCY = 1 << NDB_NO_TRANSPARENCY,
298 ND_SHADE_GREY = 1 << NDB_SHADE_GREY,
299 ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED,
300 ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE,
301 ND_SCROLLBAR_UP = 1 << NDB_SCROLLBAR_UP,
302 ND_SCROLLBAR_DOWN = 1 << NDB_SCROLLBAR_DOWN,
303 ND_SCROLLBAR_BTN = ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN,
304 };
305 DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
306
307
311 class NWidgetCore : public NWidgetResizeBase {
312 public:
313 NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
314
315 void SetIndex(int index);
316 void SetDataTip(uint32 widget_data, StringID tool_tip);
317 void SetToolTip(StringID tool_tip);
318 void SetTextColour(TextColour colour);
319 void SetAlignment(StringAlignment align);
320
321 inline void SetLowered(bool lowered);
322 inline bool IsLowered() const;
323 inline void SetDisabled(bool disabled);
324 inline bool IsDisabled() const;
325
326 void FillNestedArray(NWidgetBase **array, uint length) override;
327 NWidgetCore *GetWidgetFromPos(int x, int y) override;
328 bool IsHighlighted() const override;
329 TextColour GetHighlightColour() const override;
330 void SetHighlighted(TextColour highlight_colour) override;
331
332 NWidgetDisplay disp_flags;
333 Colours colour;
334 int index;
335 uint32 widget_data;
336 StringID tool_tip;
337 int scrollbar_index;
338 TextColour highlight_colour;
339 TextColour text_colour;
340 StringAlignment align;
341 };
342
347 inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
348 {
349 this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
350 this->highlight_colour = highlight_colour;
351 }
352
354 inline bool NWidgetCore::IsHighlighted() const
355 {
356 return HasBit(this->disp_flags, NDB_HIGHLIGHT);
357 }
358
360 inline TextColour NWidgetCore::GetHighlightColour() const
361 {
362 return this->highlight_colour;
363 }
364
369 inline void NWidgetCore::SetLowered(bool lowered)
370 {
371 this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
372 }
373
375 inline bool NWidgetCore::IsLowered() const
376 {
377 return HasBit(this->disp_flags, NDB_LOWERED);
378 }
379
384 inline void NWidgetCore::SetDisabled(bool disabled)
385 {
386 this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
387 }
388
390 inline bool NWidgetCore::IsDisabled() const
391 {
392 return HasBit(this->disp_flags, NDB_DISABLED);
393 }
394
395
400 class NWidgetContainer : public NWidgetBase {
401 public:
402 NWidgetContainer(WidgetType tp);
403 ~NWidgetContainer();
404
405 void AdjustPaddingForZoom() override;
406 void Add(NWidgetBase *wid);
407 void FillNestedArray(NWidgetBase **array, uint length) override;
408
410 inline bool IsEmpty() { return head == nullptr; }
411
412 NWidgetBase *GetWidgetOfType(WidgetType tp) override;
413
414 protected:
415 NWidgetBase *head;
416 NWidgetBase *tail;
417 };
418
420 enum StackedZeroSizePlanes {
421 SZSP_VERTICAL = INT_MAX / 2,
422 SZSP_HORIZONTAL,
423 SZSP_NONE,
424
425 SZSP_BEGIN = SZSP_VERTICAL,
426 };
427
438 class NWidgetStacked : public NWidgetContainer {
439 public:
440 NWidgetStacked();
441
442 void SetIndex(int index);
443
444 void AdjustPaddingForZoom() override;
445 void SetupSmallestSize(Window *w, bool init_array) override;
446 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
447 void FillNestedArray(NWidgetBase **array, uint length) override;
448
449 void Draw(const Window *w) override;
450 NWidgetCore *GetWidgetFromPos(int x, int y) override;
451
452 void SetDisplayedPlane(int plane);
453
454 int shown_plane;
455 int index;
456 };
457
459 enum NWidContainerFlags {
460 NCB_EQUALSIZE = 0,
461
462 NC_NONE = 0,
463 NC_EQUALSIZE = 1 << NCB_EQUALSIZE,
464 };
465 DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags)
466
467
468 class NWidgetPIPContainer : public NWidgetContainer {
469 public:
470 NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE);
471
472 void AdjustPaddingForZoom() override;
473 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
474
475 void Draw(const Window *w) override;
476 NWidgetCore *GetWidgetFromPos(int x, int y) override;
477
478 protected:
479 NWidContainerFlags flags;
480 uint8 pip_pre;
481 uint8 pip_inter;
482 uint8 pip_post;
483
484 uint8 uz_pip_pre;
485 uint8 uz_pip_inter;
486 uint8 uz_pip_post;
487 };
488
493 class NWidgetHorizontal : public NWidgetPIPContainer {
494 public:
495 NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
496
497 void SetupSmallestSize(Window *w, bool init_array) override;
498 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
499 };
500
505 class NWidgetHorizontalLTR : public NWidgetHorizontal {
506 public:
507 NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
508
509 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
510 };
511
516 class NWidgetVertical : public NWidgetPIPContainer {
517 public:
518 NWidgetVertical(NWidContainerFlags flags = NC_NONE);
519
520 void SetupSmallestSize(Window *w, bool init_array) override;
521 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
522 };
523
532 class NWidgetMatrix : public NWidgetPIPContainer {
533 public:
534 NWidgetMatrix();
535
536 void SetIndex(int index);
537 void SetColour(Colours colour);
538 void SetClicked(int clicked);
539 void SetCount(int count);
540 void SetScrollbar(Scrollbar *sb);
541
542 void SetupSmallestSize(Window *w, bool init_array) override;
543 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
544 void FillNestedArray(NWidgetBase **array, uint length) override;
545
546 NWidgetCore *GetWidgetFromPos(int x, int y) override;
547 void Draw(const Window *w) override;
548 protected:
549 int index;
550 Colours colour;
551 int clicked;
552 int count;
553 Scrollbar *sb;
554 private:
555 int widget_w;
556 int widget_h;
557 int widgets_x;
558 int widgets_y;
559
560 void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
561 };
562
563
568 class NWidgetSpacer : public NWidgetResizeBase {
569 public:
570 NWidgetSpacer(int width, int height);
571
572 void SetupSmallestSize(Window *w, bool init_array) override;
573 void FillNestedArray(NWidgetBase **array, uint length) override;
574
575 void Draw(const Window *w) override;
576 void SetDirty(const Window *w) const override;
577 NWidgetCore *GetWidgetFromPos(int x, int y) override;
578 };
579
584 class NWidgetBackground : public NWidgetCore {
585 public:
586 NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr);
587 ~NWidgetBackground();
588
589 void Add(NWidgetBase *nwid);
590 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
591
592 void AdjustPaddingForZoom() override;
593 void SetupSmallestSize(Window *w, bool init_array) override;
594 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
595
596 void FillNestedArray(NWidgetBase **array, uint length) override;
597
598 void Draw(const Window *w) override;
599 NWidgetCore *GetWidgetFromPos(int x, int y) override;
600 NWidgetBase *GetWidgetOfType(WidgetType tp) override;
601
602 private:
603 NWidgetPIPContainer *child;
604 };
605
615 class NWidgetViewport : public NWidgetCore {
616 public:
617 NWidgetViewport(int index);
618
619 void SetupSmallestSize(Window *w, bool init_array) override;
620 void Draw(const Window *w) override;
621
622 void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
623 void UpdateViewportCoordinates(Window *w);
624 };
625
629 class Scrollbar {
630 private:
631 const bool is_vertical;
632 uint16 count;
633 uint16 cap;
634 uint16 pos;
635 uint16 stepsize;
636
637 public:
639 enum ScrollbarStepping {
640 SS_RAW,
641 SS_SMALL,
642 SS_BIG,
643 };
644
645 Scrollbar(bool is_vertical) : is_vertical(is_vertical), stepsize(1)
646 {
647 }
648
653 inline uint16 GetCount() const
654 {
655 return this->count;
656 }
657
662 inline uint16 GetCapacity() const
663 {
664 return this->cap;
665 }
666
671 inline uint16 GetPosition() const
672 {
673 return this->pos;
674 }
675
681 inline bool IsVisible(uint16 item) const
682 {
683 return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
684 }
685
690 inline bool IsVertical() const
691 {
692 return this->is_vertical;
693 }
694
699 void SetStepSize(uint16 stepsize)
700 {
701 assert(stepsize > 0);
702 this->stepsize = stepsize;
703 }
704
710 void SetCount(int num)
711 {
712 assert(num >= 0);
713 assert(num <= MAX_UVALUE(uint16));
714
715 this->count = num;
716 num -= this->cap;
717 if (num < 0) num = 0;
718 if (num < this->pos) this->pos = num;
719 }
720
726 void SetCapacity(int capacity)
727 {
728 assert(capacity > 0);
729 assert(capacity <= MAX_UVALUE(uint16));
730
731 this->cap = capacity;
732 if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
733 }
734
735 void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
736
742 bool SetPosition(int position)
743 {
744 assert(position >= 0);
745 assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
746 uint16 old_pos = this->pos;
747 this->pos = position;
748 return this->pos != old_pos;
749 }
750
758 bool UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
759 {
760 if (difference == 0) return false;
761 switch (unit) {
762 case SS_SMALL: difference *= this->stepsize; break;
763 case SS_BIG: difference *= this->cap; break;
764 default: break;
765 }
766 return this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
767 }
768
775 void ScrollTowards(int position)
776 {
777 if (position < this->GetPosition()) {
778 /* scroll up to the item */
779 this->SetPosition(position);
780 } else if (position >= this->GetPosition() + this->GetCapacity()) {
781 /* scroll down so that the item is at the bottom */
782 this->SetPosition(position - this->GetCapacity() + 1);
783 }
784 }
785
786 int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0) const;
787 EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const;
788 };
789
795 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
796 public:
797 NWidgetScrollbar(WidgetType tp, Colours colour, int index);
798
799 void SetupSmallestSize(Window *w, bool init_array) override;
800 void Draw(const Window *w) override;
801
802 static void InvalidateDimensionCache();
803 static Dimension GetVerticalDimension();
804 static Dimension GetHorizontalDimension();
805
806 private:
807 static Dimension vertical_dimension;
808 static Dimension horizontal_dimension;
809 };
810
815 class NWidgetLeaf : public NWidgetCore {
816 public:
817 NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
818
819 void SetupSmallestSize(Window *w, bool init_array) override;
820 void Draw(const Window *w) override;
821
822 bool ButtonHit(const Point &pt);
823
824 static void InvalidateDimensionCache();
825
826 static Dimension dropdown_dimension;
827 static Dimension resizebox_dimension;
828 static Dimension closebox_dimension;
829 private:
830 static Dimension shadebox_dimension;
831 static Dimension debugbox_dimension;
832 static Dimension defsizebox_dimension;
833 static Dimension stickybox_dimension;
834 };
835
843 static inline uint ComputeMaxSize(uint base, uint max_space, uint step)
844 {
845 if (base >= max_space || step == 0) return base;
846 if (step == 1) return max_space;
847 uint increment = max_space - base;
848 increment -= increment % step;
849 return base + increment;
850 }
851
903 struct NWidgetPartDataTip {
904 uint32 data;
905 StringID tooltip;
906 };
907
912 struct NWidgetPartWidget {
913 Colours colour;
914 int16 index;
915 };
916
921 struct NWidgetPartPaddings {
922 uint8 top, right, bottom, left;
923 };
924
929 struct NWidgetPartPIP {
930 uint8 pre, inter, post;
931 };
932
937 struct NWidgetPartTextLines {
938 uint8 lines;
939 uint8 spacing;
940 FontSize size;
941 };
942
947 struct NWidgetPartTextColour {
948 TextColour colour;
949 };
950
955 struct NWidgetPartAlignment {
956 StringAlignment align;
957 };
958
965 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
966
971 struct NWidgetPart {
972 WidgetType type;
973 union {
974 Point xy;
975 NWidgetPartDataTip data_tip;
976 NWidgetPartWidget widget;
977 NWidgetPartPaddings padding;
978 NWidgetPartPIP pip;
979 NWidgetPartTextLines text_lines;
980 NWidgetPartTextColour colour;
981 NWidgetPartAlignment align;
982 NWidgetFunctionType *func_ptr;
983 NWidContainerFlags cont_flags;
984 } u;
985 };
986
993 static inline NWidgetPart SetResize(int16 dx, int16 dy)
994 {
995 NWidgetPart part;
996
997 part.type = WPT_RESIZE;
998 part.u.xy.x = dx;
999 part.u.xy.y = dy;
1000
1001 return part;
1002 }
1003
1010 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
1011 {
1012 NWidgetPart part;
1013
1014 part.type = WPT_MINSIZE;
1015 part.u.xy.x = x;
1016 part.u.xy.y = y;
1017
1018 return part;
1019 }
1020
1028 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
1029 {
1030 NWidgetPart part;
1031
1032 part.type = WPT_MINTEXTLINES;
1033 part.u.text_lines.lines = lines;
1034 part.u.text_lines.spacing = spacing;
1035 part.u.text_lines.size = size;
1036
1037 return part;
1038 }
1039
1045 static inline NWidgetPart SetTextColour(TextColour colour)
1046 {
1047 NWidgetPart part;
1048
1049 part.type = WPT_TEXTCOLOUR;
1050 part.u.colour.colour = colour;
1051
1052 return part;
1053 }
1054
1060 static inline NWidgetPart SetAlignment(StringAlignment align)
1061 {
1062 NWidgetPart part;
1063
1064 part.type = WPT_ALIGNMENT;
1065 part.u.align.align = align;
1066
1067 return part;
1068 }
1069
1076 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
1077 {
1078 NWidgetPart part;
1079
1080 part.type = WPT_FILL;
1081 part.u.xy.x = fill_x;
1082 part.u.xy.y = fill_y;
1083
1084 return part;
1085 }
1086
1092 static inline NWidgetPart EndContainer()
1093 {
1094 NWidgetPart part;
1095
1096 part.type = WPT_ENDCONTAINER;
1097
1098 return part;
1099 }
1100
1107 static inline NWidgetPart SetDataTip(uint32 data, StringID tip)
1108 {
1109 NWidgetPart part;
1110
1111 part.type = WPT_DATATIP;
1112 part.u.data_tip.data = data;
1113 part.u.data_tip.tooltip = tip;
1114
1115 return part;
1116 }
1117
1125 static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
1126 {
1127 return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip);
1128 }
1129
1139 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
1140 {
1141 NWidgetPart part;
1142
1143 part.type = WPT_PADDING;
1144 part.u.padding.top = top;
1145 part.u.padding.right = right;
1146 part.u.padding.bottom = bottom;
1147 part.u.padding.left = left;
1148
1149 return part;
1150 }
1151
1157 static inline NWidgetPart SetPadding(uint8 padding)
1158 {
1159 return SetPadding(padding, padding, padding, padding);
1160 }
1161
1169 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
1170 {
1171 NWidgetPart part;
1172
1173 part.type = WPT_PIPSPACE;
1174 part.u.pip.pre = pre;
1175 part.u.pip.inter = inter;
1176 part.u.pip.post = post;
1177
1178 return part;
1179 }
1180
1188 static inline NWidgetPart SetScrollbar(int index)
1189 {
1190 NWidgetPart part;
1191
1192 part.type = WPT_SCROLLBAR;
1193 part.u.widget.index = index;
1194
1195 return part;
1196 }
1197
1207 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
1208 {
1209 NWidgetPart part;
1210
1211 part.type = tp;
1212 part.u.widget.colour = col;
1213 part.u.widget.index = idx;
1214
1215 return part;
1216 }
1217
1224 static inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE)
1225 {
1226 NWidgetPart part;
1227
1228 part.type = tp;
1229 part.u.cont_flags = cont_flags;
1230
1231 return part;
1232 }
1233
1239 static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
1240 {
1241 NWidgetPart part;
1242
1243 part.type = WPT_FUNCTION;
1244 part.u.func_ptr = func_ptr;
1245
1246 return part;
1247 }
1248
1249 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
1250 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
1251
1252 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);
1253
1254 #endif /* WIDGET_TYPE_H */
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:423
NWidgetBackground::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1887
NWidgetSpacer::NWidgetSpacer
NWidgetSpacer(int width, int height)
Generic spacer widget.
Definition: widget.cpp:1561
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:252
NWidgetPartTextLines::lines
uint8 lines
Number of text lines.
Definition: widget_type.h:938
NWidgetMatrix::clicked
int clicked
The currently clicked widget.
Definition: widget_type.h:551
NWidgetScrollbar::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2210
NWidgetStacked::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1136
NWidgetMatrix::widgets_y
int widgets_y
The number of visible widgets in vertical direction.
Definition: widget_type.h:558
NDB_LOWERED
@ NDB_LOWERED
Widget is lowered (pressed down) bit.
Definition: widget_type.h:280
NWidgetStacked::NWidgetStacked
NWidgetStacked()
Widgets stacked on top of each other.
Definition: widget.cpp:1074
NWidgetResizeBase::uz_min_x
uint uz_min_x
Unscaled Minimal horizontal size of only this widget.
Definition: widget_type.h:269
NWidgetPart::colour
NWidgetPartTextColour colour
Part with text colour data.
Definition: widget_type.h:980
NWidgetCore::IsDisabled
bool IsDisabled() const
Return whether the widget is disabled.
Definition: widget_type.h:390
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:1239
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:843
NWidgetCore::GetHighlightColour
TextColour GetHighlightColour() const override
Return the colour of the highlight.
Definition: widget_type.h:360
NWidgetCore::IsHighlighted
bool IsHighlighted() const override
Return whether the widget is highlighted.
Definition: widget_type.h:354
NWidgetPart::pip
NWidgetPartPIP pip
Part with pre/inter/post spaces.
Definition: widget_type.h:978
NWidgetSpacer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1587
Scrollbar::SS_SMALL
@ SS_SMALL
Step in stepsize units.
Definition: widget_type.h:641
NWidgetPartPIP::post
uint8 post
Amount of space before/between/after child widgets.
Definition: widget_type.h:930
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1188
NWidgetPIPContainer::pip_inter
uint8 pip_inter
Amount of space between widgets.
Definition: widget_type.h:481
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:981
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:662
NWidgetStacked::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:455
NWidgetLeaf::resizebox_dimension
static Dimension resizebox_dimension
Cached size of a resizebox widget.
Definition: widget_type.h:827
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:1139
Scrollbar::is_vertical
const bool is_vertical
Scrollbar has vertical orientation.
Definition: widget_type.h:631
NWidgetCore::SetHighlighted
void SetHighlighted(TextColour highlight_colour) override
Highlight the widget or not.
Definition: widget_type.h:347
SZSP_BEGIN
@ SZSP_BEGIN
First zero-size plane.
Definition: widget_type.h:425
NWidgetBase::GetVerticalStepSize
uint GetVerticalStepSize(SizingType sizing) const
Get the vertical sizing step.
Definition: widget_type.h:222
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1047
ND_SCROLLBAR_DOWN
@ ND_SCROLLBAR_DOWN
Bit value of the 'scrollbar down' flag.
Definition: widget_type.h:302
NWID_HSCROLLBAR
@ NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:81
Scrollbar::ScrollbarStepping
ScrollbarStepping
Stepping sizes when scrolling.
Definition: widget_type.h:639
NWidgetViewport
Nested widget to display a viewport in a window.
Definition: widget_type.h:615
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:775
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:634
NWidgetPartPaddings
Widget part for storing padding.
Definition: widget_type.h:921
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:532
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:213
NWidgetPIPContainer::uz_pip_post
uint8 uz_pip_post
Unscaled space after last widget.
Definition: widget_type.h:486
ND_SHADE_DIMMED
@ ND_SHADE_DIMMED
Bit value of the 'dimmed colours' flag.
Definition: widget_type.h:299
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:892
NWidgetStacked::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1162
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NWidgetMatrix::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1749
NWidgetLeaf::stickybox_dimension
static Dimension stickybox_dimension
Cached size of a stickybox widget.
Definition: widget_type.h:833
NDB_SCROLLBAR_DOWN
@ NDB_SCROLLBAR_DOWN
Down-button is lowered bit.
Definition: widget_type.h:290
NDB_SHADE_DIMMED
@ NDB_SHADE_DIMMED
Display dimmed colours in the viewport.
Definition: widget_type.h:285
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:568
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:753
NWidgetResizeBase::uz_min_y
uint uz_min_y
Unscaled Minimal vertical size of only this widget.
Definition: widget_type.h:270
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:710
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:993
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:815
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:1651
StringAlignment
StringAlignment
How to align the to-be drawn text.
Definition: gfx_type.h:327
NWidgetMatrix::count
int count
Amount of valid widgets.
Definition: widget_type.h:552
NWidgetPart::xy
Point xy
Part with an x/y size.
Definition: widget_type.h:974
NWidgetSpacer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1573
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:422
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:336
NWidgetContainer::GetWidgetOfType
NWidgetBase * GetWidgetOfType(WidgetType tp) override
Retrieve a widget by its type.
Definition: widget.cpp:1025
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:369
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:2098
NWidgetLeaf::shadebox_dimension
static Dimension shadebox_dimension
Cached size of a shadebox widget.
Definition: widget_type.h:830
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:184
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:629
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:3015
NWidgetBase::padding_top
uint8 padding_top
Paddings added to the top of the widget. Managed by parent container widget.
Definition: widget_type.h:195
NWidgetMatrix::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1656
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1421
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
NWidgetPIPContainer::uz_pip_inter
uint8 uz_pip_inter
Unscaled space between widgets.
Definition: widget_type.h:485
NWidgetMatrix::sb
Scrollbar * sb
The scrollbar we're associated with.
Definition: widget_type.h:553
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:335
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:1627
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:193
NWidgetStacked::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1156
NWidgetLeaf::InvalidateDimensionCache
static void InvalidateDimensionCache()
Reset the cached dimensions.
Definition: widget.cpp:2291
NWidgetResizeBase::NWidgetResizeBase
NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y)
Constructor for resizable nested widgets.
Definition: widget.cpp:846
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:463
ND_DROPDOWN_ACTIVE
@ ND_DROPDOWN_ACTIVE
Bit value of the 'dropdown active' flag.
Definition: widget_type.h:300
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:758
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:922
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:198
NDB_HIGHLIGHT
@ NDB_HIGHLIGHT
Highlight of widget is on.
Definition: widget_type.h:292
NWidgetLeaf::NWidgetLeaf
NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip)
Nested leaf widget.
Definition: widget.cpp:2318
NWidgetBackground::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1953
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:826
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:929
NWidgetBase::uz_padding_bottom
uint8 uz_padding_bottom
Unscaled bottom padding, for resize calculation.
Definition: widget_type.h:202
ND_HIGHLIGHT
@ ND_HIGHLIGHT
Bit value of the highlight flag.
Definition: widget_type.h:296
NWidgetViewport::UpdateViewportCoordinates
void UpdateViewportCoordinates(Window *w)
Update the position and size of the viewport (after eg a resize).
Definition: widget.cpp:2076
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:653
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:416
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:2031
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:175
NWidgetResizeBase::SetResize
void SetResize(uint resize_x, uint resize_y)
Set resize step of the widget.
Definition: widget.cpp:916
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:183
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:831
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:827
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:2018
Scrollbar::IsVertical
bool IsVertical() const
Is the scrollbar vertical or not?
Definition: widget_type.h:690
NWidgetMatrix::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1717
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:194
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:1125
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:2119
NWidgetPart::widget
NWidgetPartWidget widget
Part with a start of a widget.
Definition: widget_type.h:976
NWidgetPartWidget::index
int16 index
Widget index in the widget array.
Definition: widget_type.h:914
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:480
NWidgetResizeBase::uz_text_size
FontSize uz_text_size
'Unscaled' font size, stored for resize calculation.
Definition: widget_type.h:274
NWidgetDisplay
NWidgetDisplay
Nested widget flags that affect display and interaction with 'real' widgets.
Definition: widget_type.h:278
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:1873
NWidgetLeaf::defsizebox_dimension
static Dimension defsizebox_dimension
Cached size of a defsizebox widget.
Definition: widget_type.h:832
ND_LOWERED
@ ND_LOWERED
Bit value of the lowered flag.
Definition: widget_type.h:294
NWidgetPartTextLines
Widget part for storing minimal text line data.
Definition: widget_type.h:937
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:1009
ND_DISABLED
@ ND_DISABLED
Bit value of the disabled flag.
Definition: widget_type.h:295
Scrollbar::SS_RAW
@ SS_RAW
Step in single units.
Definition: widget_type.h:640
NWidgetPart::func_ptr
NWidgetFunctionType * func_ptr
Part with a function call.
Definition: widget_type.h:982
NDB_SCROLLBAR_UP
@ NDB_SCROLLBAR_UP
Up-button is lowered bit.
Definition: widget_type.h:289
Scrollbar::count
uint16 count
Number of elements in the list.
Definition: widget_type.h:632
NWidgetPart::padding
NWidgetPartPaddings padding
Part with paddings.
Definition: widget_type.h:977
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:375
NWidgetPartWidget
Widget part for storing basic widget information.
Definition: widget_type.h:912
NWidgetHorizontal::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1256
NWidgetPartTextLines::spacing
uint8 spacing
Extra spacing around lines.
Definition: widget_type.h:939
NDB_NO_TRANSPARENCY
@ NDB_NO_TRANSPARENCY
Viewport is never transparent.
Definition: widget_type.h:283
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
NWidgetStacked::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1177
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:415
NWidgetMatrix::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:549
NWidgetPartDataTip
Widget part for storing data and tooltip information.
Definition: widget_type.h:903
NWidgetHorizontal::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1323
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1195
NWidgetPIPContainer::uz_pip_pre
uint8 uz_pip_pre
Unscaled space before first widget.
Definition: widget_type.h:484
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:187
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:438
NWidgetScrollbar::vertical_dimension
static Dimension vertical_dimension
Cached size of vertical scrollbar button.
Definition: widget_type.h:807
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:192
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:905
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:1582
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:410
Scrollbar::cap
uint16 cap
Number of visible elements of the scroll bar.
Definition: widget_type.h:633
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:726
NWidgetSpacer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1567
NWidgetBackground::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:2008
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:1804
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:1577
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:177
NWidgetPart::cont_flags
NWidContainerFlags cont_flags
Part with container flags.
Definition: widget_type.h:983
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
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:332
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:189
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:493
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:1835
NWidgetBase::uz_padding_right
uint8 uz_padding_right
Unscaled right padding, for resize calculation.
Definition: widget_type.h:201
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:1711
NWidgetResizeBase::uz_text_spacing
uint8 uz_text_spacing
'Unscaled' text padding, stored for resize calculation.
Definition: widget_type.h:273
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
NWidgetPIPContainer
Container with pre/inter/post child space.
Definition: widget_type.h:468
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:176
NWidgetScrollbar
Nested widget to display and control a scrollbar in a window.
Definition: widget_type.h:795
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:681
NWidgetBackground::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1971
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
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:2067
NWidgetPIPContainer::flags
NWidContainerFlags flags
Flags of the container.
Definition: widget_type.h:479
NWidgetPartTextColour::colour
TextColour colour
TextColour for DrawString.
Definition: widget_type.h:948
NDB_SHADE_GREY
@ NDB_SHADE_GREY
Shade viewport to grey-scale.
Definition: widget_type.h:284
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:482
NWidgetStacked::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1092
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:179
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:235
NWidgetPartAlignment
Widget part for setting text/image alignment within a widget.
Definition: widget_type.h:955
EventState
EventState
State of handling an event.
Definition: window_type.h:717
NWidgetVertical
Vertical container.
Definition: widget_type.h:516
NWidgetBackground::child
NWidgetPIPContainer * child
Child widget.
Definition: widget_type.h:603
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:671
NWidgetPart::data_tip
NWidgetPartDataTip data_tip
Part with a data/tooltip.
Definition: widget_type.h:975
NWidgetContainer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1064
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:469
NWidgetCore::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:333
NWidgetMatrix::widget_h
int widget_h
The height of the child widget including inter spacing.
Definition: widget_type.h:556
NWidgetCore::highlight_colour
TextColour highlight_colour
Colour of highlight.
Definition: widget_type.h:338
NCB_EQUALSIZE
@ NCB_EQUALSIZE
Containers should keep all their (resizing) children equally large.
Definition: widget_type.h:460
NWidgetResizeBase::uz_text_lines
uint8 uz_text_lines
'Unscaled' text lines, stored for resize calculation.
Definition: widget_type.h:272
Scrollbar::stepsize
uint16 stepsize
Distance to scroll, when pressing the buttons or using the wheel.
Definition: widget_type.h:635
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:1060
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:400
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:196
NC_NONE
@ NC_NONE
All flags cleared.
Definition: widget_type.h:462
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:337
NWidgetBase::SetDirty
virtual void SetDirty(const Window *w) const
Mark the widget as 'dirty' (in need of repaint).
Definition: widget.cpp:807
NWidgetBase::uz_padding_top
uint8 uz_padding_top
Unscaled top padding, for resize calculation.
Definition: widget_type.h:200
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:2172
StackedZeroSizePlanes
StackedZeroSizePlanes
Display planes with zero size for NWidgetStacked.
Definition: widget_type.h:420
NWidgetHorizontalLTR::NWidgetHorizontalLTR
NWidgetHorizontalLTR(NWidContainerFlags flags=NC_NONE)
Horizontal left-to-right container widget.
Definition: widget.cpp:1406
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1169
NWidgetPartTextColour
Widget part for storing text colour.
Definition: widget_type.h:947
NWidgetHorizontalLTR::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1411
NWidgetResizeBase::min_x
uint min_x
Minimal horizontal size of only this widget.
Definition: widget_type.h:265
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:190
ND_SCROLLBAR_UP
@ ND_SCROLLBAR_UP
Bit value of the 'scrollbar up' flag.
Definition: widget_type.h:301
NWidgetCore::align
StringAlignment align
Alignment of text/image within widget.
Definition: widget_type.h:340
Scrollbar::SS_BIG
@ SS_BIG
Step in cap units.
Definition: widget_type.h:642
Scrollbar::SetStepSize
void SetStepSize(uint16 stepsize)
Set the distance to scroll when using the buttons or the wheel.
Definition: widget_type.h:699
NWidgetScrollbar::NWidgetScrollbar
NWidgetScrollbar(WidgetType tp, Colours colour, int index)
Scrollbar widget.
Definition: widget.cpp:2188
ND_SHADE_GREY
@ ND_SHADE_GREY
Bit value of the 'shade to grey' flag.
Definition: widget_type.h:298
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:1076
NWidgetCore::text_colour
TextColour text_colour
Colour of text within widget.
Definition: widget_type.h:339
NWidgetPart::type
WidgetType type
Type of the part.
Definition: widget_type.h:972
NWidgetResizeBase::min_y
uint min_y
Minimal vertical size of only this widget.
Definition: widget_type.h:266
NWidgetHorizontalLTR
Horizontal container that doesn't change the direction of the widgets for RTL languages.
Definition: widget_type.h:505
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:555
NWidgetBase::padding_bottom
uint8 padding_bottom
Paddings added to the bottom of the widget. Managed by parent container widget.
Definition: widget_type.h:197
NWidgetBackground::Add
void Add(NWidgetBase *nwid)
Add a child to the parent.
Definition: widget.cpp:1855
SetTextColour
static NWidgetPart SetTextColour(TextColour colour)
Widget part function for setting the text colour.
Definition: widget_type.h:1045
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:279
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:459
SZSP_VERTICAL
@ SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:421
NWidgetResizeBase::absolute
bool absolute
Set if minimum size is fixed and should not be resized.
Definition: widget_type.h:268
MatrixWidgetValues
MatrixWidgetValues
Bits of the WWT_MATRIX widget data.
Definition: widget_type.h:23
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:584
NDB_DISABLED
@ NDB_DISABLED
Widget is disabled (greyed out) bit.
Definition: widget_type.h:281
NWidgetVertical::NWidgetVertical
NWidgetVertical(NWidContainerFlags flags=NC_NONE)
Vertical container widget.
Definition: widget.cpp:1417
NWidgetViewport::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2041
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:334
NWidgetMatrix::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:550
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:311
NWidgetLeaf::closebox_dimension
static Dimension closebox_dimension
Cached size of a closebox widget.
Definition: widget_type.h:828
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:905
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:2604
NWidgetVertical::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1488
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:178
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:913
NWidgetPartPaddings::left
uint8 left
Paddings for all directions.
Definition: widget_type.h:922
NWidgetPartTextLines::size
FontSize size
Font size of text lines.
Definition: widget_type.h:940
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:186
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:454
NWidgetMatrix::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1687
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:3088
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:866
NWidgetScrollbar::horizontal_dimension
static Dimension horizontal_dimension
Cached size of horizontal scrollbar button.
Definition: widget_type.h:808
NWidgetLeaf::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2410
NWidgetResizeBase::SetMinimalSizeAbsolute
void SetMinimalSizeAbsolute(uint min_x, uint min_y)
Set absolute (post-scaling) minimal size of the widget.
Definition: widget.cpp:879
NWidgetScrollbar::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2235
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:2741
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:3037
NWidgetHorizontal::NWidgetHorizontal
NWidgetHorizontal(NWidContainerFlags flags=NC_NONE)
Horizontal container widget.
Definition: widget.cpp:1252
NWidgetBackground::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1965
NWidgetCore::SetDisabled
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:384
ND_SCROLLBAR_BTN
@ ND_SCROLLBAR_BTN
Bit value of the 'scrollbar up' or 'scrollbar down' flag.
Definition: widget_type.h:303
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:742
NWidgetPartDataTip::data
uint32 data
Data value of the widget.
Definition: widget_type.h:904
NWidgetMatrix::widgets_x
int widgets_x
The number of visible widgets in horizontal direction.
Definition: widget_type.h:557
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:1028
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:297
NWidgetPart::text_lines
NWidgetPartTextLines text_lines
Part with text line data.
Definition: widget_type.h:979
NDB_DROPDOWN_ACTIVE
@ NDB_DROPDOWN_ACTIVE
Dropdown menu of the button dropdown widget is active.
Definition: widget_type.h:287
NWidgetPartAlignment::align
StringAlignment align
Alignment of text/image.
Definition: widget_type.h:956
NWidgetBase::uz_padding_left
uint8 uz_padding_left
Unscaled left padding, for resize calculation.
Definition: widget_type.h:203
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:965
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1610
WPT_ENDCONTAINER
@ WPT_ENDCONTAINER
Widget part to denote end of a container.
Definition: widget_type.h:94