73 Point _cursorpos_drag_start;
75 int _scrollbar_start_pos;
77 byte _scroller_click_timeout = 0;
99 parent_cls(parent_class),
102 nwid_parts(nwid_parts),
103 nwid_length(nwid_length),
108 default_width_trad(def_width_trad),
109 default_height_trad(def_height_trad)
112 *_window_descs->
Append() =
this;
115 WindowDesc::~WindowDesc()
117 _window_descs->
Erase(_window_descs->
Find(
this));
148 if ((*it)->ini_key == NULL)
continue;
159 if ((*a)->ini_key != NULL && (*b)->ini_key != NULL)
return strcmp((*a)->ini_key, (*b)->ini_key);
160 return ((*b)->ini_key != NULL ? 1 : 0) - ((*a)->ini_key != NULL ? 1 : 0);
174 if ((*it)->ini_key == NULL)
continue;
186 if (this->nested_root != NULL && this->nested_root->GetWidgetOfType(
WWT_STICKYBOX) != NULL) {
190 this->window_desc->pref_sticky =
false;
205 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(widget);
206 if (line_height < 0) line_height = wid->
resize_y;
207 if (clickpos < (
int)wid->
pos_y + padding)
return INT_MAX;
208 return (clickpos - (
int)wid->
pos_y - padding) / line_height;
216 for (uint i = 0; i < this->nested_array_size; i++) {
217 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
218 if (nwid == NULL)
continue;
220 if (nwid->IsHighlighted()) {
221 nwid->SetHighlighted(TC_INVALID);
222 this->SetWidgetDirty(i);
236 assert(widget_index < this->nested_array_size);
238 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
239 if (nwid == NULL)
return;
241 nwid->SetHighlighted(highlighted_colour);
242 this->SetWidgetDirty(widget_index);
244 if (highlighted_colour != TC_INVALID) {
250 for (uint i = 0; i < this->nested_array_size; i++) {
251 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
252 if (nwid == NULL)
continue;
253 if (!nwid->IsHighlighted())
continue;
269 assert(widget_index < this->nested_array_size);
271 const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
272 if (nwid == NULL)
return false;
274 return nwid->IsHighlighted();
286 if (widget < 0)
return;
292 this->OnDropdownSelect(widget, index);
297 NWidgetCore *nwi2 = this->GetWidget<NWidgetCore>(widget);
301 this->RaiseWidget(widget);
303 this->SetWidgetDirty(widget);
313 return this->GetWidget<NWidgetScrollbar>(widnum);
323 return this->GetWidget<NWidgetScrollbar>(widnum);
334 return query != this->querystrings.End() ? query->second : NULL;
345 return query != this->querystrings.End() ? query->second : NULL;
354 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
355 return this->GetQueryString(this->nested_focus->index)->GetText();
367 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
368 return this->GetQueryString(this->nested_focus->index)->GetCaret();
381 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
382 return this->GetQueryString(this->nested_focus->index)->GetMarkedText(length);
394 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
395 return this->GetQueryString(this->nested_focus->index)->GetCaretPosition(
this, this->nested_focus->index);
410 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
411 return this->GetQueryString(this->nested_focus->index)->GetBoundingRect(
this, this->nested_focus->index, from, to);
414 Rect r = {0, 0, 0, 0};
425 if (this->nested_focus != NULL && this->nested_focus->type ==
WWT_EDITBOX) {
426 return this->GetQueryString(this->nested_focus->index)->GetCharAtPosition(
this, this->nested_focus->index, pt);
438 if (_focused_window == w)
return;
441 if (_focused_window != NULL) {
446 Window *old_focused = _focused_window;
450 if (old_focused != NULL) old_focused->
OnFocusLost();
451 if (_focused_window != NULL) _focused_window->
OnFocus();
461 if (_focused_window == NULL)
return false;
474 if (this->nested_focus != NULL) {
478 this->nested_focus->SetDirty(
this);
479 this->nested_focus = NULL;
491 if ((uint)widget_index >= this->nested_array_size)
return false;
493 assert(this->nested_array[widget_index] != NULL);
494 if (this->nested_focus != NULL) {
495 if (this->GetWidget<NWidgetCore>(widget_index) == this->nested_focus)
return false;
498 this->nested_focus->SetDirty(
this);
501 this->nested_focus = this->GetWidget<NWidgetCore>(widget_index);
524 va_start(wdg_list, widgets);
527 SetWidgetDisabledState(widgets, disab_stat);
528 widgets = va_arg(wdg_list,
int);
543 va_start(wdg_list, widgets);
546 SetWidgetLoweredState(widgets, lowered_stat);
547 widgets = va_arg(wdg_list,
int);
559 for (uint i = 0; i < this->nested_array_size; i++) {
560 if (this->nested_array[i] == NULL)
continue;
561 WidgetType type = this->nested_array[i]->type;
562 if (((type & ~WWB_PUSHBUTTON) <
WWT_LAST || type == NWID_PUSHBUTTON_DROPDOWN) &&
563 (!autoraise || (type & WWB_PUSHBUTTON) || type ==
WWT_EDITBOX) && this->IsWidgetLowered(i)) {
564 this->RaiseWidget(i);
565 this->SetWidgetDirty(i);
584 if (this->nested_array == NULL)
return;
586 this->nested_array[widget_index]->SetDirty(
this);
598 NWidgetCore *nw = this->GetWidget<NWidgetCore>(hotkey);
605 this->SetFocusedWidget(hotkey);
609 this->OnClick(
Point(), hotkey, 1);
621 this->LowerWidget(widget);
623 this->SetWidgetDirty(widget);
641 bool focused_widget_changed =
false;
643 if (_focused_window != w &&
646 focused_widget_changed =
true;
650 if (nw == NULL)
return;
655 int widget_index = nw->
index;
681 switch (widget_type) {
689 if (query != NULL) query->ClickEditBox(w, pt, widget_index, click_count, focused_widget_changed);
751 if (widget_index < 0)
return;
759 w->
OnClick(pt, widget_index, click_count);
771 if (wid == NULL)
return;
776 if (wid->
index >= 0) {
799 if (wid == NULL)
return;
810 if (wid->
index < 0)
return;
824 if (nwid == NULL)
return;
890 left < v->left + v->
width &&
891 top < v->top + v->
height) {
895 if (left < (x = v->
left)) {
907 if (top < (x = v->
top)) {
925 dp->width = right - left;
926 dp->height = bottom - top;
927 dp->left = left - w->
left;
928 dp->top = top - w->
top;
929 dp->pitch = _screen.pitch;
951 FOR_ALL_WINDOWS_FROM_BACK(w) {
955 left < w->left + w->
width &&
956 top < w->top + w->
height) {
970 SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height);
984 int window_width = this->width;
985 int window_height = this->height;
989 this->nested_root->SetupSmallestSize(
this,
false);
991 this->width = this->nested_root->smallest_x;
992 this->height = this->nested_root->smallest_y;
993 this->resize.step_width = this->nested_root->resize_x;
994 this->resize.step_height = this->nested_root->resize_y;
997 window_width =
max(window_width + rx, this->width);
998 window_height =
max(window_height + ry, this->height);
999 int dx = (this->resize.step_width == 0) ? 0 : window_width - this->width;
1000 int dy = (this->resize.step_height == 0) ? 0 : window_height - this->height;
1003 if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width;
1004 if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height;
1017 if (this->shade_select == NULL)
return;
1020 if (this->shade_select->shown_plane != desired) {
1022 if (this->nested_focus != NULL) this->UnfocusFocusedWidget();
1023 this->unshaded_size.width = this->width;
1024 this->unshaded_size.height = this->height;
1025 this->shade_select->SetDisplayedPlane(desired);
1026 this->ReInit(0, -this->height);
1028 this->shade_select->SetDisplayedPlane(desired);
1029 int dx = ((int)this->unshaded_size.width > this->width) ? (int)this->unshaded_size.width - this->width : 0;
1030 int dy = ((
int)this->unshaded_size.height > this->height) ? (
int)this->unshaded_size.height - this->height : 0;
1031 this->ReInit(dx, dy);
1045 FOR_ALL_WINDOWS_FROM_BACK(v) {
1059 while (child != NULL) {
1076 if (_mouseover_last_w ==
this) _mouseover_last_w = NULL;
1079 if (_last_scroll_window ==
this) _last_scroll_window = NULL;
1082 if (_focused_window ==
this) {
1083 this->OnFocusLost();
1084 _focused_window = NULL;
1087 this->DeleteChildWindows();
1089 if (this->viewport != NULL) DeleteWindowViewport(
this);
1093 free(this->nested_array);
1094 delete this->nested_root;
1117 FOR_ALL_WINDOWS_FROM_BACK(w) {
1133 FOR_ALL_WINDOWS_FROM_BACK(w) {
1149 if (force || w == NULL ||
1167 FOR_ALL_WINDOWS_FROM_BACK(w) {
1170 goto restart_search;
1189 FOR_ALL_WINDOWS_FROM_BACK(w) {
1190 if (w->
owner ==
id) {
1192 goto restart_search;
1210 FOR_ALL_WINDOWS_FROM_BACK(w) {
1211 if (w->
owner != old_owner)
continue;
1228 w->
owner = new_owner;
1258 static inline bool IsVitalWindow(
const Window *w)
1284 uint z_priority = 0;
1362 if (_z_front_window == NULL) {
1364 _z_front_window = _z_back_window = w;
1369 uint last_z_priority = UINT_MAX;
1384 _z_back_window->
z_back = w;
1386 }
else if (v == _z_front_window) {
1391 _z_front_window = w;
1410 assert(_z_front_window == w);
1411 _z_front_window = w->
z_back;
1417 assert(_z_back_window == w);
1449 this->window_class = this->window_desc->cls;
1450 this->SetWhiteBorder();
1453 this->nested_focus = NULL;
1454 this->window_number = window_number;
1458 if (this->nested_array == NULL) {
1459 this->nested_array = CallocT<NWidgetBase *>(this->nested_array_size);
1460 this->nested_root->SetupSmallestSize(
this,
true);
1462 this->nested_root->SetupSmallestSize(
this,
false);
1469 this->resize.step_width = this->nested_root->resize_x;
1470 this->resize.step_height = this->nested_root->resize_y;
1492 this->width = sm_width;
1493 this->height = sm_height;
1508 def_width =
max(def_width, this->width);
1509 def_height =
max(def_height, this->height);
1515 if (this->width != def_width || this->height != def_height) {
1517 int free_height = _screen.height;
1519 if (wt != NULL) free_height -= wt->
height;
1521 if (wt != NULL) free_height -= wt->
height;
1523 int enlarge_x =
max(
min(def_width - this->width, _screen.width - this->width), 0);
1524 int enlarge_y =
max(
min(def_height - this->height, free_height - this->height), 0);
1529 if (this->resize.step_width > 1) enlarge_x -= enlarge_x % (int)this->resize.step_width;
1530 if (this->resize.step_height > 1) enlarge_y -= enlarge_y % (int)this->resize.step_height;
1539 int nx = this->left;
1542 if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width);
1545 ny =
max(ny, (wt == NULL ||
this == wt || this->top == 0) ? 0 : wt->
height);
1548 if (this->viewport != NULL) {
1549 this->viewport->left += nx - this->left;
1550 this->viewport->top += ny - this->top;
1572 int right = width + left;
1573 int bottom = height + top;
1575 if (left < 0 || top < toolbar_y || right > _screen.width || bottom > _screen.height)
return false;
1579 FOR_ALL_WINDOWS_FROM_BACK(w) {
1582 if (right > w->
left &&
1615 if (left < -(width >> 1) || left > _screen.width - (width >> 2))
return false;
1617 if (left < -(width >> 2) || left > _screen.width - (width >> 1))
return false;
1621 if (top < toolbar_y || top > _screen.height - (height >> 2))
return false;
1625 FOR_ALL_WINDOWS_FROM_BACK(w) {
1628 if (left + width > w->
left &&
1630 top + height > w->
top &&
1655 const int toolbar_y = main_toolbar != NULL ? main_toolbar->
height : 0;
1656 if (
IsGoodAutoPlace1(rtl ? _screen.width - width : 0, toolbar_y, width, height, toolbar_y, pt))
return pt;
1663 FOR_ALL_WINDOWS_FROM_BACK(w) {
1680 FOR_ALL_WINDOWS_FROM_BACK(w) {
1692 int left = rtl ? _screen.width - width : 0, top = toolbar_y;
1697 FOR_ALL_WINDOWS_FROM_BACK(w) {
1698 if (w->
left == left && w->
top == top) {
1752 pt.x = w->
left + (rtl ? w->
width - default_width : 0);
1761 if (w->
top + 3 * indent_y < _screen.height) {
1762 pt.y = w->
top + indent_y;
1766 pt.x =
max(w->
left + w->
width - default_width - indent_close, 0);
1767 if (pt.x + default_width >= indent_close && pt.x + indent_resize <= _screen.width)
return pt;
1769 pt.x =
min(w->
left + indent_close, _screen.width - default_width);
1770 if (pt.x + default_width >= indent_resize && pt.x + indent_close <= _screen.width)
return pt;
1784 pt.x = (_screen.width - default_width) / 2;
1785 pt.y = (_screen.height - default_height) / 2;
1814 int biggest_index = -1;
1815 this->nested_root =
MakeWindowNWidgetTree(this->window_desc->nwid_parts, this->window_desc->nwid_length, &biggest_index, &this->shade_select);
1816 this->nested_array_size = (uint)(biggest_index + 1);
1819 this->nested_array = CallocT<NWidgetBase *>(this->nested_array_size);
1820 this->nested_root->FillNestedArray(this->nested_array, this->nested_array_size);
1830 this->InitializeData(window_number);
1831 this->ApplyDefaults();
1832 Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number);
1833 this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y);
1834 this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight());
1843 this->CreateNestedTree(
false);
1844 this->FinishInitNested(window_number);
1865 FOR_ALL_WINDOWS_FROM_FRONT(w) {
1881 _z_back_window = NULL;
1882 _z_front_window = NULL;
1883 _focused_window = NULL;
1884 _mouseover_last_w = NULL;
1885 _last_scroll_window = NULL;
1890 NWidgetScrollbar::InvalidateDimensionCache();
1903 FOR_ALL_WINDOWS_FROM_FRONT(w)
delete w;
1905 for (w = _z_front_window; w != NULL; ) {
1911 _z_front_window = NULL;
1912 _z_back_window = NULL;
1925 static void DecreaseWindowCounters()
1927 if (_scroller_click_timeout != 0) _scroller_click_timeout--;
1930 FOR_ALL_WINDOWS_FROM_FRONT(w) {
1931 if (_scroller_click_timeout == 0) {
1948 it->second->HandleEditBox(w, it->first);
1954 FOR_ALL_WINDOWS_FROM_FRONT(w) {
1964 static void HandlePlacePresize()
1969 if (w == NULL)
return;
1971 Point pt = GetTileBelowCursor();
1994 pt.x = _cursor.
pos.x - w->
left;
1995 pt.y = _cursor.
pos.y - w->
top;
2013 if (_mouseover_last_w != NULL && _mouseover_last_w != w) {
2015 Point pt = { -1, -1 };
2020 _mouseover_last_w = w;
2051 if (v == NULL)
return;
2061 if (*nx + rect.left + MIN_VISIBLE_TITLE_BAR < v->
left) {
2092 if (caption != NULL) {
2093 caption_rect.left = caption->
pos_x;
2095 caption_rect.top = caption->
pos_y;
2128 if (delta_x != 0 || delta_y != 0) {
2129 if (clamp_to_screen) {
2132 int new_right = w->
left + w->
width + delta_x;
2133 int new_bottom = w->
top + w->
height + delta_y;
2165 return (w == NULL) ? 0 : w->
top + w->
height;
2176 return (w == NULL) ? _screen.height : w->
top;
2195 FOR_ALL_WINDOWS_FROM_BACK(w) {
2205 int x = _cursor.
pos.x + _drag_delta.x;
2206 int y = _cursor.
pos.y + _drag_delta.y;
2217 FOR_ALL_WINDOWS_FROM_BACK(v) {
2218 if (v == w)
continue;
2223 if (delta <= hsnap) {
2230 if (delta <= hsnap) {
2239 if (delta <= hsnap) {
2246 if (delta <= hsnap) {
2255 if (delta <= vsnap) {
2262 if (delta <= vsnap) {
2271 if (delta <= vsnap) {
2278 if (delta <= vsnap) {
2301 int x, y = _cursor.
pos.y - _drag_delta.y;
2303 x = _drag_delta.x - _cursor.
pos.x;
2305 x = _cursor.
pos.x - _drag_delta.x;
2313 if (w->
top + w->
height + y > _screen.height) {
2314 y = _screen.height - w->
height - w->
top;
2365 _drag_delta.x = w->
left - _cursor.
pos.x;
2366 _drag_delta.y = w->
top - _cursor.
pos.y;
2383 _drag_delta.x = _cursor.
pos.x;
2384 _drag_delta.y = _cursor.
pos.y;
2401 i = _cursor.
pos.x - _cursorpos_drag_start.x;
2404 i = _cursor.
pos.y - _cursorpos_drag_start.y;
2408 if (_scroller_click_timeout == 1) {
2409 _scroller_click_timeout = 3;
2432 FOR_ALL_WINDOWS_FROM_BACK(w) {
2477 _last_scroll_window = NULL;
2489 if (scrollwheel_scrolling) {
2491 delta.x = _cursor.h_wheel;
2492 delta.y = _cursor.v_wheel;
2493 _cursor.v_wheel = 0;
2494 _cursor.h_wheel = 0;
2497 delta.x = -_cursor.
delta.x;
2498 delta.y = -_cursor.
delta.y;
2500 delta.x = _cursor.
delta.x;
2501 delta.y = _cursor.
delta.y;
2506 if (delta.x != 0 || delta.y != 0) _last_scroll_window->
OnScroll(delta);
2508 _cursor.
delta.x = 0;
2509 _cursor.
delta.y = 0;
2525 bool bring_to_front =
false;
2535 int w_width = w->
width;
2536 int w_height = w->
height;
2559 if (w->
left + w_width <= u->
left ||
2561 w->
top + w_height <= u->
top ||
2566 bring_to_front =
true;
2588 switch (query->text.HandleKeyPress(key, keycode)) {
2632 if (query->text.
bytes <= 1) {
2667 if (key >= 0xE000 && key <= 0xF8FF) key = 0;
2672 if (key == 0 && keycode == 0)
return;
2686 FOR_ALL_WINDOWS_FROM_FRONT(w) {
2705 HandleGlobalHotkeys(key, keycode);
2715 FOR_ALL_WINDOWS_FROM_FRONT(w) {
2725 void Window::InsertTextString(
int wid,
const char *str,
bool marked,
const char *caret,
const char *insert_location,
const char *replacement_end)
2728 if (query == NULL)
return;
2730 if (query->text.
InsertString(str, marked, caret, insert_location, replacement_end) || marked) {
2742 void HandleTextInput(
const char *str,
bool marked,
const char *caret,
const char *insert_location,
const char *replacement_end)
2767 int x = _cursor.
pos.x;
2768 int y = _cursor.
pos.y;
2774 if (vp == NULL)
return;
2780 static const int SCROLLSPEED = 3;
2783 }
else if (15 - (vp->
width - x) > 0) {
2788 }
else if (15 - (vp->
height - y) > 0) {
2806 static void ScrollMainViewport(
int x,
int y)
2808 if (_game_mode != GM_MENU) {
2845 static void HandleKeyScrolling()
2853 ScrollMainViewport(scrollamt[
_dirkeys][0] * factor, scrollamt[
_dirkeys][1] * factor);
2857 static void MouseLoop(
MouseClick click,
int mousewheel)
2863 HandlePlacePresize();
2875 if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling)
return;
2877 int x = _cursor.
pos.x;
2878 int y = _cursor.
pos.y;
2880 if (w == NULL)
return;
2888 if (mousewheel != 0) {
2904 case MC_DOUBLE_LEFT:
2906 if (HandleViewportClicked(vp, x, y))
return;
2933 case MC_DOUBLE_LEFT:
2954 _cursor.h_wheel = 0;
2955 _cursor.v_wheel = 0;
2967 static int double_click_time = 0;
2968 static Point double_click_pos = {0, 0};
2977 click = MC_DOUBLE_LEFT;
2980 double_click_pos = _cursor.
pos;
2990 if (_cursor.
wheel) {
2991 mousewheel = _cursor.
wheel;
2996 static uint32 hover_time = 0;
2997 static Point hover_pos = {0, 0};
3003 hover_pos = _cursor.
pos;
3031 MouseLoop(click, mousewheel);
3036 _cursor.
delta.x = 0;
3037 _cursor.
delta.y = 0;
3048 uint deletable_count = 0;
3049 Window *w, *last_deletable = NULL;
3050 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3060 assert(last_deletable != NULL);
3061 delete last_deletable;
3077 for (
Window *v = _z_front_window; v != NULL; ) {
3104 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3118 if (delta_ms == 0)
return;
3125 #ifdef ENABLE_NETWORK 3127 if (network_message_timer.
Elapsed(delta_ms)) {
3128 network_message_timer.SetInterval(1000);
3136 if (window_timer.
Elapsed(delta_ms)) {
3139 extern int _caret_timer;
3143 HandleKeyScrolling();
3145 DecreaseWindowCounters();
3149 if (highlight_timer.
Elapsed(delta_ms)) {
3150 highlight_timer.SetInterval(450);
3156 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3166 if (hundredth_timer.
Elapsed(delta_ms)) {
3167 hundredth_timer.SetInterval(3000);
3169 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3174 if (window_timer.HasElapsed()) {
3177 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3187 FOR_ALL_WINDOWS_FROM_BACK(w) {
3204 FOR_ALL_WINDOWS_FROM_BACK(w) {
3218 FOR_ALL_WINDOWS_FROM_BACK(w) {
3232 FOR_ALL_WINDOWS_FROM_BACK(w) {
3304 FOR_ALL_WINDOWS_FROM_BACK(w) {
3323 FOR_ALL_WINDOWS_FROM_BACK(w) {
3336 FOR_ALL_WINDOWS_FROM_FRONT(w) {
3355 FOR_ALL_WINDOWS_FROM_BACK(w) {
3364 goto restart_search;
3387 FOR_ALL_WINDOWS_FROM_BACK(w) {
3390 goto restart_search;
3418 FOR_ALL_WINDOWS_FROM_BACK(w) {
3421 goto restart_search;
3425 FOR_ALL_WINDOWS_FROM_BACK(w) w->
SetDirty();
3439 NWidgetScrollbar::InvalidateDimensionCache();
3445 FOR_ALL_WINDOWS_FROM_BACK(w) {
3448 #ifdef ENABLE_NETWORK 3470 if (w == NULL)
return 0;
3472 int old_left = w->
left;
3474 case 1: w->
left = (_screen.width - w->
width) / 2;
break;
3475 case 2: w->
left = _screen.width - w->
width;
break;
3476 default: w->
left = 0;
break;
3490 DEBUG(misc, 5,
"Repositioning Main Toolbar...");
3501 DEBUG(misc, 5,
"Repositioning statusbar...");
3512 DEBUG(misc, 5,
"Repositioning news message...");
3523 DEBUG(misc, 5,
"Repositioning network chat window...");
3536 FOR_ALL_WINDOWS_FROM_BACK(w) {
3555 FOR_ALL_WINDOWS_FROM_BACK(w) {
3597 top = (newh - w->
height) >> 1;
3598 left = (neww - w->
width) >> 1;
3603 if (left + (w->
width >> 1) >= neww) left = neww - w->
width;
3604 if (left < 0) left = 0;
3607 if (top + (w->
height >> 1) >= newh) top = newh - w->
height;
EventState
State of handling an event.
Window * _z_back_window
List of windows opened at the screen sorted from the back.
Functions related to OTTD's strings.
static void CheckSoftLimit()
Check the soft limit of deletable (non vital, non sticky) windows.
Generate landscape (newgame); Window numbers:
SpecialMouseMode
Mouse modes.
Functions/types related to NewGRF debugging.
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
virtual void OnPlacePresize(Point pt, TileIndex tile)
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
static Window * FindChildWindow(const Window *w, WindowClass wc)
Find the Window whose parent pointer points to this window.
static const int ACTION_DESELECT
Deselect editbox.
static bool IsLocalCompany()
Is the current company the local company?
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
static int CDECL DescSorter(WindowDesc *const *a, WindowDesc *const *b)
Sort WindowDesc by ini_key.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
virtual void OnScroll(Point delta)
Handle the request for (viewport) scrolling.
static bool IsGoodAutoPlace2(int left, int top, int width, int height, int toolbar_y, Point &pos)
Decide whether a given rectangle is a good place to open a mostly visible new window.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
ViewportAutoscrolling
Values for _settings_client.gui.auto_scrolling.
Base of all video drivers.
static Window * _mouseover_last_w
Window of the last OnMouseOver event.
Data about how and where to blit pixels.
ResizeInfo resize
Resize information.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
const QueryString * GetQueryString(uint widnum) const
Return the querystring associated to a editbox.
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
uint32 _realtime_tick
The real time in the game.
WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, WindowClass window_class, WindowClass parent_class, uint32 flags, const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys=NULL)
Window description constructor.
Window * _z_front_window
List of windows opened at the screen sorted from the front.
const NWidgetCore * nested_focus
Currently focused nested widget, or NULL if no nested widget has focus.
Point pos
logical mouse position
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
static void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
Generate repaint events for the visible part of window w within the rectangle.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Window * parent
Parent window.
void HandleTextInput(const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
Handle text input.
High level window description.
Saveload window; Window numbers:
Bootstrap; Window numbers:
Landscape generation (in Scenario Editor); Window numbers:
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
Window is being resized towards the right.
WindowFlags flags
Window flags.
int left
x position of left edge of the window
static void PreventHiding(int *nx, int *ny, const Rect &rect, const Window *v, int px, PreventHideDirection dir)
Do not allow hiding of the rectangle with base coordinates nx and ny behind window v...
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
int height
Screen height of the viewport.
static Titem * Get(size_t index)
Returns Titem with given index.
Hotkey related functions.
virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond)
Event to display a custom tooltip.
int16 pref_height
User-preferred height of the window. Zero if unset.
static void RemoveWindowFromZOrdering(Window *w)
Removes a window from the z-ordering.
uint8 toolbar_pos
position of toolbars, 0=left, 1=center, 2=right
uint8 window_snap_radius
windows snap at each other if closer than this
bool _right_button_down
Is right mouse button pressed?
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
Dispatch left mouse-button (possibly double) click in window.
Progress report of landscape generation; Window numbers:
void NetworkReInitChatBoxSize()
Initialize all font-dependent chat box sizes.
void CallWindowGameTickEvent()
Dispatch OnGameTick event over all windows.
void DeleteConstructionWindows()
Delete all windows that are used for construction of vehicle etc.
textfile; Window numbers:
uint16 hover_delay_ms
time required to activate a hover event, in milliseconds
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
The passed event is not handled.
bool Elapsed(uint delta)
Test if a timer has elapsed.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
void HandleCtrlChanged()
State of CONTROL key has changed.
Types for recording game performance data.
void InitWindowSystem()
(re)initialize the windowing system
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
Time between 2 left clicks before it becoming a double click, in ms.
virtual ~PickerWindowBase()
Destructor of the base class PickerWindowBase Main utility is to stop the base Window destructor from...
void CDECL void DeleteAll()
Delete every character in the textbuffer.
PreventHideDirection
Direction for moving the window.
static const int ACTION_CLEAR
Clear editbox.
Buyout company (merger); Window numbers:
int top
y position of top edge of the window
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
void Clear()
Remove all items from the list.
void IConsoleResize(Window *w)
Change the size of the in-game console window after the screen size changed, or the window state chan...
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right...
const T * Begin() const
Get the pointer to the first item (const)
virtual const char * GetFocusedText() const
Get the current input text if an edit box has the focus.
virtual void OnEditboxChanged(int widget)
The text in an editbox has been edited.
static EventState HandleViewportScroll()
Handle viewport scrolling with the mouse.
void * clicked_pixel
Clicked pixel (pointer to blitter buffer)
static EventState HandleWindowDragging()
Handle dragging/resizing of a window.
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
void UpdateTileSelection()
Updates tile highlighting for all cases.
Dimension _cur_resolution
The current resolution.
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
static void StartWindowDrag(Window *w)
Start window dragging.
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
static bool _dragging_window
A window is being dragged or resized.
static void StartWindowSizing(Window *w, bool to_left)
Start resizing a window.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Simple vector template class.
Scroll all viewports at their edges.
WindowClass
Window classes.
#define CLRBITS(x, y)
Clears several bits in a variable.
int16 default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
void DeleteAllMessages()
Delete all messages and their corresponding window (if any).
How all blitters should look like.
uint16 bytes
the current size of the string in bytes (including terminating '\0')
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static T max(const T a, const T b)
Returns the maximum of two values.
Speed of drawing world and GUI.
Map moves with mouse movement on holding right mouse button, cursor position is fixed.
WindowClass cls
Class of the window,.
void DeleteAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
void HandleKeypress(uint keycode, WChar key)
Handle keyboard input.
Non-text change, e.g. cursor position.
Window is made sticky by user.
Presizing mode (docks, tunnels).
Above v is a safe position.
void InputLoop()
Regular call from the global game loop.
virtual void OnTimeout()
Called when this window's timeout has been reached.
Window is being resized towards the left.
const T * End() const
Get the pointer behind the last valid item (const)
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker
The sprite picker.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
bool _left_button_clicked
Is left mouse button clicked?
bool _network_dedicated
are we a dedicated server?
T * Append(uint to_add=1)
Append an item and return it.
virtual const char * GetMarkedText(size_t *length) const
Get the range of the currently marked input text.
int GetMainViewBottom()
Return the bottom of the main view available for general use.
static SmallVector< WindowDesc *, 16 > * _window_descs
List of all WindowDescs.
Functions related to (drawing on) viewports.
Sprite aligner (debug); Window numbers:
static void HandleAutoscroll()
If needed and switched on, perform auto scrolling (automatically moving window contents when mouse is...
void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index)
Switches viewports following vehicles, which get autoreplaced.
Base for the GUIs that have an edit box in them.
static void DispatchHoverEvent(Window *w, int x, int y)
Dispatch hover of the mouse over a window.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
bool InsertString(const char *str, bool marked, const char *caret=NULL, const char *insert_location=NULL, const char *replacement_end=NULL)
Insert a string into the text buffer.
static const int ACTION_NOTHING
Nothing.
Main window; Window numbers:
Vehicle orders; Window numbers:
int16 GetDefaultHeight() const
Determine default height of window.
void NetworkChatMessageLoop()
Check if a message is expired.
uint8 scroll_mode
viewport scroll mode
Point selend
The location where the drag currently ends.
int16 default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
uint8 valid
Bits indicating what variable is valid (for each bit, 0 is invalid, 1 is valid).
EventState VpHandlePlaceSizingDrag()
Handle the mouse while dragging for placement/resizing.
Functions related to errors.
static EventState HandleActiveWidget()
Handle active widget (mouse draggin on widget) with the mouse.
bool _right_button_clicked
Is right mouse button clicked?
uint Length() const
Get the number of items in the list.
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
Error message; Window numbers:
void HideVitalWindows()
Delete all always on-top windows to get an empty screen.
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
This window is used for construction; close it whenever changing company.
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
virtual void OnFocusLost()
Called when window looses focus.
static Point GetAutoPlacePosition(int width, int height)
Find a good place for opening a new window of a given width and height.
static Point _drag_delta
delta between mouse cursor and upper left corner of dragged window
Tooltip window; Window numbers:
void IniLoadWindowSettings(IniFile *ini, const char *grpname, void *desc)
Load a WindowDesc from config.
int16 GetDefaultWidth() const
Determine default width of window.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
virtual void OnFocus()
Called when window gains focus.
uint32 VehicleID
The type all our vehicle IDs have.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Small map; Window numbers:
On Screen Keyboard; Window numbers:
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
bool _left_button_down
Is left mouse button pressed?
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar...
Functions related to the gfx engine.
abort current news display (active news were deleted)
void InitNewsItemStructs()
Initialize the news-items data structures.
Functions related to setting/changing the settings.
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
Data stored about a string that can be modified in the GUI.
ClientSettings _settings_client
The current settings for this game.
Types related to global configuration settings.
uint8 scrollwheel_scrolling
scrolling using the scroll wheel?
void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
void LoadFromDisk(const char *filename, Subdirectory subdir)
Load the Ini file's data from the disk.
Functions related to modal progress.
A path without any base directory.
Definition of base types and functions in a cross-platform compatible way.
SmallVector< int, 4 > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
WindowPosition default_pos
Preferred position of the window.
Window is centered and shall stay centered after ReInit.
int GetMainViewTop()
Return the top of the main view available for general use.
A number of safeguards to prevent using unsafe methods.
static void HandleMouseOver()
Report position of the mouse to the underlying window.
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
int wheel
mouse wheel movement
List of hotkeys for a window.
static const int8 scrollamt[16][2]
Describes all the different arrow key combinations the game allows when it is in scrolling mode...
void DeleteCompanyWindows(CompanyID id)
Delete all windows of a company.
uint32 click_time
Realtime tick when clicked to detect next frame.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
static void DispatchMouseWheelEvent(Window *w, NWidgetCore *nwid, int wheel)
Dispatch the mousewheel-action to the window.
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
void DeleteChildWindows(WindowClass wc=WC_INVALID) const
Delete all children a window might have in a head-recursive manner.
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
uint nested_array_size
Size of the nested array.
bool right_mouse_wnd_close
close window with right click
Key does not affect editboxes.
Custom currency; Window numbers:
virtual void OnHover(Point pt, int widget)
The mouse is hovering over a widget in the window, perform an action for it.
Finances of a company; Window numbers:
EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode)
Process keypress for editbox widget.
virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
Insert a text string at the cursor position into the edit box widget.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
bool _mouse_hovering
The mouse is hovering over the same point.
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
virtual void OnMouseOver(Point pt, int widget)
The mouse is currently moving over the window or has just moved outside of the window.
Console functions used outside of the console code.
Company colour selection; Window numbers:
Highscore; Window numbers:
int GetRowFromWidget(int clickpos, int widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
GUI related functions in the console.
Road vehicle list; Window numbers:
static bool MaybeBringWindowToFront(Window *w)
Check if a window can be made relative top-most window, and if so do it.
const T * Find(const T &item) const
Search for the first occurrence of an item.
static void EnsureVisibleCaption(Window *w, int nx, int ny)
Make sure at least a part of the caption bar is still visible by moving the window if necessary...
uint8 white_border_timer
Timer value of the WF_WHITE_BORDER for flags.
Basic functions/variables used all over the place.
Below v is a safe position.
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
void SetDirtyBlocks(int left, int top, int right, int bottom)
This function extends the internal _invalid_rect rectangle as it now contains the rectangle defined b...
PauseModeByte _pause_mode
The current pause mode.
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
static void DispatchRightClickEvent(Window *w, int x, int y)
Dispatch right mouse-button click in window.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
static T min(const T a, const T b)
Returns the minimum of two values.
Types related to reading/writing '*.ini' files.
Window has a widget that has a highlight.
Scroll main viewport at edge.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
void HandleMouseEvents()
Handle a mouse event from the video driver.
bool pref_sticky
Preferred stickyness.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
ViewPort * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
int32 dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
void UnInitWindowSystem()
Close down the windowing system.
Maximum mouse movement before stopping a hover event.
The window is a modal child of some other window, meaning the parent is 'inactive'.
Station list; Window numbers:
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
No construction actions may be executed.
static const int MIN_VISIBLE_TITLE_BAR
The minimum number of pixels of the title bar must be visible in both the X or Y direction.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
bool _shift_pressed
Is Shift pressed?
Build toolbar; Window numbers:
#define DEBUG(name, level,...)
Output a line of debugging information.
Offset of the caption text at the top.
Network status window; Window numbers:
News history list; Window numbers:
Select game window; Window numbers:
Scroll main viewport at edge when using fullscreen.
Window * z_back
The window behind us in z-order.
int left
Screen coordinate left egde of the viewport.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
void UnshowCriticalError()
Unshow the critical error.
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
Company infrastructure overview; Window numbers:
virtual void OnPaint()
The window must be repainted.
void DeleteNonVitalWindows()
Try to delete a non-vital window.
Functions related to companies.
Return or enter key pressed.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
int32 dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
virtual ~Window()
Remove window and all its child windows from the window stack.
void ReInitAllWindows()
Re-initialize all windows.
bool EditBoxInGlobalFocus()
Check if an edit box is in global focus.
Ini file that supports both loading and saving.
Save preset; Window numbers:
GUISettings gui
settings related to the GUI
How much the mouse is allowed to move to call it a double click.
Align toward the toolbar.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
virtual const char * GetCaret() const
Get the string at the caret if an edit box has the focus.
Base class for all vehicles.
Data structure for viewport, display of a part of the world.
static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
Compute the position of the top-left corner of a new window that is opened.
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
Time spent drawing world viewports in GUI.
Offset of the caption text at the bottom.
bool IsWidgetHighlighted(byte widget_index) const
Gets the highlighted status of a widget.
Ships list; Window numbers:
Window * z_front
The window in front of us in z-order.
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
bool _window_highlight_colour
If false, highlight is white, otherwise the by the widget defined colour.
WindowClass parent_cls
Class of the parent window.
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
virtual const char * GetTextCharacterAtPosition(const Point &pt) const
Get the character that is rendered at a position by the focused edit box.
TextDirection _current_text_dir
Text direction of the currently selected language.
uint8 command_pause_level
level/amount of commands that can't be executed while paused
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
This window won't get focus/make any other window lose focus when click.
static int _input_events_this_tick
Local counter that is incremented each time an mouse input event is detected.
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
virtual Rect GetTextBoundingRect(const char *from, const char *to) const
Get the bounding rectangle for a text range if an edit box has the focus.
void Reset()
Reset tile highlighting.
Trains list; Window numbers:
void NetworkDrawChatMessage()
Draw the chat message-box.
Functions related to zooming.
virtual void OnGameTick()
Called once per (game) tick.
static void HandleScrollbarScrolling(Window *w)
Handle scrollbar scrolling with the mouse.
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
void InitDepotWindowBlockSizes()
Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle s...
Network window; Window numbers:
uint8 window_soft_limit
soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
void Erase(T *item)
Removes given item from this vector.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Functions related to the drop down widget.
bool in_window
mouse inside this window, determines drawing logic
Viewport moves with mouse movement on holding right mouse button, cursor position is fixed...
Do not autoscroll when mouse is at edge of viewport.
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
uint step_width
Step-size of width resize changes.
HotkeyList * hotkeys
Hotkeys for the window.
Aircraft list; Window numbers:
virtual void EditBoxLostFocus()
An edit box lost the input focus.
Statusbar (at the bottom of your screen); Window numbers:
Base functions for all Games.
Network functions used by other parts of OpenTTD.
Main toolbar (the long bar at the top); Window numbers:
Coordinates of a point in 2D.
static bool IsGoodAutoPlace1(int left, int top, int width, int height, int toolbar_y, Point &pos)
Decide whether a given rectangle is a good place to open a completely visible new window...
uint8 auto_scrolling
scroll when moving mouse to the edge (see ViewportAutoscrolling)
static void BringWindowToFront(Window *w)
On clicking on a window, make it the frontmost window of all windows with an equal or lower z-priorit...
int16 pref_width
User-preferred width of the window. Zero if unset.
Map moves with mouse movement on holding left mouse button, cursor moves.
Window does not do autoscroll,.
ConstructionSettings construction
construction of things in-game
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
Endscreen; Window numbers:
AI settings; Window numbers:
void ChangeWindowOwner(Owner old_owner, Owner new_owner)
Change the owner of all the windows one company can take over from another company in the case of a c...
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
int CheckMatch(uint16 keycode, bool global_only=false) const
Check if a keycode is bound to something.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Popup with confirm question; Window numbers:
ZoomLevel zoom
The zoom level of the viewport.
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
int width
width of the window (number of pixels to the right in x direction)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static EventState HandleMouseDragDrop()
Handle dragging and dropping in mouse dragging mode (WSM_DRAGDROP).
virtual void OnResize()
Called after the window got resized.
NewGRF parameters; Window numbers:
static uint GetWindowZPriority(WindowClass wc)
Get the z-priority for a given window.
int32 WindowNumber
Number to differentiate different windows of the same class.
static int PositionWindow(Window *w, WindowClass clss, int setting)
(Re)position a window at the screen.
WindowClass window_class
Window class.
virtual void OnMouseWheel(int wheel)
The mouse wheel has been turned.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
bool IsShaded() const
Is window shaded currently?
The passed event is handled.
Text is written right-to-left by default.
WindowNumber window_number
Window number within the window class.
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
Functions related to tile highlights.
Owner
Enum for all companies/owners.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
static Window * _last_scroll_window
Window of the last scroll event.
Window functions not directly related to making/drawing windows.
Point delta
relative mouse movement in this tick
int top
Screen coordinate top edge of the viewport.
static uint Ceil(uint a, uint b)
Computes ceil(a / b) * b for non-negative a and b.
Find a place automatically.
void CallWindowRealtimeTickEvent(uint delta_ms)
Dispatch OnRealtimeTick event over all windows.
Manually align the window (so no automatic location finding)
virtual void OnHundredthTick()
Called once every 100 (game) ticks.
uint8 statusbar_pos
position of statusbar, 0=left, 1=center, 2=right
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
SmallVector< SpriteID, 256 > sprites
Sprites found.
ViewportData * viewport
Pointer to viewport data, if present.
void IniSaveWindowSettings(IniFile *ini, const char *grpname, void *desc)
Save a WindowDesc to config.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Functions related to news.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Functions, definitions and such used only by the GUI.
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
uint32 WChar
Type for wide characters, i.e.
const NWID * GetWidget(uint widnum) const
Get the nested widget with number widnum from the nested widget tree.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Company view; Window numbers:
Window white border counter bit mask.
WindowPosition
How do we the window to be placed?
NWidgetBase * nested_root
Root of the nested tree.
Query string window; Window numbers:
NewGrfDebugSpritePickerMode mode
Current state.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Factory to 'query' all available blitters.
Game options window; Window numbers:
WindowDesc * window_desc
Window description.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
static bool HasModalProgress()
Check if we are currently in a modal progress state.
char * _windows_file
Config file to store WindowDesc.
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
static void AddWindowToZOrdering(Window *w)
Adds a window to the z-ordering, according to its z-priority.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Drop down menu; Window numbers:
int height
Height of the window (number of pixels down in y direction)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
News window; Window numbers:
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
void UpdateViewportPosition(Window *w)
Update the viewport position being displayed.
static bool MayBeShown(const Window *w)
Returns whether a window may be shown or not.
void IConsoleClose()
Close the in-game console.
#define FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start)
Iterate over all windows.
void ShowFirstError()
Show the first error of the queue.
int width
Screen width of the viewport.