24 #include "table/strings.h" 
   41   int rev_base = top + bottom;
 
   44     button_size = NWidgetScrollbar::GetHorizontalDimension().width;
 
   46     button_size = NWidgetScrollbar::GetVerticalDimension().height;
 
   49   bottom -= button_size; 
 
   51   int height = (bottom - top);
 
   56   if (count != 0) top += height * pos / count;
 
   58   if (cap > count) cap = count;
 
   59   if (count != 0) bottom -= (count - pos - cap) * height / count;
 
   63     pt.x = rev_base - bottom;
 
   64     pt.y = rev_base - top;
 
   90     button_size = NWidgetScrollbar::GetHorizontalDimension().width;
 
   93     button_size = NWidgetScrollbar::GetVerticalDimension().height;
 
   95   if (pos < mi + button_size) {
 
   98     if (_scroller_click_timeout <= 1) {
 
   99       _scroller_click_timeout = 3;
 
  103   } 
else if (pos >= ma - button_size) {
 
  107     if (_scroller_click_timeout <= 1) {
 
  108       _scroller_click_timeout = 3;
 
  117     } 
else if (pos > pt.y) {
 
  120       _scrollbar_start_pos = pt.x - mi - button_size;
 
  121       _scrollbar_size = ma - mi - button_size * 2;
 
  123       _cursorpos_drag_start = _cursor.
pos;
 
  150   assert(scrollbar != NULL);
 
  165   return (nw != NULL) ? nw->
index : -1;
 
  179   assert(colour < COLOUR_END);
 
  196       interior = (flags & 
FR_DARKENED ? medium_dark : medium_light);
 
  202       interior = medium_dark;
 
  223   if ((type & WWT_MASK) == 
WWT_IMGBTN_2 && clicked) img++; 
 
  236   if (str == STR_NULL) 
return;
 
  239   int offset = 
max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2); 
 
  252   int offset = 
max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2); 
 
  253   if (str != STR_NULL) 
DrawString(r.left, r.right, r.top + offset, str, colour);
 
  277 static inline void DrawMatrix(
const Rect &r, Colours colour, 
bool clicked, uint16 data, uint resize_x, uint resize_y)
 
  283   if (num_columns == 0) {
 
  284     column_width = resize_x;
 
  285     num_columns = (r.right - r.left + 1) / column_width;
 
  287     column_width = (r.right - r.left + 1) / num_columns;
 
  293     row_height = resize_y;
 
  294     num_rows = (r.bottom - r.top + 1) / row_height;
 
  296     row_height = (r.bottom - r.top + 1) / num_rows;
 
  302   for (
int ctr = num_columns; ctr > 1; ctr--) {
 
  308   for (
int ctr = num_rows; ctr > 1; ctr--) {
 
  316   for (
int ctr = num_columns; ctr > 1; ctr--) {
 
  322   for (
int ctr = num_rows; ctr > 1; ctr--) {
 
  339   int centre = (r.right - r.left) / 2;
 
  340   int height = NWidgetScrollbar::GetVerticalDimension().height;
 
  344   DrawSprite(SPR_ARROW_UP, PAL_NONE, r.left + 1 + up_clicked, r.top + 1 + up_clicked);
 
  346   DrawFrameRect(r.left, r.bottom - (height - 1), r.right, r.bottom, colour, (down_clicked) ? 
FR_LOWERED : FR_NONE);
 
  347   DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + down_clicked, r.bottom - (height - 2) + down_clicked);
 
  353   GfxFillRect(r.left, r.top + height, r.right, r.bottom - height, c2);
 
  357   GfxFillRect(r.left + centre - 3, r.top + height, r.left + centre - 3, r.bottom - height, c1);
 
  358   GfxFillRect(r.left + centre - 2, r.top + height, r.left + centre - 2, r.bottom - height, c2);
 
  359   GfxFillRect(r.left + centre + 2, r.top + height, r.left + centre + 2, r.bottom - height, c1);
 
  360   GfxFillRect(r.left + centre + 3, r.top + height, r.left + centre + 3, r.bottom - height, c2);
 
  377   int centre = (r.bottom - r.top) / 2;
 
  378   int width = NWidgetScrollbar::GetHorizontalDimension().width;
 
  381   DrawSprite(SPR_ARROW_LEFT, PAL_NONE, r.left + 1 + left_clicked, r.top + 1 + left_clicked);
 
  384   DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, r.right - (width - 2) + right_clicked, r.top + 1 + right_clicked);
 
  390   GfxFillRect(r.left + width, r.top, r.right - width, r.bottom, c2);
 
  394   GfxFillRect(r.left + width, r.top + centre - 3, r.right - width, r.top + centre - 3, c1);
 
  395   GfxFillRect(r.left + width, r.top + centre - 2, r.right - width, r.top + centre - 2, c2);
 
  396   GfxFillRect(r.left + width, r.top + centre + 2, r.right - width, r.top + centre + 2, c1);
 
  397   GfxFillRect(r.left + width, r.top + centre + 3, r.right - width, r.top + centre + 3, c2);
 
  426     GfxFillRect(r.left, r.top + dy1, r.left + 4, r.top + dy1, c1);
 
  427     GfxFillRect(r.left + 1, r.top + dy2, r.left + 4, r.top + dy2, c2);
 
  430     GfxFillRect(x2, r.top + dy1, r.right - 1, r.top + dy1, c1);
 
  431     GfxFillRect(x2, r.top + dy2, r.right - 2, r.top + dy2, c2);
 
  434     GfxFillRect(r.left, r.top + dy1, x2 - 2, r.top + dy1, c1);
 
  435     GfxFillRect(r.left + 1, r.top + dy2, x2 - 2, r.top + dy2, c2);
 
  438     GfxFillRect(r.right - 5, r.top + dy1, r.right - 1, r.top + dy1, c1);
 
  439     GfxFillRect(r.right - 5, r.top + dy2, r.right - 2, r.top + dy2, c2);
 
  443   GfxFillRect(r.left, r.top + dy2, r.left, r.bottom - 1, c1);
 
  444   GfxFillRect(r.left + 1, r.top + dy2 + 1, r.left + 1, r.bottom - 2, c2);
 
  447   GfxFillRect(r.right - 1, r.top + dy2, r.right - 1, r.bottom - 2, c1);
 
  448   GfxFillRect(r.right, r.top + dy1, r.right, r.bottom - 1, c2);
 
  450   GfxFillRect(r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1, c1);
 
  451   GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
 
  528   if (colour != COLOUR_WHITE) 
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
 
  550   if (str != STR_NULL) {
 
  552     int offset = 
max(0, ((
int)(r.bottom - r.top + 1) - (
int)d.height) / 2); 
 
  573   int image_offset = 
max(0, ((
int)(r.bottom - r.top + 1) - dd_height) / 2);
 
  577     DrawFrameRect(r.right + 1 - dd_width, r.top, r.right, r.bottom, colour, clicked_dropdown ? 
FR_LOWERED : FR_NONE);
 
  578     DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.right - (dd_width - 2) + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
  582     DrawFrameRect(r.left, r.top, r.left + dd_width - 1, r.bottom, colour, clicked_dropdown ? 
FR_LOWERED : FR_NONE);
 
  583     DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
  614       const NWidgetBase *widget = this->GetWidget<NWidgetBase>(i);
 
  615       if (widget == NULL || !widget->IsHighlighted()) 
continue;
 
  619       int right  = left + widget->
current_x - 1;
 
  620       int bottom = top  + widget->
current_y - 1;
 
  622       int colour = 
_string_colourmap[_window_highlight_colour ? widget->GetHighlightColour() : TC_WHITE];
 
  642   const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
  645   Dimension dim = NWidgetScrollbar::GetVerticalDimension();
 
  648   int y = offset + nwid->
pos_y + (nwid->
current_y - dim.height) / 2;
 
  659   return NWidgetScrollbar::GetVerticalDimension().width + 1;
 
  796   return (this->
type == tp) ? 
this : NULL;
 
  818   this->min_x = 
max(this->min_x, min_x);
 
  819   this->min_y = 
max(this->min_y, min_y);
 
  899 void NWidgetCore::FillNestedArray(
NWidgetBase **array, uint length)
 
  901   if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] = 
this;
 
  919 NWidgetContainer::~NWidgetContainer()
 
  921   while (this->
head != NULL) {
 
  931   if (this->
type == tp) 
return this;
 
  932   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
  934     if (nwid != NULL) 
return nwid;
 
  945   assert(wid->
next == NULL && wid->
prev == NULL);
 
  947   if (this->
head == NULL) {
 
  951     assert(this->
tail != NULL);
 
  960 void NWidgetContainer::FillNestedArray(
NWidgetBase **array, uint length)
 
  962   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
  963     child_wid->FillNestedArray(array, length);
 
  975 void NWidgetStacked::SetIndex(
int index)
 
  982   if (this->
index >= 0 && init_array) { 
 
  998     this->
fill_x = fill.width;
 
  999     this->
fill_y = fill.height;
 
 1012   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1013     child_wid->SetupSmallestSize(w, init_array);
 
 1015     this->
smallest_x = 
max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
 
 1016     this->
smallest_y = 
max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
 
 1031   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1032     uint hor_step = (sizing == 
ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
 
 1033     uint child_width = 
ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step);
 
 1034     uint child_pos_x = (rtl ? child_wid->padding_right : child_wid->padding_left);
 
 1036     uint vert_step = (sizing == 
ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
 
 1037     uint child_height = 
ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step);
 
 1038     uint child_pos_y = child_wid->padding_top;
 
 1040     child_wid->AssignSizePosition(sizing, x + child_pos_x, y + child_pos_y, child_width, child_height, rtl);
 
 1044 void NWidgetStacked::FillNestedArray(
NWidgetBase **array, uint length)
 
 1046   if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] = 
this;
 
 1047   NWidgetContainer::FillNestedArray(array, length);
 
 1055   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; plane++, child_wid = child_wid->
next) {
 
 1071   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; plane++, child_wid = child_wid->
next) {
 
 1090   this->flags = flags;
 
 1111   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1120   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1122     if (nwid != NULL) 
return nwid;
 
 1143   uint max_vert_fill = 0; 
 
 1144   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1145     child_wid->SetupSmallestSize(w, init_array);
 
 1146     longest = 
max(longest, child_wid->smallest_x);
 
 1147     max_vert_fill = 
max(max_vert_fill, child_wid->GetVerticalStepSize(
ST_SMALLEST));
 
 1148     this->
smallest_y = 
max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
 
 1151   uint max_smallest = this->
smallest_y + 3 * max_vert_fill; 
 
 1154     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1155       uint step_size = child_wid->GetVerticalStepSize(
ST_SMALLEST);
 
 1156       uint child_height = child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
 
 1157       if (step_size > 1 && child_height < cur_height) { 
 
 1158         uint remainder = (cur_height - child_height) % step_size;
 
 1159         if (remainder > 0) { 
 
 1160           cur_height += step_size - remainder;
 
 1161           assert(cur_height < max_smallest); 
 
 1171     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1172       if (child_wid->fill_x == 1) child_wid->smallest_x = longest;
 
 1177   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1178     if (child_wid->next != NULL) {
 
 1179       child_wid->padding_right += this->
pip_inter;
 
 1181       child_wid->padding_right += this->
pip_post;
 
 1184     this->
smallest_x += child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
 
 1185     if (child_wid->fill_x > 0) {
 
 1186       if (this->
fill_x == 0 || this->
fill_x > child_wid->fill_x) this->
fill_x = child_wid->fill_x;
 
 1190     if (child_wid->resize_x > 0) {
 
 1204   uint additional_length = given_width;
 
 1207     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1208       additional_length -= child_wid->smallest_x + child_wid->padding_right + child_wid->padding_left;
 
 1230   int num_changing_childs = 0; 
 
 1231   uint biggest_stepsize = 0;
 
 1232   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1233     uint hor_step = child_wid->GetHorizontalStepSize(sizing);
 
 1235       num_changing_childs++;
 
 1236       biggest_stepsize = 
max(biggest_stepsize, hor_step);
 
 1238       child_wid->current_x = child_wid->smallest_x;
 
 1241     uint vert_step = (sizing == 
ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
 
 1242     child_wid->current_y = 
ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step);
 
 1246   while (biggest_stepsize > 0) {
 
 1247     uint next_biggest_stepsize = 0;
 
 1248     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1249       uint hor_step = child_wid->GetHorizontalStepSize(sizing);
 
 1250       if (hor_step > biggest_stepsize) 
continue; 
 
 1251       if (hor_step == biggest_stepsize) {
 
 1252         uint increment = additional_length / num_changing_childs;
 
 1253         num_changing_childs--;
 
 1254         if (hor_step > 1) increment -= increment % hor_step;
 
 1255         child_wid->current_x = child_wid->smallest_x + increment;
 
 1256         additional_length -= increment;
 
 1259       next_biggest_stepsize = 
max(next_biggest_stepsize, hor_step);
 
 1261     biggest_stepsize = next_biggest_stepsize;
 
 1263   assert(num_changing_childs == 0);
 
 1266   uint position = rtl ? this->
current_x : 0; 
 
 1268   while (child_wid != NULL) {
 
 1269     uint child_width = child_wid->
current_x;
 
 1275     position = rtl ? position - padded_child_width : position + padded_child_width;
 
 1277     child_wid = child_wid->
next;
 
 1308   uint max_hor_fill = 0; 
 
 1309   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1310     child_wid->SetupSmallestSize(w, init_array);
 
 1311     highest = 
max(highest, child_wid->smallest_y);
 
 1312     max_hor_fill = 
max(max_hor_fill, child_wid->GetHorizontalStepSize(
ST_SMALLEST));
 
 1313     this->
smallest_x = 
max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
 
 1316   uint max_smallest = this->
smallest_x + 3 * max_hor_fill; 
 
 1319     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1320       uint step_size = child_wid->GetHorizontalStepSize(
ST_SMALLEST);
 
 1321       uint child_width = child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
 
 1322       if (step_size > 1 && child_width < cur_width) { 
 
 1323         uint remainder = (cur_width - child_width) % step_size;
 
 1324         if (remainder > 0) { 
 
 1325           cur_width += step_size - remainder;
 
 1326           assert(cur_width < max_smallest); 
 
 1336     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1337       if (child_wid->fill_y == 1) child_wid->smallest_y = highest;
 
 1342   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1343     if (child_wid->next != NULL) {
 
 1344       child_wid->padding_bottom += this->
pip_inter;
 
 1346       child_wid->padding_bottom += this->
pip_post;
 
 1349     this->
smallest_y += child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
 
 1350     if (child_wid->fill_y > 0) {
 
 1351       if (this->
fill_y == 0 || this->
fill_y > child_wid->fill_y) this->
fill_y = child_wid->fill_y;
 
 1355     if (child_wid->resize_y > 0) {
 
 1369   uint additional_length = given_height;
 
 1372     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1373       additional_length -= child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
 
 1386   int num_changing_childs = 0; 
 
 1387   uint biggest_stepsize = 0;
 
 1388   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1389     uint vert_step = child_wid->GetVerticalStepSize(sizing);
 
 1390     if (vert_step > 0) {
 
 1391       num_changing_childs++;
 
 1392       biggest_stepsize = 
max(biggest_stepsize, vert_step);
 
 1394       child_wid->current_y = child_wid->smallest_y;
 
 1397     uint hor_step = (sizing == 
ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
 
 1398     child_wid->current_x = 
ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step);
 
 1402   while (biggest_stepsize > 0) {
 
 1403     uint next_biggest_stepsize = 0;
 
 1404     for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1405       uint vert_step = child_wid->GetVerticalStepSize(sizing);
 
 1406       if (vert_step > biggest_stepsize) 
continue; 
 
 1407       if (vert_step == biggest_stepsize) {
 
 1408         uint increment = additional_length / num_changing_childs;
 
 1409         num_changing_childs--;
 
 1410         if (vert_step > 1) increment -= increment % vert_step;
 
 1411         child_wid->current_y = child_wid->smallest_y + increment;
 
 1412         additional_length -= increment;
 
 1415       next_biggest_stepsize = 
max(next_biggest_stepsize, vert_step);
 
 1417     biggest_stepsize = next_biggest_stepsize;
 
 1419   assert(num_changing_childs == 0);
 
 1423   for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
 
 1424     uint child_x = x + (rtl ? child_wid->padding_right : child_wid->padding_left);
 
 1425     uint child_height = child_wid->current_y;
 
 1427     child_wid->AssignSizePosition(sizing, child_x, y + position + child_wid->padding_top, child_wid->current_x, child_height, rtl);
 
 1428     position += child_height + child_wid->padding_top + child_wid->padding_bottom;
 
 1449 void NWidgetSpacer::FillNestedArray(
NWidgetBase **array, uint length)
 
 1472 void NWidgetMatrix::SetIndex(
int index)
 
 1474   this->index = 
index;
 
 1477 void NWidgetMatrix::SetColour(Colours colour)
 
 1489   if (this->clicked >= 0 && this->
sb != NULL && this->
widgets_x != 0) {
 
 1505   this->count = 
count;
 
 1507   if (this->
sb == NULL || this->
widgets_x == 0) 
return;
 
 1516   if (count > 0) count -= this->
pip_inter; 
 
 1534   assert(this->
head != NULL);
 
 1537   if (this->
index >= 0 && init_array) { 
 
 1557   this->
fill_x = fill.width;
 
 1558   this->
fill_y = fill.height;
 
 1587 void NWidgetMatrix::FillNestedArray(
NWidgetBase **array, uint length)
 
 1589   if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] = 
this;
 
 1590   NWidgetContainer::FillNestedArray(array, length);
 
 1598   int start_x, start_y, base_offs_x, base_offs_y;
 
 1603   int widget_col = (rtl ?
 
 1605          x - (int)this->
pip_pre  - (
int)this->
pos_x - base_offs_x
 
 1610   int sub_wid = (widget_row + start_y) * this->
widgets_x + start_x + widget_col;
 
 1611   if (sub_wid >= this->
count) 
return NULL;
 
 1614   assert(child != NULL);
 
 1620   SB(child->
index, 16, 16, sub_wid);
 
 1635   _cur_dpi = &tmp_dpi;
 
 1639   assert(child != NULL);
 
 1640   int start_x, start_y, base_offs_x, base_offs_y;
 
 1643   int offs_y = base_offs_y;
 
 1644   for (
int y = start_y; y < start_y + this->
widgets_y + 1; y++, offs_y += this->
widget_h) {
 
 1646     if (offs_y + child->
smallest_y <= 0) 
continue;
 
 1647     if (offs_y >= (
int)this->
current_y) 
break;
 
 1652     int offs_x = base_offs_x;
 
 1655       if (offs_x + child->
smallest_x <= 0) 
continue;
 
 1656       if (offs_x >= (
int)this->
current_x) 
continue;
 
 1659       int sub_wid = y * this->widgets_x + x;
 
 1660       if (sub_wid >= this->
count) 
break;
 
 1664       SB(child->
index, 16, 16, sub_wid);
 
 1686   if (this->
sb != NULL) {
 
 1694         base_offs_x += sub_x;
 
 1696         base_offs_x -= sub_x;
 
 1714   if (index >= 0) this->
SetIndex(index);
 
 1715   this->child = 
child;
 
 1718 NWidgetBackground::~NWidgetBackground()
 
 1732   if (this->
child == NULL) {
 
 1750   if (this->
child == NULL) {
 
 1753   this->
child->
SetPIP(pip_pre, pip_inter, pip_post);
 
 1758   if (init_array && this->
index >= 0) {
 
 1762   if (this->
child != NULL) {
 
 1794         d = 
maxdim(d, background);
 
 1796       if (this->
index >= 0) {
 
 1797         static const Dimension padding = {0, 0};
 
 1803     this->
fill_x = fill.width;
 
 1804     this->
fill_y = fill.height;
 
 1814   if (this->
child != NULL) {
 
 1822 void NWidgetBackground::FillNestedArray(
NWidgetBase **array, uint length)
 
 1824   if (this->
index >= 0 && (uint)(this->
index) < length) array[this->
index] = 
this;
 
 1825   if (this->
child != NULL) this->
child->FillNestedArray(array, length);
 
 1833   r.left = this->
pos_x;
 
 1835   r.top = this->
pos_y;
 
 1839   if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top) 
return;
 
 1841   switch (this->
type) {
 
 1874     if (nwid == NULL) nwid = 
this;
 
 1883   if (nwid == NULL && this->
type == tp) nwid = 
this;
 
 1894   if (init_array && this->
index >= 0) {
 
 1996   if (init_array && this->
index >= 0) {
 
 2003   switch (this->
type) {
 
 2005       this->
SetMinimalSize(NWidgetScrollbar::GetHorizontalDimension().width * 3, NWidgetScrollbar::GetHorizontalDimension().height);
 
 2008       this->
SetDataTip(0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
 
 2012       this->
SetMinimalSize(NWidgetScrollbar::GetVerticalDimension().width, NWidgetScrollbar::GetVerticalDimension().height * 3);
 
 2015       this->
SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
 
 2018     default: NOT_REACHED();
 
 2030   r.left = this->
pos_x;
 
 2032   r.top = this->
pos_y;
 
 2036   if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top) 
return;
 
 2053  void NWidgetScrollbar::InvalidateDimensionCache()
 
 2059  Dimension NWidgetScrollbar::GetVerticalDimension()
 
 2070  Dimension NWidgetScrollbar::GetHorizontalDimension()
 
 2115   if (index >= 0) this->
SetIndex(index);
 
 2135     case NWID_PUSHBUTTON_DROPDOWN:
 
 2149       this->
SetDataTip(data, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
 
 2155       this->
SetDataTip(STR_NULL, STR_TOOLTIP_STICKY);
 
 2161       this->
SetDataTip(STR_NULL, STR_TOOLTIP_SHADE);
 
 2167       this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEBUG);
 
 2173       this->
SetDataTip(STR_NULL, STR_TOOLTIP_DEFSIZE);
 
 2179       this->
SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE);
 
 2185       this->
SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW);
 
 2200   if (this->
index >= 0 && init_array) { 
 
 2210   switch (this->
type) {
 
 2224       if (NWidgetLeaf::shadebox_dimension.width == 0) {
 
 2226         NWidgetLeaf::shadebox_dimension.width += extra.width;
 
 2227         NWidgetLeaf::shadebox_dimension.height += extra.height;
 
 2229       size = 
maxdim(size, NWidgetLeaf::shadebox_dimension);
 
 2236         if (NWidgetLeaf::debugbox_dimension.width == 0) {
 
 2237           NWidgetLeaf::debugbox_dimension = 
GetSpriteSize(SPR_WINDOW_DEBUG);
 
 2238           NWidgetLeaf::debugbox_dimension.width += extra.width;
 
 2239           NWidgetLeaf::debugbox_dimension.height += extra.height;
 
 2241         size = 
maxdim(size, NWidgetLeaf::debugbox_dimension);
 
 2253       if (NWidgetLeaf::stickybox_dimension.width == 0) {
 
 2255         NWidgetLeaf::stickybox_dimension.width += extra.width;
 
 2256         NWidgetLeaf::stickybox_dimension.height += extra.height;
 
 2258       size = 
maxdim(size, NWidgetLeaf::stickybox_dimension);
 
 2265       if (NWidgetLeaf::defsizebox_dimension.width == 0) {
 
 2266         NWidgetLeaf::defsizebox_dimension = 
GetSpriteSize(SPR_WINDOW_DEFSIZE);
 
 2267         NWidgetLeaf::defsizebox_dimension.width += extra.width;
 
 2268         NWidgetLeaf::defsizebox_dimension.height += extra.height;
 
 2270       size = 
maxdim(size, NWidgetLeaf::defsizebox_dimension);
 
 2277       if (NWidgetLeaf::resizebox_dimension.width == 0) {
 
 2279         NWidgetLeaf::resizebox_dimension.width += extra.width;
 
 2280         NWidgetLeaf::resizebox_dimension.height += extra.height;
 
 2282       size = 
maxdim(size, NWidgetLeaf::resizebox_dimension);
 
 2287       size.width = 
max(size.width, 30 + sprite_size.width);
 
 2303       d2.width += extra.width;
 
 2304       d2.height += extra.height;
 
 2313       d2.width += extra.width;
 
 2314       d2.height += extra.height;
 
 2322       if (NWidgetLeaf::closebox_dimension.width == 0) {
 
 2323         NWidgetLeaf::closebox_dimension = 
GetSpriteSize(SPR_CLOSEBOX);
 
 2324         NWidgetLeaf::closebox_dimension.width += extra.width;
 
 2325         NWidgetLeaf::closebox_dimension.height += extra.height;
 
 2327       size = 
maxdim(size, NWidgetLeaf::closebox_dimension);
 
 2337       d2.width += extra.width;
 
 2338       d2.height += extra.height;
 
 2355       d2.width += extra.width;
 
 2356       d2.height += extra.height;
 
 2362     case NWID_PUSHBUTTON_DROPDOWN: {
 
 2365       if (NWidgetLeaf::dropdown_dimension.width == 0) {
 
 2366         NWidgetLeaf::dropdown_dimension = 
GetSpriteSize(SPR_ARROW_DOWN);
 
 2369         extra.width = 
WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT + NWidgetLeaf::dropdown_dimension.width;
 
 2373       d2.width += extra.width;
 
 2374       d2.height = 
max(d2.height, NWidgetLeaf::dropdown_dimension.height) + extra.height;
 
 2386   this->
fill_x = fill.width;
 
 2387   this->
fill_y = fill.height;
 
 2400   new_dpi.left += this->
pos_x;
 
 2401   new_dpi.top += this->
pos_y;
 
 2404   _cur_dpi = &new_dpi;
 
 2407   r.left = this->
pos_x;
 
 2409   r.top = this->
pos_y;
 
 2413   switch (this->
type) {
 
 2442         case AWV_LEFT:     sprite = SPR_ARROW_LEFT;  
break;
 
 2443         case AWV_RIGHT:    sprite = SPR_ARROW_RIGHT; 
break;
 
 2444         default: NOT_REACHED();
 
 2466       if (query != NULL) query->DrawEditBox(w, this->
index);
 
 2509     case NWID_PUSHBUTTON_DROPDOWN:
 
 2536     int button_width = this->
pos_x + this->
current_x - NWidgetLeaf::dropdown_dimension.width;
 
 2537     return pt.x < button_width;
 
 2539     int button_left = this->
pos_x + NWidgetLeaf::dropdown_dimension.width;
 
 2540     return pt.x >= button_left;
 
 2568   while (count > num_used) {
 
 2569     switch (parts->
type) {
 
 2571         if (*dest != NULL) 
return num_used;
 
 2576         if (*dest != NULL) 
return num_used;
 
 2582         if (*dest != NULL) 
return num_used;
 
 2590         if (*dest != NULL) 
return num_used;
 
 2592         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2597         if (*dest != NULL) 
return num_used;
 
 2603         if (*dest != NULL) 
return num_used;
 
 2609         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2614         if (*dest != NULL) 
return num_used;
 
 2617         *dest = parts->u.
func_ptr(&biggest);
 
 2618         *biggest_index = 
max(*biggest_index, biggest);
 
 2626           assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
 
 2635           assert(parts->u.
xy.x >= 0 && parts->u.
xy.y >= 0);
 
 2652         if (nwrb != NULL) nwrb->
SetFill(parts->u.
xy.x, parts->u.
xy.y);
 
 2690         if (*dest != NULL) 
return num_used;
 
 2692         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2697         if (*dest != NULL) 
return num_used;
 
 2699         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2703         if (*dest != NULL) 
return num_used;
 
 2708         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2713         if (*dest != NULL) 
return num_used;
 
 2716         *biggest_index = 
max(*biggest_index, (
int)parts->u.
widget.
index);
 
 2741   assert(*parent == NULL || (nwid_cont != NULL && nwid_parent == NULL) || (nwid_cont == NULL && nwid_parent != NULL));
 
 2746     bool fill_sub = 
false;
 
 2747     int num_used = 
MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
 
 2749     total_used += num_used;
 
 2752     if (sub_widget == NULL) 
break;
 
 2759       int num_used = 
MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index);
 
 2761       total_used += num_used;
 
 2765     if (nwid_cont != NULL) nwid_cont->
Add(sub_widget);
 
 2766     if (nwid_parent != NULL) nwid_parent->
Add(sub_widget);
 
 2767     if (nwid_cont == NULL && nwid_parent == NULL) {
 
 2768       *parent = sub_widget;
 
 2773   if (count == total_used) 
return total_used; 
 
 2775   assert(total_used < count);
 
 2777   return total_used + 1; 
 
 2793   *biggest_index = -1;
 
 2815   *biggest_index = -1;
 
 2819   int num_used = 
MakeWidgetTree(parts, count, &nwid, biggest_index);
 
 2820   assert(nwid != NULL);
 
 2827     *shade_select = NULL;
 
 2837     root->
Add(*shade_select);
 
 2839     (*shade_select)->
Add(body);
 
 2841     *shade_select = NULL;
 
 2849   *biggest_index = 
max(*biggest_index, biggest2);
 
 2865   assert(max_length >= 1);
 
 2874   for (
int widnum = widget_first; widnum <= widget_last; widnum++) {
 
 2876     if (hor_length == max_length) {
 
 2895   *biggest_index = widget_last;
 
 2896   if (vert == NULL) 
return hor; 
 
 2898   if (hor_length > 0 && hor_length < max_length) {
 
 2905   if (hor != NULL) vert->
Add(hor);