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);
1159 uint max_smallest = this->
smallest_y + 3 * max_vert_fill;
1162 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1163 uint step_size = child_wid->GetVerticalStepSize(
ST_SMALLEST);
1164 uint child_height = child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1165 if (step_size > 1 && child_height < cur_height) {
1166 uint remainder = (cur_height - child_height) % step_size;
1167 if (remainder > 0) {
1168 cur_height += step_size - remainder;
1169 assert(cur_height < max_smallest);
1179 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1180 if (child_wid->fill_x == 1) child_wid->smallest_x = longest;
1185 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1186 if (child_wid->next !=
nullptr) {
1187 child_wid->padding_right += this->
pip_inter;
1189 child_wid->padding_right += this->
pip_post;
1192 this->
smallest_x += child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
1193 if (child_wid->fill_x > 0) {
1194 if (this->
fill_x == 0 || this->
fill_x > child_wid->fill_x) this->
fill_x = child_wid->fill_x;
1198 if (child_wid->resize_x > 0) {
1212 uint additional_length = given_width;
1215 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1216 additional_length -= child_wid->smallest_x + child_wid->padding_right + child_wid->padding_left;
1238 int num_changing_childs = 0;
1239 uint biggest_stepsize = 0;
1240 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1241 uint hor_step = child_wid->GetHorizontalStepSize(sizing);
1243 num_changing_childs++;
1244 biggest_stepsize = std::max(biggest_stepsize, hor_step);
1246 child_wid->current_x = child_wid->smallest_x;
1249 uint vert_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
1250 child_wid->current_y =
ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step);
1254 while (biggest_stepsize > 0) {
1255 uint next_biggest_stepsize = 0;
1256 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1257 uint hor_step = child_wid->GetHorizontalStepSize(sizing);
1258 if (hor_step > biggest_stepsize)
continue;
1259 if (hor_step == biggest_stepsize) {
1260 uint increment = additional_length / num_changing_childs;
1261 num_changing_childs--;
1262 if (hor_step > 1) increment -= increment % hor_step;
1263 child_wid->current_x = child_wid->smallest_x + increment;
1264 additional_length -= increment;
1267 next_biggest_stepsize = std::max(next_biggest_stepsize, hor_step);
1269 biggest_stepsize = next_biggest_stepsize;
1271 assert(num_changing_childs == 0);
1274 uint position = rtl ? this->
current_x : 0;
1276 while (child_wid !=
nullptr) {
1277 uint child_width = child_wid->
current_x;
1283 position = rtl ? position - padded_child_width : position + padded_child_width;
1285 child_wid = child_wid->
next;
1316 uint max_hor_fill = 0;
1317 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1318 child_wid->SetupSmallestSize(w, init_array);
1319 highest = std::max(highest, child_wid->smallest_y);
1320 max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(
ST_SMALLEST));
1321 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1324 uint max_smallest = this->
smallest_x + 3 * max_hor_fill;
1327 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1328 uint step_size = child_wid->GetHorizontalStepSize(
ST_SMALLEST);
1329 uint child_width = child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
1330 if (step_size > 1 && child_width < cur_width) {
1331 uint remainder = (cur_width - child_width) % step_size;
1332 if (remainder > 0) {
1333 cur_width += step_size - remainder;
1334 assert(cur_width < max_smallest);
1344 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1345 if (child_wid->fill_y == 1) child_wid->smallest_y = highest;
1350 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1351 if (child_wid->next !=
nullptr) {
1352 child_wid->padding_bottom += this->
pip_inter;
1354 child_wid->padding_bottom += this->
pip_post;
1357 this->
smallest_y += child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1358 if (child_wid->fill_y > 0) {
1359 if (this->
fill_y == 0 || this->
fill_y > child_wid->fill_y) this->
fill_y = child_wid->fill_y;
1363 if (child_wid->resize_y > 0) {
1377 uint additional_length = given_height;
1380 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1381 additional_length -= child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
1394 int num_changing_childs = 0;
1395 uint biggest_stepsize = 0;
1396 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1397 uint vert_step = child_wid->GetVerticalStepSize(sizing);
1398 if (vert_step > 0) {
1399 num_changing_childs++;
1400 biggest_stepsize = std::max(biggest_stepsize, vert_step);
1402 child_wid->current_y = child_wid->smallest_y;
1405 uint hor_step = (sizing ==
ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
1406 child_wid->current_x =
ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step);
1410 while (biggest_stepsize > 0) {
1411 uint next_biggest_stepsize = 0;
1412 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1413 uint vert_step = child_wid->GetVerticalStepSize(sizing);
1414 if (vert_step > biggest_stepsize)
continue;
1415 if (vert_step == biggest_stepsize) {
1416 uint increment = additional_length / num_changing_childs;
1417 num_changing_childs--;
1418 if (vert_step > 1) increment -= increment % vert_step;
1419 child_wid->current_y = child_wid->smallest_y + increment;
1420 additional_length -= increment;
1423 next_biggest_stepsize = std::max(next_biggest_stepsize, vert_step);
1425 biggest_stepsize = next_biggest_stepsize;
1427 assert(num_changing_childs == 0);
1431 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1432 uint child_x = x + (rtl ? child_wid->padding_right : child_wid->padding_left);
1433 uint child_height = child_wid->current_y;
1435 child_wid->AssignSizePosition(sizing, child_x, y + position + child_wid->padding_top, child_wid->current_x, child_height, rtl);
1436 position += child_height + child_wid->padding_top + child_wid->padding_bottom;
1480 void NWidgetMatrix::SetIndex(
int index)
1482 this->index =
index;
1485 void NWidgetMatrix::SetColour(Colours colour)
1497 if (this->clicked >= 0 && this->
sb !=
nullptr && this->
widgets_x != 0) {
1513 this->count =
count;
1515 if (this->
sb ==
nullptr || this->
widgets_x == 0)
return;
1542 assert(this->
head !=
nullptr);
1543 assert(this->
head->
next ==
nullptr);
1545 if (this->
index >= 0 && init_array) {
1552 assert(nw !=
nullptr);
1565 this->
fill_x = fill.width;
1566 this->
fill_y = fill.height;
1597 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
1606 int start_x, start_y, base_offs_x, base_offs_y;
1611 int widget_col = (rtl ?
1613 x - (int)this->
pip_pre - (
int)this->
pos_x - base_offs_x
1618 int sub_wid = (widget_row + start_y) * this->
widgets_x + start_x + widget_col;
1619 if (sub_wid >= this->
count)
return nullptr;
1622 assert(child !=
nullptr);
1628 SB(child->
index, 16, 16, sub_wid);
1643 _cur_dpi = &tmp_dpi;
1647 assert(child !=
nullptr);
1648 int start_x, start_y, base_offs_x, base_offs_y;
1651 int offs_y = base_offs_y;
1652 for (
int y = start_y; y < start_y + this->
widgets_y + 1; y++, offs_y += this->
widget_h) {
1654 if (offs_y + child->
smallest_y <= 0)
continue;
1655 if (offs_y >= (
int)this->
current_y)
break;
1660 int offs_x = base_offs_x;
1663 if (offs_x + child->
smallest_x <= 0)
continue;
1664 if (offs_x >= (
int)this->
current_x)
continue;
1667 int sub_wid = y * this->widgets_x + x;
1668 if (sub_wid >= this->
count)
break;
1672 SB(child->
index, 16, 16, sub_wid);
1694 if (this->
sb !=
nullptr) {
1702 base_offs_x += sub_x;
1704 base_offs_x -= sub_x;
1723 this->child =
child;
1726 NWidgetBackground::~NWidgetBackground()
1728 if (this->
child !=
nullptr)
delete this->
child;
1740 if (this->
child ==
nullptr) {
1758 if (this->
child ==
nullptr) {
1761 this->
child->
SetPIP(pip_pre, pip_inter, pip_post);
1766 if (init_array && this->
index >= 0) {
1770 if (this->
child !=
nullptr) {
1802 d =
maxdim(d, background);
1804 if (this->
index >= 0) {
1805 static const Dimension padding = {0, 0};
1811 this->
fill_x = fill.width;
1812 this->
fill_y = fill.height;
1822 if (this->
child !=
nullptr) {
1832 if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] =
this;
1841 r.left = this->
pos_x;
1843 r.top = this->
pos_y;
1847 if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top)
return;
1849 switch (this->
type) {
1882 if (nwid ==
nullptr) nwid =
this;
1891 if (nwid ==
nullptr && this->
type == tp) nwid =
this;
1902 if (init_array && this->
index >= 0) {
1946 if (vp !=
nullptr) {
2004 if (init_array && this->
index >= 0) {
2011 switch (this->
type) {
2013 this->
SetMinimalSize(NWidgetScrollbar::GetHorizontalDimension().width * 3, NWidgetScrollbar::GetHorizontalDimension().height);
2016 this->
SetDataTip(0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
2020 this->
SetMinimalSize(NWidgetScrollbar::GetVerticalDimension().width, NWidgetScrollbar::GetVerticalDimension().height * 3);
2023 this->
SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
2026 default: NOT_REACHED();
2038 r.left = this->
pos_x;
2040 r.top = this->
pos_y;
2044 if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top)
return;
2061 void NWidgetScrollbar::InvalidateDimensionCache()
2067 Dimension NWidgetScrollbar::GetVerticalDimension()
2078 Dimension NWidgetScrollbar::GetHorizontalDimension()
2143 case NWID_PUSHBUTTON_DROPDOWN:
2157 this->
SetDataTip(data, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
2163 this->
SetDataTip(STR_NULL, STR_TOOLTIP_STICKY);
2169 this->
SetDataTip(STR_NULL, STR_TOOLTIP_SHADE);
2175 this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEBUG);
2181 this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEFSIZE);
2187 this->
SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE);
2193 this->
SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW);
2208 if (this->
index >= 0 && init_array) {
2218 switch (this->
type) {
2295 size.width = std::max(size.width, 30 + sprite_size.width);
2311 d2.width += extra.width;
2312 d2.height += extra.height;
2321 d2.width += extra.width;
2322 d2.height += extra.height;
2345 d2.width += extra.width;
2346 d2.height += extra.height;
2363 d2.width += extra.width;
2364 d2.height += extra.height;
2370 case NWID_PUSHBUTTON_DROPDOWN: {
2381 d2.width += extra.width;
2394 this->
fill_x = fill.width;
2395 this->
fill_y = fill.height;
2408 new_dpi.left += this->
pos_x;
2409 new_dpi.top += this->
pos_y;
2412 _cur_dpi = &new_dpi;
2415 r.left = this->
pos_x;
2417 r.top = this->
pos_y;
2421 switch (this->
type) {
2450 case AWV_LEFT: sprite = SPR_ARROW_LEFT;
break;
2451 case AWV_RIGHT: sprite = SPR_ARROW_RIGHT;
break;
2452 default: NOT_REACHED();
2474 if (query !=
nullptr) query->DrawEditBox(w, this->
index);
2517 case NWID_PUSHBUTTON_DROPDOWN:
2544 int button_width = this->
pos_x + this->
current_x - NWidgetLeaf::dropdown_dimension.width;
2545 return pt.x < button_width;
2547 int button_left = this->
pos_x + NWidgetLeaf::dropdown_dimension.width;
2548 return pt.x >= button_left;
2576 while (count > num_used) {
2577 switch (parts->
type) {
2579 if (*dest !=
nullptr)
return num_used;
2584 if (*dest !=
nullptr)
return num_used;
2590 if (*dest !=
nullptr)
return num_used;
2598 if (*dest !=
nullptr)
return num_used;
2600 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2605 if (*dest !=
nullptr)
return num_used;
2611 if (*dest !=
nullptr)
return num_used;
2617 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2622 if (*dest !=
nullptr)
return num_used;
2625 *dest = parts->u.
func_ptr(&biggest);
2626 *biggest_index = std::max(*biggest_index, biggest);
2633 if (nwrb !=
nullptr) {
2634 assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
2642 if (nwrb !=
nullptr) {
2643 assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
2651 if (nwrb !=
nullptr) {
2660 if (nwrb !=
nullptr) nwrb->
SetFill(parts->u.
xy.x, parts->u.
xy.y);
2666 if (nwc !=
nullptr) {
2688 if (nwc !=
nullptr) {
2698 if (*dest !=
nullptr)
return num_used;
2700 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2705 if (*dest !=
nullptr)
return num_used;
2707 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2711 if (*dest !=
nullptr)
return num_used;
2716 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2721 if (*dest !=
nullptr)
return num_used;
2724 *biggest_index = std::max(*biggest_index, (
int)parts->u.
widget.
index);
2749 assert(*parent ==
nullptr || (nwid_cont !=
nullptr && nwid_parent ==
nullptr) || (nwid_cont ==
nullptr && nwid_parent !=
nullptr));
2754 bool fill_sub =
false;
2755 int num_used =
MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
2757 total_used += num_used;
2760 if (sub_widget ==
nullptr)
break;
2767 int num_used =
MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index);
2769 total_used += num_used;
2773 if (nwid_cont !=
nullptr) nwid_cont->
Add(sub_widget);
2774 if (nwid_parent !=
nullptr) nwid_parent->
Add(sub_widget);
2775 if (nwid_cont ==
nullptr && nwid_parent ==
nullptr) {
2776 *parent = sub_widget;
2781 if (count == total_used)
return total_used;
2783 assert(total_used < count);
2785 return total_used + 1;
2801 *biggest_index = -1;
2823 *biggest_index = -1;
2827 int num_used =
MakeWidgetTree(parts, count, &nwid, biggest_index);
2828 assert(nwid !=
nullptr);
2835 *shade_select =
nullptr;
2845 root->
Add(*shade_select);
2847 (*shade_select)->
Add(body);
2849 *shade_select =
nullptr;
2857 *biggest_index = std::max(*biggest_index, biggest2);
2873 assert(max_length >= 1);
2882 for (
int widnum = widget_first; widnum <= widget_last; widnum++) {
2884 if (hor_length == max_length) {
2890 if (hor ==
nullptr) {
2903 *biggest_index = widget_last;
2904 if (vert ==
nullptr)
return hor;
2906 if (hor_length > 0 && hor_length < max_length) {
2913 if (hor !=
nullptr) vert->
Add(hor);