Class for managing the vehicle details window. More...
Public Member Functions | |
VehicleDetailsWindow (const WindowDesc *desc, WindowNumber window_number) | |
Initialize a newly created vehicle details window. | |
virtual void | OnInvalidateData (int data) |
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 | 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 |
Class for managing the vehicle details window.
Definition at line 1743 of file vehicle_gui.cpp.
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.
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 1879 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.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 1895 of file vehicle_gui.cpp.
References _current_text_dir, _settings_game, Vehicle::age, GroundVehicleCache::cached_max_te, GroundVehicleCache::cached_power, GroundVehicleCache::cached_weight, DAYS_IN_LEAP_YEAR, DIR_E, DIR_W, DrawString(), DrawVehicleDetails(), DrawVehicleImage(), FONT_HEIGHT_NORMAL, SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::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::GetGroundVehicleCache(), Vehicle::GetImage(), GetRailTypeInfo(), GroundVehicle< T, Type >::HasArticulatedPart(), INVALID_VEHICLE, Vehicle::max_age, Vehicle::owner, Vehicle::reliability, VehicleSettings::roadveh_acceleration_model, SetDParam(), ST_NORMAL, tab, TD_RTL, ToPercent16(), VehicleSettings::train_acceleration_model, BaseVehicle::type, VEH_ROAD, VEH_TRAIN, GameSettings::vehicle, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, WD_MATRIX_TOP, and Window::width.
uint VehicleDetailsWindow::GetRoadVehDetailsHeight | ( | const Vehicle * | v | ) | [inline] |
Gets the desired height for the road vehicle details panel.
v | Road vehicle being shown. |
Definition at line 1780 of file vehicle_gui.cpp.
References Vehicle::cargo_cap, FONT_HEIGHT_NORMAL, SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< T, Type >::Next(), WD_FRAMERECT_BOTTOM, 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 1856 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.
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 2003 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_CHARS, MAX_LENGTH_VEHICLE_NAME_PIXELS, Vehicle::owner, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, Window::SetDirty(), SetDParam(), Window::SetWidgetsDisabledState(), ShowQueryString(), tab, Vehicle::tile, BaseVehicle::type, and WIDGET_LIST_END.
virtual void VehicleDetailsWindow::OnInvalidateData | ( | int | data | ) | [inline, virtual] |
Some data on this window has become invalid.
data | information about the changed data. |
Reimplemented from Window.
Definition at line 1762 of file vehicle_gui.cpp.
References NWidgetBase::current_y, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetRoadVehDetailsHeight(), Window::ReInit(), BaseVehicle::type, and VEH_ROAD.
virtual void VehicleDetailsWindow::OnPaint | ( | ) | [inline, virtual] |
Repaint vehicle details window.
Reimplemented from Window.
Definition at line 1983 of file vehicle_gui.cpp.
References _local_company, 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(), Vehicle::owner, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), tab, BaseVehicle::type, VEH_TRAIN, and WIDGET_LIST_END.
virtual void VehicleDetailsWindow::OnQueryTextFinished | ( | char * | str | ) | [inline, virtual] |
The query window opened from this window has closed.
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 2045 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 2052 of file vehicle_gui.cpp.
References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, Scrollbar::SetCapacityFromWidget(), 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.
widget | Widget number. |
Reimplemented from Window.
Definition at line 1890 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.
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 1796 of file vehicle_gui.cpp.
References DAYS_IN_YEAR, FONT_HEIGHT_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetRoadVehDetailsHeight(), GetStringBoundingBox(), lengthof, max(), MAX_YEAR, maxdim(), 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.