#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. | |
Scrollbar * | FindScrollbar (Window *w, bool allow_next=true) const |
Find the scrollbar of the widget through the Window::nested_array. | |
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). |
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 456 of file widget_type.h.
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 1627 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::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 1637 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, NWidgetCore::disp_flags, Window::DrawViewport(), FILLRECT_RECOLOUR, GfxFillRect(), ND_NO_TRANSPARENCY, ND_SHADE_DIMMED, ND_SHADE_GREY, NWidgetBase::pos_x, and NWidgetBase::pos_y.
Find the scrollbar of the widget through the Window::nested_array.
w | Window containing the widgets and the scrollbar, | |
allow_next | Search may be extended to the next widget. |
Implements NWidgetCore.
Definition at line 1655 of file widget.cpp.
Initialize the viewport of the window.
w | Window owning the viewport. | |
follow_flags | Type of viewport, see InitializeViewport(). | |
zoom | Zoom level. |
Definition at line 1666 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, InitializeWindowViewport(), NWidgetBase::pos_x, and NWidgetBase::pos_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 1675 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 VehicleViewWindow::OnResize().