| OpenTTD
    | 
Functions, definitions and such used only by the GUI. More...
#include "vehicle_type.h"#include "viewport_type.h"#include "company_type.h"#include "tile_type.h"#include "widget_type.h"#include "core/smallvec_type.hpp"#include "core/smallmap_type.hpp"#include "string_type.h"Go to the source code of this file.
| Data Structures | |
| struct | WindowDesc | 
| High level window description.  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... | |
| Macros | |
| #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) | 
| Functions | |
| void | DrawFrameRect (int left, int top, int right, int bottom, Colours colour, FrameFlags flags) | 
| Draw frame rectangle. | |
| void | DrawCaption (const Rect &r, Colours colour, Owner owner, StringID str) | 
| Draw a caption bar. | |
| 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 relative 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 (WindowDesc *desc, int window_number, bool return_existing=false) | 
| 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 (Window *parent, StringID str, uint paramcount=0, const uint64 params[]=NULL, TooltipCloseCondition close_tooltip=TCC_HOVER) | 
| 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. | |
| void | SetFocusedWindow (Window *w) | 
| Set the window that has the focus. | |
| void | ScrollbarClickHandler (Window *w, 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 | 
| static const int | TIMEOUT_DURATION = 7 | 
| The initial timeout value for WF_TIMEOUT. | |
| static const int | WHITE_BORDER_DURATION = 3 | 
| The initial timeout value for WF_WHITE_BORDER. | |
| Point | _cursorpos_drag_start | 
| int | _scrollbar_start_pos | 
| int | _scrollbar_size | 
| byte | _scroller_click_timeout | 
| 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. | |
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 27 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 224 of file window_gui.h.
| enum SpecialMouseMode | 
Mouse modes.
| WSM_NONE | No special mouse mode. | 
| WSM_DRAGDROP | Dragging an object. | 
| WSM_SIZING | Sizing mode. | 
| WSM_PRESIZE | Presizing mode (docks, tunnels). | 
Definition at line 896 of file window_gui.h.
| enum WidgetDrawDistances | 
Distances used in drawing widgets.
Definition at line 38 of file window_gui.h.
| enum WindowDefaultFlag | 
Window default widget/window handling flags.
Definition at line 209 of file window_gui.h.
| enum WindowFlags | 
Window flags.
| WF_TIMEOUT | Window timeout counter. | 
| WF_DRAGGING | Window is being dragged. | 
| 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,. 
 | 
| WF_WHITE_BORDER | Window white border counter bit mask. | 
| WF_HIGHLIGHTED | Window has a widget that has a highlight. | 
| WF_CENTERED | Window is centered and shall stay centered after ReInit. | 
Definition at line 233 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 154 of file window_gui.h.
| Wcls* AllocateWindowDescFront | ( | WindowDesc * | desc, | 
| int | window_number, | ||
| bool | return_existing = false | ||
| ) | 
Open a new window.
| Wcls | Window class to use if the window does not exist. | 
| desc | The pointer to the WindowDesc to be created | 
| window_number | the window number of the new window | 
| return_existing | If set, also return the window if it already existed. | 
NULL. Definition at line 859 of file window_gui.h.
References BringWindowToFrontById(), and WindowDesc::cls.
| 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().
Draw a caption bar.
| r | Rectangle of the bar. | 
| colour | Colour of the window. | 
| owner | 'Owner' of the window. | 
| str | Text to draw in the bar. | 
Definition at line 539 of file widget.cpp.
References _colour_gradient, _company_colours, DrawFrameRect(), DrawString(), FR_BORDERONLY, FR_DARKENED, FR_LOWERED, GetStringBoundingBox(), GfxFillRect(), max(), MAX_COMPANIES, SA_HOR_CENTER, WD_CAPTIONTEXT_LEFT, and WD_CAPTIONTEXT_RIGHT.
Referenced by NWidgetLeaf::Draw(), and NewsWindow::DrawWidget().
| 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 177 of file widget.cpp.
References _colour_gradient, FILLRECT_RECOLOUR, FR_BORDERONLY, FR_DARKENED, FR_LOWERED, FR_TRANSPARENT, GfxFillRect(), PALETTE_TO_TRANSPARENT, WD_BEVEL_BOTTOM, WD_BEVEL_LEFT, WD_BEVEL_RIGHT, and WD_BEVEL_TOP.
Referenced by NWidgetBackground::Draw(), NWidgetLeaf::Draw(), DrawAircraftImage(), DrawArrowButtons(), DrawBoolButton(), DrawButtonDropdown(), DrawCaption(), DrawCloseBox(), DrawDebugBox(), DrawDefSizeBox(), DrawDropDownButton(), DrawHorizontalScrollbar(), DrawImageButtons(), DrawInset(), DrawMatrix(), DrawResizeBox(), DrawRoadVehImage(), DrawShadeBox(), DrawShipImage(), DrawStickyBox(), DrawTrainImage(), DrawVerticalScrollbar(), TransparenciesWindow::DrawWidget(), MusicWindow::DrawWidget(), RefitWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), and Window::DrawWidgets().
| 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().
| 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().
| 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.
Definition at line 162 of file widget.cpp.
References NWidgetBase::GetWidgetFromPos(), NWidgetCore::index, and Window::nested_root.
Referenced by DropdownWindow::GetDropDownItem(), HandleMouseDragDrop(), and Window::OnDropdownClose().
| void GuiShowTooltips | ( | Window * | parent, | 
| StringID | str, | ||
| uint | paramcount, | ||
| const uint64 | params[], | ||
| TooltipCloseCondition | close_tooltip | ||
| ) | 
Shows a tooltip.
| parent | The window this tooltip is related to. | 
| 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) mouse button is released | 
Definition at line 741 of file misc_gui.cpp.
References DeleteWindowById(), and WC_TOOLTIPS.
Referenced by DispatchHoverEvent(), DispatchRightClickEvent(), IndustryCargoesWindow::OnHover(), 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 application screen. | 
Definition at line 3409 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().
| void ScrollbarClickHandler | ( | Window * | w, | 
| 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 138 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, NWID_HSCROLLBAR, NWidgetBase::pos_x, NWidgetBase::pos_y, ScrollbarClickPositioning(), and NWidgetBase::type.
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 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().
| Window* _z_back_window | 
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 | 
List of windows opened at the screen sorted from the front.
Definition at line 55 of file window.cpp.
Referenced by AddWindowToZOrdering().
 1.8.1.2
 1.8.1.2