OpenTTD
|
Windowing system, widgets and events. More...
#include "stdafx.h"
#include <stdarg.h>
#include "company_func.h"
#include "gfx_func.h"
#include "console_func.h"
#include "console_gui.h"
#include "viewport_func.h"
#include "progress.h"
#include "blitter/factory.hpp"
#include "zoom_func.h"
#include "vehicle_base.h"
#include "window_func.h"
#include "tilehighlight_func.h"
#include "network/network.h"
#include "querystring_gui.h"
#include "widgets/dropdown_func.h"
#include "strings_func.h"
#include "settings_type.h"
#include "settings_func.h"
#include "ini_type.h"
#include "newgrf_debug.h"
#include "hotkeys.h"
#include "toolbar_gui.h"
#include "statusbar_gui.h"
#include "error.h"
#include "game/game.hpp"
#include "video/video_driver.hpp"
#include "safeguards.h"
Go to the source code of this file.
Macros | |
#define | scrollspeed 3 |
Enumerations | |
enum | ViewportAutoscrolling { VA_DISABLED, VA_MAIN_VIEWPORT_FULLSCREEN, VA_MAIN_VIEWPORT, VA_EVERY_VIEWPORT } |
Values for _settings_client.gui.auto_scrolling. More... | |
enum | PreventHideDirection { PHD_UP, PHD_DOWN } |
Direction for moving the window. More... | |
enum | MouseClick { MC_NONE = 0, MC_LEFT, MC_RIGHT, MC_DOUBLE_LEFT, MC_HOVER, MAX_OFFSET_DOUBLE_CLICK = 5, TIME_BETWEEN_DOUBLE_CLICK = 500, MAX_OFFSET_HOVER = 5 } |
Functions | |
static int CDECL | DescSorter (WindowDesc *const *a, WindowDesc *const *b) |
Sort WindowDesc by ini_key. | |
void | SetFocusedWindow (Window *w) |
Set the window that has the focus. | |
bool | EditBoxInGlobalFocus () |
Check if an edit box is in global focus. | |
static void | StartWindowDrag (Window *w) |
Start window dragging. | |
static void | StartWindowSizing (Window *w, bool to_left) |
Start resizing a window. | |
static void | DispatchLeftClickEvent (Window *w, int x, int y, int click_count) |
Dispatch left mouse-button (possibly double) click in window. | |
static void | DispatchRightClickEvent (Window *w, int x, int y) |
Dispatch right mouse-button click in window. | |
static void | DispatchHoverEvent (Window *w, int x, int y) |
Dispatch hover of the mouse over a window. | |
static void | DispatchMouseWheelEvent (Window *w, NWidgetCore *nwid, int wheel) |
Dispatch the mousewheel-action to the window. | |
static bool | MayBeShown (const Window *w) |
Returns whether a window may be shown or not. | |
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 | DrawOverlappedWindowForAll (int left, int top, int right, int bottom) |
From a rectangle that needs redrawing, find the windows that intersect with the rectangle. | |
static Window * | FindChildWindow (const Window *w, WindowClass wc) |
Find the Window whose parent pointer points to this window. | |
Window * | FindWindowById (WindowClass cls, WindowNumber number) |
Find a window by its class and window number. | |
Window * | FindWindowByClass (WindowClass cls) |
Find any window by its class. | |
void | DeleteWindowById (WindowClass cls, WindowNumber number, bool force) |
Delete a window by its class and window number (if it is open). | |
void | DeleteWindowByClass (WindowClass cls) |
Delete all windows of a given class. | |
void | DeleteCompanyWindows (CompanyID id) |
Delete all windows of a company. | |
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 company merger. | |
static void | BringWindowToFront (Window *w) |
On clicking on a window, make it the frontmost window of all windows with an equal or lower z-priority. | |
Window * | BringWindowToFrontById (WindowClass cls, WindowNumber number) |
Find a window and make it the relative top-window on the screen. | |
static bool | IsVitalWindow (const Window *w) |
static uint | GetWindowZPriority (const Window *w) |
Get the z-priority for a given window. | |
static void | AddWindowToZOrdering (Window *w) |
Adds a window to the z-ordering, according to its z-priority. | |
static void | RemoveWindowFromZOrdering (Window *w) |
Removes a window from the z-ordering. | |
static bool | IsGoodAutoPlace1 (int left, int top, int width, int height, Point &pos) |
Decide whether a given rectangle is a good place to open a completely visible new window. | |
static bool | IsGoodAutoPlace2 (int left, int top, int width, int height, Point &pos) |
Decide whether a given rectangle is a good place to open a mostly visible new window. | |
static Point | GetAutoPlacePosition (int width, int height) |
Find a good place for opening a new window of a given width and height. | |
Point | GetToolbarAlignedWindowPosition (int window_width) |
Computer the position of the top-left corner of a window to be opened right under the toolbar. | |
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. | |
Window * | FindWindowFromPt (int x, int y) |
Do a search for a window at specific coordinates. | |
void | InitWindowSystem () |
(re)initialize the windowing system | |
void | UnInitWindowSystem () |
Close down the windowing system. | |
void | ResetWindowSystem () |
Reset the windowing system, by means of shutting it down followed by re-initialization. | |
static void | DecreaseWindowCounters () |
static void | HandlePlacePresize () |
static EventState | HandleMouseDragDrop () |
Handle dragging and dropping in mouse dragging mode (WSM_DRAGDROP). | |
static void | HandleMouseOver () |
Report position of the mouse to the underlying 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. | |
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. | |
void | ResizeWindow (Window *w, int delta_x, int delta_y, bool clamp_to_screen) |
Resize the window. | |
int | GetMainViewTop () |
Return the top of the main view available for general use. | |
int | GetMainViewBottom () |
Return the bottom of the main view available for general use. | |
static EventState | HandleWindowDragging () |
Handle dragging/resizing of a window. | |
static EventState | HandleScrollbarScrolling () |
handle scrollbar scrolling with the mouse. | |
static EventState | HandleViewportScroll () |
Handle viewport scrolling with the mouse. | |
static bool | MaybeBringWindowToFront (Window *w) |
Check if a window can be made relative top-most window, and if so do it. | |
void | HandleKeypress (uint keycode, WChar key) |
Handle keyboard input. | |
void | HandleCtrlChanged () |
State of CONTROL key has changed. | |
void | HandleTextInput (const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) |
Handle text input. | |
static void | HandleAutoscroll () |
If needed and switched on, perform auto scrolling (automatically moving window contents when mouse is near edge of the window). | |
EventState | VpHandlePlaceSizingDrag () |
Handle the mouse while dragging for placement/resizing. | |
static void | ScrollMainViewport (int x, int y) |
static void | HandleKeyScrolling () |
static void | MouseLoop (MouseClick click, int mousewheel) |
void | HandleMouseEvents () |
Handle a mouse event from the video driver. | |
static void | CheckSoftLimit () |
Check the soft limit of deletable (non vital, non sticky) windows. | |
void | InputLoop () |
Regular call from the global game loop. | |
void | UpdateWindows () |
Update the continuously changing contents of the windows, such as the viewports. | |
void | SetWindowDirty (WindowClass cls, WindowNumber number) |
Mark window as dirty (in need of repainting) | |
void | SetWindowWidgetDirty (WindowClass cls, WindowNumber number, byte widget_index) |
Mark a particular widget in a particular window as dirty (in need of repainting) | |
void | SetWindowClassesDirty (WindowClass cls) |
Mark all windows of a particular class as dirty (in need of repainting) | |
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-computing) | |
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 default the invalidation is not considered to be called from GUI scope. | |
void | CallWindowTickEvent () |
Dispatch WE_TICK event over all windows. | |
void | DeleteNonVitalWindows () |
Try to delete a non-vital window. | |
void | DeleteAllNonVitalWindows () |
It is possible that a stickied window gets to a position where the 'close' button is outside the gaming area. | |
void | DeleteConstructionWindows () |
Delete all windows that are used for construction of vehicle etc. | |
void | HideVitalWindows () |
Delete all always on-top windows to get an empty screen. | |
void | ReInitAllWindows () |
Re-initialize all windows. | |
static int | PositionWindow (Window *w, WindowClass clss, int setting) |
(Re)position a window at the screen. | |
int | PositionMainToolbar (Window *w) |
(Re)position main toolbar window at the screen. | |
int | PositionStatusbar (Window *w) |
(Re)position statusbar window at the screen. | |
int | PositionNewsMessage (Window *w) |
(Re)position news message window at the screen. | |
int | PositionNetworkChatWindow (Window *w) |
(Re)position network chat window at the screen. | |
void | ChangeVehicleViewports (VehicleID from_index, VehicleID to_index) |
Switches viewports following vehicles, which get autoreplaced. | |
void | RelocateAllWindows (int neww, int newh) |
Relocate all windows to fit the new size of the game application screen. |
Variables | |
static Point | _drag_delta |
delta between mouse cursor and upper left corner of dragged window | |
static Window * | _mouseover_last_w = NULL |
Window of the last #MOUSEOVER event. | |
static Window * | _last_scroll_window = NULL |
Window of the last scroll event. | |
Window * | _z_front_window = NULL |
List of windows opened at the screen sorted from the front. | |
Window * | _z_back_window = NULL |
List of windows opened at the screen sorted from the back. | |
bool | _window_highlight_colour = false |
If false, highlight is white, otherwise the by the widget defined colour. | |
Window * | _focused_window |
Point | _cursorpos_drag_start |
int | _scrollbar_start_pos |
int | _scrollbar_size |
byte | _scroller_click_timeout = 0 |
bool | _scrolling_viewport |
A viewport is being scrolled with the mouse. | |
bool | _mouse_hovering |
The mouse is hovering over the same point. | |
SpecialMouseMode | _special_mouse_mode |
Mode of the mouse. | |
static SmallVector< WindowDesc *, 16 > * | _window_descs = NULL |
List of all WindowDescs. | |
char * | _windows_file |
Config file to store WindowDesc. | |
static const int | MIN_VISIBLE_TITLE_BAR = 13 |
The minimum number of pixels of the title bar must be visible in both the X or Y direction. | |
static bool | _dragging_window |
A window is being dragged or resized. | |
static int | _input_events_this_tick = 0 |
Local counter that is incremented each time an mouse input event is detected. | |
static const int8 | scrollamt [16][2] |
Describes all the different arrow key combinations the game allows when it is in scrolling mode. |
Windowing system, widgets and events.
Definition in file window.cpp.
enum MouseClick |
Definition at line 2720 of file window.cpp.
enum PreventHideDirection |
Direction for moving the window.
Definition at line 1979 of file window.cpp.
Values for _settings_client.gui.auto_scrolling.
Definition at line 43 of file window.cpp.
|
static |
Adds a window to the z-ordering, according to its z-priority.
w | Window to add |
Definition at line 1332 of file window.cpp.
References _z_back_window, _z_front_window, GetWindowZPriority(), WC_INVALID, Window::window_class, Window::z_back, and Window::z_front.
Referenced by BringWindowToFront(), and Window::InitializeData().
|
static |
On clicking on a window, make it the frontmost window of all windows with an equal or lower z-priority.
The window is marked dirty for a repaint
w | window that is put into the relative foreground |
Definition at line 1405 of file window.cpp.
References AddWindowToZOrdering(), RemoveWindowFromZOrdering(), and Window::SetDirty().
Referenced by BringWindowToFrontById(), MaybeBringWindowToFront(), StartWindowDrag(), and StartWindowSizing().
Window* BringWindowToFrontById | ( | WindowClass | cls, |
WindowNumber | number | ||
) |
Find a window and make it the relative top-window on the screen.
The window gets unshaded if it was shaded, and a white border is drawn at its edges for a brief period of time to visualize its "activation".
cls | WindowClass of the window to activate |
number | WindowNumber of the window to activate |
Definition at line 1229 of file window.cpp.
References BringWindowToFront(), FindWindowById(), Window::IsShaded(), Window::SetDirty(), Window::SetShaded(), and Window::SetWhiteBorder().
Referenced by AllocateWindowDescFront(), DoSelectCompanyManagerFace(), CompanyWindow::OnClick(), ShowAIDebugWindow(), ShowCompanyFinances(), ShowDepotWindow(), ShowGenerateWorldProgress(), and ShowIndustryCargoesWindow().
Switches viewports following vehicles, which get autoreplaced.
from_index | the old vehicle ID |
to_index | the new vehicle ID |
Definition at line 3389 of file window.cpp.
References ViewportData::follow_vehicle, Window::SetDirty(), and Window::viewport.
Referenced by CopyHeadSpecificThings().
Change the owner of all the windows one company can take over from another company in the case of a company merger.
Do not change ownership of windows that need to be deleted once takeover is complete
old_owner | original owner of the window |
new_owner | the new owner of the window |
Definition at line 1193 of file window.cpp.
References Window::owner, WC_AIRCRAFT_LIST, WC_BUY_COMPANY, WC_COMPANY, WC_COMPANY_COLOUR, WC_COMPANY_INFRASTRUCTURE, WC_FINANCES, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_STATION_LIST, WC_TRAINS_LIST, WC_VEHICLE_ORDERS, and Window::window_class.
Referenced by ChangeOwnershipOfCompanyItems().
void DeleteAllNonVitalWindows | ( | ) |
It is possible that a stickied window gets to a position where the 'close' button is outside the gaming area.
You cannot close it then; except with this function. It closes all windows calling the standard function, then, does a little hacked loop of closing all stickied windows. Note that standard windows (status bar, etc.) are not stickied, so these aren't affected
Definition at line 3243 of file window.cpp.
References DeleteNonVitalWindows(), Window::flags, and WF_STICKY.
Referenced by GenerateWorld(), and MainWindow::OnHotkey().
void DeleteCompanyWindows | ( | CompanyID | id | ) |
Delete all windows of a company.
We identify windows of a company by looking at the caption colour. If it is equal to the company ID then we say the window belongs to the company and should be deleted
id | company identifier |
Definition at line 1167 of file window.cpp.
References DeleteWindowById(), Window::owner, and WC_BUY_COMPANY.
Referenced by CmdCompanyCtrl(), and Company::~Company().
void DeleteConstructionWindows | ( | ) |
Delete all windows that are used for construction of vehicle etc.
Once done with that invalidate the others to ensure they get refreshed too.
Definition at line 3266 of file window.cpp.
References WindowDesc::flags, Window::SetDirty(), WDF_CONSTRUCTION, and Window::window_desc.
Referenced by SetLocalCompany().
void DeleteNonVitalWindows | ( | ) |
Try to delete a non-vital window.
Non-vital windows are windows other than the game selection, main toolbar, status bar, toolbar menu, and tooltip windows. Stickied windows are also considered vital.
Definition at line 3214 of file window.cpp.
References Window::flags, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, WC_SELECT_GAME, WC_STATUS_BAR, WC_TOOLTIPS, WF_STICKY, and Window::window_class.
Referenced by DeleteAllNonVitalWindows(), and MainWindow::OnHotkey().
void DeleteWindowByClass | ( | WindowClass | cls | ) |
Delete all windows of a given class.
cls | Window class of windows to delete |
Definition at line 1145 of file window.cpp.
References Window::window_class.
Referenced by AIListWindow::ChangeAI(), AIDebugWindow::ChangeToAI(), CleanupGeneration(), DoScanNewGRFFiles(), InvalidateNewGRFChangeWindows(), NewGRFConfirmationCallback(), NewGRFWindow::OnClick(), GameOptionsWindow::OnDropdownSelect(), NewGRFWindow::OnDropdownSelect(), VehicleGroupWindow::OnInvalidateData(), NetworkClientListPopupWindow::OnMouseLoop(), BuildDocksToolbarWindow::OnPlaceObjectAbort(), BuildRoadToolbarWindow::OnPlaceObjectAbort(), BuildRailToolbarWindow::OnPlaceObjectAbort(), PopupClientList(), SetupEngines(), ShowAIConfigWindow(), ShowAIListWindow(), ShowAISettingsWindow(), ShowBaseSetTextfileWindow(), ShowBuildAirToolbar(), ShowBuildBridgeWindow(), ShowBuildDocksToolbar(), ShowBuildRailToolbar(), ShowBuildRoadToolbar(), ShowCreateScenario(), ShowEndGameChart(), ShowGameOptions(), ShowGameSettings(), ShowHighscoreTable(), ShowNetworkChatQueryWindow(), ShowNewGRFSettings(), ShowQueryString(), ShowRenameSignWindow(), ShowSavePresetWindow(), ShowScriptTextfileWindow(), and ShowSetDateWindow().
void DeleteWindowById | ( | WindowClass | cls, |
WindowNumber | number, | ||
bool | force | ||
) |
Delete a window by its class and window number (if it is open).
cls | Window class |
number | Number of the window within the window class |
force | force deletion; if false don't delete when stickied |
Definition at line 1132 of file window.cpp.
References FindWindowById(), Window::flags, and WF_STICKY.
Referenced by ClientNetworkContentSocketHandler::BeforeDownload(), ClientNetworkGameSocketHandler::ClientError(), ServerNetworkGameSocketHandler::CloseConnection(), CmdCompanyCtrl(), CmdDeleteGroup(), CmdGoalQuestionAnswer(), CmdMoveRailVehicle(), DeleteCompanyWindows(), DeleteNewGRFInspectWindow(), EnginesDailyLoop(), GuiShowTooltips(), HideVitalWindows(), IConsoleSwitch(), MoveToNextItem(), NetworkDisconnect(), NewVehicleAvailable(), BuildRoadToolbarWindow::OnClick(), NetworkGameWindow::OnClick(), BuildRoadStationWindow::OnClick(), BuildRailStationWindow::OnClick(), SelectStationWindow< T >::OnClick(), BuildDocksToolbarWindow::OnInvalidateData(), BuildRoadToolbarWindow::OnInvalidateData(), BuildAirToolbarWindow::OnPlaceObjectAbort(), BuildDocksToolbarWindow::OnPlaceObjectAbort(), BuildRoadToolbarWindow::OnPlaceObjectAbort(), BuildRailToolbarWindow::OnPlaceObjectAbort(), Vehicle::PreDestructor(), ClientNetworkGameSocketHandler::Receive_SERVER_BANNED(), ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(), ClientNetworkGameSocketHandler::Receive_SERVER_FULL(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), RemoveAirport(), Vehicle::RemoveFromShared(), ShowCheatWindow(), ShowCustCurrency(), ShowDropDownListAt(), ShowLandInfo(), ShowMessageHistory(), ShowNetworkContentListWindow(), ShowNetworkLobbyWindow(), ShowNewsMessage(), ShowOnScreenKeyboard(), ShowReplaceGroupVehicleWindow(), ShowSaveLoadDialog(), ShowTerraformToolbar(), ShowTimetableWindow(), ShowVehicleDetailsWindow(), ShowVehicleRefitWindow(), StartWindowDrag(), StartWindowSizing(), AI::Stop(), ToggleRailButton_Remove(), Depot::~Depot(), Station::~Station(), and Town::~Town().
|
static |
Dispatch hover of the mouse over a window.
w | Window to dispatch event in. |
x | X coordinate of the click. |
y | Y coordinate of the click. |
Definition at line 784 of file window.cpp.
References NWidgetBase::GetWidgetFromPos(), GuiShowTooltips(), NWidgetCore::index, Window::nested_root, Window::OnHover(), and NWidgetCore::tool_tip.
|
static |
Dispatch left mouse-button (possibly double) click in window.
w | Window to dispatch event in |
x | X coordinate of the click |
y | Y coordinate of the click |
click_count | Number of fast consecutive clicks at same position |
< Index of the widget
Definition at line 632 of file window.cpp.
References _ctrl_pressed, WindowDesc::flags, Window::flags, WindowDesc::GetDefaultHeight(), WindowDesc::GetDefaultWidth(), Window::GetQueryString(), NWidgetBase::GetWidgetFromPos(), Window::HandleButtonClick(), Window::height, HideDropDownMenu(), NWidgetCore::index, NWidgetCore::IsDisabled(), Window::IsShaded(), Window::IsWidgetHighlighted(), min(), Window::nested_root, Game::NewEvent(), NWID_HSCROLLBAR, NWID_VSCROLLBAR, Window::OnClick(), NWidgetBase::pos_x, WindowDesc::pref_height, WindowDesc::pref_sticky, WindowDesc::pref_width, Window::resize, ResizeWindow(), ScrollbarClickHandler(), NWidgetBase::SetDirty(), Window::SetFocusedWidget(), SetFocusedWindow(), NWidgetCore::SetLowered(), Window::SetShaded(), Window::SetTimeout(), Window::SetWidgetHighlight(), Window::ShowNewGRFInspectWindow(), NWidgetBase::smallest_x, NWidgetBase::smallest_y, StartWindowDrag(), StartWindowSizing(), ResizeInfo::step_height, ResizeInfo::step_width, NWidgetBase::type, WC_OSK, WDF_NO_FOCUS, WF_STICKY, Window::width, Window::window_class, Window::window_desc, Window::window_number, WWT_CAPTION, WWT_CLOSEBOX, WWT_DEBUGBOX, WWT_DEFSIZEBOX, WWT_EDITBOX, WWT_EMPTY, WWT_LAST, WWT_RESIZEBOX, WWT_SHADEBOX, and WWT_STICKYBOX.
|
static |
Dispatch the mousewheel-action to the window.
The window will scroll any compatible scrollbars if the mouse is pointed over the bar or its contents
w | Window |
nwid | the widget where the scrollwheel was used |
wheel | scroll up or down |
Definition at line 811 of file window.cpp.
References Scrollbar::GetCapacity(), Scrollbar::GetCount(), Window::GetScrollbar(), NWID_VSCROLLBAR, NWidgetCore::scrollbar_index, Window::SetDirty(), Window::SetShaded(), NWidgetBase::type, Scrollbar::UpdatePosition(), WWT_CAPTION, and WWT_SHADEBOX.
|
static |
Dispatch right mouse-button click in window.
w | Window to dispatch event in |
x | X coordinate of the click |
y | Y coordinate of the click |
Definition at line 764 of file window.cpp.
References _settings_client, NWidgetBase::GetWidgetFromPos(), ClientSettings::gui, GuiShowTooltips(), GUISettings::hover_delay_ms, NWidgetCore::index, Window::nested_root, Window::OnRightClick(), and NWidgetCore::tool_tip.
|
static |
Generate repaint events for the visible part of window w within the rectangle.
The function goes recursively upwards in the window stack, and splits the rectangle into multiple pieces at the window edges, so obscured parts are not redrawn.
w | Window that needs to be repainted |
left | Left edge of the rectangle that should be repainted |
top | Top edge of the rectangle that should be repainted |
right | Right edge of the rectangle that should be repainted |
bottom | Bottom edge of the rectangle that should be repainted |
Definition at line 872 of file window.cpp.
References FOR_ALL_WINDOWS_FROM_BACK_FROM, BlitterFactory::GetCurrentBlitter(), Window::height, Window::left, MayBeShown(), Blitter::MoveTo(), Window::OnPaint(), Window::top, Window::width, Window::z_front, and ZOOM_LVL_NORMAL.
Referenced by DrawOverlappedWindowForAll().
void DrawOverlappedWindowForAll | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
These windows should be re-painted.
left | Left edge of the rectangle that should be repainted |
top | Top edge of the rectangle that should be repainted |
right | Right edge of the rectangle that should be repainted |
bottom | Bottom edge of the rectangle that should be repainted |
Definition at line 932 of file window.cpp.
References DrawOverlappedWindow(), Window::height, Window::left, MayBeShown(), Window::top, and Window::width.
bool EditBoxInGlobalFocus | ( | ) |
Check if an edit box is in global focus.
That is if focused window has a edit box as focused widget, or if a console is focused.
Definition at line 455 of file window.cpp.
References Window::nested_focus, NWidgetBase::type, WC_CONSOLE, Window::window_class, and WWT_EDITBOX.
Referenced by HandleKeypress(), HandleTextInput(), Window::InitializeData(), VideoDriver_Win32::MainLoop(), SetCandidatePos(), and SetCompositionPos().
|
static |
Make sure at least a part of the caption bar is still visible by moving the window if necessary.
w | The window to check. |
nx | The proposed new x-location of the window. |
ny | The proposed new y-location of the window. |
Definition at line 2032 of file window.cpp.
References Clamp(), NWidgetBase::current_x, NWidgetBase::current_y, FindWindowById(), NWidgetBase::GetWidgetOfType(), ViewPort::left, Window::left, Window::nested_root, PHD_DOWN, PHD_UP, NWidgetBase::pos_x, NWidgetBase::pos_y, PreventHiding(), ViewPort::top, Window::top, Window::viewport, WC_MAIN_TOOLBAR, WC_STATUS_BAR, and WWT_CAPTION.
Referenced by HandleWindowDragging(), RelocateAllWindows(), and ResizeWindow().
|
static |
Find the Window whose parent pointer points to this window.
w | parent Window to find child of |
wc | Window class of the window to remove; WC_INVALID if class does not matter |
NULL
otherwise Definition at line 1028 of file window.cpp.
References Window::parent, WC_INVALID, and Window::window_class.
Referenced by Window::DeleteChildWindows().
Window* FindWindowByClass | ( | WindowClass | cls | ) |
Find any window by its class.
Useful when searching for a window that uses the window number as a #WindowType, like WC_SEND_NETWORK_MSG.
cls | Window class |
NULL
if not available Definition at line 1116 of file window.cpp.
References Window::window_class.
Referenced by GetAutoPlacePosition(), IsGoodAutoPlace1(), IndustryCargoesWindow::OnClick(), and UpdateNewGRFScanStatus().
Window* FindWindowById | ( | WindowClass | cls, |
WindowNumber | number | ||
) |
Find a window by its class and window number.
cls | Window class |
number | Number of the window within the window class |
NULL
if not available Definition at line 1100 of file window.cpp.
References Window::window_class, and Window::window_number.
Referenced by BringWindowToFrontById(), ChangeVehicleWindow(), DeleteDepotHighlightOfVehicle(), DeleteRenameSignWindow(), DeleteWindowById(), SmallMapWindow::DrawMapIndicators(), StatusBarWindow::DrawWidget(), EnsureVisibleCaption(), FindVehicleGroupWindow(), Window::FindWindowPlacementAndResize(), GenerateWorld(), GenericPlaceSignals(), TileHighlightData::GetCallbackWnd(), GetLobbyCompanyInfo(), GetMainViewBottom(), GetMainViewTop(), GetToolbarAlignedWindowPosition(), HandleAutoSignalPlacement(), HandleKeypress(), HandleViewportScroll(), IsNewsTickerShown(), IsOSKOpenedFor(), LoadFromConfig(), LocalGetWindowPlacement(), NetworkContentDownloadStatusWindow::NetworkContentDownloadStatusWindow(), ExtraViewportWindow::OnClick(), SmallMapWindow::OnClick(), BuildSignalWindow::OnClick(), SavePresetWindow::OnClick(), VehicleViewWindow::OnClick(), ErrmsgWindow::OnInitialPosition(), NetworkChatWindow::OnInitialPosition(), NetworkContentListWindow::OnInvalidateData(), MainToolbarWindow::OnInvalidateData(), ScenarioEditorToolbarWindow::OnInvalidateData(), DropdownWindow::OnMouseLoop(), BuildRailToolbarWindow::OnPlaceDrag(), PositionWindow(), ReadyForNextItem(), ReinitGuiAfterToggleElrail(), RelocateAllWindows(), ResetSignalVariant(), ScrollMainWindowTo(), SetDefaultRailGui(), SetupScreenshotViewport(), ShowErrorMessage(), ShowExtraViewPortWindow(), ShowLastNewsMessage(), ShowQuery(), SmallMapWindow::SmallMapCenterOnCurrentPos(), StationJoinerNeeded(), UnshowCriticalError(), and UpdateOSKOriginalText().
Window* FindWindowFromPt | ( | int | x, |
int | y | ||
) |
Do a search for a window at specific coordinates.
For this we start at the topmost window, obviously and work our way down to the bottom
x | position x to query |
y | position y to query |
Definition at line 1809 of file window.cpp.
References Window::height, IsInsideBS(), Window::left, MayBeShown(), Window::top, and Window::width.
Referenced by HandleAutoscroll(), HandleMouseOver(), and HandleViewportScroll().
|
static |
Find a good place for opening a new window of a given width and height.
width | Width of the new window |
height | Height of the new window |
Definition at line 1614 of file window.cpp.
References FindWindowByClass(), Window::height, IsGoodAutoPlace1(), IsGoodAutoPlace2(), Window::left, Window::top, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, Window::width, and Window::window_class.
Referenced by LocalGetWindowPlacement().
int GetMainViewBottom | ( | ) |
Return the bottom of the main view available for general use.
Definition at line 2118 of file window.cpp.
References FindWindowById(), Window::top, and WC_STATUS_BAR.
Referenced by BuildBridgeWindow::OnInitialPosition(), ErrmsgWindow::OnInitialPosition(), TooltipsWindow::OnInitialPosition(), and ShowDropDownListAt().
int GetMainViewTop | ( | ) |
Return the top of the main view available for general use.
Definition at line 2107 of file window.cpp.
References FindWindowById(), Window::height, Window::top, and WC_MAIN_TOOLBAR.
Referenced by BuildBridgeWindow::OnInitialPosition(), ErrmsgWindow::OnInitialPosition(), TooltipsWindow::OnInitialPosition(), and ShowDropDownListAt().
Point GetToolbarAlignedWindowPosition | ( | int | window_width | ) |
Computer the position of the top-left corner of a window to be opened right under the toolbar.
window_width | the width of the window to get the position for |
Definition at line 1678 of file window.cpp.
References _current_text_dir, FindWindowById(), Window::height, Window::left, TD_RTL, Window::top, WC_MAIN_TOOLBAR, and Window::width.
Referenced by LocalGetWindowPlacement(), TransparenciesWindow::OnInitialPosition(), and TerraformToolbarWindow::OnInitialPosition().
|
static |
Get the z-priority for a given window.
This is used in comparison with other z-priority values; a window with a given z-priority will appear above other windows with a lower value, and below those with a higher one (the ordering within z-priorities is arbitrary).
w | The window to get the z-priority for |
Definition at line 1266 of file window.cpp.
References WC_AI_LIST, WC_AI_SETTINGS, WC_CONFIRM_POPUP_QUERY, WC_CONSOLE, WC_CUSTOM_CURRENCY, WC_DROPDOWN_MENU, WC_ENDSCREEN, WC_ERRMSG, WC_GAME_OPTIONS, WC_GENERATE_LANDSCAPE, WC_GRF_PARAMETERS, WC_HIGHSCORE, WC_INVALID, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, WC_MODAL_PROGRESS, WC_NETWORK_STATUS_WINDOW, WC_NETWORK_WINDOW, WC_NEWS_WINDOW, WC_OSK, WC_QUERY_STRING, WC_SAVE_PRESET, WC_SAVELOAD, WC_SEND_NETWORK_MSG, WC_STATUS_BAR, WC_TEXTFILE, WC_TOOLTIPS, and Window::window_class.
Referenced by AddWindowToZOrdering().
void HandleKeypress | ( | uint | keycode, |
WChar | key | ||
) |
Handle keyboard input.
keycode | Virtual keycode of the key. |
key | Unicode character of the key. |
Definition at line 2580 of file window.cpp.
References HotkeyList::CheckMatch(), EditBoxInGlobalFocus(), ES_HANDLED, FindWindowById(), Window::HandleEditBoxKey(), HasModalProgress(), WindowDesc::hotkeys, NWidgetCore::index, IsLocalCompany(), Window::nested_focus, Window::OnHotkey(), Window::OnKeyPress(), WC_CONSOLE, WC_MAIN_TOOLBAR, Window::window_class, and Window::window_desc.
Referenced by HandleCharMsg().
|
static |
Handle dragging and dropping in mouse dragging mode (WSM_DRAGDROP).
Definition at line 1929 of file window.cpp.
References _left_button_down, _special_mouse_mode, CursorVars::delta, ES_HANDLED, ES_NOT_HANDLED, TileHighlightData::GetCallbackWnd(), GetWidgetFromPos(), Window::left, Window::OnDragDrop(), Window::OnMouseDrag(), ResetObjectToPlace(), Window::top, and WSM_DRAGDROP.
|
static |
Report position of the mouse to the underlying window.
Definition at line 1953 of file window.cpp.
References FindWindowFromPt(), NWidgetBase::GetWidgetFromPos(), NWidgetCore::index, Window::left, Window::nested_root, Window::OnMouseOver(), and Window::top.
|
static |
handle scrollbar scrolling with the mouse.
Definition at line 2339 of file window.cpp.
References _current_text_dir, _left_button_down, NWidgetCore::disp_flags, ES_HANDLED, ES_NOT_HANDLED, Scrollbar::GetCapacity(), Scrollbar::GetCount(), Scrollbar::GetPosition(), Window::GetWidget(), HasBit(), max(), min(), ND_SCROLLBAR_BTN, NDB_SCROLLBAR_UP, NWID_HSCROLLBAR, Window::scrolling_scrollbar, Window::SetDirty(), Scrollbar::SetPosition(), TD_RTL, NWidgetBase::type, and Scrollbar::UpdatePosition().
void HandleTextInput | ( | const char * | str, |
bool | marked, | ||
const char * | caret, | ||
const char * | insert_location, | ||
const char * | replacement_end | ||
) |
Handle text input.
str | Text string to input. |
marked | Is the input a marked composition string from an IME? |
caret | Move the caret to this point in the insertion string. |
Definition at line 2668 of file window.cpp.
References EditBoxInGlobalFocus(), NWidgetCore::index, Window::InsertTextString(), Window::nested_focus, WC_CONSOLE, and Window::window_class.
Referenced by CancelIMEComposition(), and HandleIMEComposition().
|
static |
Handle viewport scrolling with the mouse.
Definition at line 2389 of file window.cpp.
References _left_button_down, _right_button_down, _scrolling_viewport, _settings_client, CursorVars::delta, ES_HANDLED, ES_NOT_HANDLED, FindWindowById(), FindWindowFromPt(), CursorVars::fix_at, ViewportData::follow_vehicle, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), ClientSettings::gui, INVALID_VEHICLE, GUISettings::left_mouse_btn_scrolling, Window::OnScroll(), GUISettings::reverse_scroll, ScrollMainWindowTo(), GUISettings::scrollwheel_scrolling, Window::viewport, WC_MAIN_WINDOW, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
|
static |
Handle dragging/resizing of a window.
Definition at line 2130 of file window.cpp.
References _left_button_down, _settings_client, abs(), CursorVars::delta, EnsureVisibleCaption(), ES_HANDLED, ES_NOT_HANDLED, Window::flags, ClientSettings::gui, Window::height, Window::left, Window::nested_root, Window::resize, ResizeWindow(), Window::SetDirty(), NWidgetBase::smallest_x, NWidgetBase::smallest_y, ResizeInfo::step_height, ResizeInfo::step_width, Window::top, WF_DRAGGING, WF_SIZING, WF_SIZING_LEFT, Window::width, and GUISettings::window_snap_radius.
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 default the invalidation is not considered to be called from GUI scope.
See InvalidateWindowData() for details on GUI-scope vs. command-scope.
cls | Window class |
data | The data to invalidate with |
gui_scope | Whether the call is done from GUI scope |
Definition at line 3186 of file window.cpp.
References Window::InvalidateData(), and Window::window_class.
Referenced by AddRemoveEngineFromAutoreplaceAndBuildWindows(), CcBuildWagon(), AIListWindow::ChangeAI(), ClickChangeDateCheat(), ClickChangeMaxHlCheat(), ClickSetProdCheat(), CmdBuildVehicle(), CmdCloneOrder(), CmdCompanyCtrl(), CmdCreateGoal(), CmdCreateStoryPage(), CmdCreateStoryPageElement(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdRefitVehicle(), CmdRemoveGoal(), CmdRemoveStoryPage(), CmdRemoveStoryPageElement(), CmdRenameVehicle(), CmdSellRailWagon(), CmdSetGoalCompleted(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetStoryPageDate(), CmdSetStoryPageTitle(), CmdUpdateStoryPageElement(), Vehicle::Crash(), DecloneOrder(), DeleteOrder(), OrderBackup::DoRestore(), DoScanNewGRFFiles(), EnginesMonthlyLoop(), GenerateDesertArea(), InsertOrder(), OrderList::InsertOrderAt(), InvalidateCompanyInfrastructureWindow(), InvalidateCompanyWindow(), InvalidateNewGRFChangeWindows(), MenuClickSettings(), NetworkAfterNewGRFScan(), IndustryCargoesWindow::NotifySmallmap(), SmallMapWindow::OnClick(), OnNewYear(), Vehicle::PreDestructor(), ReadLanguagePack(), ReloadNewGRFData(), AI::Rescan(), RoadVehAccelerationModelChanged(), SetLocalCompany(), SetNewLandscapeType(), StartupEngines(), Order::~Order(), and Station::~Station().
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-computing)
Note that by default the invalidation is not considered to be called from GUI scope. That means only a part of invalidation is executed immediately. The rest is scheduled for the next redraw. The asynchronous execution is important to prevent GUI code being executed from command scope. When not in GUI-scope:
However, when invalidations are scheduled, then multiple calls may be scheduled before execution starts. Earlier scheduled invalidations may be called with invalidation-data, which is already invalid at the point of execution. That means some stuff requires to be executed immediately in command scope, while not everything may be executed in command scope. While GUI-scope calls have no restrictions on what they may do, they cannot assume the game to still be in the state when the invalidation was scheduled; passed IDs may have got invalid in the mean time.
Finally, note that invalidations triggered from commands or the game loop result in OnInvalidateData() being called twice. Once in command-scope, once in GUI-scope. So make sure to not process differential-changes twice.
cls | Window class |
number | Window number within the class |
data | The data to invalidate with |
gui_scope | Whether the call is done from GUI scope |
Definition at line 3168 of file window.cpp.
References Window::InvalidateData(), Window::window_class, and Window::window_number.
Referenced by AcceptEnginePreview(), AddRemoveEngineFromAutoreplaceAndBuildWindows(), AircraftLeaveHangar(), Subsidy::AwardTo(), AIListWindow::ChangeAI(), ChangePopulation(), CheckTrainStayInDepot(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdAlterGroup(), CmdBuildAirport(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRailStation(), CmdBuildRailWagon(), CmdBuildRoadStop(), CmdBuildVehicle(), CmdBuyShareInCompany(), CmdCompanyCtrl(), CmdConvertRail(), CmdCreateGoal(), CmdCreateGroup(), CmdCreateStoryPage(), CmdDeleteGroup(), CmdMoveRailVehicle(), CmdPlaceSign(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRemoveGoal(), CmdRemoveStoryPage(), CmdRenameSign(), CmdRenameStation(), CmdRenameTown(), CmdSellRailWagon(), CmdSellShareInCompany(), CmdSetCompanyColour(), CmdSetGoalCompleted(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetGroupReplaceProtection(), CmdTownCargoGoal(), CmdTownGrowthRate(), CmdTownSetText(), Company::Company(), Train::ConsistChanged(), CreateSubsidy(), DeleteNewGRFInspectWindow(), DeleteStationIfEmpty(), DeleteSubsidyWith(), DoCreateNewIndustry(), DoCreateTown(), DoScanNewGRFFiles(), DoStartupNewCompany(), StatusBarWindow::DrawWidget(), HandleMouseEvents(), IndustryDailyLoop(), InvalidateAutoreplaceWindow(), InvalidateNewGRFInspectWindow(), InvalidateVehicleOrder(), LoadUnloadVehicle(), MoveToNextItem(), NetworkChatWindow::NetworkChatWindow(), NewVehicleAvailable(), NormaliseTrainHead(), GraphLegendWindow::OnClick(), MainWindow::OnInvalidateData(), Industry::PostDestructor(), Town::PostDestructor(), BaseStation::PostDestructor(), Company::PostDestructor(), Vehicle::PreDestructor(), RecomputePrices(), ReloadNewGRFData(), RemoveAirport(), RemoveBuoy(), Vehicle::RemoveFromShared(), AI::Rescan(), ReverseTrainDirection(), SaveFileDone(), SaveFileStart(), SetLocalCompany(), ShowTicker(), Game::StartNew(), AI::StartNew(), AI::Stop(), SubsidyMonthlyLoop(), UpdateNetworkGameWindow(), Waypoint::UpdateVirtCoord(), VehicleEnter_Track(), VehicleEnterDepot(), LinkGraphJob::~LinkGraphJob(), NetworkClientInfo::~NetworkClientInfo(), NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow(), and Station::~Station().
|
static |
Decide whether a given rectangle is a good place to open a completely visible new window.
The new window should be within screen borders, and not overlap with another already existing window (except for the main window in the background).
left | Left edge of the rectangle |
top | Top edge of the rectangle |
width | Width of the rectangle |
height | Height of the rectangle |
pos | If rectangle is good, use this parameter to return the top-left corner of the new window |
Definition at line 1544 of file window.cpp.
References FindWindowByClass(), Window::height, Window::left, Window::top, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, Window::width, and Window::window_class.
Referenced by GetAutoPlacePosition().
|
static |
Decide whether a given rectangle is a good place to open a mostly visible new window.
The new window should be mostly within screen borders, and not overlap with another already existing window (except for the main window in the background).
left | Left edge of the rectangle |
top | Top edge of the rectangle |
width | Width of the rectangle |
height | Height of the rectangle |
pos | If rectangle is good, use this parameter to return the top-left corner of the new window |
Definition at line 1581 of file window.cpp.
References Window::height, Window::left, Window::top, WC_MAIN_WINDOW, Window::width, and Window::window_class.
Referenced by GetAutoPlacePosition().
|
static |
Compute the position of the top-left corner of a new window that is opened.
By default position a child window at an offset of 10/10 of its parent. With the exception of WC_BUILD_TOOLBAR (build railway/roads/ship docks/airports) and WC_SCEN_LAND_GEN (landscaping). Whose child window has an offset of 0/toolbar-height of its parent. So it's exactly under the parent toolbar and no buttons will be covered. However if it falls too extremely outside window positions, reposition it to an automatic place.
*desc | The pointer to the WindowDesc to be created. |
sm_width | Smallest width of the window. |
sm_height | Smallest height of the window. |
window_number | The window number of the new window. |
Definition at line 1703 of file window.cpp.
References WindowDesc::default_pos, FindWindowById(), GetAutoPlacePosition(), WindowDesc::GetDefaultHeight(), WindowDesc::GetDefaultWidth(), GetToolbarAlignedWindowPosition(), Window::height, Window::left, max(), WindowDesc::parent_cls, Window::top, WC_BUILD_TOOLBAR, WC_SCEN_LAND_GEN, WDP_ALIGN_TOOLBAR, WDP_AUTO, WDP_CENTER, and WDP_MANUAL.
Referenced by Window::OnInitialPosition().
|
static |
Check if a window can be made relative top-most window, and if so do it.
If a window does not obscure any other windows, it will not be brought to the foreground. Also if the only obscuring windows are so-called system-windows, the window will not be moved. The function will return false when a child window of this window is a modal-popup; function returns a false and child window gets a white border
w | Window to bring relatively on-top |
Definition at line 2449 of file window.cpp.
References BringWindowToFront(), WindowDesc::flags, FOR_ALL_WINDOWS_FROM_BACK_FROM, Window::height, Window::IsShaded(), Window::left, Window::parent, Window::SetDirty(), Window::SetWhiteBorder(), Window::top, Window::unshaded_size, WC_DROPDOWN_MENU, WC_MAIN_WINDOW, WC_TOOLTIPS, WDF_MODAL, Window::width, Window::window_class, Window::window_desc, and Window::z_front.
|
static |
Returns whether a window may be shown or not.
w | The window to consider. |
< The background, i.e. the game.
< The actual progress window.
< The abort window.
Definition at line 844 of file window.cpp.
References HasModalProgress(), WC_CONFIRM_POPUP_QUERY, WC_MAIN_WINDOW, WC_MODAL_PROGRESS, and Window::window_class.
Referenced by DrawOverlappedWindow(), DrawOverlappedWindowForAll(), and FindWindowFromPt().
int PositionMainToolbar | ( | Window * | w | ) |
(Re)position main toolbar window at the screen.
w | Window structure of the main toolbar window, may also be NULL . |
Definition at line 3344 of file window.cpp.
References _settings_client, DEBUG, ClientSettings::gui, PositionWindow(), GUISettings::toolbar_pos, and WC_MAIN_TOOLBAR.
Referenced by RelocateAllWindows(), and v_PositionMainToolbar().
int PositionNetworkChatWindow | ( | Window * | w | ) |
(Re)position network chat window at the screen.
w | Window structure of the network chat window, may also be NULL . |
Definition at line 3377 of file window.cpp.
References _settings_client, DEBUG, ClientSettings::gui, PositionWindow(), GUISettings::statusbar_pos, and WC_SEND_NETWORK_MSG.
Referenced by NetworkChatWindow::NetworkChatWindow(), RelocateAllWindows(), and v_PositionStatusbar().
int PositionNewsMessage | ( | Window * | w | ) |
(Re)position news message window at the screen.
w | Window structure of the news message window, may also be NULL . |
Definition at line 3366 of file window.cpp.
References _settings_client, DEBUG, ClientSettings::gui, PositionWindow(), GUISettings::statusbar_pos, and WC_NEWS_WINDOW.
Referenced by RelocateAllWindows(), and v_PositionStatusbar().
int PositionStatusbar | ( | Window * | w | ) |
(Re)position statusbar window at the screen.
w | Window structure of the statusbar window, may also be NULL . |
Definition at line 3355 of file window.cpp.
References _settings_client, DEBUG, ClientSettings::gui, PositionWindow(), GUISettings::statusbar_pos, and WC_STATUS_BAR.
Referenced by RelocateAllWindows(), and v_PositionStatusbar().
|
static |
(Re)position a window at the screen.
w | Window structure of the window, may also be NULL . |
clss | The class of the window to position. |
setting | The actual setting used for the window's position. |
Definition at line 3321 of file window.cpp.
References FindWindowById(), Window::height, ViewPort::left, Window::left, SetDirtyBlocks(), Window::top, Window::viewport, Window::width, and Window::window_class.
Referenced by PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), and PositionStatusbar().
|
static |
Do not allow hiding of the rectangle with base coordinates nx and ny behind window v.
If needed, move the window base coordinates to keep it visible.
nx | Base horizontal coordinate of the rectangle. |
ny | Base vertical coordinate of the rectangle. |
rect | Rectangle that must stay visible for MIN_VISIBLE_TITLE_BAR pixels (horizontally, vertically, or both) |
v | Window lying in front of the rectangle. |
px | Previous horizontal base coordinate. |
dir | If no room horizontally, move the rectangle to the indicated position. |
Definition at line 1994 of file window.cpp.
References Window::height, Window::left, PHD_UP, Window::top, and Window::width.
Referenced by EnsureVisibleCaption().
void ReInitAllWindows | ( | ) |
Re-initialize all windows.
Definition at line 3292 of file window.cpp.
References _cur_resolution, InitDepotWindowBlockSizes(), NWidgetLeaf::InvalidateDimensionCache(), MarkWholeScreenDirty(), NetworkReInitChatBoxSize(), Window::ReInit(), and RelocateAllWindows().
Referenced by CheckBlitter(), InvalidateNewGRFChangeWindows(), LoadStringWidthTable(), NewGRFConfirmationCallback(), and GameOptionsWindow::OnDropdownSelect().
void RelocateAllWindows | ( | int | neww, |
int | newh | ||
) |
Relocate all windows to fit the new size of the game application screen.
neww | New width of the game application screen |
newh | New height of the game application screen. |
Definition at line 3406 of file window.cpp.
References _toolbar_width, EnsureVisibleCaption(), FindWindowById(), Window::flags, Window::height, IConsoleResize(), Window::left, min(), PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), PositionStatusbar(), ResizeWindow(), Window::top, WC_BOOTSTRAP, WC_CONSOLE, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, WC_NEWS_WINDOW, WC_SEND_NETWORK_MSG, WC_STATUS_BAR, WF_CENTERED, Window::width, and Window::window_class.
Referenced by GameSizeChanged(), and ReInitAllWindows().
|
static |
Removes a window from the z-ordering.
w | Window to remove |
Definition at line 1381 of file window.cpp.
References Window::z_back, and Window::z_front.
Referenced by BringWindowToFront(), and InputLoop().
void ResizeWindow | ( | Window * | w, |
int | delta_x, | ||
int | delta_y, | ||
bool | clamp_to_screen | ||
) |
Resize the window.
Update all the widgets of a window based on their resize flags Both the areas of the old window and the new sized window are set dirty ensuring proper redrawal.
w | Window to resize |
delta_x | Delta x-size of changed window (positive if larger, etc.) |
delta_y | Delta y-size of changed window |
clamp_to_screen | Whether to make sure the whole window stays visible |
Definition at line 2071 of file window.cpp.
References _cur_resolution, _current_text_dir, NWidgetBase::AssignSizePosition(), Ceil(), NWidgetBase::current_x, NWidgetBase::current_y, EnsureVisibleCaption(), Window::height, Window::left, max(), Window::nested_root, Window::OnResize(), NWidgetBase::resize_x, NWidgetBase::resize_y, Window::SetDirty(), NWidgetBase::smallest_x, NWidgetBase::smallest_y, ST_RESIZE, TD_RTL, Window::top, and Window::width.
Referenced by NetworkClientListWindow::CheckClientListHeight(), DispatchLeftClickEvent(), TownAuthorityWindow::DrawRatings(), Window::FindWindowPlacementAndResize(), HandleWindowDragging(), BuildAirportWindow::OnPaint(), BuildDocksStationWindow::OnPaint(), BuildRoadStationWindow::OnPaint(), Window::ReInit(), and RelocateAllWindows().
void SetFocusedWindow | ( | Window * | w | ) |
Set the window that has the focus.
w | The window to set the focus on |
Definition at line 432 of file window.cpp.
References Window::nested_focus, Window::OnFocus(), Window::OnFocusLost(), and NWidgetBase::SetDirty().
Referenced by DispatchLeftClickEvent(), Window::InitializeData(), SignListWindow::OnHotkey(), and Window::OnHotkey().
void SetWindowClassesDirty | ( | WindowClass | cls | ) |
Mark all windows of a particular class as dirty (in need of repainting)
cls | Window class |
Definition at line 3096 of file window.cpp.
References Window::SetDirty(), and Window::window_class.
Referenced by AircraftLeaveHangar(), CalcEngineReliability(), CheckTrainStayInDepot(), CmdChangeCompanySetting(), CmdChangeSetting(), CmdRenameDepot(), CmdReverseTrainDirection(), CmdSkipToOrder(), CmdStartStopVehicle(), DoStartupNewCompany(), NetworkServerUpdateCompanyPassworded(), Ship::OnNewDay(), Aircraft::OnNewDay(), RoadVehicle::OnNewDay(), Train::OnNewDay(), OnNewDay(), OnNewMonth(), ProcessOrders(), ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(), RecomputePrices(), RedrawSmallmap(), RedrawTownAuthority(), AI::Rescan(), RoadVehAccelerationModelChanged(), SetSettingValue(), and VehicleEnterDepot().
void SetWindowDirty | ( | WindowClass | cls, |
WindowNumber | number | ||
) |
Mark window as dirty (in need of repainting)
Definition at line 3068 of file window.cpp.
References Window::SetDirty(), Window::window_class, and Window::window_number.
Referenced by ServerNetworkGameSocketHandler::AcceptConnection(), AddNewsItem(), AgeVehicle(), AircraftEventHandler_AtTerminal(), Vehicle::BeginLoading(), ChangeIndustryProduction(), ChangeTimetable(), ChangeTownRating(), CheckTrainStayInDepot(), ClickChangeDateCheat(), ServerNetworkGameSocketHandler::CloseConnection(), CmdAddVehicleGroup(), CmdAlterGroup(), CmdAutofillTimetable(), CmdBuildAirport(), CmdBuildObject(), CmdBuildVehicle(), CmdChangeServiceInt(), CmdDoTownAction(), CmdForceTrainProceed(), CmdMoveRailVehicle(), CmdPause(), CmdRefitVehicle(), CmdRenameDepot(), CmdReverseTrainDirection(), CmdSetAutoReplace(), CmdSetGroupReplaceProtection(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdStartStopVehicle(), CompaniesGenStatistics(), CompaniesYearlyLoop(), Train::ConsistChanged(), Vehicle::Crash(), DecreaseVehicleValue(), DeleteLastWagon(), DeleteNewsItem(), DirtyCompanyInfrastructureWindows(), DoStartupNewCompany(), Vehicle::HandleBreakdown(), IConsoleGUIPrint(), IndustryDailyLoop(), IndustryProductionCallback(), InvalidateCompanyWindows(), InvalidateVehicleOrder(), LoadUnloadVehicle(), NewGRFParametersWindow::OnClick(), BuildSignalWindow::OnClick(), GameOptionsWindow::OnDropdownSelect(), Ship::OnNewDay(), Aircraft::OnNewDay(), RoadVehicle::OnNewDay(), Train::OnNewDay(), OnNewMonth(), GroundVehicle< T, Type >::PowerChanged(), Vehicle::PreDestructor(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(), ClientNetworkGameSocketHandler::Receive_SERVER_JOIN(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_SIZE(), ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(), ClientNetworkGameSocketHandler::Receive_SERVER_WAIT(), RemoveAirport(), RemoveOrderFromAllVehicles(), ClientNetworkGameSocketHandler::SendCompanyInformationQuery(), ClientNetworkGameSocketHandler::SendJoin(), SetTrainGroupID(), GRFParameterInfo::SetValue(), TrainController(), TrainEnterStation(), TriggerIndustryProduction(), UpdateCompanyRatingAndValue(), UpdateTownGrowRate(), UpdateTrainGroupID(), UpdateVehicleTimetable(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), VehicleEnterDepot(), VehicleServiceInDepot(), and NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow().
void SetWindowWidgetDirty | ( | WindowClass | cls, |
WindowNumber | number, | ||
byte | widget_index | ||
) |
Mark a particular widget in a particular window as dirty (in need of repainting)
cls | Window class |
number | Window number in that class |
widget_index | Index number of the widget that needs repainting |
Definition at line 3082 of file window.cpp.
References Window::SetWidgetDirty(), Window::window_class, and Window::window_number.
Referenced by AircraftHandleDestTooFar(), Vehicle::BeginLoading(), CheckIfTrainNeedsService(), CmdBuildDock(), CmdBuildRailStation(), CmdBuildRoadStop(), CmdOpenCloseAirport(), CmdRemoveFromRailStation(), CmdStartStopVehicle(), Vehicle::Crash(), MarkTrainAsStuck(), NormaliseTrainHead(), OnNewDay(), GroundVehicle< T, Type >::PowerChanged(), RemoveDock(), RemoveFromRailBaseStation(), RemoveRoadStop(), ReverseTrainDirection(), Vehicle::SendToDepot(), GroundVehicle< RoadVehicle, VEH_ROAD >::SetLastSpeed(), TryPathReserve(), UpdateAircraftSpeed(), and UpdateStationAcceptance().
|
static |
Start window dragging.
w | Window to start dragging |
Definition at line 2304 of file window.cpp.
References BringWindowToFront(), DeleteWindowById(), Window::flags, Window::left, Window::top, WC_DROPDOWN_MENU, WF_CENTERED, and WF_DRAGGING.
Referenced by DispatchLeftClickEvent().
|
static |
Start resizing a window.
w | Window to start resizing. |
to_left | Whether to drag towards the left or not |
Definition at line 2322 of file window.cpp.
References BringWindowToFront(), DeleteWindowById(), Window::flags, WC_DROPDOWN_MENU, WF_CENTERED, WF_SIZING_LEFT, and WF_SIZING_RIGHT.
Referenced by DispatchLeftClickEvent().
EventState VpHandlePlaceSizingDrag | ( | ) |
Handle the mouse while dragging for placement/resizing.
Definition at line 3107 of file viewport.cpp.
References _left_button_down, _special_mouse_mode, ES_HANDLED, ES_NOT_HANDLED, TileHighlightData::GetCallbackWnd(), HT_DIR_MASK, HT_DRAG_MASK, HT_POINT, HT_RAIL, HT_RECT, TileHighlightData::next_drawstyle, Window::OnPlaceDrag(), Window::OnPlaceMouseUp(), TileHighlightData::place_mode, ResetObjectToPlace(), TileHighlightData::select_method, TileHighlightData::select_proc, TileHighlightData::selend, TileHighlightData::selstart, SetTileSelectSize(), TileVirtXY(), VPM_RAILDIRS, VPM_SIGNALDIRS, WSM_NONE, and WSM_SIZING.
|
static |
Local counter that is incremented each time an mouse input event is detected.
The counter is used to stop auto-scrolling.
Definition at line 2681 of file window.cpp.
|
static |
List of all WindowDescs.
This is a pointer to ensure initialisation order with the various static WindowDesc instances.
Definition at line 84 of file window.cpp.
bool _window_highlight_colour = false |
If false, highlight is white, otherwise the by the widget defined colour.
Definition at line 60 of file window.cpp.
Referenced by Window::DrawWidgets(), and UpdateWindows().
Window* _z_back_window = NULL |
List of windows opened at the screen sorted from the back.
Definition at line 57 of file window.cpp.
Referenced by AddWindowToZOrdering().
Window* _z_front_window = NULL |
List of windows opened at the screen sorted from the front.
Definition at line 55 of file window.cpp.
Referenced by AddWindowToZOrdering().
|
static |
Describes all the different arrow key combinations the game allows when it is in scrolling mode.
The real arrow keys are bitwise numbered as 1 = left 2 = up 4 = right 8 = down
Definition at line 2753 of file window.cpp.