# VehicleDetailsWindow Struct Reference

Class for managing the vehicle details window. More...

Inheritance diagram for VehicleDetailsWindow:

## Public Member Functions

| VehicleDetailsWindow (const WindowDesc *desc, WindowNumber window_number)
| Initialize a newly created vehicle details window.
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
| Update size and resize step of a widget in the window.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
virtual void | OnPaint ()
| Repaint vehicle details window.
virtual void | OnClick (Point pt, int widget, int click_count)
| A click with the left mouse button has been made on the window.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
virtual void | OnResize ()
| Called after the window got resized.

## Static Public Member Functions

static bool | IsVehicleServiceIntervalEnabled (const VehicleType vehicle_type, CompanyID company_id)
| Checks whether service interval is enabled for the vehicle.
static void | DrawVehicleDetails (const Vehicle *v, int left, int right, int y, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
| Draw the details for the given vehicle at the position of the Details windows.

## Data Fields

TrainDetailsWindowTabs | tab
| For train vehicles: which tab is displayed.

## Detailed Description

Class for managing the vehicle details window.

Definition at line 1385 of file vehicle_gui.cpp.

## Member Function Documentation

static void VehicleDetailsWindow::DrawVehicleDetails | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | int | vscroll_pos,
|  | uint | vscroll_cap,
|  | TrainDetailsWindowTabs | det_tab |
| ) |  |  | `[inline, static]`

Draw the details for the given vehicle at the position of the Details windows.

Parameters:

  | v | current vehicle
  | left | The left most coordinate to draw
  | right | The right most coordinate to draw
  | y | The y coordinate
  | vscroll_pos | Position of scrollbar (train only)
  | vscroll_cap | Number of lines currently displayed (train only)
  | det_tab | Selected details tab (train only)

Definition at line 1492 of file vehicle_gui.cpp.

References DrawAircraftDetails(), DrawRoadVehDetails(), DrawShipDetails(), DrawTrainDetails(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Train, VEH_TRAIN >::From(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by DrawWidget().

virtual void VehicleDetailsWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[inline, virtual]`

Draw the contents of a nested widget.

Parameters:

  | r | Rectangle occupied by the widget.
  | widget | Number of the widget to draw.

Note:
  This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 1508 of file vehicle_gui.cpp.

References _dynlang, _settings_game, DAYS_IN_LEAP_YEAR, DIR_E, DIR_W, DrawString(), DrawVehicleDetails(), DrawVehicleImage(), FONT_HEIGHT_NORMAL, SpecializedVehicle< Train, VEH_TRAIN >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), Vehicle::GetDisplayMaxSpeed(), Vehicle::GetDisplayProfitLastYear(), Vehicle::GetDisplayProfitThisYear(), Vehicle::GetDisplayRunningCost(), Vehicle::GetImage(), GetRailTypeInfo(), INVALID_VEHICLE, SetDParam(), ST_NORMAL, tab, TD_RTL, DynamicLanguages::text_dir, ToPercent16(), VehicleSettings::train_acceleration_model, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, GameSettings::vehicle, Window::vscroll, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, WD_MATRIX_TOP, and Window::width.

static bool VehicleDetailsWindow::IsVehicleServiceIntervalEnabled | ( | const VehicleType | vehicle_type,
|  | CompanyID | company_id |
| ) |  |  | `[inline, static]`

Checks whether service interval is enabled for the vehicle.

Definition at line 1469 of file vehicle_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), VehicleDefaultSettings::servint_aircraft, VehicleDefaultSettings::servint_roadveh, VehicleDefaultSettings::servint_ships, VehicleDefaultSettings::servint_trains, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by OnPaint().

virtual void VehicleDetailsWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count |
| ) |  |  | `[inline, virtual]`

A click with the left mouse button has been made on the window.

Parameters:

  | pt | the point inside the window that has been clicked.
  | widget | the clicked widget.
  | click_count | Number of fast consecutive clicks at same position

Reimplemented from Window.

Definition at line 1610 of file vehicle_gui.cpp.

References _ctrl_pressed, CMD_CHANGE_SERVICE_INT, CMD_MSG, CS_ALPHANUMERAL, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetServiceIntervalClamped(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, MAX_LENGTH_VEHICLE_NAME_BYTES, MAX_LENGTH_VEHICLE_NAME_PIXELS, QSF_ENABLE_DEFAULT, Window::SetDirty(), SetDParam(), Window::SetWidgetsDisabledState(), ShowQueryString(), tab, Vehicle::tile, BaseVehicle::type, and WIDGET_LIST_END.

virtual void VehicleDetailsWindow::OnPaint | ( |  | ) | `[inline, virtual]`

Repaint vehicle details window.

Reimplemented from Window.

Definition at line 1590 of file vehicle_gui.cpp.

References Window::DisableWidget(), Window::DrawWidgets(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetTrainDetailsWndVScroll(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsVehicleServiceIntervalEnabled(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), tab, BaseVehicle::type, VEH_TRAIN, Window::vscroll, and WIDGET_LIST_END.

virtual void VehicleDetailsWindow::OnQueryTextFinished | ( | char * | str | ) | `[inline, virtual]`

The query window opened from this window has closed.

Parameters:

  | str | the new value of the string, NULL if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str).

Reimplemented from Window.

Definition at line 1650 of file vehicle_gui.cpp.

References CMD_MSG, CMD_RENAME_VEHICLE, DoCommandP(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get().

virtual void VehicleDetailsWindow::OnResize | ( |  | ) | `[inline, virtual]`

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented from Window.

Definition at line 1657 of file vehicle_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, Scrollbar::SetCapacityFromWidget(), Window::vscroll, and NWidgetCore::widget_data.

virtual void VehicleDetailsWindow::SetStringParameters | ( | int | widget | ) | const`[inline, virtual]`

Initialize string parameters for a widget.

Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

Definition at line 1503 of file vehicle_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), and SetDParam().

virtual void VehicleDetailsWindow::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize |
| ) |  |  | `[inline, virtual]`

Update size and resize step of a widget in the window.

After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.

Parameters:

  | widget | Widget number.
  | size | Size of the widget.
  | padding | Recommended amount of space between the widget content and the widget edge.
  | fill | Fill step of the widget.
  | resize | Resize step of the widget.

Reimplemented from Window.

Definition at line 1401 of file vehicle_gui.cpp.

References DAYS_IN_YEAR, FONT_HEIGHT_NORMAL, SpecializedVehicle< RoadVehicle, VEH_ROAD >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetStringBoundingBox(), lengthof, max(), MAX_YEAR, maxdim(), Vehicle::Next(), SetDParam(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_BOTTOM, WD_MATRIX_TOP, and Window::width.

The documentation for this struct was generated from the following file:

- src/vehicle_gui.cpp