Nested widget to display a viewport in a window. More...
#include <widget_type.h>
Public Member Functions | |
NWidgetViewport (int index) | |
void | SetupSmallestSize (Window *w, bool init_array) |
Compute smallest size needed by the widget. | |
void | Draw (const Window *w) |
Draw the widgets of the tree. | |
void | InitializeViewport (Window *w, uint32 follow_flags, ZoomLevel zoom) |
Initialize the viewport of the window. | |
void | UpdateViewportCoordinates (Window *w) |
Update the position and size of the viewport (after eg a resize). |
Nested widget to display a viewport in a window.
After initializing the nested widget tree, call InitializeViewport(). After changing the window size, call UpdateViewportCoordinates() eg from Window::OnResize(). If the display_flags field contains the ND_NO_TRANSPARENCY bit, the viewport will disable transparency. Shading to grey-scale is controlled with the ND_SHADE_GREY bit (used for B&W news papers), the ND_SHADE_DIMMED gives dimmed colours (for colour news papers).
Definition at line 572 of file widget_type.h.
void NWidgetViewport::Draw | ( | const Window * | w | ) | [virtual] |
Draw the widgets of the tree.
The function calls Window::DrawWidget for each widget with a non-negative index, after the widget itself is painted.
w | Window that owns the tree. |
Implements NWidgetBase.
Definition at line 1846 of file widget.cpp.
References _transparency_opt, NWidgetBase::current_x, NWidgetBase::current_y, NWidgetCore::disp_flags, Window::DrawViewport(), FILLRECT_RECOLOUR, GfxFillRect(), ND_NO_TRANSPARENCY, ND_SHADE_DIMMED, ND_SHADE_GREY, PALETTE_NEWSPAPER, PALETTE_TO_TRANSPARENT, NWidgetBase::pos_x, NWidgetBase::pos_y, and TO_LOADING.
Initialize the viewport of the window.
w | Window owning the viewport. | |
follow_flags | Type of viewport, see InitializeWindowViewport(). | |
zoom | Zoom level. |
Definition at line 1870 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, InitializeWindowViewport(), NWidgetBase::pos_x, and NWidgetBase::pos_y.
Referenced by WaypointWindow::WaypointWindow().
void NWidgetViewport::SetupSmallestSize | ( | Window * | w, | |
bool | init_array | |||
) | [virtual] |
Compute smallest size needed by the widget.
The smallest size of a widget is the smallest size that a widget needs to display itself properly. In addition, filling and resizing of the widget are computed. The function calls Window::UpdateWidgetSize for each leaf widget and background widget without child with a non-negative index.
w | Window owning the widget. | |
init_array | Initialize the w->nested_array . |
Implements NWidgetBase.
Definition at line 1836 of file widget.cpp.
References NWidgetCore::index, NWidgetResizeBase::min_x, NWidgetResizeBase::min_y, Window::nested_array, Window::nested_array_size, NWidgetBase::smallest_x, and NWidgetBase::smallest_y.
void NWidgetViewport::UpdateViewportCoordinates | ( | Window * | w | ) |
Update the position and size of the viewport (after eg a resize).
w | Window owning the viewport. |
Definition at line 1879 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, ViewPort::height, Window::left, ViewPort::left, NWidgetBase::pos_x, NWidgetBase::pos_y, ScaleByZoom(), Window::top, ViewPort::top, Window::viewport, ViewPort::virtual_height, ViewPort::virtual_width, ViewPort::width, and ViewPort::zoom.
Referenced by WaypointWindow::OnResize(), ExtraViewportWindow::OnResize(), VehicleViewWindow::OnResize(), TownViewWindow::OnResize(), MainWindow::OnResize(), and IndustryViewWindow::OnResize().