Public Member Functions | Static Public Member Functions | Data Fields

# 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 | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
uint | GetRoadVehDetailsHeight (const Vehicle *v)
| Gets the desired height for the road vehicle details panel.
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 | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
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.
Scrollbar * | vscroll

## Detailed Description

Class for managing the vehicle details window.

Definition at line 1833 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 1990 of file vehicle_gui.cpp.

References DrawAircraftDetails(), DrawRoadVehDetails(), DrawShipDetails(), DrawTrainDetails(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Train, Type >::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 2006 of file vehicle_gui.cpp.

References _current_text_dir, _settings_game, Vehicle::age, Vehicle::breakdowns_since_last_service, GroundVehicleCache::cached_max_te, GroundVehicleCache::cached_power, GroundVehicleCache::cached_weight, Vehicle::date_of_last_service, DAYS_IN_LEAP_YEAR, DIR_E, DIR_W, DrawString(), DrawVehicleDetails(), DrawVehicleImage(), EIT_IN_DETAILS, FONT_HEIGHT_NORMAL, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), Vehicle::GetDisplayMaxSpeed(), Vehicle::GetDisplayProfitLastYear(), Vehicle::GetDisplayProfitThisYear(), Vehicle::GetDisplayRunningCost(), Vehicle::GetGroundVehicleCache(), Vehicle::GetImage(), GetRailTypeInfo(), Aircraft::GetRange(), Vehicle::HasArticulatedPart(), INVALID_VEHICLE, Vehicle::max_age, Vehicle::reliability, VehicleSettings::roadveh_acceleration_model, SetDParam(), tab, ToPercent16(), VehicleSettings::train_acceleration_model, BaseVehicle::type, UnScaleByZoom(), VEH_AIRCRAFT, VEH_ROAD, VEH_TRAIN, GameSettings::vehicle, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, WD_MATRIX_TOP, WID_VD_MATRIX, WID_VD_MIDDLE_DETAILS, WID_VD_SERVICING_INTERVAL, WID_VD_TOP_DETAILS, Window::width, and ZOOM_LVL_GUI.

uint VehicleDetailsWindow::GetRoadVehDetailsHeight | ( | const Vehicle * | v | ) | `[inline]`

Gets the desired height for the road vehicle details panel.

Parameters:

  | v | Road vehicle being shown.

Returns:
  Desired height in pixels.

Definition at line 1881 of file vehicle_gui.cpp.

References Vehicle::cargo_cap, FONT_HEIGHT_NORMAL, Vehicle::HasArticulatedPart(), SpecializedVehicle< T, Type >::Next(), and WD_FRAMERECT_TOP.

Referenced by OnInvalidateData(), and UpdateWidgetSize().

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 1967 of file vehicle_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, 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 2124 of file vehicle_gui.cpp.

References _ctrl_pressed, CMD_CHANGE_SERVICE_INT, CMD_MSG, CS_ALPHANUMERAL, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetServiceIntervalClamped(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, MAX_LENGTH_VEHICLE_NAME_CHARS, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, Window::SetDirty(), SetDParam(), Window::SetWidgetsDisabledState(), ShowDropDownMenu(), ShowQueryString(), tab, Vehicle::tile, BaseVehicle::type, WID_VD_DECREASE_SERVICING_INTERVAL, WID_VD_DETAILS_CAPACITY_OF_EACH, WID_VD_DETAILS_CARGO_CARRIED, WID_VD_DETAILS_TOTAL_CARGO, WID_VD_DETAILS_TRAIN_VEHICLES, WID_VD_INCREASE_SERVICING_INTERVAL, WID_VD_RENAME_VEHICLE, WID_VD_SERVICE_INTERVAL_DROPDOWN, and WIDGET_LIST_END.

virtual void VehicleDetailsWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 2172 of file vehicle_gui.cpp.

References CMD_CHANGE_SERVICE_INT, CMD_MSG, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetServiceIntervalClamped(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::owner, Vehicle::tile, and WID_VD_SERVICE_INTERVAL_DROPDOWN.

virtual void VehicleDetailsWindow::OnInvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true` |
| ) |  |  | `[inline, virtual]`

Some data on this window has become invalid.

Parameters:

  | data | Information about the changed data.
  | gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Reimplemented from Window.

Definition at line 1857 of file vehicle_gui.cpp.

References NWidgetBase::current_y, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetRoadVehDetailsHeight(), Window::ReInit(), BaseVehicle::type, VEH_ROAD, and VIWD_AUTOREPLACE.

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

Repaint vehicle details window.

Reimplemented from Window.

Definition at line 2099 of file vehicle_gui.cpp.

References _local_company, Window::DisableWidget(), Window::DrawWidgets(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetTrainDetailsWndVScroll(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsVehicleServiceIntervalEnabled(), Vehicle::owner, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), tab, BaseVehicle::type, VEH_TRAIN, WID_VD_DECREASE_SERVICING_INTERVAL, WID_VD_DETAILS_CARGO_CARRIED, WID_VD_INCREASE_SERVICING_INTERVAL, WID_VD_RENAME_VEHICLE, 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 2186 of file vehicle_gui.cpp.

References CMD_MSG, CMD_RENAME_VEHICLE, DoCommandP(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, 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 2193 of file vehicle_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacityFromWidget(), WID_VD_MATRIX, 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 2001 of file vehicle_gui.cpp.

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

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 1897 of file vehicle_gui.cpp.

References DAYS_IN_YEAR, FONT_HEIGHT_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetRoadVehDetailsHeight(), GetStringBoundingBox(), INVALID_STRING_ID, lengthof, max(), MAX_YEAR, maxdim(), SetDParam(), SetDParamMaxValue(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, WD_DROPDOWNTEXT_TOP, WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_MATRIX_TOP, WID_VD_MATRIX, WID_VD_MIDDLE_DETAILS, WID_VD_SERVICE_INTERVAL_DROPDOWN, WID_VD_SERVICING_INTERVAL, WID_VD_TOP_DETAILS, and Window::width.

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

- src/vehicle_gui.cpp