Go to the documentation of this file.
83 Point _cursorpos_drag_start;
85 int _scrollbar_start_pos;
87 byte _scroller_click_timeout = 0;
107 default_pos(def_pos),
109 parent_cls(parent_class),
112 nwid_parts(nwid_parts),
113 nwid_length(nwid_length),
118 default_width_trad(def_width_trad),
119 default_height_trad(def_height_trad)
125 WindowDesc::~WindowDesc()
158 if (wd->ini_key ==
nullptr)
continue;
183 if (wd->ini_key ==
nullptr)
continue;
213 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(widget);
214 if (line_height < 0) line_height = wid->
resize_y;
215 if (clickpos < (
int)wid->
pos_y + padding)
return INT_MAX;
216 return (clickpos - (
int)wid->
pos_y - padding) / line_height;
225 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
226 if (nwid ==
nullptr)
continue;
228 if (nwid->IsHighlighted()) {
229 nwid->SetHighlighted(TC_INVALID);
246 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
247 if (nwid ==
nullptr)
return;
249 nwid->SetHighlighted(highlighted_colour);
252 if (highlighted_colour != TC_INVALID) {
259 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
260 if (nwid ==
nullptr)
continue;
261 if (!nwid->IsHighlighted())
continue;
279 const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget_index);
280 if (nwid ==
nullptr)
return false;
282 return nwid->IsHighlighted();
294 if (widget < 0)
return;
305 NWidgetCore *nwi2 = this->GetWidget<NWidgetCore>(widget);
321 return this->GetWidget<NWidgetScrollbar>(widnum);
331 return this->GetWidget<NWidgetScrollbar>(widnum);
342 return query != this->
querystrings.end() ? query->second :
nullptr;
353 return query != this->
querystrings.End() ? query->second :
nullptr;
363 qs.second->text.UpdateSize();
433 Rect r = {0, 0, 0, 0};
457 if (_focused_window == w)
return;
463 if (_focused_window !=
nullptr) {
468 Window *old_focused = _focused_window;
472 if (old_focused !=
nullptr) old_focused->
OnFocusLost();
473 if (_focused_window !=
nullptr) _focused_window->
OnFocus();
483 if (_focused_window ==
nullptr)
return false;
526 if (this->GetWidget<NWidgetCore>(widget_index) == this->
nested_focus)
return false;
532 this->
nested_focus = this->GetWidget<NWidgetCore>(widget_index);
564 va_start(wdg_list, widgets);
568 widgets = va_arg(wdg_list,
int);
583 va_start(wdg_list, widgets);
587 widgets = va_arg(wdg_list,
int);
602 if (((type & ~WWB_PUSHBUTTON) <
WWT_LAST || type == NWID_PUSHBUTTON_DROPDOWN) &&
611 if (wid !=
nullptr) {
638 NWidgetCore *nw = this->GetWidget<NWidgetCore>(hotkey);
684 bool focused_widget_changed =
false;
686 if (_focused_window != w &&
689 focused_widget_changed =
true;
693 if (nw ==
nullptr)
return;
698 int widget_index = nw->
index;
723 switch (widget_type) {
731 if (query !=
nullptr) query->ClickEditBox(w, pt, widget_index, click_count, focused_widget_changed);
793 if (widget_index < 0)
return;
801 w->
OnClick(pt, widget_index, click_count);
813 if (wid ==
nullptr)
return;
818 if (wid->
index >= 0) {
841 if (wid ==
nullptr)
return;
852 if (wid->
index < 0)
return;
866 if (nwid ==
nullptr)
return;
927 for (; !it.IsEnd(); ++it) {
932 left < v->left + v->
width &&
933 top < v->top + v->
height) {
937 if (left < (x = v->
left)) {
949 if (top < (x = v->
top)) {
967 dp->width = right - left;
968 dp->height = bottom - top;
969 dp->left = left - w->
left;
970 dp->top = top - w->
top;
971 dp->pitch = _screen.pitch;
995 left < w->left + w->width &&
996 top < w->top + w->height) {
998 DrawOverlappedWindow(w, std::max(left, w->left), std::max(top, w->top), std::min(right, w->left + w->width), std::min(bottom, w->top + w->height));
1024 int window_width = this->
width;
1025 int window_height = this->
height;
1037 window_width = std::max(window_width + rx, this->
width);
1038 window_height = std::max(window_height + ry, this->
height);
1085 if ((wc ==
WC_INVALID || wc == v->window_class) && v->parent == w)
return v;
1098 while (child !=
nullptr) {
1110 if (*this->z_position ==
nullptr)
return;
1112 *this->z_position =
nullptr;
1129 if (_focused_window ==
this) {
1131 _focused_window =
nullptr;
1147 assert(*this->z_position ==
nullptr);
1149 if (this->
viewport !=
nullptr) DeleteWindowViewport(
this);
1164 if (w->window_class == cls && w->window_number == number)
return w;
1179 if (w->window_class == cls)
return w;
1207 if (w->window_class == cls) {
1223 if (w->owner ==
id) {
1242 if (w->owner != old_owner)
continue;
1244 switch (w->window_class) {
1259 w->owner = new_owner;
1289 static inline bool IsVitalWindow(
const Window *w)
1315 uint z_priority = 0;
1395 WindowList::iterator dest =
_z_windows.begin();
1398 if (dest != w->z_position) {
1458 this->
width = sm_width;
1459 this->
height = sm_height;
1474 def_width = std::max(def_width, this->
width);
1475 def_height = std::max(def_height, this->
height);
1481 if (this->
width != def_width || this->
height != def_height) {
1483 int free_height = _screen.height;
1485 if (wt !=
nullptr) free_height -= wt->
height;
1487 if (wt !=
nullptr) free_height -= wt->
height;
1489 int enlarge_x = std::max(std::min(def_width - this->
width, _screen.width - this->width), 0);
1490 int enlarge_y = std::max(std::min(def_height - this->
height, free_height - this->
height), 0);
1505 int nx = this->
left;
1508 if (nx + this->
width > _screen.width) nx -= (nx + this->
width - _screen.width);
1511 ny = std::max(ny, (wt ==
nullptr ||
this == wt || this->
top == 0) ? 0 : wt->
height);
1512 nx = std::max(nx, 0);
1538 int right = width + left;
1539 int bottom = height + top;
1541 if (left < 0 || top < toolbar_y || right > _screen.width || bottom > _screen.height)
return false;
1547 if (right > w->
left &&
1580 if (left < -(width >> 1) || left > _screen.width - (width >> 2))
return false;
1582 if (left < -(width >> 2) || left > _screen.width - (width >> 1))
return false;
1586 if (top < toolbar_y || top > _screen.height - (height >> 2))
return false;
1592 if (left + width > w->
left &&
1594 top + height > w->
top &&
1619 const int toolbar_y = main_toolbar !=
nullptr ? main_toolbar->
height : 0;
1620 if (
IsGoodAutoPlace1(rtl ? _screen.width - width : 0, toolbar_y, width, height, toolbar_y, pt))
return pt;
1655 int left = rtl ? _screen.width - width : 0, top = toolbar_y;
1661 if (w->
left == left && w->
top == top) {
1682 assert(w !=
nullptr);
1715 pt.x = w->
left + (rtl ? w->
width - default_width : 0);
1724 if (w->
top + 3 * indent_y < _screen.height) {
1725 pt.y = w->
top + indent_y;
1729 pt.x = std::max(w->
left + w->
width - default_width - indent_close, 0);
1730 if (pt.x + default_width >= indent_close && pt.x + indent_resize <= _screen.width)
return pt;
1732 pt.x = std::min(w->
left + indent_close, _screen.width - default_width);
1733 if (pt.x + default_width >= indent_resize && pt.x + indent_close <= _screen.width)
return pt;
1747 pt.x = (_screen.width - default_width) / 2;
1748 pt.y = (_screen.height - default_height) / 2;
1777 int biggest_index = -1;
1844 _focused_window =
nullptr;
1851 NWidgetScrollbar::InvalidateDimensionCache();
1880 static void DecreaseWindowCounters()
1882 static byte hundredth_tick_timeout = 100;
1884 if (_scroller_click_timeout != 0) _scroller_click_timeout--;
1885 if (hundredth_tick_timeout != 0) hundredth_tick_timeout--;
1890 if (_scroller_click_timeout == 0) {
1907 pair.second->HandleEditBox(w, pair.first);
1922 if (hundredth_tick_timeout == 0) hundredth_tick_timeout = 100;
1925 static void HandlePlacePresize()
1930 if (w ==
nullptr)
return;
1932 Point pt = GetTileBelowCursor();
1955 pt.x = _cursor.
pos.x - w->
left;
1956 pt.y = _cursor.
pos.y - w->
top;
1976 Point pt = { -1, -1 };
2012 if (v ==
nullptr)
return;
2018 int safe_y = (dir ==
PHD_UP) ? (v->
top - min_visible - rect.top) : (v_bottom + min_visible - rect.bottom);
2020 if (*ny + rect.top <= v->
top - min_visible)
return;
2021 if (*ny + rect.bottom >= v_bottom + min_visible)
return;
2024 if (*nx + rect.left + min_visible < v->left) {
2025 if (v->
left < min_visible) *ny = safe_y;
2028 if (*nx + rect.right - min_visible > v_right) {
2029 if (v_right > _screen.width - min_visible) *ny = safe_y;
2034 if (px + rect.left < v->
left && v->
left >= min_visible) {
2035 *nx = v->
left - min_visible - rect.left;
2036 }
else if (px + rect.right > v_right && v_right <= _screen.width - min_visible) {
2037 *nx = v_right + min_visible - rect.right;
2055 if (caption !=
nullptr) {
2056 caption_rect = caption->GetCurrentRect();
2061 nx =
Clamp(nx, min_visible - caption_rect.right, _screen.width - min_visible - caption_rect.left);
2062 ny =
Clamp(ny, 0, _screen.height - min_visible);
2090 if (delta_x != 0 || delta_y != 0) {
2091 if (clamp_to_screen) {
2094 int new_right = w->
left + w->
width + delta_x;
2095 int new_bottom = w->
top + w->
height + delta_y;
2096 if (new_right >= (
int)_screen.width) delta_x -=
Ceil(new_right - _screen.width, std::max(1U, w->
nested_root->
resize_x));
2097 if (new_bottom >= (
int)_screen.height) delta_y -=
Ceil(new_bottom - _screen.height, std::max(1U, w->
nested_root->
resize_y));
2127 return (w ==
nullptr) ? 0 : w->
top + w->
height;
2138 return (w ==
nullptr) ? _screen.height : w->
top;
2177 if (v == w)
continue;
2179 if (y + w->
height > v->top && y < v->top + v->height) {
2181 delta =
abs(v->left + v->width - x);
2182 if (delta <= hsnap) {
2183 nx = v->left + v->width;
2188 delta =
abs(v->left - x - w->
width);
2189 if (delta <= hsnap) {
2190 nx = v->left - w->
width;
2195 if (w->
top + w->
height >= v->top && w->
top <= v->top + v->height) {
2197 delta =
abs(v->left - x);
2198 if (delta <= hsnap) {
2204 delta =
abs(v->left + v->width - x - w->
width);
2205 if (delta <= hsnap) {
2206 nx = v->left + v->width - w->
width;
2211 if (x + w->
width > v->left && x < v->left + v->width) {
2213 delta =
abs(v->top + v->height - y);
2214 if (delta <= vsnap) {
2215 ny = v->top + v->height;
2221 if (delta <= vsnap) {
2227 if (w->
left + w->
width >= v->left && w->
left <= v->left + v->width) {
2229 delta =
abs(v->top - y);
2230 if (delta <= vsnap) {
2236 delta =
abs(v->top + v->height - y - w->
height);
2237 if (delta <= vsnap) {
2238 ny = v->top + v->height - w->
height;
2272 if (w->
top + w->
height + y > _screen.height) {
2273 y = _screen.height - w->
height - w->
top;
2358 i = _cursor.
pos.x - _cursorpos_drag_start.x;
2361 i = _cursor.
pos.y - _cursorpos_drag_start.y;
2365 if (_scroller_click_timeout == 1) {
2366 _scroller_click_timeout = 3;
2444 if (scrollwheel_scrolling) {
2446 delta.x = _cursor.h_wheel;
2447 delta.y = _cursor.v_wheel;
2448 _cursor.v_wheel = 0;
2449 _cursor.h_wheel = 0;
2452 delta.x = -_cursor.
delta.x;
2453 delta.y = -_cursor.
delta.y;
2455 delta.x = _cursor.
delta.x;
2456 delta.y = _cursor.
delta.y;
2463 _cursor.
delta.x = 0;
2464 _cursor.
delta.y = 0;
2480 bool bring_to_front =
false;
2490 int w_width = w->
width;
2491 int w_height = w->
height;
2499 for (; !it.IsEnd(); ++it) {
2516 if (w->
left + w_width <= u->left ||
2518 w->
top + w_height <= u->top ||
2523 bring_to_front =
true;
2545 switch (query->text.HandleKeyPress(key, keycode)) {
2589 if (query->text.
bytes <= 1) {
2640 if (key >= 0xE000 && key <= 0xF8FF) key = 0;
2645 if (key == 0 && keycode == 0)
return;
2677 HandleGlobalHotkeys(key, keycode);
2696 void Window::InsertTextString(
int wid,
const char *str,
bool marked,
const char *caret,
const char *insert_location,
const char *replacement_end)
2699 if (query ==
nullptr)
return;
2701 if (query->text.
InsertString(str, marked, caret, insert_location, replacement_end) || marked) {
2713 void HandleTextInput(
const char *str,
bool marked,
const char *caret,
const char *insert_location,
const char *replacement_end)
2738 int x = _cursor.
pos.x;
2739 int y = _cursor.
pos.y;
2745 if (vp ==
nullptr)
return;
2751 static const int SCROLLSPEED = 3;
2754 }
else if (15 - (vp->
width - x) > 0) {
2759 }
else if (15 - (vp->
height - y) > 0) {
2778 static void ScrollMainViewport(
int x,
int y)
2780 if (_game_mode != GM_MENU) {
2817 static void HandleKeyScrolling()
2829 static void MouseLoop(
MouseClick click,
int mousewheel)
2835 HandlePlacePresize();
2847 if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling)
return;
2849 int x = _cursor.
pos.x;
2850 int y = _cursor.
pos.y;
2852 if (w ==
nullptr)
return;
2858 if (vp !=
nullptr && (_game_mode == GM_MENU ||
HasModalProgress()))
return;
2860 if (mousewheel != 0) {
2868 if (vp !=
nullptr) {
2876 case MC_DOUBLE_LEFT:
2878 if (HandleViewportClicked(vp, x, y))
return;
2905 case MC_DOUBLE_LEFT:
2925 _cursor.h_wheel = 0;
2926 _cursor.v_wheel = 0;
2946 static std::chrono::steady_clock::time_point double_click_time = {};
2947 static Point double_click_pos = {0, 0};
2956 click = MC_DOUBLE_LEFT;
2958 double_click_time = std::chrono::steady_clock::now();
2959 double_click_pos = _cursor.
pos;
2969 if (_cursor.
wheel) {
2970 mousewheel = _cursor.
wheel;
2975 static std::chrono::steady_clock::time_point hover_time = {};
2976 static Point hover_pos = {0, 0};
2982 hover_pos = _cursor.
pos;
2983 hover_time = std::chrono::steady_clock::now();
2990 hover_time = std::chrono::steady_clock::now();
3003 MouseLoop(click, mousewheel);
3008 _cursor.
delta.x = 0;
3009 _cursor.
delta.y = 0;
3020 uint deletable_count = 0;
3021 Window *last_deletable =
nullptr;
3032 assert(last_deletable !=
nullptr);
3033 last_deletable->
Close();
3077 static std::chrono::steady_clock::time_point last_time = std::chrono::steady_clock::now();
3078 uint delta_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - last_time).count();
3080 if (delta_ms == 0)
return;
3082 last_time = std::chrono::steady_clock::now();
3093 if (network_message_timer.
Elapsed(delta_ms)) {
3094 network_message_timer.SetInterval(1000);
3105 if (window_timer.
Elapsed(delta_ms)) {
3108 extern int _caret_timer;
3112 HandleKeyScrolling();
3114 DecreaseWindowCounters();
3118 if (highlight_timer.
Elapsed(delta_ms)) {
3119 highlight_timer.SetInterval(450);
3129 if (window_timer.HasElapsed()) {
3213 this->scheduled_invalidation_data.clear();
3366 void ReInitWindow(
Window *w,
bool zoom_changed)
3368 if (w ==
nullptr)
return;
3381 NWidgetScrollbar::InvalidateDimensionCache();
3392 ReInitWindow(w, zoom_changed);
3415 if (w ==
nullptr)
return 0;
3417 int old_left = w->
left;
3419 case 1: w->
left = (_screen.width - w->
width) / 2;
break;
3420 case 2: w->
left = _screen.width - w->
width;
break;
3421 default: w->
left = 0;
break;
3435 Debug(misc, 5,
"Repositioning Main Toolbar...");
3446 Debug(misc, 5,
"Repositioning statusbar...");
3457 Debug(misc, 5,
"Repositioning news message...");
3468 Debug(misc, 5,
"Repositioning network chat window...");
3540 top = (newh - w->
height) >> 1;
3541 left = (neww - w->
width) >> 1;
3546 if (left + (w->
width >> 1) >= neww) left = neww - w->
width;
3547 if (left < 0) left = 0;
3550 if (top + (w->
height >> 1) >= newh) top = newh - w->
height;
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
void * clicked_pixel
Clicked pixel (pointer to blitter buffer)
@ ES_HANDLED
The passed event is handled.
void ShowFirstError()
Show the first error of the queue.
Iterator to iterate all valid Windows.
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
@ WC_SAVELOAD
Saveload window; Window numbers:
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
@ WC_ROADVEH_LIST
Road vehicle list; Window numbers:
@ MAX_OFFSET_HOVER
Maximum mouse movement before stopping a hover event.
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-...
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
@ WC_INVALID
Invalid window.
static Window * _mouseover_last_w
Window of the last OnMouseOver event.
static Titem * Get(size_t index)
Returns Titem with given index.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
virtual void OnHundredthTick()
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
@ HKPR_EDITING
Textbuf content changed.
char32_t WChar
Type for wide characters, i.e.
void AddDirtyBlock(int left, int top, int right, int bottom)
Extend the internal _invalid_rect rectangle to contain the rectangle defined by the given parameters.
@ WF_SIZING
Window is being resized.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
static void CheckSoftLimit()
Check the soft limit of deletable (non vital, non sticky) windows.
void UpdateTileSelection()
Updates tile highlighting for all cases.
virtual void OnEditboxChanged(int widget)
The text in an editbox has been edited.
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
List of hotkeys for a window.
static Window * FindChildWindow(const Window *w, WindowClass wc)
Find the Window whose parent pointer points to this window.
const char * GetText() const
Get the current text.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
virtual ~Window()
Remove window and all its child windows from the window stack.
NWidgetBase * nested_root
Root of the nested tree.
@ HKPR_CONFIRM
Return or enter key pressed.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
NWidgetStacked * shade_select
Selection widget (NWID_SELECTION) to use for shading the window. If nullptr, window cannot shade.
@ WF_SIZING_RIGHT
Window is being resized towards the right.
virtual void OnHover(Point pt, int widget)
The mouse is hovering over a widget in the window, perform an action for it.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
bool _left_button_down
Is left mouse button pressed?
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
static const int8 scrollamt[16][2]
Describes all the different arrow key combinations the game allows when it is in scrolling mode.
void CloseCompanyWindows(CompanyID id)
Close all windows of a company.
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.
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
How all blitters should look like.
void IniLoadWindowSettings(IniFile &ini, const char *grpname, void *desc)
Load a WindowDesc from config.
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
static void HandleScrollbarScrolling(Window *w)
Handle scrollbar scrolling with the mouse.
void HandleTextInput(const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
Handle text input.
@ WC_SELECT_GAME
Select game window; Window numbers:
int width
Screen width of the viewport.
@ PHD_DOWN
Below v is a safe position.
@ WF_DISABLE_VP_SCROLL
Window does not do autoscroll,.
ViewportData * viewport
Pointer to viewport data, if present.
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker
The sprite picker.
int height
Screen height of the viewport.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
std::vector< SpriteID > sprites
Sprites found.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
void InitWindowSystem()
(re)initialize the windowing system
NewGrfDebugSpritePickerMode mode
Current state.
virtual void OnGameTick()
Called once per (game) tick.
int top
Screen coordinate top edge of the viewport.
@ WF_STICKY
Window is made sticky by user.
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void InitNewsItemStructs()
Initialize the news-items data structures.
static void StartWindowSizing(Window *w, bool to_left)
Start resizing a window.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static void BringWindowToFront(Window *w, bool dirty=true)
On clicking on a window, make it the frontmost window of all windows with an equal or lower z-priorit...
uint8 valid
Bits indicating what variable is valid (for each bit, 0 is invalid, 1 is valid).
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
void UnInitWindowSystem()
Close down the windowing system.
@ VA_DISABLED
Do not autoscroll when mouse is at edge of viewport.
bool _ctrl_pressed
Is Ctrl pressed?
uint8 window_soft_limit
soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
@ WC_BOOTSTRAP
Bootstrap; Window numbers:
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
@ WC_MESSAGE_HISTORY
News history list; Window numbers:
ClientSettings _settings_client
The current settings for this game.
void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
@ WC_OSK
On Screen Keyboard; Window numbers:
WindowClass cls
Class of the window,.
@ VSM_VIEWPORT_RMB_FIXED
Viewport moves with mouse movement on holding right mouse button, cursor position is fixed.
virtual void OnTimeout()
Called when this window's timeout has been reached.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
int32 WindowNumber
Number to differentiate different windows of the same class.
@ WC_COMPANY
Company view; Window numbers:
const char * GetCharAtPosition(const Window *w, int wid, const Point &pt) const
Get the character that is rendered at a position.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
Owner
Enum for all companies/owners.
uint8 toolbar_pos
position of toolbars, 0=left, 1=center, 2=right
bool EditBoxInGlobalFocus()
Check if an edit box is in global focus.
static void HandleAutoscroll()
If needed and switched on, perform auto scrolling (automatically moving window contents when mouse is...
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static void StartWindowDrag(Window *w)
Start window dragging.
static bool IsLocalCompany()
Is the current company the local company?
void HandleKeypress(uint keycode, WChar key)
Handle keyboard input.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
bool InsertString(const char *str, bool marked, const char *caret=nullptr, const char *insert_location=nullptr, const char *replacement_end=nullptr)
Insert a string into the text buffer.
const NWidgetCore * nested_focus
Currently focused nested widget, or nullptr if no nested widget has focus.
Data stored about a string that can be modified in the GUI.
static uint GetWindowZPriority(WindowClass wc)
Get the z-priority for a given window.
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
std::vector< int > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
bool IsWidgetHighlighted(byte widget_index) const
Gets the highlighted status of a widget.
@ WC_SAVE_PRESET
Save preset; Window numbers:
virtual const char * GetCaret() const
Get the string at the caret if an edit box has the focus.
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.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Implementation of simple mapping class.
@ WC_HIGHSCORE
Highscore; Window numbers:
void NetworkReInitChatBoxSize()
Initialize all font-dependent chat box sizes.
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
int16 default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
@ PHD_UP
Above v is a safe position.
WindowPosition default_pos
Preferred position of the window.
High level window description.
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
@ WF_SIZING_LEFT
Window is being resized towards the left.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
const NWID * GetWidget(uint widnum) const
Get the nested widget with number widnum from the nested widget tree.
uint8 scrollwheel_scrolling
scrolling using the scroll wheel?
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
virtual void OnFocusLost()
Called when window loses focus.
static bool MayBeShown(const Window *w)
Returns whether a window may be shown or not.
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
@ WC_QUERY_STRING
Query string window; Window numbers:
Data structure for viewport, display of a part of the world.
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
@ WDP_AUTO
Find a place automatically.
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index)
Switches viewports following vehicles, which get autoreplaced.
ResizeInfo resize
Resize information.
static int _input_events_this_tick
Local counter that is incremented each time an mouse input event is detected.
@ WSM_PRESIZE
Presizing mode (docks, tunnels).
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
@ WC_BUY_COMPANY
Buyout company (merger); Window numbers:
static bool DescSorter(WindowDesc *const &a, WindowDesc *const &b)
Sort WindowDesc by ini_key.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
void CloseNonVitalWindows()
Try to close a non-vital window.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
const std::chrono::milliseconds TIME_BETWEEN_DOUBLE_CLICK(500)
Time between 2 left clicks before it becoming a double click.
int height
Height of the window (number of pixels down in y direction)
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
@ WF_WHITE_BORDER
Window white border counter bit mask.
SpecialMouseMode
Mouse modes.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
int left
Screen coordinate left edge of the viewport.
@ SBI_NEWS_DELETED
abort current news display (active news were deleted)
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Rect GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const
Get the bounding rectangle for a range of the query string.
@ INVALID_OWNER
An invalid owner.
virtual void OnFocus()
Called when window gains focus.
bool SaveToDisk(const std::string &filename)
Save the Ini file's data to the disk.
@ ES_NOT_HANDLED
The passed event is not handled.
static void DispatchMouseWheelEvent(Window *w, NWidgetCore *nwid, int wheel)
Dispatch the mousewheel-action to the window.
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode)
Process keypress for editbox widget.
static Point GetAutoPlacePosition(int width, int height)
Find a good place for opening a new window of a given width and height.
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.
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
PauseMode _pause_mode
The current pause mode.
void ProcessPendingPerformanceMeasurements()
This drains the PFE_SOUND measurement data queue into _pf_data.
int GetMainViewTop()
Return the top of the main view available for general use.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
const QueryString * GetQueryString(uint widnum) const
Return the querystring associated to a editbox.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
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.
int16 GetDefaultWidth() const
Determine default width of window.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
static void DeleteClosedWindows()
Delete all closed windows.
Window * parent
Parent window.
void CallWindowGameTickEvent()
Dispatch OnGameTick event over all windows.
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar.
uint16 hover_delay_ms
time required to activate a hover event, in milliseconds
int left
x position of left edge of the window
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
WindowFlags flags
Window flags.
WindowList _z_windows
List of windows opened at the screen sorted from the front to back.
@ WF_TIMEOUT
Window timeout counter.
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
@ WC_SHIPS_LIST
Ships list; Window numbers:
WindowClass
Window classes.
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
void HandleCtrlChanged()
State of CONTROL key has changed.
bool _mouse_hovering
The mouse is hovering over the same point.
int16 default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
void IConsoleResize(Window *w)
Change the size of the in-game console window after the screen size changed, or the window state chan...
bool _shift_pressed
Is Shift pressed?
int wheel
mouse wheel movement
static int PositionWindow(Window *w, WindowClass clss, int setting)
(Re)position a window at the screen.
static void HandleMouseOver()
Report position of the mouse to the underlying window.
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
@ PFE_DRAWING
Speed of drawing world and GUI.
@ VSM_MAP_RMB_FIXED
Map moves with mouse movement on holding right mouse button, cursor position is fixed.
int16 GetDefaultHeight() const
Determine default height of window.
Coordinates of a point in 2D.
@ WF_HIGHLIGHTED
Window has a widget that has a highlight.
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
const NWidgetPart * nwid_parts
Nested widget parts describing the window.
bool FocusedWindowIsConsole()
Check if a console is focused.
int32 dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
@ WC_TRAINS_LIST
Trains list; Window numbers:
@ WSM_DRAGDROP
Drag&drop an object.
virtual void OnInit()
Notification that the nested widget tree gets initialized.
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
bool _network_dedicated
are we a dedicated server?
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
WindowNumber window_number
Window number within the window class.
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
uint step_height
Step-size of height resize changes.
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=nullptr)
Window description constructor.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void HandleMouseEvents()
Handle a mouse event from the video driver.
Iterable ensemble of all valid Windows.
uint8 statusbar_pos
position of statusbar, 0=left, 1=center, 2=right
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
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...
const char * GetCaret() const
Get the position of the caret in the text buffer.
static void DispatchRightClickEvent(Window *w, int x, int y)
Dispatch right mouse-button click in window.
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.
static EventState HandleViewportScroll()
Handle viewport scrolling with the mouse.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
uint16 bytes
the current size of the string in bytes (including terminating '\0')
std::string _windows_file
Config file to store WindowDesc.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
@ VA_EVERY_VIEWPORT
Scroll all viewports at their edges.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right,...
uint step_width
Step-size of width resize changes.
@ VSM_MAP_LMB
Map moves with mouse movement on holding left mouse button, cursor moves.
@ MAX_OFFSET_DOUBLE_CLICK
How much the mouse is allowed to move to call it a double click.
virtual void OnMouseWheel(int wheel)
The mouse wheel has been turned.
Ini file that supports both loading and saving.
bool IsShaded() const
Is window shaded currently?
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...
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
ViewportAutoscrolling
Values for _settings_client.gui.auto_scrolling.
static std::vector< Window * > closed_windows
List of closed windows to delete.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
void UnshowCriticalError()
Unshow the critical error.
@ VA_MAIN_VIEWPORT_FULLSCREEN
Scroll main viewport at edge when using fullscreen.
@ WC_AI_LIST
AI list; Window numbers:
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond)
Event to display a custom tooltip.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
static void DispatchHoverEvent(Window *w, int x, int y)
Dispatch hover of the mouse over a window.
@ NO_DIRECTORY
A path without any base directory.
@ WC_NETWORK_WINDOW
Network window; Window numbers:
@ WC_CONSOLE
Console; Window numbers:
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
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...
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.
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
@ WC_TOOLTIPS
Tooltip window; Window numbers:
@ WC_AI_SETTINGS
AI settings; Window numbers:
bool _window_highlight_colour
If false, highlight is white, otherwise the by the widget defined colour.
virtual void OnPaint()
The window must be repainted.
Point delta
relative mouse movement in this tick
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void IniSaveWindowSettings(IniFile &ini, const char *grpname, void *desc)
Save a WindowDesc to config.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
const char * GetMarkedText(size_t *length) const
Get the currently marked text.
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
@ HKPR_CANCEL
Escape key pressed.
EventState VpHandlePlaceSizingDrag()
Handle the mouse while dragging for placement/resizing.
virtual void OnMouseOver(Point pt, int widget)
The mouse is currently moving over the window or has just moved outside of the window.
EventState
State of handling an event.
void UpdateViewportPosition(Window *w)
Update the viewport position being displayed.
bool pref_sticky
Preferred stickyness.
@ WF_DRAGGING
Window is being dragged.
@ WC_NETWORK_ASK_RELAY
Network ask relay window; Window numbers:
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
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...
void NetworkChatMessageLoop()
Check if a message is expired.
WindowClass window_class
Window class.
@ WC_MAIN_WINDOW
Main window; Window numbers:
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
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.
static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
Dispatch left mouse-button (possibly double) click in window.
@ WC_ENDSCREEN
Endscreen; Window numbers:
PreventHideDirection
Direction for moving the window.
int CheckMatch(uint16 keycode, bool global_only=false) const
Check if a keycode is bound to something.
static const int ACTION_CLEAR
Clear editbox.
void UpdateQueryStringSize()
Update size of all QueryStrings of this window.
int top
y position of top edge of the window
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Viewport * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
bool Elapsed(uint delta)
Test if a timer has elapsed.
uint32 VehicleID
The type all our vehicle IDs have.
static uint Ceil(uint a, uint b)
Computes ceil(a / b) * b for non-negative a and b.
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
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...
std::vector< Pair >::const_iterator Find(const T &key) const
Finds given key in this map.
@ WC_SEND_NETWORK_MSG
Chatbox; Window numbers:
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
static EventState HandleActiveWidget()
Handle active widget (mouse draggin on widget) with the mouse.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
int width
width of the window (number of pixels to the right in x direction)
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
ZoomLevel zoom
The zoom level of the viewport.
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
int32 dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
static EventState HandleMouseDragDrop()
Handle dragging and dropping in mouse dragging mode (WSM_DRAGDROP).
void IConsoleClose()
Close the in-game console.
static Point _drag_delta
delta between mouse cursor and upper left corner of dragged window
static bool _dragging_window
A window is being dragged or resized.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
void NetworkDrawChatMessage()
Draw the chat message-box.
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.
Point GetCaretPosition(const Window *w, int wid) const
Get the current caret position.
static std::vector< WindowDesc * > * _window_descs
List of all WindowDescs.
WindowDesc * window_desc
Window description.
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
@ ZOOM_LVL_NORMAL
The normal zoom level.
static EventState HandleWindowDragging()
Handle dragging/resizing of a window.
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
virtual void EditBoxLostFocus()
An edit box lost the input focus.
ConstructionSettings construction
construction of things in-game
uint8 auto_scrolling
scroll when moving mouse to the edge (see ViewportAutoscrolling)
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
WindowClass parent_cls
Class of the parent window.
Data structure for an opened window.
static const int ACTION_DESELECT
Deselect editbox.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
void InputLoop()
Regular call from the global game loop.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
uint8 scroll_mode
viewport scroll mode
@ WC_NEWS_WINDOW
News window; Window numbers:
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
static bool HasModalProgress()
Check if we are currently in a modal progress state.
void CloseConstructionWindows()
Close all windows that are used for construction of vehicle etc.
@ WC_FINANCES
Finances of a company; Window numbers:
virtual void OnScroll(Point delta)
Handle the request for (viewport) scrolling.
@ HKPR_NOT_HANDLED
Key does not affect editboxes.
uint8 command_pause_level
level/amount of commands that can't be executed while paused
@ WC_ERRMSG
Error message; Window numbers:
uint nested_array_size
Size of the nested array.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static Window * _last_scroll_window
Window of the last scroll event.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
void LoadFromDisk(const std::string &filename, Subdirectory subdir)
Load the Ini file's data from the disk.
int GetMainViewBottom()
Return the bottom of the main view available for general use.
void CallWindowRealtimeTickEvent(uint delta_ms)
Dispatch OnRealtimeTick event over all windows.
Specification of a rectangle with absolute coordinates of all edges.
Point pos
logical mouse position
void LowerWidget(byte widget_index)
Marks a widget as lowered.
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
bool _right_button_clicked
Is right mouse button clicked?
virtual const char * GetMarkedText(size_t *length) const
Get the range of the currently marked input text.
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
@ WC_SPRITE_ALIGNER
Sprite aligner (debug); Window numbers:
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
@ WC_AIRCRAFT_LIST
Aircraft list; 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.
virtual void OnResize()
Called after the window got resized.
@ CMDPL_NO_CONSTRUCTION
No construction actions may be executed.
bool in_window
mouse inside this window, determines drawing logic
#define CLRBITS(x, y)
Clears several bits in a variable.
@ WC_TEXTFILE
textfile; Window numbers:
HotkeyList * hotkeys
Hotkeys for the window.
@ WC_STATION_LIST
Station list; Window numbers:
WindowPosition
How do we the window to be placed?
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
@ WC_SMALLMAP
Small map; Window numbers:
@ WDP_CENTER
Center the window.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
bool _left_button_clicked
Is left mouse button clicked?
int16 pref_height
User-preferred height of the window. Zero if unset.
static bool MaybeBringWindowToFront(Window *w)
Check if a window can be made relative top-most window, and if so do it.
void CDECL void DeleteAll()
Delete every character in the textbuffer.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
uint8 white_border_timer
Timer value of the WF_WHITE_BORDER for flags.
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.
bool _right_button_down
Is right mouse button pressed?
@ PFE_DRAWWORLD
Time spent drawing world viewports in GUI.
uint8 window_snap_radius
windows snap at each other if closer than this
int16 pref_width
User-preferred width of the window. Zero if unset.
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
GUISettings gui
settings related to the GUI
virtual void EditBoxGainedFocus()
An edit box gained the input focus.
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
Point selend
The location where the drag currently ends.
void HandleToolbarHotkey(int hotkey)
Handle Toolbar hotkey events - can come from a source like the MacBook Touch Bar.
@ VA_MAIN_VIEWPORT
Scroll main viewport at edge.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
Data about how and where to blit pixels.
bool right_mouse_wnd_close
close window with right click
virtual const char * GetFocusedText() const
Get the current input text if an edit box has the focus.
@ HKPR_CURSOR
Non-text change, e.g. cursor position.
void Reset()
Reset tile highlighting.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
static const int ACTION_NOTHING
Nothing.
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.
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.