#include "core/bitmath_func.hpp"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "player_type.h"
#include "strings_type.h"
Go to the source code of this file.
Data Structures | |
struct | Widget |
struct | WindowEvent |
struct | WindowDesc |
struct | Scrollbar |
struct | ResizeInfo |
struct | WindowMessage |
struct | Window |
struct | menu_d |
struct | def_d |
struct | void_d |
struct | tree_d |
struct | tooltips_d |
struct | replaceveh_d |
struct | depot_d |
struct | order_d |
struct | vehicledetails_d |
struct | smallmap_d |
struct | refit_d |
struct | vp_d |
struct | news_d |
struct | highscore_d |
struct | scroller_d |
struct | Listing |
struct | list_d |
struct | message_d |
struct | vehiclelist_d |
struct | grouplist_d |
struct | groupveh_d |
Defines | |
#define | WP(ptr, str) (*(str*)(ptr)->custom) |
#define | WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL |
#define | FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++) |
Typedefs | |
typedef void | WindowProc (Window *w, WindowEvent *e) |
Enumerations | |
enum | ResizeFlag { RESIZE_NONE = 0, RESIZE_LEFT = 1, RESIZE_RIGHT = 2, RESIZE_TOP = 4, RESIZE_BOTTOM = 8, RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, WIDG_DISABLED = 4, WIDG_HIDDEN = 5, WIDG_LOWERED = 6 } |
enum | { WIDGET_LIST_END = -1 } |
enum | FrameFlags { FR_NONE = 0, FR_TRANSPARENT = 1 << 0, FR_BORDERONLY = 1 << 4, FR_LOWERED = 1 << 5, FR_DARKENED = 1 << 6 } |
enum | WindowEventCodes { WE_CREATE, WE_DESTROY, WE_PAINT, WE_KEYPRESS, WE_CLICK, WE_DOUBLE_CLICK, WE_RCLICK, WE_MOUSEOVER, WE_MOUSELOOP, WE_MOUSEWHEEL, WE_TICK, WE_4, WE_TIMEOUT, WE_PLACE_OBJ, WE_ABORT_PLACE_OBJ, WE_ON_EDIT_TEXT, WE_ON_EDIT_TEXT_CANCEL, WE_POPUPMENU_SELECT, WE_POPUPMENU_OVER, WE_DRAGDROP, WE_PLACE_DRAG, WE_PLACE_MOUSEUP, WE_PLACE_PRESIZE, WE_DROPDOWN_SELECT, WE_RESIZE, WE_MESSAGE, WE_SCROLL, WE_INVALIDATE_DATA, WE_CTRL_CHANGED } |
enum | WindowDefaultFlag { WDF_STD_TOOLTIPS = 1 << 0, WDF_DEF_WIDGET = 1 << 1, WDF_STD_BTN = 1 << 2, WDF_UNCLICK_BUTTONS = 1 << 4, WDF_STICKY_BUTTON = 1 << 5, WDF_RESIZABLE = 1 << 6, WDF_MODAL = 1 << 7 } |
enum | WindowDefaultPosition { WDP_AUTO = -1, WDP_CENTER = -2, WDP_ALIGN_TBR = -3, WDP_ALIGN_TBL = -4 } |
enum | SortListFlags { VL_NONE = 0, VL_DESC = 1 << 0, VL_RESORT = 1 << 1, VL_REBUILD = 1 << 2, VL_END = 1 << 3 } |
enum | WindowWidgetBehaviours { WWB_PUSHBUTTON = 1 << 5, WWB_MASK = 0xE0 } |
enum | WindowWidgetTypes { WWT_EMPTY, WWT_PANEL, WWT_INSET, WWT_IMGBTN, WWT_IMGBTN_2, WWT_TEXTBTN, WWT_TEXTBTN_2, WWT_LABEL, WWT_TEXT, WWT_MATRIX, WWT_SCROLLBAR, WWT_FRAME, WWT_CAPTION, WWT_HSCROLLBAR, WWT_STICKYBOX, WWT_SCROLL2BAR, WWT_RESIZEBOX, WWT_CLOSEBOX, WWT_DROPDOWN, WWT_DROPDOWNIN, WWT_LAST, WWT_MASK = 0x1F, WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON } |
enum | WindowFlags { WF_TIMEOUT_SHL = 0, WF_TIMEOUT_MASK = 7, WF_DRAGGING = 1 << 3, WF_SCROLL_UP = 1 << 4, WF_SCROLL_DOWN = 1 << 5, WF_SCROLL_MIDDLE = 1 << 6, WF_HSCROLL = 1 << 7, WF_SIZING = 1 << 8, WF_STICKY = 1 << 9, WF_DISABLE_VP_SCROLL = 1 << 10, WF_WHITE_BORDER_ONE = 1 << 11, WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE, WF_SCROLL2 = 1 << 13 } |
enum | SortButtonState { SBS_OFF, SBS_DOWN, SBS_UP } |
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, int color, FrameFlags flags) |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(menu_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(def_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(void_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(tree_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(tooltips_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(replaceveh_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(depot_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(order_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(vehicledetails_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(smallmap_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(refit_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(vp_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(news_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(highscore_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(scroller_d)) | |
DECLARE_ENUM_AS_BIT_SET (SortListFlags) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(list_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(message_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(vehiclelist_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(grouplist_d)) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(groupveh_d)) | |
void | CallWindowEventNP (Window *w, int event) |
void | CallWindowTickEvent () |
void | SetWindowDirty (const Window *w) |
Marks the window as dirty for repaint. | |
void | SendWindowMessage (WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam) |
Send a message from one window to another. | |
void | SendWindowMessageClass (WindowClass wnd_class, int msg, int wparam, int lparam) |
Send a message from one window to another. | |
Window * | FindWindowById (WindowClass cls, WindowNumber number) |
void | DeleteWindow (Window *w) |
void | DeletePlayerWindows (PlayerID pi) |
Delete all windows of a player. | |
void | ChangeWindowOwner (PlayerID old_player, PlayerID new_player) |
Change the owner of all the windows one player can take over from another player in the case of a company merger. | |
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. | |
bool | IsWindowOfPrototype (const Window *w, const Widget *widget) |
void | AssignWidgetToWindow (Window *w, const Widget *widget) |
Copies 'widget' to 'w->widget' to allow for resizable windows. | |
Window * | AllocateWindow (int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data=NULL) |
Open a new window. | |
Window * | AllocateWindowDesc (const WindowDesc *desc, void *data=NULL) |
Open a new window. | |
Window * | AllocateWindowDescFront (const WindowDesc *desc, int window_number, void *data=NULL) |
Open a new window. | |
void | DrawWindowViewport (const Window *w) |
void | ResizeWindow (Window *w, int x, int y) |
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. | |
void | InitWindowSystem () |
void | UnInitWindowSystem () |
void | ResetWindowSystem () |
int | GetMenuItemIndex (const Window *w, int x, int y) |
void | InputLoop () |
void | InvalidateThisWindowData (Window *w) |
void | InvalidateWindowData (WindowClass cls, WindowNumber number) |
void | RelocateAllWindows (int neww, int newh) |
void | GuiShowTooltipsWithArgs (StringID str, uint paramcount, const uint64 params[]) |
Shows a tooltip. | |
static void | GuiShowTooltips (StringID str) |
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 | DrawWindowWidgets (const Window *w) |
void | DrawSortButtonState (const Window *w, int widget, SortButtonState state) |
Draw a sort button's up or down arrow symbol. | |
Window * | GetCallbackWnd () |
void | DeleteNonVitalWindows () |
void | DeleteAllNonVitalWindows () |
It is possible that a stickied window gets to a position where the 'close' button is outside the gaming area. | |
void | HideVitalWindows () |
Delete all always on-top windows to get an empty screen. | |
void | ShowVitalWindows () |
Window ** | FindWindowZPosition (const Window *w) |
Find the z-value of a window. | |
void | ScrollbarClickHandler (Window *w, const Widget *wi, int x, int y) |
Special handling for the scrollbar widget type. | |
void | ResizeButtons (Window *w, byte left, byte right) |
Evenly distribute some widgets when resizing horizontally (often a button row) The widgets are presumed to be in a line and numberef from left to right (without gaps). | |
void | ResizeWindowForWidget (Window *w, int widget, int delta_x, int delta_y) |
Resize a widget an shuffle other widgets around to fit. | |
Variables | |
static const int | MAX_NUMBER_OF_WINDOWS = 25 |
The maximum number of windows that can be opened. | |
Window * | _z_windows [] |
Window ** | _last_z_window |
always points to the next free space in the z-array | |
Point | _cursorpos_drag_start |
int | _scrollbar_start_pos |
int | _scrollbar_size |
byte | _scroller_click_timeout |
bool | _scrolling_scrollbar |
bool | _scrolling_viewport |
bool | _popup_menu_active |
byte | _special_mouse_mode |
Definition in file window_gui.h.
anonymous enum |
Definition at line 72 of file window_gui.h.
enum FrameFlags |
Definition at line 85 of file window_gui.h.
enum ResizeFlag |
Definition at line 48 of file window_gui.h.
enum SortListFlags |
VL_NONE | no sort |
VL_DESC | sort descending or ascending |
VL_RESORT | instruct the code to resort the list in the next loop |
VL_REBUILD | create sort-listing to use for qsort and friends |
Definition at line 417 of file window_gui.h.
enum WindowDefaultFlag |
Definition at line 212 of file window_gui.h.
Definition at line 224 of file window_gui.h.
enum WindowWidgetTypes |
Definition at line 478 of file window_gui.h.
Window* AllocateWindow | ( | int | x, | |
int | y, | |||
int | width, | |||
int | height, | |||
WindowProc * | proc, | |||
WindowClass | cls, | |||
const Widget * | widget, | |||
void * | data | |||
) |
Open a new window.
If there is no space for a new window, close an open window. Try to avoid stickied windows, but if there is no else, close one of those as well. Then make sure all created windows are below some always-on-top ones. Finally set all variables and call the WE_CREATE event
x | offset in pixels from the left of the screen | |
y | offset in pixels from the top of the screen | |
width | width in pixels of the window | |
height | height in pixels of the window | |
*proc | see WindowProc function to call when any messages/updates happen to the window | |
cls | see WindowClass class of the window, used for identification and grouping | |
*widget | see Widget pointer to the window layout and various elements |
Definition at line 755 of file window.cpp.
References LocalAllocateWindow().
Referenced by GuiShowTooltipsWithArgs(), and PopupMainToolbMenu().
Window* AllocateWindowDesc | ( | const WindowDesc * | desc, | |
void * | data | |||
) |
Open a new window.
*desc | The pointer to the WindowDesc to be created | |
data | arbitrary data that is send with the WE_CREATE message |
Definition at line 949 of file window.cpp.
References LocalAllocateWindowDesc().
Referenced by ShowEndGameChart(), ShowHighscoreTable(), ShowMessageHistory(), ShowNewGRFSettings(), ShowNewspaper(), ShowQuery(), ShowQueryString(), and ShowSignalBuilder().
Window* AllocateWindowDescFront | ( | const WindowDesc * | desc, | |
int | window_number, | |||
void * | data | |||
) |
Open a new window.
*desc | The pointer to the WindowDesc to be created | |
window_number | the window number of the new window | |
data | arbitrary data that is send with the WE_CREATE message |
Definition at line 961 of file window.cpp.
References BringWindowToFrontById(), and LocalAllocateWindowDesc().
Referenced by DoSelectPlayerFace(), PlayerCompanyWndProc(), ShowDepotWindow(), ShowGenerateWorldProgress(), ShowPlayerStations(), ShowStationViewWindow(), ShowVehicleDetailsWindow(), ShowVehicleRefitWindow(), and ShowVehicleViewWindow().
void AssignWidgetToWindow | ( | Window * | w, | |
const Widget * | widget | |||
) |
Copies 'widget' to 'w->widget' to allow for resizable windows.
w | Window on which to attach the widget array | |
widget | pointer of widget array to fill the window with |
Definition at line 570 of file window.cpp.
References ReallocT(), and WWT_LAST.
Referenced by LocalAllocateWindow().
Window* BringWindowToFrontById | ( | WindowClass | cls, | |
WindowNumber | number | |||
) |
Find a window and make it the top-window on the screen.
The window gets a white border 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 476 of file window.cpp.
References BringWindowToFront(), and SetWindowDirty().
Referenced by AllocateWindowDescFront().
Change the owner of all the windows one player can take over from another player in the case of a company merger.
Do not change ownership of windows that need to be deleted once takeover is complete
old_player | PlayerID of original owner of the window | |
new_player | PlayerID of the new owner of the window |
Definition at line 447 of file window.cpp.
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 2069 of file window.cpp.
Referenced by GenerateWorld().
void DeletePlayerWindows | ( | PlayerID | id | ) |
Delete all windows of a player.
We identify windows of a player by looking at the caption colour. If it is equal to the player ID then we say the window belongs to the player and should be deleted
id | PlayerID player identifier |
Definition at line 422 of file window.cpp.
void DrawSortButtonState | ( | const Window * | w, | |
int | widget, | |||
SortButtonState | state | |||
) |
Draw a sort button's up or down arrow symbol.
w | Window of widget | |
widget | Sort button widget | |
state | State of sort button |
Definition at line 609 of file widget.cpp.
References DoDrawString().
Referenced by GroupWndProc().
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 975 of file window.cpp.
References _last_z_window, and IsInsideBS().
Window** FindWindowZPosition | ( | const Window * | w | ) |
Find the z-value of a window.
A window must already be open or the behaviour is undefined but function should never fail
w | window to query Z Position |
Definition at line 338 of file window.cpp.
References _last_z_window.
Referenced by BringWindowToFront(), and MaybeBringWindowToFront().
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 136 of file widget.cpp.
References WWT_FRAME.
void GuiShowTooltipsWithArgs | ( | StringID | str, | |
uint | paramcount, | |||
const uint64 | params[] | |||
) |
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; currently only supports parameters of {NUM} (integer) |
Definition at line 735 of file misc_gui.cpp.
References AllocateWindow(), Clamp(), and GetStringBoundingBox().
Referenced by CalcRaildirsDrawstyle(), VpSelectTilesWithMethod(), and VpSetPresizeRange().
void ResizeButtons | ( | Window * | w, | |
byte | left, | |||
byte | right | |||
) |
Evenly distribute some widgets when resizing horizontally (often a button row) The widgets are presumed to be in a line and numberef from left to right (without gaps).
w | widow to modify | |
left | The leftmost widget to resize | |
right | The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT |
w | Window to modify | |
left | The leftmost widget to resize | |
right | The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT |
Definition at line 546 of file widget.cpp.
References ResizeButtons().
Referenced by ResizeButtons(), StationViewWndProc(), and VehicleDetailsWndProc().
void ResizeWindow | ( | Window * | w, | |
int | x, | |||
int | y | |||
) |
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 | |
x | delta x-size of changed window (positive if larger, etc.) | |
y | delta y-size of changed window |
Definition at line 1167 of file window.cpp.
References GB(), RESIZE_BOTTOM, RESIZE_LEFT, RESIZE_NONE, RESIZE_RIGHT, RESIZE_TOP, SetWindowDirty(), and WWT_LAST.
Referenced by CreateVehicleDetailsWindow(), LocalAllocateWindow(), and ShowPlayerStations().
void ScrollbarClickHandler | ( | Window * | w, | |
const Widget * | wi, | |||
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. | |
wi | Pointer to the scrollbar widget. | |
x | The X coordinate of the mouse click. | |
y | The Y coordinate of the mouse click. |
Definition at line 51 of file widget.cpp.
References max(), min(), SetWindowDirty(), and WWT_SCROLL2BAR.
void SendWindowMessage | ( | WindowClass | wnd_class, | |
WindowNumber | wnd_num, | |||
int | msg, | |||
int | wparam, | |||
int | lparam | |||
) |
Send a message from one window to another.
The receiving window is found by
wnd_class | see WindowClass class AND | |
wnd_num | see WindowNumber number, mostly 0 | |
msg | Specifies the message to be sent | |
wparam | Specifies additional message-specific information | |
lparam | Specifies additional message-specific information |
Definition at line 1612 of file window.cpp.
References SendWindowMessageW().
Referenced by SaveFileDone(), and SaveFileStart().
void SendWindowMessageClass | ( | WindowClass | wnd_class, | |
int | msg, | |||
int | wparam, | |||
int | lparam | |||
) |
Send a message from one window to another.
The message will be sent to ALL windows of the windowclass specified in the first parameter
wnd_class | see WindowClass class | |
msg | Specifies the message to be sent | |
wparam | Specifies additional message-specific information | |
lparam | Specifies additional message-specific information |
Definition at line 1625 of file window.cpp.
References SendWindowMessageW().