OpenTTD
dropdown.cpp
Go to the documentation of this file.
1 /* $Id$ */
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 #include "../stdafx.h"
13 #include "../window_gui.h"
14 #include "../string_func.h"
15 #include "../strings_func.h"
16 #include "../window_func.h"
17 #include "../guitimer_func.h"
18 #include "dropdown_type.h"
19 
20 #include "dropdown_widget.h"
21 
22 #include "../safeguards.h"
23 
24 
25 void DropDownListItem::Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
26 {
27  int c1 = _colour_gradient[bg_colour][3];
28  int c2 = _colour_gradient[bg_colour][7];
29 
30  int mid = top + this->Height(0) / 2;
31  GfxFillRect(left + 1, mid - 2, right - 1, mid - 2, c1);
32  GfxFillRect(left + 1, mid - 1, right - 1, mid - 1, c2);
33 }
34 
35 uint DropDownListStringItem::Width() const
36 {
37  char buffer[512];
38  GetString(buffer, this->String(), lastof(buffer));
39  return GetStringBoundingBox(buffer).width;
40 }
41 
42 void DropDownListStringItem::Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
43 {
44  DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, this->String(), sel ? TC_WHITE : TC_BLACK);
45 }
46 
54 /* static */ int DropDownListStringItem::NatSortFunc(const DropDownListItem * const *first, const DropDownListItem * const * second)
55 {
56  char buffer1[512], buffer2[512];
57  GetString(buffer1, static_cast<const DropDownListStringItem*>(*first)->String(), lastof(buffer1));
58  GetString(buffer2, static_cast<const DropDownListStringItem*>(*second)->String(), lastof(buffer2));
59  return strnatcmp(buffer1, buffer2);
60 }
61 
62 StringID DropDownListParamStringItem::String() const
63 {
64  for (uint i = 0; i < lengthof(this->decode_params); i++) SetDParam(i, this->decode_params[i]);
65  return this->string;
66 }
67 
68 StringID DropDownListCharStringItem::String() const
69 {
70  SetDParamStr(0, this->raw_string);
71  return this->string;
72 }
73 
74 static const NWidgetPart _nested_dropdown_menu_widgets[] = {
77  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_DM_SHOW_SCROLL),
79  EndContainer(),
80  EndContainer(),
81 };
82 
83 static WindowDesc _dropdown_desc(
84  WDP_MANUAL, NULL, 0, 0,
87  _nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets)
88 );
89 
95  const DropDownList *list;
97  byte click_delay;
98  bool drag_mode;
100  int scrolling;
103  Scrollbar *vscroll;
104 
117  DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
118  : Window(&_dropdown_desc)
119  {
120  assert(list->Length() > 0);
121 
122  this->position = position;
123 
124  this->CreateNestedTree();
125 
126  this->vscroll = this->GetScrollbar(WID_DM_SCROLL);
127 
128  uint items_width = size.width - (scroll ? NWidgetScrollbar::GetVerticalDimension().width : 0);
129  NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_DM_ITEMS);
130  nwi->SetMinimalSize(items_width, size.height + 4);
131  nwi->colour = wi_colour;
132 
133  nwi = this->GetWidget<NWidgetCore>(WID_DM_SCROLL);
134  nwi->colour = wi_colour;
135 
136  this->GetWidget<NWidgetStacked>(WID_DM_SHOW_SCROLL)->SetDisplayedPlane(scroll ? 0 : SZSP_NONE);
137 
138  this->FinishInitNested(0);
139  CLRBITS(this->flags, WF_WHITE_BORDER);
140 
141  /* Total length of list */
142  int list_height = 0;
143  for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
144  const DropDownListItem *item = *it;
145  list_height += item->Height(items_width);
146  }
147 
148  /* Capacity is the average number of items visible */
149  this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);
150  this->vscroll->SetCount((uint16)list->Length());
151 
152  this->parent_wnd_class = parent->window_class;
153  this->parent_wnd_num = parent->window_number;
154  this->parent_button = button;
155  this->list = list;
156  this->selected_index = selected;
157  this->click_delay = 0;
158  this->drag_mode = true;
159  this->instant_close = instant_close;
160  this->scrolling_timer = GUITimer(MILLISECONDS_PER_TICK);
161  }
162 
163  ~DropdownWindow()
164  {
165  /* Make the dropdown "invisible", so it doesn't affect new window placement.
166  * Also mark it dirty in case the callback deals with the screen. (e.g. screenshots). */
167  this->window_class = WC_INVALID;
168  this->SetDirty();
169 
170  Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
171  if (w2 != NULL) {
172  Point pt = _cursor.pos;
173  pt.x -= w2->left;
174  pt.y -= w2->top;
175  w2->OnDropdownClose(pt, this->parent_button, this->selected_index, this->instant_close);
176  }
177  delete this->list;
178  }
179 
180  virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
181  {
182  return this->position;
183  }
184 
190  bool GetDropDownItem(int &value)
191  {
192  if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) < 0) return false;
193 
194  NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_DM_ITEMS);
195  int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
196  int width = nwi->current_x - 4;
197  int pos = this->vscroll->GetPosition();
198 
199  const DropDownList *list = this->list;
200 
201  for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
202  /* Skip items that are scrolled up */
203  if (--pos >= 0) continue;
204 
205  const DropDownListItem *item = *it;
206  int item_height = item->Height(width);
207 
208  if (y < item_height) {
209  if (item->masked || !item->Selectable()) return false;
210  value = item->result;
211  return true;
212  }
213 
214  y -= item_height;
215  }
216 
217  return false;
218  }
219 
220  virtual void DrawWidget(const Rect &r, int widget) const
221  {
222  if (widget != WID_DM_ITEMS) return;
223 
224  Colours colour = this->GetWidget<NWidgetCore>(widget)->colour;
225 
226  int y = r.top + 2;
227  int pos = this->vscroll->GetPosition();
228  for (const DropDownListItem * const *it = this->list->Begin(); it != this->list->End(); ++it) {
229  const DropDownListItem *item = *it;
230  int item_height = item->Height(r.right - r.left + 1);
231 
232  /* Skip items that are scrolled up */
233  if (--pos >= 0) continue;
234 
235  if (y + item_height < r.bottom) {
236  bool selected = (this->selected_index == item->result);
237  if (selected) GfxFillRect(r.left + 2, y, r.right - 1, y + item_height - 1, PC_BLACK);
238 
239  item->Draw(r.left, r.right, y, y + item_height, selected, colour);
240 
241  if (item->masked) {
242  GfxFillRect(r.left + 1, y, r.right - 1, y + item_height - 1, _colour_gradient[colour][5], FILLRECT_CHECKER);
243  }
244  }
245  y += item_height;
246  }
247  }
248 
249  virtual void OnClick(Point pt, int widget, int click_count)
250  {
251  if (widget != WID_DM_ITEMS) return;
252  int item;
253  if (this->GetDropDownItem(item)) {
254  this->click_delay = 4;
255  this->selected_index = item;
256  this->SetDirty();
257  }
258  }
259 
260  virtual void OnRealtimeTick(uint delta_ms)
261  {
262  if (!this->scrolling_timer.Elapsed(delta_ms)) return;
263  this->scrolling_timer.SetInterval(MILLISECONDS_PER_TICK);
264 
265  if (this->scrolling != 0) {
266  int pos = this->vscroll->GetPosition();
267 
268  this->vscroll->UpdatePosition(this->scrolling);
269  this->scrolling = 0;
270 
271  if (pos != this->vscroll->GetPosition()) {
272  this->SetDirty();
273  }
274  }
275  }
276 
277  virtual void OnMouseLoop()
278  {
279  Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
280  if (w2 == NULL) {
281  delete this;
282  return;
283  }
284 
285  if (this->click_delay != 0 && --this->click_delay == 0) {
286  /* Make the dropdown "invisible", so it doesn't affect new window placement.
287  * Also mark it dirty in case the callback deals with the screen. (e.g. screenshots). */
288  this->window_class = WC_INVALID;
289  this->SetDirty();
290 
291  w2->OnDropdownSelect(this->parent_button, this->selected_index);
292  delete this;
293  return;
294  }
295 
296  if (this->drag_mode) {
297  int item;
298 
299  if (!_left_button_clicked) {
300  this->drag_mode = false;
301  if (!this->GetDropDownItem(item)) {
302  if (this->instant_close) delete this;
303  return;
304  }
305  this->click_delay = 2;
306  } else {
307  if (_cursor.pos.y <= this->top + 2) {
308  /* Cursor is above the list, set scroll up */
309  this->scrolling = -1;
310  return;
311  } else if (_cursor.pos.y >= this->top + this->height - 2) {
312  /* Cursor is below list, set scroll down */
313  this->scrolling = 1;
314  return;
315  }
316 
317  if (!this->GetDropDownItem(item)) return;
318  }
319 
320  if (this->selected_index != item) {
321  this->selected_index = item;
322  this->SetDirty();
323  }
324  }
325  }
326 };
327 
342 void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
343 {
345 
346  /* The preferred position is just below the dropdown calling widget */
347  int top = w->top + wi_rect.bottom + 1;
348 
349  /* The preferred width equals the calling widget */
350  uint width = wi_rect.right - wi_rect.left + 1;
351 
352  /* Longest item in the list, if auto_width is enabled */
353  uint max_item_width = 0;
354 
355  /* Total height of list */
356  uint height = 0;
357 
358  for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
359  const DropDownListItem *item = *it;
360  height += item->Height(width);
361  if (auto_width) max_item_width = max(max_item_width, item->Width() + 5);
362  }
363 
364  /* Scrollbar needed? */
365  bool scroll = false;
366 
367  /* Is it better to place the dropdown above the widget? */
368  bool above = false;
369 
370  /* Available height below (or above, if the dropdown is placed above the widget). */
371  uint available_height = (uint)max(GetMainViewBottom() - top - 4, 0);
372 
373  /* If the dropdown doesn't fully fit below the widget... */
374  if (height > available_height) {
375 
376  uint available_height_above = (uint)max(w->top + wi_rect.top - GetMainViewTop() - 4, 0);
377 
378  /* Put the dropdown above if there is more available space. */
379  if (available_height_above > available_height) {
380  above = true;
381  available_height = available_height_above;
382  }
383 
384  /* If the dropdown doesn't fully fit, we need a dropdown. */
385  if (height > available_height) {
386  scroll = true;
387  uint avg_height = height / list->Length();
388 
389  /* Check at least there is space for one item. */
390  assert(available_height >= avg_height);
391 
392  /* Fit the list. */
393  uint rows = available_height / avg_height;
394  height = rows * avg_height;
395 
396  /* Add space for the scrollbar. */
397  max_item_width += NWidgetScrollbar::GetVerticalDimension().width;
398  }
399 
400  /* Set the top position if needed. */
401  if (above) {
402  top = w->top + wi_rect.top - height - 4;
403  }
404  }
405 
406  if (auto_width) width = max(width, max_item_width);
407 
408  Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - (int)width : wi_rect.left), top};
409  Dimension dw_size = {width, height};
410  DropdownWindow *dropdown = new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
411 
412  /* The dropdown starts scrolling downwards when opening it towards
413  * the top and holding down the mouse button. It can be fooled by
414  * opening the dropdown scrolled to the very bottom. */
415  if (above && scroll) dropdown->vscroll->UpdatePosition(INT_MAX);
416 }
417 
431 void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
432 {
433  /* Our parent's button widget is used to determine where to place the drop
434  * down list window. */
435  Rect wi_rect;
436  NWidgetCore *nwi = w->GetWidget<NWidgetCore>(button);
437  wi_rect.left = nwi->pos_x;
438  wi_rect.right = nwi->pos_x + nwi->current_x - 1;
439  wi_rect.top = nwi->pos_y;
440  wi_rect.bottom = nwi->pos_y + nwi->current_y - 1;
441  Colours wi_colour = nwi->colour;
442 
443  if ((nwi->type & WWT_MASK) == NWID_BUTTON_DROPDOWN) {
445  } else {
446  w->LowerWidget(button);
447  }
448  w->SetWidgetDirty(button);
449 
450  if (width != 0) {
451  if (_current_text_dir == TD_RTL) {
452  wi_rect.left = wi_rect.right + 1 - width;
453  } else {
454  wi_rect.right = wi_rect.left + width - 1;
455  }
456  }
457 
458  ShowDropDownListAt(w, list, selected, button, wi_rect, wi_colour, auto_width, instant_close);
459 }
460 
472 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
473 {
474  DropDownList *list = new DropDownList();
475 
476  for (uint i = 0; strings[i] != INVALID_STRING_ID; i++) {
477  if (!HasBit(hidden_mask, i)) {
478  *list->Append() = new DropDownListStringItem(strings[i], i, HasBit(disabled_mask, i));
479  }
480  }
481 
482  /* No entries in the list? */
483  if (list->Length() == 0) {
484  delete list;
485  return;
486  }
487 
488  ShowDropDownList(w, list, selected, button, width);
489 }
490 
497 {
498  Window *w;
499  FOR_ALL_WINDOWS_FROM_BACK(w) {
500  if (w->window_class != WC_DROPDOWN_MENU) continue;
501 
502  DropdownWindow *dw = dynamic_cast<DropdownWindow*>(w);
503  assert(dw != NULL);
504  if (pw->window_class == dw->parent_wnd_class &&
505  pw->window_number == dw->parent_wnd_num) {
506  int parent_button = dw->parent_button;
507  delete dw;
508  return parent_button;
509  }
510  }
511 
512  return -1;
513 }
514 
Colours colour
Colour of this widget.
Definition: widget_type.h:303
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Definition: gfx.cpp:113
Point pos
logical mouse position
Definition: gfx_type.h:119
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
Definition: dropdown.cpp:180
High level window description.
Definition: window_gui.h:168
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:817
int left
x position of left edge of the window
Definition: window_gui.h:319
Scrollbar data structure.
Definition: widget_type.h:589
bool instant_close
Close the window when the mouse button is raised.
Definition: dropdown.cpp:99
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:581
Horizontal container.
Definition: widget_type.h:75
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1114
bool Elapsed(uint delta)
Test if a timer has elapsed.
Definition: guitimer_func.h:57
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:53
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:163
WindowClass parent_wnd_class
Parent window class.
Definition: dropdown.cpp:92
int selected_index
Index of the selected item in the list.
Definition: dropdown.cpp:96
int top
y position of top edge of the window
Definition: window_gui.h:320
const T * Begin() const
Get the pointer to the first item (const)
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
Definition: dropdown.cpp:277
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
WindowClass
Window classes.
Definition: window_type.h:39
#define CLRBITS(x, y)
Clears several bits in a variable.
Invalid window.
Definition: window_type.h:696
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
Common string list item.
Definition: dropdown_type.h:41
const T * End() const
Get the pointer behind the last valid item (const)
const DropDownList * list
List with dropdown menu items.
Definition: dropdown.cpp:95
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:40
T * Append(uint to_add=1)
Append an item and return it.
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:686
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:670
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Definition: window.cpp:2173
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
Data structure for an opened window.
Definition: window_gui.h:278
byte click_delay
Timer to delay selection.
Definition: dropdown.cpp:97
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:282
Bit value of the &#39;dropdown active&#39; flag.
Definition: widget_type.h:273
uint Length() const
Get the number of items in the list.
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:175
Simple vector template class, with automatic delete.
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
bool masked
Masked and unselectable item.
Definition: dropdown_type.h:27
int GetMainViewTop()
Return the top of the main view available for general use.
Definition: window.cpp:2162
Simple depressed panel.
Definition: widget_type.h:50
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Definition: gfx_type.h:306
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:476
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
Definition: window_gui.h:725
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:162
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
Baseclass for nested widgets.
Definition: widget_type.h:126
Button with a drop-down.
Definition: widget_type.h:82
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:500
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:390
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
int scrolling
If non-zero, auto-scroll the item list (one time).
Definition: dropdown.cpp:100
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:207
Drop-down menu window.
Definition: dropdown.cpp:91
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:700
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:284
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1146
WindowNumber parent_wnd_num
Parent window number.
Definition: dropdown.cpp:93
bool GetDropDownItem(int &value)
Find the dropdown item under the cursor.
Definition: dropdown.cpp:190
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: dropdown.cpp:249
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Definition: string.cpp:580
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
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:52
int result
Result code to return to window on selection.
Definition: dropdown_type.h:26
This window won&#39;t get focus/make any other window lose focus when click.
Definition: window_gui.h:212
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
Point position
Position of the topleft corner of the window.
Definition: dropdown.cpp:102
GUITimer scrolling_timer
Timer for auto-scroll of the item list.
Definition: dropdown.cpp:101
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
int parent_button
Parent widget number where the window is dropped from.
Definition: dropdown.cpp:94
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: dropdown.cpp:220
Coordinates of a point in 2D.
DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
Create a dropdown menu.
Definition: dropdown.cpp:117
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:707
WindowClass window_class
Window class.
Definition: window_gui.h:313
Specification of a rectangle with absolute coordinates of all edges.
Vertical scrollbar.
Definition: widget_type.h:84
Text is written right-to-left by default.
Definition: strings_type.h:26
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:314
Manually align the window (so no automatic location finding)
Definition: window_gui.h:155
NWidgetDisplay disp_flags
Flags that affect display and interaction with the widget.
Definition: widget_type.h:302
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Definition: window.cpp:284
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
Definition: dropdown.cpp:260
const NWID * GetWidget(uint widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition: window_gui.h:847
Window white border counter bit mask.
Definition: window_gui.h:242
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
Base list item class from which others are derived.
Definition: dropdown_type.h:24
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
Drop down menu; Window numbers:
Definition: window_type.h:151
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:631
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201
Base class for a &#39;real&#39; widget.
Definition: widget_type.h:284
static int CDECL NatSortFunc(const DropDownListItem *const *first, const DropDownListItem *const *second)
Natural sorting comparator function for DropDownList::sort().
Definition: dropdown.cpp:54