Public Member Functions

# NWidgetViewport Class Reference
[Hierarchical widgets]

Nested widget to display a viewport in a window. More...

`#include <widget_type.h>`

Inheritance diagram for NWidgetViewport:

## 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).

## Detailed Description

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).

Todo:
  Class derives from NWidgetCore, but does not use colour, widget_data, or tool_tip.

Definition at line 572 of file widget_type.h.

## Member Function Documentation

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.

Parameters:

  | w | Window that owns the tree.

Implements NWidgetBase.

Definition at line 1828 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.

void NWidgetViewport::InitializeViewport | ( | Window * | w,
|  | uint32 | follow_flags,
|  | ZoomLevel | zoom |
| ) |  |  |

Initialize the viewport of the window.

Parameters:

  | w | Window owning the viewport.
  | follow_flags | Type of viewport, see InitializeWindowViewport().
  | zoom | Zoom level.

Definition at line 1852 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.

Parameters:

  | w | Window owning the widget.
  | init_array | Initialize the `w->nested_array`.

Note:
  After the computation, the results can be queried by accessing the smallest_x and smallest_y data members of the widget.

Implements NWidgetBase.

Definition at line 1818 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).

Parameters:

  | w | Window owning the viewport.

Definition at line 1861 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().

The documentation for this class was generated from the following files:

- src/widget_type.h
- src/widget.cpp