22 #include "table/strings.h"
39 int rev_base = top + bottom;
42 button_size = NWidgetScrollbar::GetHorizontalDimension().width;
44 button_size = NWidgetScrollbar::GetVerticalDimension().height;
47 bottom -= button_size;
49 int height = (bottom - top);
54 if (count != 0) top += height * pos / count;
56 if (cap > count) cap = count;
57 if (count != 0) bottom -= (count - pos - cap) * height / count;
61 pt.x = rev_base - bottom;
62 pt.y = rev_base - top;
88 button_size = NWidgetScrollbar::GetHorizontalDimension().width;
91 button_size = NWidgetScrollbar::GetVerticalDimension().height;
93 if (pos < mi + button_size) {
96 if (_scroller_click_timeout <= 1) {
97 _scroller_click_timeout = 3;
101 }
else if (pos >= ma - button_size) {
105 if (_scroller_click_timeout <= 1) {
106 _scroller_click_timeout = 3;
115 }
else if (pos > pt.y) {
118 _scrollbar_start_pos = pt.x - mi - button_size;
119 _scrollbar_size = ma - mi - button_size * 2;
121 _cursorpos_drag_start = _cursor.
pos;
148 assert(scrollbar !=
nullptr);
163 return (nw !=
nullptr) ? nw->
index : -1;
177 assert(colour < COLOUR_END);
194 interior = (flags &
FR_DARKENED ? medium_dark : medium_light);
200 interior = medium_dark;
221 if ((type & WWT_MASK) ==
WWT_IMGBTN_2 && clicked) img++;
235 if (str == STR_NULL)
return;
238 int offset = std::max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2);
251 int offset = std::max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2);
252 if (str != STR_NULL)
DrawString(r.left, r.right, r.top + offset, str, colour);
276 static inline void DrawMatrix(
const Rect &r, Colours colour,
bool clicked, uint16 data, uint resize_x, uint resize_y)
282 if (num_columns == 0) {
283 column_width = resize_x;
284 num_columns = (r.right - r.left + 1) / column_width;
286 column_width = (r.right - r.left + 1) / num_columns;
292 row_height = resize_y;
293 num_rows = (r.bottom - r.top + 1) / row_height;
295 row_height = (r.bottom - r.top + 1) / num_rows;
301 for (
int ctr = num_columns; ctr > 1; ctr--) {
307 for (
int ctr = num_rows; ctr > 1; ctr--) {
315 for (
int ctr = num_columns; ctr > 1; ctr--) {
321 for (
int ctr = num_rows; ctr > 1; ctr--) {
338 int centre = (r.right - r.left) / 2;
339 int height = NWidgetScrollbar::GetVerticalDimension().height;
343 DrawSprite(SPR_ARROW_UP, PAL_NONE, r.left + 1 + up_clicked, r.top + 1 + up_clicked);
345 DrawFrameRect(r.left, r.bottom - (height - 1), r.right, r.bottom, colour, (down_clicked) ?
FR_LOWERED : FR_NONE);
346 DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + down_clicked, r.bottom - (height - 2) + down_clicked);
352 GfxFillRect(r.left, r.top + height, r.right, r.bottom - height, c2);
356 GfxFillRect(r.left + centre - 3, r.top + height, r.left + centre - 3, r.bottom - height, c1);
357 GfxFillRect(r.left + centre - 2, r.top + height, r.left + centre - 2, r.bottom - height, c2);
358 GfxFillRect(r.left + centre + 2, r.top + height, r.left + centre + 2, r.bottom - height, c1);
359 GfxFillRect(r.left + centre + 3, r.top + height, r.left + centre + 3, r.bottom - height, c2);
376 int centre = (r.bottom - r.top) / 2;
377 int width = NWidgetScrollbar::GetHorizontalDimension().width;
380 DrawSprite(SPR_ARROW_LEFT, PAL_NONE, r.left + 1 + left_clicked, r.top + 1 + left_clicked);
383 DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, r.right - (width - 2) + right_clicked, r.top + 1 + right_clicked);
389 GfxFillRect(r.left + width, r.top, r.right - width, r.bottom, c2);
393 GfxFillRect(r.left + width, r.top + centre - 3, r.right - width, r.top + centre - 3, c1);
394 GfxFillRect(r.left + width, r.top + centre - 2, r.right - width, r.top + centre - 2, c2);
395 GfxFillRect(r.left + width, r.top + centre + 2, r.right - width, r.top + centre + 2, c1);
396 GfxFillRect(r.left + width, r.top + centre + 3, r.right - width, r.top + centre + 3, c2);
425 GfxFillRect(r.left, r.top + dy1, r.left + 4, r.top + dy1, c1);
426 GfxFillRect(r.left + 1, r.top + dy2, r.left + 4, r.top + dy2, c2);
429 GfxFillRect(x2, r.top + dy1, r.right - 1, r.top + dy1, c1);
430 GfxFillRect(x2, r.top + dy2, r.right - 2, r.top + dy2, c2);
433 GfxFillRect(r.left, r.top + dy1, x2 - 2, r.top + dy1, c1);
434 GfxFillRect(r.left + 1, r.top + dy2, x2 - 2, r.top + dy2, c2);
437 GfxFillRect(r.right - 5, r.top + dy1, r.right - 1, r.top + dy1, c1);
438 GfxFillRect(r.right - 5, r.top + dy2, r.right - 2, r.top + dy2, c2);
442 GfxFillRect(r.left, r.top + dy2, r.left, r.bottom - 1, c1);
443 GfxFillRect(r.left + 1, r.top + dy2 + 1, r.left + 1, r.bottom - 2, c2);
446 GfxFillRect(r.right - 1, r.top + dy2, r.right - 1, r.bottom - 2, c1);
447 GfxFillRect(r.right, r.top + dy1, r.right, r.bottom - 1, c2);
449 GfxFillRect(r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1, c1);
450 GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
525 if (colour != COLOUR_WHITE)
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
549 if (str != STR_NULL) {
551 int offset = std::max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2);
568 int text_offset = std::max(0, ((
int)(r.bottom - r.top + 1) -
FONT_HEIGHT_NORMAL) / 2);
572 int image_offset = std::max(0, ((
int)(r.bottom - r.top + 1) - dd_height) / 2);
576 DrawFrameRect(r.right + 1 - dd_width, r.top, r.right, r.bottom, colour, clicked_dropdown ?
FR_LOWERED : FR_NONE);
577 DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.right - (dd_width - 2) + clicked_dropdown, r.top + image_offset + clicked_dropdown);
581 DrawFrameRect(r.left, r.top, r.left + dd_width - 1, r.bottom, colour, clicked_dropdown ?
FR_LOWERED : FR_NONE);
582 DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + clicked_dropdown, r.top + image_offset + clicked_dropdown);
613 const NWidgetBase *widget = this->GetWidget<NWidgetBase>(i);
614 if (widget ==
nullptr || !widget->IsHighlighted())
continue;
641 const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
644 Dimension dim = NWidgetScrollbar::GetVerticalDimension();
647 int y = offset + nwid->
pos_y + (nwid->
current_y - dim.height) / 2;
658 return NWidgetScrollbar::GetVerticalDimension().width + 1;
795 return (this->
type == tp) ? this :
nullptr;
817 this->min_x = std::max(this->min_x,
min_x);
818 this->min_y = std::max(this->min_y,
min_y);
909 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
923 this->
head =
nullptr;
924 this->
tail =
nullptr;
927 NWidgetContainer::~NWidgetContainer()
929 while (this->
head !=
nullptr) {
934 this->
tail =
nullptr;
939 if (this->
type == tp)
return this;
940 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
942 if (nwid !=
nullptr)
return nwid;
953 assert(wid->
next ==
nullptr && wid->
prev ==
nullptr);
955 if (this->
head ==
nullptr) {
959 assert(this->
tail !=
nullptr);
960 assert(this->
tail->
next ==
nullptr);
970 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
971 child_wid->FillNestedArray(array, length);
983 void NWidgetStacked::SetIndex(
int index)
990 if (this->
index >= 0 && init_array) {
1006 this->
fill_x = fill.width;
1007 this->
fill_y = fill.height;
1016 this->
fill_x = (this->
head !=
nullptr) ? 1 : 0;
1017 this->
fill_y = (this->
head !=
nullptr) ? 1 : 0;
1020 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1021 child_wid->SetupSmallestSize(w, init_array);
1023 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1024 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1039 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1040 uint hor_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
1041 uint child_width =
ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step);
1042 uint child_pos_x = (rtl ? child_wid->padding_right : child_wid->padding_left);
1044 uint vert_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
1045 uint child_height =
ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step);
1046 uint child_pos_y = child_wid->padding_top;
1048 child_wid->AssignSizePosition(sizing, x + child_pos_x, y + child_pos_y, child_width, child_height, rtl);
1054 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
1063 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; plane++, child_wid = child_wid->
next) {
1079 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; plane++, child_wid = child_wid->
next) {
1098 this->flags = flags;
1119 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1128 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1130 if (nwid !=
nullptr)
return nwid;
1151 uint max_vert_fill = 0;
1152 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1153 child_wid->SetupSmallestSize(w, init_array);
1154 longest = std::max(longest, child_wid->smallest_x);
1155 max_vert_fill = std::max(max_vert_fill, child_wid->GetVerticalStepSize(
ST_SMALLEST));
1156 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1160 uint max_smallest = this->
smallest_y + 3 * max_vert_fill;
1164 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1165 uint step_size = child_wid->GetVerticalStepSize(
ST_SMALLEST);
1166 uint child_height = child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1167 if (step_size > 1 && child_height < cur_height) {
1168 uint remainder = (cur_height - child_height) % step_size;
1169 if (remainder > 0) {
1170 cur_height += step_size - remainder;
1171 assert(cur_height < max_smallest);
1181 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1182 if (child_wid->fill_x == 1) child_wid->smallest_x = longest;
1187 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1188 if (child_wid->next !=
nullptr) {
1189 child_wid->padding_right += this->
pip_inter;
1191 child_wid->padding_right += this->
pip_post;
1194 this->
smallest_x += child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
1195 if (child_wid->fill_x > 0) {
1196 if (this->
fill_x == 0 || this->
fill_x > child_wid->fill_x) this->
fill_x = child_wid->fill_x;
1200 if (child_wid->resize_x > 0) {
1214 uint additional_length = given_width;
1217 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1218 additional_length -= child_wid->smallest_x + child_wid->padding_right + child_wid->padding_left;
1240 int num_changing_childs = 0;
1241 uint biggest_stepsize = 0;
1242 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1243 uint hor_step = child_wid->GetHorizontalStepSize(sizing);
1245 num_changing_childs++;
1246 biggest_stepsize = std::max(biggest_stepsize, hor_step);
1248 child_wid->current_x = child_wid->smallest_x;
1251 uint vert_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
1252 child_wid->current_y =
ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step);
1256 while (biggest_stepsize > 0) {
1257 uint next_biggest_stepsize = 0;
1258 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1259 uint hor_step = child_wid->GetHorizontalStepSize(sizing);
1260 if (hor_step > biggest_stepsize)
continue;
1261 if (hor_step == biggest_stepsize) {
1262 uint increment = additional_length / num_changing_childs;
1263 num_changing_childs--;
1264 if (hor_step > 1) increment -= increment % hor_step;
1265 child_wid->current_x = child_wid->smallest_x + increment;
1266 additional_length -= increment;
1269 next_biggest_stepsize = std::max(next_biggest_stepsize, hor_step);
1271 biggest_stepsize = next_biggest_stepsize;
1273 assert(num_changing_childs == 0);
1276 uint position = rtl ? this->
current_x : 0;
1278 while (child_wid !=
nullptr) {
1279 uint child_width = child_wid->
current_x;
1285 position = rtl ? position - padded_child_width : position + padded_child_width;
1287 child_wid = child_wid->
next;
1318 uint max_hor_fill = 0;
1319 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1320 child_wid->SetupSmallestSize(w, init_array);
1321 highest = std::max(highest, child_wid->smallest_y);
1322 max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(
ST_SMALLEST));
1323 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1327 uint max_smallest = this->
smallest_x + 3 * max_hor_fill;
1331 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1332 uint step_size = child_wid->GetHorizontalStepSize(
ST_SMALLEST);
1333 uint child_width = child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
1334 if (step_size > 1 && child_width < cur_width) {
1335 uint remainder = (cur_width - child_width) % step_size;
1336 if (remainder > 0) {
1337 cur_width += step_size - remainder;
1338 assert(cur_width < max_smallest);
1348 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1349 if (child_wid->fill_y == 1) child_wid->smallest_y = highest;
1354 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1355 if (child_wid->next !=
nullptr) {
1356 child_wid->padding_bottom += this->
pip_inter;
1358 child_wid->padding_bottom += this->
pip_post;
1361 this->
smallest_y += child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1362 if (child_wid->fill_y > 0) {
1363 if (this->
fill_y == 0 || this->
fill_y > child_wid->fill_y) this->
fill_y = child_wid->fill_y;
1367 if (child_wid->resize_y > 0) {
1381 uint additional_length = given_height;
1384 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1385 additional_length -= child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1398 int num_changing_childs = 0;
1399 uint biggest_stepsize = 0;
1400 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1401 uint vert_step = child_wid->GetVerticalStepSize(sizing);
1402 if (vert_step > 0) {
1403 num_changing_childs++;
1404 biggest_stepsize = std::max(biggest_stepsize, vert_step);
1406 child_wid->current_y = child_wid->smallest_y;
1409 uint hor_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
1410 child_wid->current_x =
ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step);
1414 while (biggest_stepsize > 0) {
1415 uint next_biggest_stepsize = 0;
1416 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1417 uint vert_step = child_wid->GetVerticalStepSize(sizing);
1418 if (vert_step > biggest_stepsize)
continue;
1419 if (vert_step == biggest_stepsize) {
1420 uint increment = additional_length / num_changing_childs;
1421 num_changing_childs--;
1422 if (vert_step > 1) increment -= increment % vert_step;
1423 child_wid->current_y = child_wid->smallest_y + increment;
1424 additional_length -= increment;
1427 next_biggest_stepsize = std::max(next_biggest_stepsize, vert_step);
1429 biggest_stepsize = next_biggest_stepsize;
1431 assert(num_changing_childs == 0);
1435 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1436 uint child_x = x + (rtl ? child_wid->padding_right : child_wid->padding_left);
1437 uint child_height = child_wid->current_y;
1439 child_wid->AssignSizePosition(sizing, child_x, y + position + child_wid->padding_top, child_wid->current_x, child_height, rtl);
1440 position += child_height + child_wid->padding_top + child_wid->padding_bottom;
1484 void NWidgetMatrix::SetIndex(
int index)
1486 this->index =
index;
1489 void NWidgetMatrix::SetColour(Colours colour)
1501 if (this->clicked >= 0 && this->
sb !=
nullptr && this->
widgets_x != 0) {
1517 this->count =
count;
1519 if (this->
sb ==
nullptr || this->
widgets_x == 0)
return;
1546 assert(this->
head !=
nullptr);
1547 assert(this->
head->
next ==
nullptr);
1549 if (this->
index >= 0 && init_array) {
1556 assert(nw !=
nullptr);
1569 this->
fill_x = fill.width;
1570 this->
fill_y = fill.height;
1601 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
1610 int start_x, start_y, base_offs_x, base_offs_y;
1615 int widget_col = (rtl ?
1617 x - (int)this->
pip_pre - (
int)this->
pos_x - base_offs_x
1622 int sub_wid = (widget_row + start_y) * this->
widgets_x + start_x + widget_col;
1623 if (sub_wid >= this->
count)
return nullptr;
1626 assert(child !=
nullptr);
1632 SB(child->
index, 16, 16, sub_wid);
1647 _cur_dpi = &tmp_dpi;
1651 assert(child !=
nullptr);
1652 int start_x, start_y, base_offs_x, base_offs_y;
1655 int offs_y = base_offs_y;
1656 for (
int y = start_y; y < start_y + this->
widgets_y + 1; y++, offs_y += this->
widget_h) {
1658 if (offs_y + child->
smallest_y <= 0)
continue;
1659 if (offs_y >= (
int)this->
current_y)
break;
1664 int offs_x = base_offs_x;
1667 if (offs_x + child->
smallest_x <= 0)
continue;
1668 if (offs_x >= (
int)this->
current_x)
continue;
1671 int sub_wid = y * this->widgets_x + x;
1672 if (sub_wid >= this->
count)
break;
1676 SB(child->
index, 16, 16, sub_wid);
1698 if (this->
sb !=
nullptr) {
1706 base_offs_x += sub_x;
1708 base_offs_x -= sub_x;
1727 this->child =
child;
1730 NWidgetBackground::~NWidgetBackground()
1732 if (this->
child !=
nullptr)
delete this->
child;
1744 if (this->
child ==
nullptr) {
1762 if (this->
child ==
nullptr) {
1765 this->
child->
SetPIP(pip_pre, pip_inter, pip_post);
1770 if (init_array && this->
index >= 0) {
1774 if (this->
child !=
nullptr) {
1806 d =
maxdim(d, background);
1808 if (this->
index >= 0) {
1809 static const Dimension padding = {0, 0};
1815 this->
fill_x = fill.width;
1816 this->
fill_y = fill.height;
1826 if (this->
child !=
nullptr) {
1836 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
1845 r.left = this->
pos_x;
1847 r.top = this->
pos_y;
1851 if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top)
return;
1853 switch (this->
type) {
1886 if (nwid ==
nullptr) nwid =
this;
1895 if (nwid ==
nullptr && this->
type == tp) nwid =
this;
1906 if (init_array && this->
index >= 0) {
1952 if (vp !=
nullptr) {
2010 if (init_array && this->
index >= 0) {
2017 switch (this->
type) {
2019 this->
SetMinimalSize(NWidgetScrollbar::GetHorizontalDimension().width * 3, NWidgetScrollbar::GetHorizontalDimension().height);
2022 this->
SetDataTip(0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
2026 this->
SetMinimalSize(NWidgetScrollbar::GetVerticalDimension().width, NWidgetScrollbar::GetVerticalDimension().height * 3);
2029 this->
SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
2032 default: NOT_REACHED();
2044 r.left = this->
pos_x;
2046 r.top = this->
pos_y;
2050 if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top)
return;
2067 void NWidgetScrollbar::InvalidateDimensionCache()
2073 Dimension NWidgetScrollbar::GetVerticalDimension()
2084 Dimension NWidgetScrollbar::GetHorizontalDimension()
2149 case NWID_PUSHBUTTON_DROPDOWN:
2163 this->
SetDataTip(data, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
2169 this->
SetDataTip(STR_NULL, STR_TOOLTIP_STICKY);
2175 this->
SetDataTip(STR_NULL, STR_TOOLTIP_SHADE);
2181 this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEBUG);
2187 this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEFSIZE);
2193 this->
SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE);
2199 this->
SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW);
2214 if (this->
index >= 0 && init_array) {
2224 switch (this->
type) {
2301 size.width = std::max(size.width, 30 + sprite_size.width);
2317 d2.width += extra.width;
2318 d2.height += extra.height;
2327 d2.width += extra.width;
2328 d2.height += extra.height;
2351 d2.width += extra.width;
2352 d2.height += extra.height;
2369 d2.width += extra.width;
2370 d2.height += extra.height;
2376 case NWID_PUSHBUTTON_DROPDOWN: {
2387 d2.width += extra.width;
2400 this->
fill_x = fill.width;
2401 this->
fill_y = fill.height;
2414 new_dpi.left += this->
pos_x;
2415 new_dpi.top += this->
pos_y;
2418 _cur_dpi = &new_dpi;
2421 r.left = this->
pos_x;
2423 r.top = this->
pos_y;
2427 switch (this->
type) {
2456 case AWV_LEFT: sprite = SPR_ARROW_LEFT;
break;
2457 case AWV_RIGHT: sprite = SPR_ARROW_RIGHT;
break;
2458 default: NOT_REACHED();
2480 if (query !=
nullptr) query->DrawEditBox(w, this->
index);
2523 case NWID_PUSHBUTTON_DROPDOWN:
2550 int button_width = this->
pos_x + this->
current_x - NWidgetLeaf::dropdown_dimension.width;
2551 return pt.x < button_width;
2553 int button_left = this->
pos_x + NWidgetLeaf::dropdown_dimension.width;
2554 return pt.x >= button_left;
2582 while (count > num_used) {
2583 switch (parts->
type) {
2585 if (*dest !=
nullptr)
return num_used;
2590 if (*dest !=
nullptr)
return num_used;
2596 if (*dest !=
nullptr)
return num_used;
2604 if (*dest !=
nullptr)
return num_used;
2606 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2611 if (*dest !=
nullptr)
return num_used;
2617 if (*dest !=
nullptr)
return num_used;
2623 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2628 if (*dest !=
nullptr)
return num_used;
2631 *dest = parts->u.
func_ptr(&biggest);
2632 *biggest_index = std::max(*biggest_index, biggest);
2639 if (nwrb !=
nullptr) {
2640 assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
2648 if (nwrb !=
nullptr) {
2649 assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
2657 if (nwrb !=
nullptr) {
2666 if (nwrb !=
nullptr) nwrb->
SetFill(parts->u.
xy.x, parts->u.
xy.y);
2672 if (nwc !=
nullptr) {
2694 if (nwc !=
nullptr) {
2704 if (*dest !=
nullptr)
return num_used;
2706 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2711 if (*dest !=
nullptr)
return num_used;
2713 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2717 if (*dest !=
nullptr)
return num_used;
2722 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2727 if (*dest !=
nullptr)
return num_used;
2730 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2755 assert(*parent ==
nullptr || (nwid_cont !=
nullptr && nwid_parent ==
nullptr) || (nwid_cont ==
nullptr && nwid_parent !=
nullptr));
2760 bool fill_sub =
false;
2761 int num_used =
MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
2763 total_used += num_used;
2766 if (sub_widget ==
nullptr)
break;
2773 int num_used =
MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index);
2775 total_used += num_used;
2779 if (nwid_cont !=
nullptr) nwid_cont->
Add(sub_widget);
2780 if (nwid_parent !=
nullptr) nwid_parent->
Add(sub_widget);
2781 if (nwid_cont ==
nullptr && nwid_parent ==
nullptr) {
2782 *parent = sub_widget;
2787 if (count == total_used)
return total_used;
2789 assert(total_used < count);
2791 return total_used + 1;
2807 *biggest_index = -1;
2829 *biggest_index = -1;
2833 int num_used =
MakeWidgetTree(parts, count, &nwid, biggest_index);
2834 assert(nwid !=
nullptr);
2841 *shade_select =
nullptr;
2851 root->
Add(*shade_select);
2853 (*shade_select)->
Add(body);
2855 *shade_select =
nullptr;
2863 *biggest_index = std::max(*biggest_index, biggest2);
2880 assert(max_length >= 1);
2889 for (
int widnum = widget_first; widnum <= widget_last; widnum++) {
2891 if (hor_length == max_length) {
2897 if (hor ==
nullptr) {
2910 *biggest_index = widget_last;
2911 if (vert ==
nullptr)
return hor;
2913 if (hor_length > 0 && hor_length < max_length) {
2920 if (hor !=
nullptr) vert->
Add(hor);