OpenTTD Source: src/widget_type.h Source File

OpenTTD Source 1.11.0-RC1

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_ENDCONTAINER,
93 WPT_FUNCTION,
94 WPT_SCROLLBAR,
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
109 enum SizingType {
110 ST_SMALLEST,
111 ST_RESIZE,
112 };
113
114 /* Forward declarations. */
115 class NWidgetCore;
116 class Scrollbar;
117
124 class NWidgetBase : public ZeroedMemoryAllocator {
125 public:
126 NWidgetBase(WidgetType tp);
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;
134 virtual NWidgetBase *GetWidgetOfType(WidgetType tp);
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 WidgetType type;
162 uint fill_x;
163 uint fill_y;
164 uint resize_x;
165 uint resize_y;
166 /* Size of the widget in the smallest window possible.
167 * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
168 */
169 uint smallest_x;
170 uint smallest_y;
171 /* Current widget size (that is, after resizing). */
172 uint current_x;
173 uint current_y;
174
175 int pos_x;
176 int pos_y;
177
178 NWidgetBase *next;
179 NWidgetBase *prev;
180
181 uint8 padding_top;
182 uint8 padding_right;
183 uint8 padding_bottom;
184 uint8 padding_left;
185
186 protected:
187 inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
188 };
189
194 inline uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const
195 {
196 return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
197 }
198
203 inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const
204 {
205 return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
206 }
207
216 inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
217 {
218 this->pos_x = x;
219 this->pos_y = y;
220 if (sizing == ST_SMALLEST) {
221 this->smallest_x = given_width;
222 this->smallest_y = given_height;
223 }
224 this->current_x = given_width;
225 this->current_y = given_height;
226 }
227
228
233 class NWidgetResizeBase : public NWidgetBase {
234 public:
235 NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
236
237 void SetMinimalSize(uint min_x, uint min_y);
238 void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
239 void SetFill(uint fill_x, uint fill_y);
240 void SetResize(uint resize_x, uint resize_y);
241
242 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
243
244 uint min_x;
245 uint min_y;
246 };
247
249 enum NWidgetDisplay {
250 /* Generic. */
251 NDB_LOWERED = 0,
252 NDB_DISABLED = 1,
253 /* Viewport widget. */
254 NDB_NO_TRANSPARENCY = 2,
255 NDB_SHADE_GREY = 3,
256 NDB_SHADE_DIMMED = 4,
257 /* Button dropdown widget. */
258 NDB_DROPDOWN_ACTIVE = 5,
259 /* Scrollbar widget. */
260 NDB_SCROLLBAR_UP = 6,
261 NDB_SCROLLBAR_DOWN = 7,
262 /* Generic. */
263 NDB_HIGHLIGHT = 8,
264
265 ND_LOWERED = 1 << NDB_LOWERED,
266 ND_DISABLED = 1 << NDB_DISABLED,
267 ND_HIGHLIGHT = 1 << NDB_HIGHLIGHT,
268 ND_NO_TRANSPARENCY = 1 << NDB_NO_TRANSPARENCY,
269 ND_SHADE_GREY = 1 << NDB_SHADE_GREY,
270 ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED,
271 ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE,
272 ND_SCROLLBAR_UP = 1 << NDB_SCROLLBAR_UP,
273 ND_SCROLLBAR_DOWN = 1 << NDB_SCROLLBAR_DOWN,
274 ND_SCROLLBAR_BTN = ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN,
275 };
276 DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
277
278
282 class NWidgetCore : public NWidgetResizeBase {
283 public:
284 NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
285
286 void SetIndex(int index);
287 void SetDataTip(uint32 widget_data, StringID tool_tip);
288 void SetToolTip(StringID tool_tip);
289
290 inline void SetLowered(bool lowered);
291 inline bool IsLowered() const;
292 inline void SetDisabled(bool disabled);
293 inline bool IsDisabled() const;
294
295 void FillNestedArray(NWidgetBase **array, uint length) override;
296 NWidgetCore *GetWidgetFromPos(int x, int y) override;
297 bool IsHighlighted() const override;
298 TextColour GetHighlightColour() const override;
299 void SetHighlighted(TextColour highlight_colour) override;
300
301 NWidgetDisplay disp_flags;
302 Colours colour;
303 int index;
304 uint32 widget_data;
305 StringID tool_tip;
306 int scrollbar_index;
307 TextColour highlight_colour;
308 };
309
314 inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
315 {
316 this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
317 this->highlight_colour = highlight_colour;
318 }
319
321 inline bool NWidgetCore::IsHighlighted() const
322 {
323 return HasBit(this->disp_flags, NDB_HIGHLIGHT);
324 }
325
327 inline TextColour NWidgetCore::GetHighlightColour() const
328 {
329 return this->highlight_colour;
330 }
331
336 inline void NWidgetCore::SetLowered(bool lowered)
337 {
338 this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
339 }
340
342 inline bool NWidgetCore::IsLowered() const
343 {
344 return HasBit(this->disp_flags, NDB_LOWERED);
345 }
346
351 inline void NWidgetCore::SetDisabled(bool disabled)
352 {
353 this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
354 }
355
357 inline bool NWidgetCore::IsDisabled() const
358 {
359 return HasBit(this->disp_flags, NDB_DISABLED);
360 }
361
362
367 class NWidgetContainer : public NWidgetBase {
368 public:
369 NWidgetContainer(WidgetType tp);
370 ~NWidgetContainer();
371
372 void Add(NWidgetBase *wid);
373 void FillNestedArray(NWidgetBase **array, uint length) override;
374
376 inline bool IsEmpty() { return head == nullptr; }
377
378 NWidgetBase *GetWidgetOfType(WidgetType tp) override;
379
380 protected:
381 NWidgetBase *head;
382 NWidgetBase *tail;
383 };
384
386 enum StackedZeroSizePlanes {
387 SZSP_VERTICAL = INT_MAX / 2,
388 SZSP_HORIZONTAL,
389 SZSP_NONE,
390
391 SZSP_BEGIN = SZSP_VERTICAL,
392 };
393
404 class NWidgetStacked : public NWidgetContainer {
405 public:
406 NWidgetStacked();
407
408 void SetIndex(int index);
409
410 void SetupSmallestSize(Window *w, bool init_array) override;
411 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
412 void FillNestedArray(NWidgetBase **array, uint length) override;
413
414 void Draw(const Window *w) override;
415 NWidgetCore *GetWidgetFromPos(int x, int y) override;
416
417 void SetDisplayedPlane(int plane);
418
419 int shown_plane;
420 int index;
421 };
422
424 enum NWidContainerFlags {
425 NCB_EQUALSIZE = 0,
426
427 NC_NONE = 0,
428 NC_EQUALSIZE = 1 << NCB_EQUALSIZE,
429 };
430 DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags)
431
432
433 class NWidgetPIPContainer : public NWidgetContainer {
434 public:
435 NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE);
436
437 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
438
439 void Draw(const Window *w) override;
440 NWidgetCore *GetWidgetFromPos(int x, int y) override;
441
442 protected:
443 NWidContainerFlags flags;
444 uint8 pip_pre;
445 uint8 pip_inter;
446 uint8 pip_post;
447 };
448
453 class NWidgetHorizontal : public NWidgetPIPContainer {
454 public:
455 NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
456
457 void SetupSmallestSize(Window *w, bool init_array);
458 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
459 };
460
465 class NWidgetHorizontalLTR : public NWidgetHorizontal {
466 public:
467 NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
468
469 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
470 };
471
476 class NWidgetVertical : public NWidgetPIPContainer {
477 public:
478 NWidgetVertical(NWidContainerFlags flags = NC_NONE);
479
480 void SetupSmallestSize(Window *w, bool init_array);
481 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
482 };
483
492 class NWidgetMatrix : public NWidgetPIPContainer {
493 public:
494 NWidgetMatrix();
495
496 void SetIndex(int index);
497 void SetColour(Colours colour);
498 void SetClicked(int clicked);
499 void SetCount(int count);
500 void SetScrollbar(Scrollbar *sb);
501
502 void SetupSmallestSize(Window *w, bool init_array) override;
503 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
504 void FillNestedArray(NWidgetBase **array, uint length) override;
505
506 NWidgetCore *GetWidgetFromPos(int x, int y) override;
507 void Draw(const Window *w) override;
508 protected:
509 int index;
510 Colours colour;
511 int clicked;
512 int count;
513 Scrollbar *sb;
514 private:
515 int widget_w;
516 int widget_h;
517 int widgets_x;
518 int widgets_y;
519
520 void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
521 };
522
523
528 class NWidgetSpacer : public NWidgetResizeBase {
529 public:
530 NWidgetSpacer(int length, int height);
531
532 void SetupSmallestSize(Window *w, bool init_array) override;
533 void FillNestedArray(NWidgetBase **array, uint length) override;
534
535 void Draw(const Window *w) override;
536 void SetDirty(const Window *w) const override;
537 NWidgetCore *GetWidgetFromPos(int x, int y) override;
538 };
539
544 class NWidgetBackground : public NWidgetCore {
545 public:
546 NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr);
547 ~NWidgetBackground();
548
549 void Add(NWidgetBase *nwid);
550 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
551
552 void SetupSmallestSize(Window *w, bool init_array) override;
553 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
554
555 void FillNestedArray(NWidgetBase **array, uint length) override;
556
557 void Draw(const Window *w) override;
558 NWidgetCore *GetWidgetFromPos(int x, int y) override;
559 NWidgetBase *GetWidgetOfType(WidgetType tp) override;
560
561 private:
562 NWidgetPIPContainer *child;
563 };
564
574 class NWidgetViewport : public NWidgetCore {
575 public:
576 NWidgetViewport(int index);
577
578 void SetupSmallestSize(Window *w, bool init_array) override;
579 void Draw(const Window *w) override;
580
581 void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
582 void UpdateViewportCoordinates(Window *w);
583 };
584
588 class Scrollbar {
589 private:
590 const bool is_vertical;
591 uint16 count;
592 uint16 cap;
593 uint16 pos;
594 uint16 stepsize;
595
596 public:
598 enum ScrollbarStepping {
599 SS_RAW,
600 SS_SMALL,
601 SS_BIG,
602 };
603
604 Scrollbar(bool is_vertical) : is_vertical(is_vertical), stepsize(1)
605 {
606 }
607
612 inline uint16 GetCount() const
613 {
614 return this->count;
615 }
616
621 inline uint16 GetCapacity() const
622 {
623 return this->cap;
624 }
625
630 inline uint16 GetPosition() const
631 {
632 return this->pos;
633 }
634
640 inline bool IsVisible(uint16 item) const
641 {
642 return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
643 }
644
649 inline bool IsVertical() const
650 {
651 return this->is_vertical;
652 }
653
658 void SetStepSize(uint16 stepsize)
659 {
660 assert(stepsize > 0);
661 this->stepsize = stepsize;
662 }
663
669 void SetCount(int num)
670 {
671 assert(num >= 0);
672 assert(num <= MAX_UVALUE(uint16));
673
674 this->count = num;
675 num -= this->cap;
676 if (num < 0) num = 0;
677 if (num < this->pos) this->pos = num;
678 }
679
685 void SetCapacity(int capacity)
686 {
687 assert(capacity > 0);
688 assert(capacity <= MAX_UVALUE(uint16));
689
690 this->cap = capacity;
691 if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
692 }
693
694 void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
695
700 void SetPosition(int position)
701 {
702 assert(position >= 0);
703 assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
704 this->pos = position;
705 }
706
713 void UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
714 {
715 if (difference == 0) return;
716 switch (unit) {
717 case SS_SMALL: difference *= this->stepsize; break;
718 case SS_BIG: difference *= this->cap; break;
719 default: break;
720 }
721 this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
722 }
723
730 void ScrollTowards(int position)
731 {
732 if (position < this->GetPosition()) {
733 /* scroll up to the item */
734 this->SetPosition(position);
735 } else if (position >= this->GetPosition() + this->GetCapacity()) {
736 /* scroll down so that the item is at the bottom */
737 this->SetPosition(position - this->GetCapacity() + 1);
738 }
739 }
740
741 int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const;
742 };
743
749 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
750 public:
751 NWidgetScrollbar(WidgetType tp, Colours colour, int index);
752
753 void SetupSmallestSize(Window *w, bool init_array) override;
754 void Draw(const Window *w) override;
755
756 static void InvalidateDimensionCache();
757 static Dimension GetVerticalDimension();
758 static Dimension GetHorizontalDimension();
759
760 private:
761 static Dimension vertical_dimension;
762 static Dimension horizontal_dimension;
763 };
764
769 class NWidgetLeaf : public NWidgetCore {
770 public:
771 NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
772
773 void SetupSmallestSize(Window *w, bool init_array) override;
774 void Draw(const Window *w) override;
775
776 bool ButtonHit(const Point &pt);
777
778 static void InvalidateDimensionCache();
779
780 static Dimension dropdown_dimension;
781 static Dimension resizebox_dimension;
782 static Dimension closebox_dimension;
783 private:
784 static Dimension shadebox_dimension;
785 static Dimension debugbox_dimension;
786 static Dimension defsizebox_dimension;
787 static Dimension stickybox_dimension;
788 };
789
797 static inline uint ComputeMaxSize(uint base, uint max_space, uint step)
798 {
799 if (base >= max_space || step == 0) return base;
800 if (step == 1) return max_space;
801 uint increment = max_space - base;
802 increment -= increment % step;
803 return base + increment;
804 }
805
857 struct NWidgetPartDataTip {
858 uint32 data;
859 StringID tooltip;
860 };
861
866 struct NWidgetPartWidget {
867 Colours colour;
868 int16 index;
869 };
870
875 struct NWidgetPartPaddings {
876 uint8 top, right, bottom, left;
877 };
878
883 struct NWidgetPartPIP {
884 uint8 pre, inter, post;
885 };
886
891 struct NWidgetPartTextLines {
892 uint8 lines;
893 uint8 spacing;
894 FontSize size;
895 };
896
903 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
904
909 struct NWidgetPart {
910 WidgetType type;
911 union {
912 Point xy;
913 NWidgetPartDataTip data_tip;
914 NWidgetPartWidget widget;
915 NWidgetPartPaddings padding;
916 NWidgetPartPIP pip;
917 NWidgetPartTextLines text_lines;
918 NWidgetFunctionType *func_ptr;
919 NWidContainerFlags cont_flags;
920 } u;
921 };
922
929 static inline NWidgetPart SetResize(int16 dx, int16 dy)
930 {
931 NWidgetPart part;
932
933 part.type = WPT_RESIZE;
934 part.u.xy.x = dx;
935 part.u.xy.y = dy;
936
937 return part;
938 }
939
946 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
947 {
948 NWidgetPart part;
949
950 part.type = WPT_MINSIZE;
951 part.u.xy.x = x;
952 part.u.xy.y = y;
953
954 return part;
955 }
956
964 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
965 {
966 NWidgetPart part;
967
968 part.type = WPT_MINTEXTLINES;
969 part.u.text_lines.lines = lines;
970 part.u.text_lines.spacing = spacing;
971 part.u.text_lines.size = size;
972
973 return part;
974 }
975
982 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
983 {
984 NWidgetPart part;
985
986 part.type = WPT_FILL;
987 part.u.xy.x = fill_x;
988 part.u.xy.y = fill_y;
989
990 return part;
991 }
992
998 static inline NWidgetPart EndContainer()
999 {
1000 NWidgetPart part;
1001
1002 part.type = WPT_ENDCONTAINER;
1003
1004 return part;
1005 }
1006
1013 static inline NWidgetPart SetDataTip(uint32 data, StringID tip)
1014 {
1015 NWidgetPart part;
1016
1017 part.type = WPT_DATATIP;
1018 part.u.data_tip.data = data;
1019 part.u.data_tip.tooltip = tip;
1020
1021 return part;
1022 }
1023
1031 static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
1032 {
1033 return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip);
1034 }
1035
1045 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
1046 {
1047 NWidgetPart part;
1048
1049 part.type = WPT_PADDING;
1050 part.u.padding.top = top;
1051 part.u.padding.right = right;
1052 part.u.padding.bottom = bottom;
1053 part.u.padding.left = left;
1054
1055 return part;
1056 }
1057
1063 static inline NWidgetPart SetPadding(uint8 padding)
1064 {
1065 return SetPadding(padding, padding, padding, padding);
1066 }
1067
1075 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
1076 {
1077 NWidgetPart part;
1078
1079 part.type = WPT_PIPSPACE;
1080 part.u.pip.pre = pre;
1081 part.u.pip.inter = inter;
1082 part.u.pip.post = post;
1083
1084 return part;
1085 }
1086
1094 static inline NWidgetPart SetScrollbar(int index)
1095 {
1096 NWidgetPart part;
1097
1098 part.type = WPT_SCROLLBAR;
1099 part.u.widget.index = index;
1100
1101 return part;
1102 }
1103
1113 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
1114 {
1115 NWidgetPart part;
1116
1117 part.type = tp;
1118 part.u.widget.colour = col;
1119 part.u.widget.index = idx;
1120
1121 return part;
1122 }
1123
1130 static inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE)
1131 {
1132 NWidgetPart part;
1133
1134 part.type = tp;
1135 part.u.cont_flags = cont_flags;
1136
1137 return part;
1138 }
1139
1145 static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
1146 {
1147 NWidgetPart part;
1148
1149 part.type = WPT_FUNCTION;
1150 part.u.func_ptr = func_ptr;
1151
1152 return part;
1153 }
1154
1155 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
1156 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
1157
1158 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);
1159
1160 #endif /* WIDGET_TYPE_H */
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:389
NWidgetBackground::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1764
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:233
NWidgetPartTextLines::lines
uint8 lines
Number of text lines.
Definition: widget_type.h:892
NWidgetMatrix::clicked
int clicked
The currently clicked widget.
Definition: widget_type.h:511
NWidgetScrollbar::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2002
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:518
NDB_LOWERED
@ NDB_LOWERED
Widget is lowered (pressed down) bit.
Definition: widget_type.h:251
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:357
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:1145
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:797
NWidgetCore::GetHighlightColour
TextColour GetHighlightColour() const override
Return the colour of the highlight.
Definition: widget_type.h:327
NWidgetCore::IsHighlighted
bool IsHighlighted() const override
Return whether the widget is highlighted.
Definition: widget_type.h:321
NWidgetPart::pip
NWidgetPartPIP pip
Part with pre/inter/post spaces.
Definition: widget_type.h:916
NWidgetSpacer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1471
Scrollbar::SS_SMALL
@ SS_SMALL
Step in stepsize units.
Definition: widget_type.h:600
NWidgetPartPIP::post
uint8 post
Amount of space before/between/after child widgets.
Definition: widget_type.h:884
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
NWidgetPIPContainer::pip_inter
uint8 pip_inter
Amount of space between widgets.
Definition: widget_type.h:445
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:621
NWidgetStacked::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:420
NWidgetLeaf::resizebox_dimension
static Dimension resizebox_dimension
Cached size of a resizebox widget.
Definition: widget_type.h:781
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:1045
Scrollbar::is_vertical
const bool is_vertical
Scrollbar has vertical orientation.
Definition: widget_type.h:590
NWidgetCore::SetHighlighted
void SetHighlighted(TextColour highlight_colour) override
Highlight the widget or not.
Definition: widget_type.h:314
SZSP_BEGIN
@ SZSP_BEGIN
First zero-size plane.
Definition: widget_type.h:391
NWidgetBase::GetVerticalStepSize
uint GetVerticalStepSize(SizingType sizing) const
Get the vertical sizing step.
Definition: widget_type.h:203
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:273
NWID_HSCROLLBAR
@ NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:81
Scrollbar::ScrollbarStepping
ScrollbarStepping
Stepping sizes when scrolling.
Definition: widget_type.h:598
NWidgetViewport
Nested widget to display a viewport in a window.
Definition: widget_type.h:574
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:730
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:593
NWidgetPartPaddings
Widget part for storing padding.
Definition: widget_type.h:875
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:492
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:1966
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:194
ND_SHADE_DIMMED
@ ND_SHADE_DIMMED
Bit value of the 'dimmed colours' flag.
Definition: widget_type.h:270
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:1633
NWidgetLeaf::stickybox_dimension
static Dimension stickybox_dimension
Cached size of a stickybox widget.
Definition: widget_type.h:787
NDB_SCROLLBAR_DOWN
@ NDB_SCROLLBAR_DOWN
Down-button is lowered bit.
Definition: widget_type.h:261
NDB_SHADE_DIMMED
@ NDB_SHADE_DIMMED
Display dimmed colours in the viewport.
Definition: widget_type.h:256
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:528
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:669
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:929
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:769
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:1535
NWidgetMatrix::count
int count
Amount of valid widgets.
Definition: widget_type.h:512
NWidgetPart::xy
Point xy
Part with an x/y size.
Definition: widget_type.h:912
NWidgetSpacer::FillNestedArray
void FillNestedArray(NWidgetBase **array, uint length) override
Definition: widget.cpp:1457
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:388
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:305
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:336
strings_type.h
NWidgetLeaf::shadebox_dimension
static Dimension shadebox_dimension
Cached size of a shadebox widget.
Definition: widget_type.h:784
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:170
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
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:2799
NWidgetBase::padding_top
uint8 padding_top
Paddings added to the top of the widget. Managed by parent container widget.
Definition: widget_type.h:181
NWidgetMatrix::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1540
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
NWidgetMatrix::sb
Scrollbar * sb
The scrollbar we're associated with.
Definition: widget_type.h:513
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:304
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:1511
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:179
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:2093
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:428
ND_DROPDOWN_ACTIVE
@ ND_DROPDOWN_ACTIVE
Bit value of the 'dropdown active' flag.
Definition: widget_type.h:271
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:184
NDB_HIGHLIGHT
@ NDB_HIGHLIGHT
Highlight of widget is on.
Definition: widget_type.h:263
NWidgetLeaf::NWidgetLeaf
NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip)
Nested leaf widget.
Definition: widget.cpp:2120
NWidgetBackground::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1818
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:780
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:883
ND_HIGHLIGHT
@ ND_HIGHLIGHT
Bit value of the highlight flag.
Definition: widget_type.h:267
NWidgetViewport::UpdateViewportCoordinates
void UpdateViewportCoordinates(Window *w)
Update the position and size of the viewport (after eg a resize).
Definition: widget.cpp:1943
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:612
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:382
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:1900
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:161
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:169
NWidgetHorizontal::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1207
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array)
Definition: widget.cpp:1305
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:785
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:1887
Scrollbar::IsVertical
bool IsVertical() const
Is the scrollbar vertical or not?
Definition: widget_type.h:649
NWidgetMatrix::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1601
NWidgetVertical::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1372
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:1031
NWidgetPart::widget
NWidgetPartWidget widget
Part with a start of a widget.
Definition: widget_type.h:914
NWidgetPartWidget::index
int16 index
Widget index in the widget array.
Definition: widget_type.h:868
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:444
NWidgetDisplay
NWidgetDisplay
Nested widget flags that affect display and interaction with 'real' widgets.
Definition: widget_type.h:249
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:1756
NWidgetLeaf::defsizebox_dimension
static Dimension defsizebox_dimension
Cached size of a defsizebox widget.
Definition: widget_type.h:786
ND_LOWERED
@ ND_LOWERED
Bit value of the lowered flag.
Definition: widget_type.h:265
NWidgetPartTextLines
Widget part for storing minimal text line data.
Definition: widget_type.h:891
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:266
Scrollbar::SS_RAW
@ SS_RAW
Step in single units.
Definition: widget_type.h:599
NWidgetPart::func_ptr
NWidgetFunctionType * func_ptr
Part with a function call.
Definition: widget_type.h:918
NDB_SCROLLBAR_UP
@ NDB_SCROLLBAR_UP
Up-button is lowered bit.
Definition: widget_type.h:260
Scrollbar::count
uint16 count
Number of elements in the list.
Definition: widget_type.h:591
NWidgetPart::padding
NWidgetPartPaddings padding
Part with paddings.
Definition: widget_type.h:915
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:342
NWidgetPartWidget
Widget part for storing basic widget information.
Definition: widget_type.h:866
NWidgetPartTextLines::spacing
uint8 spacing
Extra spacing around lines.
Definition: widget_type.h:893
NDB_NO_TRANSPARENCY
@ NDB_NO_TRANSPARENCY
Viewport is never transparent.
Definition: widget_type.h:254
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:381
NWidgetMatrix::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:509
NWidgetPartDataTip
Widget part for storing data and tooltip information.
Definition: widget_type.h:857
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:173
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:404
NWidgetScrollbar::vertical_dimension
static Dimension vertical_dimension
Cached size of vertical scrollbar button.
Definition: widget_type.h:761
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:178
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:1466
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:376
Scrollbar::cap
uint16 cap
Number of visible elements of the scroll bar.
Definition: widget_type.h:592
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:685
NWidgetSpacer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:1451
NWidgetBackground::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1877
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:1688
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:1461
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:163
NWidgetPart::cont_flags
NWidContainerFlags cont_flags
Part with container flags.
Definition: widget_type.h:919
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
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:301
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:453
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:1719
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:1595
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
NWidgetPIPContainer
Container with pre/inter/post child space.
Definition: widget_type.h:433
Scrollbar::SetPosition
void SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:700
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:162
NWidgetScrollbar
Nested widget to display and control a scrollbar in a window.
Definition: widget_type.h:749
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:640
NWidgetBackground::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1836
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
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:1934
NWidgetPIPContainer::flags
NWidContainerFlags flags
Flags of the container.
Definition: widget_type.h:443
NDB_SHADE_GREY
@ NDB_SHADE_GREY
Shade viewport to grey-scale.
Definition: widget_type.h:255
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:446
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:165
NWidgetBase::StoreSizePosition
void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
Store size and position.
Definition: widget_type.h:216
NWidgetVertical
Vertical container.
Definition: widget_type.h:476
NWidgetBackground::child
NWidgetPIPContainer * child
Child widget.
Definition: widget_type.h:562
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:630
NWidgetPart::data_tip
NWidgetPartDataTip data_tip
Part with a data/tooltip.
Definition: widget_type.h:913
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:463
NWidgetHorizontalLTR::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
Definition: widget.cpp:1295
NWidgetCore::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:302
NWidgetMatrix::widget_h
int widget_h
The height of the child widget including inter spacing.
Definition: widget_type.h:516
NWidgetCore::highlight_colour
TextColour highlight_colour
Colour of highlight.
Definition: widget_type.h:307
NCB_EQUALSIZE
@ NCB_EQUALSIZE
Containers should keep all their (resizing) children equally large.
Definition: widget_type.h:425
Scrollbar::stepsize
uint16 stepsize
Distance to scroll, when pressing the buttons or using the wheel.
Definition: widget_type.h:594
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:367
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:182
NC_NONE
@ NC_NONE
All flags cleared.
Definition: widget_type.h:427
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:306
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:1445
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:1980
StackedZeroSizePlanes
StackedZeroSizePlanes
Display planes with zero size for NWidgetStacked.
Definition: widget_type.h:386
NWidgetHorizontalLTR::NWidgetHorizontalLTR
NWidgetHorizontalLTR(NWidContainerFlags flags=NC_NONE)
Horizontal left-to-right container widget.
Definition: widget.cpp:1290
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
NWidgetResizeBase::min_x
uint min_x
Minimal horizontal size of only this widget.
Definition: widget_type.h:244
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
ND_SCROLLBAR_UP
@ ND_SCROLLBAR_UP
Bit value of the 'scrollbar up' flag.
Definition: widget_type.h:272
Scrollbar::SS_BIG
@ SS_BIG
Step in cap units.
Definition: widget_type.h:601
Scrollbar::SetStepSize
void SetStepSize(uint16 stepsize)
Set the distance to scroll when using the buttons or the wheel.
Definition: widget_type.h:658
NWidgetScrollbar::NWidgetScrollbar
NWidgetScrollbar(WidgetType tp, Colours colour, int index)
Scrollbar widget.
Definition: widget.cpp:1996
ND_SHADE_GREY
@ ND_SHADE_GREY
Bit value of the 'shade to grey' flag.
Definition: widget_type.h:269
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:713
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
NWidgetPart::type
WidgetType type
Type of the part.
Definition: widget_type.h:910
NWidgetResizeBase::min_y
uint min_y
Minimal vertical size of only this widget.
Definition: widget_type.h:245
NWidgetHorizontalLTR
Horizontal container that doesn't change the direction of the widgets for RTL languages.
Definition: widget_type.h:465
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:515
NWidgetBase::padding_bottom
uint8 padding_bottom
Paddings added to the bottom of the widget. Managed by parent container widget.
Definition: widget_type.h:183
NWidgetBackground::Add
void Add(NWidgetBase *nwid)
Add a child to the parent.
Definition: widget.cpp:1738
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:276
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:424
SZSP_VERTICAL
@ SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:387
MatrixWidgetValues
MatrixWidgetValues
Bits of the WWT_MATRIX widget data.
Definition: widget_type.h:23
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:544
NDB_DISABLED
@ NDB_DISABLED
Widget is disabled (greyed out) bit.
Definition: widget_type.h:252
NWidgetVertical::NWidgetVertical
NWidgetVertical(NWidContainerFlags flags=NC_NONE)
Vertical container widget.
Definition: widget.cpp:1301
NWidgetViewport::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1910
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:303
NWidgetMatrix::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:510
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:282
NWidgetLeaf::closebox_dimension
static Dimension closebox_dimension
Cached size of a closebox widget.
Definition: widget_type.h:782
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
NWidgetPartDataTip::tooltip
StringID tooltip
Tooltip of the widget.
Definition: widget_type.h:859
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:2400
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:164
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:867
NWidgetPartPaddings::left
uint8 left
Paddings for all directions.
Definition: widget_type.h:876
NWidgetPartTextLines::size
FontSize size
Font size of text lines.
Definition: widget_type.h:894
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:172
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:419
NWidgetMatrix::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: widget.cpp:1571
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:2872
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:762
NWidgetLeaf::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: widget.cpp:2206
NWidgetScrollbar::Draw
void Draw(const Window *w) override
Definition: widget.cpp:2033
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:2541
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:2821
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:1830
NWidgetCore::SetDisabled
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:351
ND_SCROLLBAR_BTN
@ ND_SCROLLBAR_BTN
Bit value of the 'scrollbar up' or 'scrollbar down' flag.
Definition: widget_type.h:274
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:858
NWidgetMatrix::widgets_x
int widgets_x
The number of visible widgets in horizontal direction.
Definition: widget_type.h:517
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:964
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:268
NWidgetPart::text_lines
NWidgetPartTextLines text_lines
Part with text line data.
Definition: widget_type.h:917
NDB_DROPDOWN_ACTIVE
@ NDB_DROPDOWN_ACTIVE
Dropdown menu of the button dropdown widget is active.
Definition: widget_type.h:258
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:903
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1494
WPT_ENDCONTAINER
@ WPT_ENDCONTAINER
Widget part to denote end of a container.
Definition: widget_type.h:92