Functions, definitions and such used only by the GUI. More...
#include "core/math_func.hpp"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "company_type.h"
#include "tile_type.h"
#include "widget_type.h"
Go to the source code of this file.
Data Structures | |
struct | WindowDesc |
High level window description. More... | |
class | Scrollbar |
Scrollbar data structure. More... | |
struct | ResizeInfo |
Data structure for resizing a window. More... | |
struct | ViewportData |
Data structure for a window viewport. More... | |
struct | Window |
Data structure for an opened window. More... | |
class | PickerWindowBase |
Base class for windows opened from a toolbar. More... | |
Defines | |
#define | FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start) for (w = start; w != NULL; w = w->z_front) if (w->window_class != WC_INVALID) |
Iterate over all windows. | |
#define | FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, start) for (w = start; w != NULL; w = w->z_back) if (w->window_class != WC_INVALID) |
#define | FOR_ALL_WINDOWS_FROM_BACK(w) FOR_ALL_WINDOWS_FROM_BACK_FROM(w, _z_back_window) |
#define | FOR_ALL_WINDOWS_FROM_FRONT(w) FOR_ALL_WINDOWS_FROM_FRONT_FROM(w, _z_front_window) |
Enumerations | |
enum | FrameFlags { FR_NONE = 0, FR_TRANSPARENT = 1 << 0, FR_BORDERONLY = 1 << 4, FR_LOWERED = 1 << 5, FR_DARKENED = 1 << 6 } |
Flags to describe the look of the frame. More... | |
enum | WidgetDrawDistances { WD_IMGBTN_LEFT = 1, WD_IMGBTN_RIGHT = 2, WD_IMGBTN_TOP = 1, WD_IMGBTN_BOTTOM = 2, WD_INSET_LEFT = 2, WD_INSET_RIGHT = 2, WD_INSET_TOP = 1, WD_VSCROLLBAR_WIDTH = 12, WD_HSCROLLBAR_HEIGHT = 12, WD_FRAMERECT_LEFT = 2, WD_FRAMERECT_RIGHT = 2, WD_FRAMERECT_TOP = 1, WD_FRAMERECT_BOTTOM = 1, WD_TEXTPANEL_TOP = 6, WD_TEXTPANEL_BOTTOM = 6, WD_FRAMETEXT_LEFT = 6, WD_FRAMETEXT_RIGHT = 6, WD_FRAMETEXT_TOP = 6, WD_FRAMETEXT_BOTTOM = 6, WD_MATRIX_LEFT = 2, WD_MATRIX_RIGHT = 2, WD_MATRIX_TOP = 3, WD_MATRIX_BOTTOM = 1, WD_SHADEBOX_WIDTH = 12, WD_SHADEBOX_LEFT = 2, WD_SHADEBOX_RIGHT = 2, WD_SHADEBOX_TOP = 3, WD_SHADEBOX_BOTTOM = 3, WD_STICKYBOX_WIDTH = 12, WD_STICKYBOX_LEFT = 2, WD_STICKYBOX_RIGHT = 2, WD_STICKYBOX_TOP = 3, WD_STICKYBOX_BOTTOM = 3, WD_RESIZEBOX_WIDTH = 12, WD_RESIZEBOX_LEFT = 3, WD_RESIZEBOX_RIGHT = 2, WD_RESIZEBOX_TOP = 3, WD_RESIZEBOX_BOTTOM = 2, WD_CLOSEBOX_WIDTH = 11, WD_CLOSEBOX_LEFT = 2, WD_CLOSEBOX_RIGHT = 1, WD_CLOSEBOX_TOP = 2, WD_CLOSEBOX_BOTTOM = 2, WD_CAPTION_HEIGHT = 14, WD_CAPTIONTEXT_LEFT = 2, WD_CAPTIONTEXT_RIGHT = 2, WD_CAPTIONTEXT_TOP = 2, WD_CAPTIONTEXT_BOTTOM = 2, WD_DROPDOWN_HEIGHT = 12, WD_DROPDOWNTEXT_LEFT = 2, WD_DROPDOWNTEXT_RIGHT = 14, WD_DROPDOWNTEXT_TOP = 1, WD_DROPDOWNTEXT_BOTTOM = 1, WD_SORTBUTTON_ARROW_WIDTH = 11, WD_PAR_VSEP_NORMAL = 2, WD_PAR_VSEP_WIDE = 8 } |
Distances used in drawing widgets. More... | |
enum | WindowPosition { WDP_MANUAL, WDP_AUTO, WDP_CENTER, WDP_ALIGN_TOOLBAR } |
How do we the window to be placed? More... | |
enum | WindowDefaultFlag { WDF_CONSTRUCTION = 1 << 0, WDF_UNCLICK_BUTTONS = 1 << 1, WDF_MODAL = 1 << 2, WDF_NO_FOCUS = 1 << 3 } |
Window default widget/window handling flags. More... | |
enum | SortButtonState { SBS_OFF, SBS_DOWN, SBS_UP } |
State of a sort direction button. More... | |
enum | WindowFlags { WF_TIMEOUT_TRIGGER = 1, WF_TIMEOUT_BEGIN = 7, WF_TIMEOUT_MASK = 7, WF_DRAGGING = 1 << 3, WF_SCROLL_UP = 1 << 4, WF_SCROLL_DOWN = 1 << 5, WF_SCROLL_MIDDLE = 1 << 6, WF_SCROLL2 = 1 << 7, WF_HSCROLL = 1 << 8, WF_SIZING_RIGHT = 1 << 9, WF_SIZING_LEFT = 1 << 10, WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, WF_STICKY = 1 << 11, WF_DISABLE_VP_SCROLL = 1 << 12, WF_WHITE_BORDER_ONE = 1 << 13, WF_WHITE_BORDER_MASK = 1 << 14 | WF_WHITE_BORDER_ONE } |
Window flags. More... | |
enum | SpecialMouseMode { WSM_NONE = 0, WSM_DRAGDROP = 1, WSM_SIZING = 2, WSM_PRESIZE = 3 } |
Functions | |
DECLARE_ENUM_AS_BIT_SET (FrameFlags) | |
void | DrawFrameRect (int left, int top, int right, int bottom, Colours colour, FrameFlags flags) |
Draw frame rectangle. | |
Point | GetToolbarAlignedWindowPosition (int window_width) |
Computer the position of the top-left corner of a window to be opened right under the toolbar. | |
Window * | BringWindowToFrontById (WindowClass cls, WindowNumber number) |
Find a window and make it the top-window on the screen. | |
Window * | FindWindowFromPt (int x, int y) |
Do a search for a window at specific coordinates. | |
template<typename Wcls > | |
Wcls * | AllocateWindowDescFront (const WindowDesc *desc, int window_number) |
Open a new window. | |
void | RelocateAllWindows (int neww, int newh) |
Relocate all windows to fit the new size of the game application screen. | |
void | GuiShowTooltips (StringID str, uint paramcount=0, const uint64 params[]=NULL, bool use_left_mouse_button=false) |
Shows a tooltip. | |
int | GetWidgetFromPos (const Window *w, int x, int y) |
Returns the index for the widget located at the given position relative to the window. | |
Window * | GetCallbackWnd () |
void | SetFocusedWindow (Window *w) |
Set the window that has the focus. | |
bool | EditBoxInGlobalFocus () |
Check if an edit box is in global focus. | |
void | ScrollbarClickHandler (Window *w, const NWidgetCore *nw, int x, int y) |
Special handling for the scrollbar widget type. | |
Variables | |
Window * | _z_front_window |
List of windows opened at the screen sorted from the front. | |
Window * | _z_back_window |
List of windows opened at the screen sorted from the back. | |
Window * | _focused_window |
Point | _cursorpos_drag_start |
int | _scrollbar_start_pos |
int | _scrollbar_size |
byte | _scroller_click_timeout |
bool | _scrolling_scrollbar |
bool | _scrolling_viewport |
byte | _special_mouse_mode |
Functions, definitions and such used only by the GUI.
Definition in file window_gui.h.
enum FrameFlags |
Flags to describe the look of the frame.
Definition at line 25 of file window_gui.h.
enum SortButtonState |
State of a sort direction button.
SBS_OFF |
Do not sort (with this button). |
SBS_DOWN |
Sort ascending. |
SBS_UP |
Sort descending. |
Definition at line 305 of file window_gui.h.
enum WidgetDrawDistances |
Distances used in drawing widgets.
Definition at line 36 of file window_gui.h.
enum WindowDefaultFlag |
Window default widget/window handling flags.
Definition at line 165 of file window_gui.h.
enum WindowFlags |
Window flags.
WF_TIMEOUT_TRIGGER |
When the timeout should start triggering. |
WF_TIMEOUT_BEGIN |
The initial value for the timeout. |
WF_TIMEOUT_MASK |
Window timeout counter bit mask (3 bits). |
WF_DRAGGING |
Window is being dragged. |
WF_SCROLL_UP |
Upper scroll button has been pressed,.
|
WF_SCROLL_DOWN |
Lower scroll button has been pressed,.
|
WF_SCROLL_MIDDLE |
Scrollbar scrolling,.
|
WF_SIZING_RIGHT |
Window is being resized towards the right. |
WF_SIZING_LEFT |
Window is being resized towards the left. |
WF_SIZING |
Window is being resized. |
WF_STICKY |
Window is made sticky by user. |
WF_DISABLE_VP_SCROLL |
Window does not do autoscroll,.
|
Definition at line 826 of file window_gui.h.
enum WindowPosition |
How do we the window to be placed?
WDP_MANUAL |
Manually align the window (so no automatic location finding). |
WDP_AUTO |
Find a place automatically. |
WDP_CENTER |
Center the window. |
WDP_ALIGN_TOOLBAR |
Align toward the toolbar. |
Definition at line 132 of file window_gui.h.
Wcls* AllocateWindowDescFront | ( | const WindowDesc * | desc, | |
int | window_number | |||
) | [inline] |
Open a new window.
desc | The pointer to the WindowDesc to be created | |
window_number | the window number of the new window |
Definition at line 857 of file window_gui.h.
References BringWindowToFrontById(), and WindowDesc::cls.
Window* BringWindowToFrontById | ( | WindowClass | cls, | |
WindowNumber | number | |||
) |
Find a window and make it the 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 762 of file window.cpp.
References BringWindowToFront(), FindWindowById(), Window::flags4, Window::IsShaded(), Window::SetDirty(), and Window::SetShaded().
Referenced by AllocateWindowDescFront(), DoSelectCompanyManagerFace(), NetworkContentListWindow::OnClick(), CompanyWindow::OnClick(), ShowCompanyFinances(), ShowDepotWindow(), ShowGenerateWorldProgress(), and ShowSelectBaseStationIfNeeded().
void DrawFrameRect | ( | int | left, | |
int | top, | |||
int | right, | |||
int | bottom, | |||
Colours | colour, | |||
FrameFlags | flags | |||
) |
Draw frame rectangle.
left | Left edge of the frame | |
top | Top edge of the frame | |
right | Right edge of the frame | |
bottom | Bottom edge of the frame | |
colour | Colour table to use. |
flags | Flags controlling how to draw the frame. |
Definition at line 200 of file widget.cpp.
References _colour_gradient, FILLRECT_RECOLOUR, FR_BORDERONLY, FR_DARKENED, FR_LOWERED, FR_TRANSPARENT, and GfxFillRect().
Referenced by NWidgetLeaf::Draw(), NWidgetBackground::Draw(), DrawAircraftImage(), DrawArrowButtons(), DrawButtonDropdown(), DrawCaption(), DrawCloseBox(), DrawHorizontalScrollbar(), DrawImageButtons(), DrawInset(), DrawMatrix(), DrawResizeBox(), DrawRoadVehImage(), SettingEntry::DrawSetting(), DrawShadeBox(), DrawShipImage(), DrawStickyBox(), DrawTrainImage(), DrawVerticalScrollbar(), TransparenciesWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NetworkContentDownloadStatusWindow::DrawWidget(), MusicWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), CheatWindow::DrawWidget(), AISettingsWindow::DrawWidget(), and Window::DrawWidgets().
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 126 of file window.cpp.
References Window::nested_focus, NWidgetBase::type, Window::window_class, and WWT_EDITBOX.
Referenced by HandleKeypress(), and Window::InitializeData().
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 1260 of file window.cpp.
References Window::height, IsInsideBS(), Window::left, Window::top, and Window::width.
Referenced by HandleAutoscroll().
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 1132 of file window.cpp.
References _dynlang, FindWindowById(), Window::height, Window::left, TD_RTL, DynamicLanguages::text_dir, Window::top, and Window::width.
Referenced by LocalGetWindowPlacement(), TransparenciesWindow::OnInitialPosition(), and TerraformToolbarWindow::OnInitialPosition().
int GetWidgetFromPos | ( | const Window * | w, | |
int | x, | |||
int | y | |||
) |
Returns the index for the widget located at the given position relative to the window.
It includes all widget-corner pixels as well.
*w | Window to look inside | |
x | The Window client X coordinate | |
y | The Window client y coordinate |
Definition at line 185 of file widget.cpp.
References NWidgetBase::GetWidgetFromPos(), NWidgetCore::index, and Window::nested_root.
Referenced by DropdownWindow::GetDropDownItem(), and DropdownWindow::OnMouseLoop().
void GuiShowTooltips | ( | StringID | str, | |
uint | paramcount, | |||
const uint64 | params[], | |||
bool | use_left_mouse_button | |||
) |
Shows a tooltip.
str | String to be displayed | |
paramcount | number of params to deal with | |
params | (optional) up to 5 pieces of additional information that may be added to a tooltip | |
use_left_mouse_button | close the tooltip when the left (true) or right (false) mousebutton is released |
Definition at line 877 of file misc_gui.cpp.
References DeleteWindowById().
Referenced by DispatchRightClickEvent(), DepotWindow::OnRightClick(), and ShowMeasurementTooltips().
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 appliction screen |
Definition at line 2533 of file window.cpp.
References Clamp(), FindWindowById(), Window::height, ViewPort::height, ViewPort::left, Window::left, min(), PositionMainToolbar(), ResizeWindow(), ScaleByZoom(), ViewPort::top, Window::top, Window::viewport, ViewPort::virtual_height, ViewPort::virtual_width, Window::width, ViewPort::width, and Window::window_class.
Referenced by GameSizeChanged(), and ReInitAllWindows().
void ScrollbarClickHandler | ( | Window * | w, | |
const NWidgetCore * | nw, | |||
int | x, | |||
int | y | |||
) |
Special handling for the scrollbar widget type.
Handles the special scrolling buttons and other scrolling.
w | Window on which a scroll was performed. | |
nw | Pointer to the scrollbar widget. | |
x | The X coordinate of the mouse click. | |
y | The Y coordinate of the mouse click. |
Definition at line 150 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, NWidgetBase::pos_x, NWidgetBase::pos_y, ScrollbarClickPositioning(), NWidgetBase::type, WWT_HSCROLLBAR, WWT_SCROLL2BAR, and WWT_SCROLLBAR.
Referenced by DispatchLeftClickEvent().
void SetFocusedWindow | ( | Window * | w | ) |
Set the window that has the focus.
w | The window to set the focus on |
Definition at line 103 of file window.cpp.
References Window::nested_focus, Window::OnFocus(), Window::OnFocusLost(), and NWidgetBase::SetDirty().
Referenced by DispatchLeftClickEvent(), Window::InitializeData(), and OskWindow::OnClick().
List of windows opened at the screen sorted from the back.
Definition at line 43 of file window.cpp.
List of windows opened at the screen sorted from the front.
Definition at line 41 of file window.cpp.