VehicleDetailsWindow Struct Reference

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

Inheritance diagram for VehicleDetailsWindow:
Window ZeroedMemoryAllocator

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

Detailed Description

Class for managing the vehicle details window.

Definition at line 1777 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 1924 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 1940 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(), FONT_HEIGHT_NORMAL, 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(), Vehicle::HasArticulatedPart(), INVALID_VEHICLE, Vehicle::max_age, Vehicle::owner, Vehicle::reliability, VehicleSettings::roadveh_acceleration_model, Vehicle::service_interval, 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.

Parameters:
v Road vehicle being shown.
Returns:
Desired height in pixels.

Definition at line 1825 of file vehicle_gui.cpp.

References Vehicle::cargo_cap, FONT_HEIGHT_NORMAL, Vehicle::HasArticulatedPart(), 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]
virtual void VehicleDetailsWindow::OnClick ( Point  pt,
int  widget,
int  click_count 
) [inline, virtual]
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 1801 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]
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 2090 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 2097 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.

Parameters:
widget Widget number.

Reimplemented from Window.

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


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

Generated on Thu Apr 14 00:49:42 2011 for OpenTTD by  doxygen 1.6.1