OpenTTD

widget_type.h
Go to the documentation of this file.
1 /* $Id: widget_type.h 27900 2017-08-27 11:48:38Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef WIDGET_TYPE_H
13 #define WIDGET_TYPE_H
14
15 #include "core/alloc_type.hpp"
16 #include "core/bitmath_func.hpp"
17 #include "core/math_func.hpp"
18 #include "strings_type.h"
19 #include "gfx_type.h"
20 #include "window_type.h"
21
22 static const int WIDGET_LIST_END = -1;
23
25 enum MatrixWidgetValues {
26 /* Number of column bits of the WWT_MATRIX widget data. */
27 MAT_COL_START = 0,
28 MAT_COL_BITS = 8,
29
30 /* Number of row bits of the WWT_MATRIX widget data. */
31 MAT_ROW_START = 8,
32 MAT_ROW_BITS = 8,
33 };
34
36 enum ArrowWidgetValues {
37 AWV_DECREASE,
38 AWV_INCREASE,
39 AWV_LEFT,
40 AWV_RIGHT,
41 };
42
46 enum WidgetType {
47 /* Window widget types. */
48 WWT_EMPTY,
49
50 WWT_PANEL,
51 WWT_INSET,
52 WWT_IMGBTN,
53 WWT_IMGBTN_2,
54 WWT_ARROWBTN,
55 WWT_TEXTBTN,
56 WWT_TEXTBTN_2,
57 WWT_LABEL,
58 WWT_TEXT,
59 WWT_MATRIX,
60 WWT_FRAME,
61 WWT_CAPTION,
62
63 WWT_DEBUGBOX,
64 WWT_SHADEBOX,
65 WWT_DEFSIZEBOX,
66 WWT_STICKYBOX,
67
68 WWT_RESIZEBOX,
69 WWT_CLOSEBOX,
70 WWT_DROPDOWN,
71 WWT_EDITBOX,
72 WWT_LAST,
73
74 /* Nested widget types. */
75 NWID_HORIZONTAL,
76 NWID_HORIZONTAL_LTR,
77 NWID_VERTICAL,
78 NWID_MATRIX,
79 NWID_SPACER,
80 NWID_SELECTION,
81 NWID_VIEWPORT,
82 NWID_BUTTON_DROPDOWN,
83 NWID_HSCROLLBAR,
84 NWID_VSCROLLBAR,
85
86 /* Nested widget part types. */
87 WPT_RESIZE,
88 WPT_MINSIZE,
89 WPT_MINTEXTLINES,
90 WPT_FILL,
91 WPT_DATATIP,
92 WPT_PADDING,
93 WPT_PIPSPACE,
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 SetupSmallestSize(Window *w, bool init_array) = 0;
131 virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0;
132
133 virtual void FillNestedArray(NWidgetBase **array, uint length) = 0;
134
135 virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
136 virtual NWidgetBase *GetWidgetOfType(WidgetType tp);
137
138 virtual bool IsHighlighted() const { return false; }
139 virtual TextColour GetHighlightColour() const { return TC_INVALID; }
140 virtual void SetHighlighted(TextColour highlight_colour) {}
141
149 inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
150 {
151 this->padding_top = top;
152 this->padding_right = right;
153 this->padding_bottom = bottom;
154 this->padding_left = left;
155 }
156
157 inline uint GetHorizontalStepSize(SizingType sizing) const;
158 inline uint GetVerticalStepSize(SizingType sizing) const;
159
160 virtual void Draw(const Window *w) = 0;
161 virtual void SetDirty(const Window *w) const;
162
163 WidgetType type;
164 uint fill_x;
165 uint fill_y;
166 uint resize_x;
167 uint resize_y;
168 /* Size of the widget in the smallest window possible.
169 * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
170 */
171 uint smallest_x;
172 uint smallest_y;
173 /* Current widget size (that is, after resizing). */
174 uint current_x;
175 uint current_y;
176
177 uint pos_x;
178 uint pos_y;
179
180 NWidgetBase *next;
181 NWidgetBase *prev;
182
183 uint8 padding_top;
184 uint8 padding_right;
185 uint8 padding_bottom;
186 uint8 padding_left;
187
188 protected:
189 inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
190 };
191
196 inline uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const
197 {
198 return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
199 }
200
205 inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const
206 {
207 return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
208 }
209
218 inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
219 {
220 this->pos_x = x;
221 this->pos_y = y;
222 if (sizing == ST_SMALLEST) {
223 this->smallest_x = given_width;
224 this->smallest_y = given_height;
225 }
226 this->current_x = given_width;
227 this->current_y = given_height;
228 }
229
230
235 class NWidgetResizeBase : public NWidgetBase {
236 public:
237 NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
238
239 void SetMinimalSize(uint min_x, uint min_y);
240 void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
241 void SetFill(uint fill_x, uint fill_y);
242 void SetResize(uint resize_x, uint resize_y);
243
244 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
245
246 uint min_x;
247 uint min_y;
248 };
249
251 enum NWidgetDisplay {
252 /* Generic. */
253 NDB_LOWERED = 0,
254 NDB_DISABLED = 1,
255 /* Viewport widget. */
256 NDB_NO_TRANSPARENCY = 2,
257 NDB_SHADE_GREY = 3,
258 NDB_SHADE_DIMMED = 4,
259 /* Button dropdown widget. */
260 NDB_DROPDOWN_ACTIVE = 5,
261 /* Scrollbar widget. */
262 NDB_SCROLLBAR_UP = 6,
263 NDB_SCROLLBAR_DOWN = 7,
264 /* Generic. */
265 NDB_HIGHLIGHT = 8,
266
267 ND_LOWERED = 1 << NDB_LOWERED,
268 ND_DISABLED = 1 << NDB_DISABLED,
269 ND_HIGHLIGHT = 1 << NDB_HIGHLIGHT,
270 ND_NO_TRANSPARENCY = 1 << NDB_NO_TRANSPARENCY,
271 ND_SHADE_GREY = 1 << NDB_SHADE_GREY,
272 ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED,
273 ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE,
274 ND_SCROLLBAR_UP = 1 << NDB_SCROLLBAR_UP,
275 ND_SCROLLBAR_DOWN = 1 << NDB_SCROLLBAR_DOWN,
276 ND_SCROLLBAR_BTN = ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN,
277 };
278 DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
279
280
284 class NWidgetCore : public NWidgetResizeBase {
285 public:
286 NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
287
288 void SetIndex(int index);
289 void SetDataTip(uint32 widget_data, StringID tool_tip);
290
291 inline void SetLowered(bool lowered);
292 inline bool IsLowered() const;
293 inline void SetDisabled(bool disabled);
294 inline bool IsDisabled() const;
295
296 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
297 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
298 /* virtual */ bool IsHighlighted() const;
299 /* virtual */ TextColour GetHighlightColour() const;
300 /* virtual */ void SetHighlighted(TextColour highlight_colour);
301
302 NWidgetDisplay disp_flags;
303 Colours colour;
304 int index;
305 uint32 widget_data;
306 StringID tool_tip;
307 int scrollbar_index;
308 TextColour highlight_colour;
309 };
310
315 inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
316 {
317 this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
318 this->highlight_colour = highlight_colour;
319 }
320
322 inline bool NWidgetCore::IsHighlighted() const
323 {
324 return HasBit(this->disp_flags, NDB_HIGHLIGHT);
325 }
326
328 inline TextColour NWidgetCore::GetHighlightColour() const
329 {
330 return this->highlight_colour;
331 }
332
337 inline void NWidgetCore::SetLowered(bool lowered)
338 {
339 this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
340 }
341
343 inline bool NWidgetCore::IsLowered() const
344 {
345 return HasBit(this->disp_flags, NDB_LOWERED);
346 }
347
352 inline void NWidgetCore::SetDisabled(bool disabled)
353 {
354 this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
355 }
356
358 inline bool NWidgetCore::IsDisabled() const
359 {
360 return HasBit(this->disp_flags, NDB_DISABLED);
361 }
362
363
368 class NWidgetContainer : public NWidgetBase {
369 public:
370 NWidgetContainer(WidgetType tp);
371 ~NWidgetContainer();
372
373 void Add(NWidgetBase *wid);
374 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
375
377 inline bool IsEmpty() { return head == NULL; }
378
379 /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
380
381 protected:
382 NWidgetBase *head;
383 NWidgetBase *tail;
384 };
385
387 enum StackedZeroSizePlanes {
388 SZSP_VERTICAL = INT_MAX / 2,
389 SZSP_HORIZONTAL,
390 SZSP_NONE,
391
392 SZSP_BEGIN = SZSP_VERTICAL,
393 };
394
405 class NWidgetStacked : public NWidgetContainer {
406 public:
407 NWidgetStacked();
408
409 void SetIndex(int index);
410
411 void SetupSmallestSize(Window *w, bool init_array);
412 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
413 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
414
415 /* virtual */ void Draw(const Window *w);
416 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
417
418 void SetDisplayedPlane(int plane);
419
420 int shown_plane;
421 int index;
422 };
423
425 enum NWidContainerFlags {
426 NCB_EQUALSIZE = 0,
427
428 NC_NONE = 0,
429 NC_EQUALSIZE = 1 << NCB_EQUALSIZE,
430 };
431 DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags)
432
433
434 class NWidgetPIPContainer : public NWidgetContainer {
435 public:
436 NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE);
437
438 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
439
440 /* virtual */ void Draw(const Window *w);
441 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
442
443 protected:
444 NWidContainerFlags flags;
445 uint8 pip_pre;
446 uint8 pip_inter;
447 uint8 pip_post;
448 };
449
454 class NWidgetHorizontal : public NWidgetPIPContainer {
455 public:
456 NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
457
458 void SetupSmallestSize(Window *w, bool init_array);
459 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
460 };
461
466 class NWidgetHorizontalLTR : public NWidgetHorizontal {
467 public:
468 NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
469
470 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
471 };
472
477 class NWidgetVertical : public NWidgetPIPContainer {
478 public:
479 NWidgetVertical(NWidContainerFlags flags = NC_NONE);
480
481 void SetupSmallestSize(Window *w, bool init_array);
482 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
483 };
484
493 class NWidgetMatrix : public NWidgetPIPContainer {
494 public:
495 NWidgetMatrix();
496
497 void SetIndex(int index);
498 void SetColour(Colours colour);
499 void SetClicked(int clicked);
500 void SetCount(int count);
501 void SetScrollbar(Scrollbar *sb);
502
503 void SetupSmallestSize(Window *w, bool init_array);
504 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
505 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
506
507 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
508 /* virtual */ void Draw(const Window *w);
509 protected:
510 int index;
511 Colours colour;
512 int clicked;
513 int count;
514 Scrollbar *sb;
515 private:
516 int widget_w;
517 int widget_h;
518 int widgets_x;
519 int widgets_y;
520
521 void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
522 };
523
524
529 class NWidgetSpacer : public NWidgetResizeBase {
530 public:
531 NWidgetSpacer(int length, int height);
532
533 void SetupSmallestSize(Window *w, bool init_array);
534 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
535
536 /* virtual */ void Draw(const Window *w);
537 /* virtual */ void SetDirty(const Window *w) const;
538 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
539 };
540
545 class NWidgetBackground : public NWidgetCore {
546 public:
547 NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = NULL);
548 ~NWidgetBackground();
549
550 void Add(NWidgetBase *nwid);
551 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
552
553 void SetupSmallestSize(Window *w, bool init_array);
554 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
555
556 /* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
557
558 /* virtual */ void Draw(const Window *w);
559 /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
560 /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
561
562 private:
563 NWidgetPIPContainer *child;
564 };
565
575 class NWidgetViewport : public NWidgetCore {
576 public:
577 NWidgetViewport(int index);
578
579 /* virtual */ void SetupSmallestSize(Window *w, bool init_array);
580 /* virtual */ void Draw(const Window *w);
581
582 void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
583 void UpdateViewportCoordinates(Window *w);
584 };
585
589 class Scrollbar {
590 private:
591 const bool is_vertical;
592 uint16 count;
593 uint16 cap;
594 uint16 pos;
595 uint16 stepsize;
596
597 public:
599 enum ScrollbarStepping {
600 SS_RAW,
601 SS_SMALL,
602 SS_BIG,
603 };
604
605 Scrollbar(bool is_vertical) : is_vertical(is_vertical), stepsize(1)
606 {
607 }
608
613 inline uint16 GetCount() const
614 {
615 return this->count;
616 }
617
622 inline uint16 GetCapacity() const
623 {
624 return this->cap;
625 }
626
631 inline uint16 GetPosition() const
632 {
633 return this->pos;
634 }
635
641 inline bool IsVisible(uint16 item) const
642 {
643 return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
644 }
645
650 inline bool IsVertical() const
651 {
652 return this->is_vertical;
653 }
654
659 void SetStepSize(uint16 stepsize)
660 {
661 assert(stepsize > 0);
662 this->stepsize = stepsize;
663 }
664
670 void SetCount(int num)
671 {
672 assert(num >= 0);
673 assert(num <= MAX_UVALUE(uint16));
674
675 this->count = num;
676 num -= this->cap;
677 if (num < 0) num = 0;
678 if (num < this->pos) this->pos = num;
679 }
680
686 void SetCapacity(int capacity)
687 {
688 assert(capacity > 0);
689 assert(capacity <= MAX_UVALUE(uint16));
690
691 this->cap = capacity;
692 if (this->cap + this->pos > this->count) this->pos = max(0, this->count - this->cap);
693 }
694
695 void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
696
701 void SetPosition(int position)
702 {
703 assert(position >= 0);
704 assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
705 this->pos = position;
706 }
707
714 void UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
715 {
716 if (difference == 0) return;
717 switch (unit) {
718 case SS_SMALL: difference *= this->stepsize; break;
719 case SS_BIG: difference *= this->cap; break;
720 default: break;
721 }
722 this->SetPosition(Clamp(this->pos + difference, 0, max(this->count - this->cap, 0)));
723 }
724
731 void ScrollTowards(int position)
732 {
733 if (position < this->GetPosition()) {
734 /* scroll up to the item */
735 this->SetPosition(position);
736 } else if (position >= this->GetPosition() + this->GetCapacity()) {
737 /* scroll down so that the item is at the bottom */
738 this->SetPosition(position - this->GetCapacity() + 1);
739 }
740 }
741
742 int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const;
743 };
744
750 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
751 public:
752 NWidgetScrollbar(WidgetType tp, Colours colour, int index);
753
754 /* virtual */ void SetupSmallestSize(Window *w, bool init_array);
755 /* virtual */ void Draw(const Window *w);
756
757 static void InvalidateDimensionCache();
758 static Dimension GetVerticalDimension();
759 static Dimension GetHorizontalDimension();
760
761 private:
762 static Dimension vertical_dimension;
763 static Dimension horizontal_dimension;
764 };
765
770 class NWidgetLeaf : public NWidgetCore {
771 public:
772 NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
773
774 /* virtual */ void SetupSmallestSize(Window *w, bool init_array);
775 /* virtual */ void Draw(const Window *w);
776
777 bool ButtonHit(const Point &pt);
778
779 static void InvalidateDimensionCache();
780
781 static Dimension dropdown_dimension;
782 static Dimension resizebox_dimension;
783 static Dimension closebox_dimension;
784 private:
785 static Dimension shadebox_dimension;
786 static Dimension debugbox_dimension;
787 static Dimension defsizebox_dimension;
788 static Dimension stickybox_dimension;
789 };
790
798 static inline uint ComputeMaxSize(uint base, uint max_space, uint step)
799 {
800 if (base >= max_space || step == 0) return base;
801 if (step == 1) return max_space;
802 uint increment = max_space - base;
803 increment -= increment % step;
804 return base + increment;
805 }
806
858 struct NWidgetPartDataTip {
859 uint32 data;
860 StringID tooltip;
861 };
862
867 struct NWidgetPartWidget {
868 Colours colour;
869 int16 index;
870 };
871
876 struct NWidgetPartPaddings {
877 uint8 top, right, bottom, left;
878 };
879
884 struct NWidgetPartPIP {
885 uint8 pre, inter, post;
886 };
887
892 struct NWidgetPartTextLines {
893 uint8 lines;
894 uint8 spacing;
895 FontSize size;
896 };
897
904 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
905
910 struct NWidgetPart {
911 WidgetType type;
912 union {
913 Point xy;
914 NWidgetPartDataTip data_tip;
915 NWidgetPartWidget widget;
916 NWidgetPartPaddings padding;
917 NWidgetPartPIP pip;
918 NWidgetPartTextLines text_lines;
919 NWidgetFunctionType *func_ptr;
920 NWidContainerFlags cont_flags;
921 } u;
922 };
923
930 static inline NWidgetPart SetResize(int16 dx, int16 dy)
931 {
932 NWidgetPart part;
933
934 part.type = WPT_RESIZE;
935 part.u.xy.x = dx;
936 part.u.xy.y = dy;
937
938 return part;
939 }
940
947 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
948 {
949 NWidgetPart part;
950
951 part.type = WPT_MINSIZE;
952 part.u.xy.x = x;
953 part.u.xy.y = y;
954
955 return part;
956 }
957
965 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
966 {
967 NWidgetPart part;
968
969 part.type = WPT_MINTEXTLINES;
970 part.u.text_lines.lines = lines;
971 part.u.text_lines.spacing = spacing;
972 part.u.text_lines.size = size;
973
974 return part;
975 }
976
983 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
984 {
985 NWidgetPart part;
986
987 part.type = WPT_FILL;
988 part.u.xy.x = fill_x;
989 part.u.xy.y = fill_y;
990
991 return part;
992 }
993
999 static inline NWidgetPart EndContainer()
1000 {
1001 NWidgetPart part;
1002
1003 part.type = WPT_ENDCONTAINER;
1004
1005 return part;
1006 }
1007
1014 static inline NWidgetPart SetDataTip(uint32 data, StringID tip)
1015 {
1016 NWidgetPart part;
1017
1018 part.type = WPT_DATATIP;
1019 part.u.data_tip.data = data;
1020 part.u.data_tip.tooltip = tip;
1021
1022 return part;
1023 }
1024
1032 static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
1033 {
1034 return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip);
1035 }
1036
1046 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
1047 {
1048 NWidgetPart part;
1049
1050 part.type = WPT_PADDING;
1051 part.u.padding.top = top;
1052 part.u.padding.right = right;
1053 part.u.padding.bottom = bottom;
1054 part.u.padding.left = left;
1055
1056 return part;
1057 }
1058
1064 static inline NWidgetPart SetPadding(uint8 padding)
1065 {
1066 return SetPadding(padding, padding, padding, padding);
1067 }
1068
1076 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
1077 {
1078 NWidgetPart part;
1079
1080 part.type = WPT_PIPSPACE;
1081 part.u.pip.pre = pre;
1082 part.u.pip.inter = inter;
1083 part.u.pip.post = post;
1084
1085 return part;
1086 }
1087
1095 static inline NWidgetPart SetScrollbar(int index)
1096 {
1097 NWidgetPart part;
1098
1099 part.type = WPT_SCROLLBAR;
1100 part.u.widget.index = index;
1101
1102 return part;
1103 }
1104
1114 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
1115 {
1116 NWidgetPart part;
1117
1118 part.type = tp;
1119 part.u.widget.colour = col;
1120 part.u.widget.index = idx;
1121
1122 return part;
1123 }
1124
1131 static inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE)
1132 {
1133 NWidgetPart part;
1134
1135 part.type = tp;
1136 part.u.cont_flags = cont_flags;
1137
1138 return part;
1139 }
1140
1146 static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
1147 {
1148 NWidgetPart part;
1149
1150 part.type = WPT_FUNCTION;
1151 part.u.func_ptr = func_ptr;
1152
1153 return part;
1154 }
1155
1156 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
1157 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
1158
1159 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip);
1160
1161 #endif /* WIDGET_TYPE_H */
NWID_VIEWPORT
Nested widget containing a viewport.
Definition: widget_type.h:81
NWidgetCore::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:303
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:493
Scrollbar::pos
uint16 pos
Index of first visible item of the list.
Definition: widget_type.h:594
NWidgetLeaf::shadebox_dimension
static Dimension shadebox_dimension
Cached size of a shadebox widget.
Definition: widget_type.h:785
WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition() ...
Definition: widget_type.h:111
WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
NWidContainerFlags
NWidContainerFlags
Nested widget container flags,.
Definition: widget_type.h:425
NWidgetCore::widget_data
uint32 widget_data
Data of the widget.
Definition: widget_type.h:305
NWidgetBase::NWidgetBase
NWidgetBase(WidgetType tp)
Base class constructor.
Definition: widget.cpp:721
NWID_MATRIX
Matrix container.
Definition: widget_type.h:78
Scrollbar::SS_RAW
Step in single units.
Definition: widget_type.h:600
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:731
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
NWidgetFunctionType
NWidgetBase * NWidgetFunctionType(int *biggest_index)
Pointer to function returning a nested widget.
Definition: widget_type.h:904
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1146
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:166
MAT_COL_START
Lowest bit of the number of columns.
Definition: widget_type.h:27
NWidgetPartDataTip
Widget part for storing data and tooltip information.
Definition: widget_type.h:858
NWidgetResizeBase::min_x
uint min_x
Minimal horizontal size of only this widget.
Definition: widget_type.h:246
WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:53
MAT_COL_BITS
Number of bits for the number of columns in the matrix.
Definition: widget_type.h:28
NWidgetCore::IsHighlighted
bool IsHighlighted() const
Return whether the widget is highlighted.
Definition: widget_type.h:322
NWidgetCore::tool_tip
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:306
NWidgetMatrix::clicked
int clicked
The currently clicked widget.
Definition: widget_type.h:512
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:368
WWT_LABEL
Centered label.
Definition: widget_type.h:57
Scrollbar::cap
uint16 cap
Number of visible elements of the scroll bar.
Definition: widget_type.h:593
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:589
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:235
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:405
window_type.h
Types related to windows.
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:798
NWidgetScrollbar
Nested widget to display and control a scrollbar in a window.
Definition: widget_type.h:750
NWidgetCore::SetHighlighted
void SetHighlighted(TextColour highlight_colour)
Highlight the widget or not.
Definition: widget_type.h:315
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:38
AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:37
ND_NO_TRANSPARENCY
Bit value of the &#39;no transparency&#39; flag.
Definition: widget_type.h:270
WWT_DEBUGBOX
NewGRF debug box (at top-right of a window, between WWT_CAPTION and WWT_SHADEBOX) ...
Definition: widget_type.h:63
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:163
NWidgetScrollbar::vertical_dimension
static Dimension vertical_dimension
Cached size of vertical scrollbar button.
Definition: widget_type.h:762
NWidgetContainer::tail
NWidgetBase * tail
Pointer to last widget in container.
Definition: widget_type.h:383
NDB_SCROLLBAR_DOWN
Down-button is lowered bit.
Definition: widget_type.h:263
NWidgetPIPContainer::flags
NWidContainerFlags flags
Flags of the container.
Definition: widget_type.h:444
NWidgetLeaf::closebox_dimension
static Dimension closebox_dimension
Cached size of a closebox widget.
Definition: widget_type.h:783
Scrollbar::is_vertical
const bool is_vertical
Scrollbar has vertical orientation.
Definition: widget_type.h:591
SETBITS
#define SETBITS(x, y)
Sets several bits in a variable.
Definition: bitmath_func.hpp:138
NWidgetPIPContainer::pip_inter
uint8 pip_inter
Amount of space between widgets.
Definition: widget_type.h:446
WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:71
NWidgetStacked::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:421
WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition: widget_type.h:51
Scrollbar::SetPosition
void SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:701
NWidgetHorizontalLTR
Horizontal container that doesn&#39;t change the direction of the widgets for RTL languages.
Definition: widget_type.h:466
IsInsideBS
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:250
NDB_DROPDOWN_ACTIVE
Dropdown menu of the button dropdown widget is active.
Definition: widget_type.h:260
WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:103
WWT_ARROWBTN
(Toggle) Button with an arrow
Definition: widget_type.h:54
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
ND_SHADE_GREY
Bit value of the &#39;shade to grey&#39; flag.
Definition: widget_type.h:271
bitmath_func.hpp
Functions related to bit mathematics.
NWidgetPIPContainer::pip_post
uint8 pip_post
Amount of space after last widget.
Definition: widget_type.h:447
NWidgetPart::func_ptr
NWidgetFunctionType * func_ptr
Part with a function call.
Definition: widget_type.h:919
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:965
NWidgetLeaf::resizebox_dimension
static Dimension resizebox_dimension
Cached size of a resizebox widget.
Definition: widget_type.h:782
NWidgetPart::pip
NWidgetPartPIP pip
Part with pre/inter/post spaces.
Definition: widget_type.h:917
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:168
Scrollbar::SS_BIG
Step in cap units.
Definition: widget_type.h:602
alloc_type.hpp
Helper types related to the allocation of memory.
NWidgetSpacer
Spacer widget.
Definition: widget_type.h:529
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:171
max
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
WPT_PADDING
Widget part for specifying a padding.
Definition: widget_type.h:92
WPT_RESIZE
Widget part for specifying resizing.
Definition: widget_type.h:87
WPT_DATATIP
Widget part for specifying data and tooltip.
Definition: widget_type.h:91
NWidgetViewport
Nested widget to display a viewport in a window.
Definition: widget_type.h:575
NWidgetPart::widget
NWidgetPartWidget widget
Part with a start of a widget.
Definition: widget_type.h:915
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:2792
WWT_TEXT
Pure simple text.
Definition: widget_type.h:58
NWidgetPart::xy
Point xy
Part with an x/y size.
Definition: widget_type.h:913
NWidgetBase::GetHorizontalStepSize
uint GetHorizontalStepSize(SizingType sizing) const
Get the horizontal sizing step.
Definition: widget_type.h:196
NWidgetCore::IsDisabled
bool IsDisabled() const
Return whether the widget is disabled.
Definition: widget_type.h:358
ND_DISABLED
Bit value of the disabled flag.
Definition: widget_type.h:268
Scrollbar::SetCapacity
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:686
Scrollbar::stepsize
uint16 stepsize
Distance to scroll, when pressing the buttons or using the wheel.
Definition: widget_type.h:595
NWidgetDisplay
NWidgetDisplay
Nested widget flags that affect display and interaction withe &#39;real&#39; widgets.
Definition: widget_type.h:251
NDB_DISABLED
Widget is disabled (greyed out) bit.
Definition: widget_type.h:254
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:770
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:670
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
MakeCompanyButtonRows
NWidgetBase * MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip)
Make a number of rows with button-like graphics, for enabling/disabling each company.
Definition: widget.cpp:2864
Window
Data structure for an opened window.
Definition: window_gui.h:271
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:180
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:1032
WPT_FILL
Widget part for specifying fill.
Definition: widget_type.h:90
ArrowWidgetValues
ArrowWidgetValues
Values for an arrow widget.
Definition: widget_type.h:36
NWidgetPartDataTip::tooltip
StringID tooltip
Tooltip of the widget.
Definition: widget_type.h:860
MAT_ROW_START
Lowest bit of the number of rows.
Definition: widget_type.h:31
NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:79
NWidgetMatrix::count
int count
Amount of valid widgets.
Definition: widget_type.h:513
NWidgetPart::type
WidgetType type
Type of the part.
Definition: widget_type.h:911
ND_DROPDOWN_ACTIVE
Bit value of the &#39;dropdown active&#39; flag.
Definition: widget_type.h:273
WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:65
NWidgetBase::pos_y
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
WPT_PIPSPACE
Widget part for specifying pre/inter/post space for containers.
Definition: widget_type.h:93
NWidgetScrollbar::horizontal_dimension
static Dimension horizontal_dimension
Cached size of horizontal scrollbar button.
Definition: widget_type.h:763
NWidgetPartDataTip::data
uint32 data
Data value of the widget.
Definition: widget_type.h:859
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:337
ND_SCROLLBAR_UP
Bit value of the &#39;scrollbar up&#39; flag.
Definition: widget_type.h:274
NWidgetBase::padding_top
uint8 padding_top
Paddings added to the top of the widget. Managed by parent container widget.
Definition: widget_type.h:183
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:172
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:175
NWidgetLeaf::stickybox_dimension
static Dimension stickybox_dimension
Cached size of a stickybox widget.
Definition: widget_type.h:788
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
MAT_ROW_BITS
Number of bits for the number of rows in the matrix.
Definition: widget_type.h:32
Scrollbar::count
uint16 count
Number of elements in the list.
Definition: widget_type.h:592
SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:389
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
NDB_LOWERED
Widget is lowered (pressed down) bit.
Definition: widget_type.h:253
WPT_SCROLLBAR
Widget part for attaching a scrollbar.
Definition: widget_type.h:96
NWidgetPartPIP
Widget part for storing pre/inter/post spaces.
Definition: widget_type.h:884
NWidgetBase::GetWidgetFromPos
virtual NWidgetCore * GetWidgetFromPos(int x, int y)=0
Retrieve a widget by its position.
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:247
WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Scrollbar::ScrollbarStepping
ScrollbarStepping
Stepping sizes when scrolling.
Definition: widget_type.h:599
NWidgetVertical
Vertical container.
Definition: widget_type.h:477
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:165
WPT_FUNCTION
Widget part for calling a user function.
Definition: widget_type.h:95
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidgetPart::data_tip
NWidgetPartDataTip data_tip
Part with a data/tooltip.
Definition: widget_type.h:914
NWidgetPartWidget::index
int16 index
Widget index in the widget array.
Definition: widget_type.h:869
NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:83
NDB_NO_TRANSPARENCY
Viewport is never transparent.
Definition: widget_type.h:256
NWidgetBase::SetPadding
void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Set additional space (padding) around the widget.
Definition: widget_type.h:149
WWT_FRAME
Frame.
Definition: widget_type.h:60
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:186
NWidgetCore::scrollbar_index
int scrollbar_index
Index of an attached scrollbar.
Definition: widget_type.h:307
NWidgetLeaf::dropdown_dimension
static Dimension dropdown_dimension
Cached size of a dropdown widget.
Definition: widget_type.h:781
ND_SHADE_DIMMED
Bit value of the &#39;dimmed colours&#39; flag.
Definition: widget_type.h:272
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
ND_LOWERED
Bit value of the lowered flag.
Definition: widget_type.h:267
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
NWID_BUTTON_DROPDOWN
Button with a drop-down.
Definition: widget_type.h:82
NC_NONE
All flags cleared.
Definition: widget_type.h:428
NDB_SHADE_GREY
Shade viewport to grey-scale.
Definition: widget_type.h:257
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:167
NWidgetPIPContainer
Container with pre/inter/post child space.
Definition: widget_type.h:434
WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:59
NWidgetBase::pos_x
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:515
NWidgetPartPaddings
Widget part for storing padding.
Definition: widget_type.h:876
NWidgetBase::StoreSizePosition
void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
Store size and position.
Definition: widget_type.h:218
NWidgetBase::Draw
virtual void Draw(const Window *w)=0
Draw the widgets of the tree.
SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:390
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:181
AWV_LEFT
Force the arrow to the left.
Definition: widget_type.h:39
NWidgetBackground::child
NWidgetPIPContainer * child
Child widget.
Definition: widget_type.h:563
NWidgetLeaf::debugbox_dimension
static Dimension debugbox_dimension
Cached size of a debugbox widget.
Definition: widget_type.h:786
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:454
ZeroedMemoryAllocator
Base class that provides memory initialization on dynamically created objects.
Definition: alloc_type.hpp:150
NWidgetPartPIP::post
uint8 post
Amount of space before/between/after child widgets.
Definition: widget_type.h:885
NWidgetResizeBase::min_y
uint min_y
Minimal vertical size of only this widget.
Definition: widget_type.h:247
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
ND_HIGHLIGHT
Bit value of the highlight flag.
Definition: widget_type.h:269
NDB_HIGHLIGHT
Highlight of widget is on.
Definition: widget_type.h:265
NWidgetBase::padding_bottom
uint8 padding_bottom
Paddings added to the bottom of the widget. Managed by parent container widget.
Definition: widget_type.h:185
NWidgetCore::highlight_colour
TextColour highlight_colour
Colour of highlight.
Definition: widget_type.h:308
ST_SMALLEST
Initialize nested widget tree to smallest size. Also updates current_x and current_y.
Definition: widget_type.h:112
math_func.hpp
Integer math functions.
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets&#39; list for vararg functions
Definition: widget_type.h:22
NWidgetPart::text_lines
NWidgetPartTextLines text_lines
Part with text line data.
Definition: widget_type.h:918
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
NWidgetMatrix::colour
Colours colour
Colour of this widget.
Definition: widget_type.h:511
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:641
NWidgetMatrix::widget_h
int widget_h
The height of the child widget including inter spacing.
Definition: widget_type.h:517
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:613
NWidgetPartWidget::colour
Colours colour
Widget colour.
Definition: widget_type.h:868
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition: widget_type.h:46
Scrollbar::SS_SMALL
Step in stepsize units.
Definition: widget_type.h:601
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
Assign size and position to the widget.
NWidgetBase::GetWidgetOfType
virtual NWidgetBase * GetWidgetOfType(WidgetType tp)
Retrieve a widget by its type.
Definition: widget.cpp:795
SZSP_BEGIN
First zero-size plane.
Definition: widget_type.h:392
NWidgetCore::IsLowered
bool IsLowered() const
Return whether the widget is lowered.
Definition: widget_type.h:343
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Scrollbar::SetStepSize
void SetStepSize(uint16 stepsize)
Set the distance to scroll when using the buttons or the wheel.
Definition: widget_type.h:659
NWidgetPart::padding
NWidgetPartPaddings padding
Part with paddings.
Definition: widget_type.h:916
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:714
NCB_EQUALSIZE
Containers should keep all their (resizing) children equally large.
Definition: widget_type.h:426
WWT_LAST
Last Item. use WIDGETS_END to fill up padding!!
Definition: widget_type.h:72
NWidgetPartTextLines::spacing
uint8 spacing
Extra spacing around lines.
Definition: widget_type.h:894
ND_SCROLLBAR_BTN
Bit value of the &#39;scrollbar up&#39; or &#39;scrollbar down&#39; flag.
Definition: widget_type.h:276
NWidgetPartTextLines
Widget part for storing minimal text line data.
Definition: widget_type.h:892
NDB_SCROLLBAR_UP
Up-button is lowered bit.
Definition: widget_type.h:262
NWidgetCore::index
int index
Index of the nested widget in the widget array of the window (-1 means &#39;not used&#39;).
Definition: widget_type.h:304
NWidgetPart::cont_flags
NWidContainerFlags cont_flags
Part with container flags.
Definition: widget_type.h:920
NDB_SHADE_DIMMED
Display dimmed colours in the viewport.
Definition: widget_type.h:258
NWidgetLeaf::defsizebox_dimension
static Dimension defsizebox_dimension
Cached size of a defsizebox widget.
Definition: widget_type.h:787
NWID_VERTICAL
Vertical container.
Definition: widget_type.h:77
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
WWT_TEXTBTN_2
(Toggle) Button with diff text when clicked
Definition: widget_type.h:56
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:203
NWidgetStacked::shown_plane
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Definition: widget_type.h:420
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:204
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:2814
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:382
NWidgetCore::SetDisabled
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Definition: widget_type.h:352
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
NWidgetMatrix::index
int index
If non-negative, index in the Window::nested_array.
Definition: widget_type.h:510
WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:70
MatrixWidgetValues
MatrixWidgetValues
Bits of the WWT_MATRIX widget data.
Definition: widget_type.h:25
WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:622
strings_type.h
Types related to strings.
NWidgetMatrix::widgets_x
int widgets_x
The number of visible widgets in horizontal direction.
Definition: widget_type.h:518
NWidgetPIPContainer::pip_pre
uint8 pip_pre
Amount of space before first widget.
Definition: widget_type.h:445
NWidgetBase::SetupSmallestSize
virtual void SetupSmallestSize(Window *w, bool init_array)=0
Compute smallest size needed by the widget.
WPT_MINTEXTLINES
Widget part for specifying minimal number of lines of text.
Definition: widget_type.h:89
WPT_ENDCONTAINER
Widget part to denote end of a container.
Definition: widget_type.h:94
NWidgetMatrix::sb
Scrollbar * sb
The scrollbar we&#39;re associated with.
Definition: widget_type.h:514
SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:388
WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
NWidgetBase::GetVerticalStepSize
uint GetVerticalStepSize(SizingType sizing) const
Get the vertical sizing step.
Definition: widget_type.h:205
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:105
AWV_RIGHT
Force the arrow to the right.
Definition: widget_type.h:40
NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:84
StackedZeroSizePlanes
StackedZeroSizePlanes
Display planes with zero size for NWidgetStacked.
Definition: widget_type.h:387
ST_RESIZE
Resize the nested widget tree.
Definition: widget_type.h:113
WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:52
NWidgetPartWidget
Widget part for storing basic widget information.
Definition: widget_type.h:867
NWidgetCore::disp_flags
NWidgetDisplay disp_flags
Flags that affect display and interaction with the widget.
Definition: widget_type.h:302
NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
NWidgetPartPaddings::left
uint8 left
Paddings for all directions.
Definition: widget_type.h:877
NWidgetPartTextLines::lines
uint8 lines
Number of text lines.
Definition: widget_type.h:893
NWidgetPartTextLines::size
FontSize size
Font size of text lines.
Definition: widget_type.h:895
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:184
NWidgetCore::GetHighlightColour
TextColour GetHighlightColour() const
Return the colour of the highlight.
Definition: widget_type.h:328
NWidgetBase::SetDirty
virtual void SetDirty(const Window *w) const
Mark the widget as &#39;dirty&#39; (in need of repaint).
Definition: widget.cpp:775
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:164
Scrollbar::IsVertical
bool IsVertical() const
Is the scrollbar vertical or not?
Definition: widget_type.h:650
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34
NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
ND_SCROLLBAR_DOWN
Bit value of the &#39;scrollbar down&#39; flag.
Definition: widget_type.h:275
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:545
WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64
WPT_MINSIZE
Widget part for specifying minimal size.
Definition: widget_type.h:88
NWidgetMatrix::widget_w
int widget_w
The width of the child widget including inter spacing.
Definition: widget_type.h:516
NWID_HORIZONTAL_LTR
Horizontal container that doesn&#39;t change the order of the widgets for RTL languages.
Definition: widget_type.h:76
gfx_type.h
Types related to the graphics and/or input devices.
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076
NWidgetContainer::IsEmpty
bool IsEmpty()
Return whether the container is empty.
Definition: widget_type.h:377
WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:55
NWidgetMatrix::widgets_y
int widgets_y
The number of visible widgets in vertical direction.
Definition: widget_type.h:519
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:631
NWidgetCore
Base class for a &#39;real&#39; widget.
Definition: widget_type.h:284