Data Structures | Public Types | Public Member Functions | Data Fields

# DepotWindow Struct Reference

Inheritance diagram for DepotWindow:

## Data Structures
struct | GetDepotVehiclePtData
## Public Types
enum | DepotGUIAction { MODE_ERROR, MODE_DRAG_VEHICLE, MODE_SHOW_VEHICLE, MODE_START_STOP }
## Public Member Functions
| DepotWindow (const WindowDesc *desc, TileIndex tile, VehicleType type)
void | DrawVehicleInDepot (const Vehicle *v, int left, int right, int y) const
| Draw a vehicle in the depot window in the box with the top left corner at x,y.
void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
DepotGUIAction | GetVehicleFromDepotWndPt (int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
void | DepotClick (int x, int y)
| Handle click in the depot matrix.
void | SetupWidgetData (VehicleType type)
| Function to set up vehicle specific widgets (mainly sprites and strings).
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 | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
virtual void | OnPaint ()
| The window must be repainted.
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 bool | OnRightClick (Point pt, int widget)
| A click with the right mouse button has been made on the window.
virtual bool | OnVehicleSelect (const Vehicle *v)
| Clones a vehicle.
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
virtual void | OnMouseDrag (Point pt, int widget)
| An 'object' is being dragged at the provided position, highlight the target if possible.
virtual void | OnDragDrop (Point pt, int widget)
| A dragged 'object' has been released.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnResize ()
| Called after the window got resized.
virtual EventState | OnCTRLStateChange ()
| The state of the control key has changed.
## Data Fields
VehicleID | sel
VehicleID | vehicle_over
| Rail vehicle over which another one is dragged, `INVALID_VEHICLE` if none.
VehicleType | type
bool | generate_list
VehicleList | vehicle_list
VehicleList | wagon_list
uint | num_columns
| Number of columns.
Scrollbar * | hscroll
| Only for trains.
Scrollbar * | vscroll
uint | count_width
uint | header_width
uint | flag_width
uint | flag_height

## Detailed Description

Definition at line 221 of file depot_gui.cpp.

## Member Function Documentation

void DepotWindow::DepotClick | ( | int | x,
|  | int | y |
| ) |  |  | `[inline]`

Handle click in the depot matrix.

Parameters:

  | x | Horizontal position in the matrix widget in pixels.
  | y | Vertical position in the matrix widget in pixels.

Definition at line 483 of file depot_gui.cpp.

References _ctrl_pressed, _current_text_dir, GroundVehicleCache::cached_veh_length, DIR_E, DIR_W, EIT_IN_DEPOT, Vehicle::GetGroundVehicleCache(), Vehicle::GetImage(), GetVehiclePalette(), HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::IsGroundVehicle(), Window::SetDirty(), CursorVars::short_vehicle_offset, ShowVehicleViewWindow(), StartStopVehicle(), VEH_TRAIN, CursorVars::vehchain, and VehicleClicked().

Referenced by OnClick().

void DepotWindow::DrawVehicleInDepot | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y |
| ) |  |  | const`[inline]`

Draw a vehicle in the depot window in the box with the top left corner at x,y.

Parameters:

  | v | Vehicle to draw.
  | left | Left side of the box to draw in.
  | right | Right side of the box to draw in.
  | y | Top of the box to draw in.

Definition at line 270 of file depot_gui.cpp.

References _current_text_dir, Vehicle::age, GroundVehicleCache::cached_total_length, CeilDiv(), DAYS_IN_LEAP_YEAR, DIR_W, DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawSprite(), DrawString(), DrawTrainImage(), EIT_IN_DEPOT, FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL, SpecializedVehicle< Train, Type >::From(), GroundVehicle< T, Type >::gcache, Vehicle::GetImage(), Scrollbar::GetPosition(), GetVehicleHeight(), Sprite::height, hscroll, GroundVehicle< T, Type >::IsFreeWagon(), Vehicle::IsGroundVehicle(), max(), Vehicle::max_age, Window::resize, SA_RIGHT, SetDParam(), ResizeInfo::step_height, TILE_SIZE, BaseVehicle::type, Vehicle::unitnumber, UnScaleByZoom(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, vehicle_over, Vehicle::vehstatus, VS_STOPPED, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, Sprite::y_offs, and ZOOM_LVL_GUI.

Referenced by DrawWidget().

void DepotWindow::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 330 of file depot_gui.cpp.

References _current_text_dir, DrawVehicleInDepot(), GB(), Scrollbar::GetPosition(), SmallVector< T, S >::Length(), MAT_COL_BITS, MAT_COL_START, MAT_ROW_BITS, MAT_ROW_START, min(), Window::resize, ResizeInfo::step_height, ResizeInfo::step_width, and WID_D_MATRIX.

virtual void DepotWindow::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 695 of file depot_gui.cpp.

References _ctrl_pressed, CMD_DEPOT_MASS_AUTOREPLACE, CS_ALPHANUMERAL, DepotClick(), DoCommandP(), GetDepotIndex(), GetStationIndex(), GetTileOwner(), HT_VEHICLE, Window::IsWidgetLowered(), SmallVector< T, S >::Length(), MAX_LENGTH_DEPOT_NAME_CHARS, Window::owner, VehicleListIdentifier::Pack(), NWidgetBase::pos_x, NWidgetBase::pos_y, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, ScrollMainWindowToTile(), SetDParam(), Window::SetWidgetDirty(), ShowExtraViewPortWindow(), ShowQuery(), ShowQueryString(), Window::ToggleWidgetLoweredState(), VEH_AIRCRAFT, WID_D_AUTOREPLACE, WID_D_BUILD, WID_D_CLONE, WID_D_LOCATION, WID_D_MATRIX, WID_D_RENAME, WID_D_SELL_ALL, WID_D_START_ALL, WID_D_STOP_ALL, WID_D_VEHICLE_LIST, and Window::window_number.

virtual EventState DepotWindow::OnCTRLStateChange | ( |  | ) | `[inline, virtual]`

The state of the control key has changed.

Returns:
  ES_HANDLED if the change has been handled and no other window should receive the event.

Reimplemented from Window.

Definition at line 981 of file depot_gui.cpp.

References _ctrl_pressed, INVALID_VEHICLE, Window::SetWidgetDirty(), CursorVars::vehchain, and WID_D_MATRIX.

virtual void DepotWindow::OnDragDrop | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[inline, virtual]`

A dragged 'object' has been released.

Parameters:

  | pt | the point inside the window where the release took place.
  | widget | the widget where the release took place.

Reimplemented from Window.

Definition at line 903 of file depot_gui.cpp.

References _ctrl_pressed, CMD_MSG, CMD_REVERSE_TRAIN_DIRECTION, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Window::HandleButtonClick(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::IsFrontEngine(), Window::IsWidgetDisabled(), MAKE_ORDER_BACKUP_FLAG, NWidgetBase::pos_x, NWidgetBase::pos_y, Window::SetDirty(), ShowVehicleViewWindow(), Vehicle::tile, BaseVehicle::type, VEH_TRAIN, CursorVars::vehchain, vehicle_over, WID_D_MATRIX, WID_D_SELL, and WID_D_SELL_CHAIN.

virtual void DepotWindow::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 646 of file depot_gui.cpp.

virtual void DepotWindow::OnMouseDrag | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[inline, virtual]`

An 'object' is being dragged at the provided position, highlight the target if possible.

Parameters:

  | pt | The point inside the window that the mouse hovers over.
  | widget | The widget the mouse hovers over.

Reimplemented from Window.

Definition at line 863 of file depot_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::Last(), NWidgetBase::pos_x, NWidgetBase::pos_y, Vehicle::Previous(), Window::SetWidgetDirty(), VEH_TRAIN, vehicle_over, and WID_D_MATRIX.

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

The window must be repainted.

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

Reimplemented from Window.

Definition at line 651 of file depot_gui.cpp.

References _local_company, BuildDepotVehicleList(), CeilDiv(), Window::DrawWidgets(), SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), hscroll, IsTileOwner(), SmallVector< T, S >::Length(), max(), SpecializedVehicle< T, Type >::Next(), num_columns, Scrollbar::SetCount(), Window::SetWidgetsDisabledState(), VEH_TRAIN, WID_D_AUTOREPLACE, WID_D_BUILD, WID_D_CLONE, WID_D_RENAME, WID_D_SELL, WID_D_SELL_ALL, WID_D_SELL_CHAIN, WID_D_START_ALL, WID_D_STOP_ALL, WIDGET_LIST_END, Window::width, and Window::window_number.

virtual void DepotWindow::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 774 of file depot_gui.cpp.

References CMD_MSG, CMD_RENAME_DEPOT, DoCommandP(), GetDepotIndex(), and Window::window_number.

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

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 968 of file depot_gui.cpp.

References NWidgetBase::current_x, Scrollbar::GetCapacity(), hscroll, MAT_COL_START, num_columns, NWidgetBase::resize_x, Scrollbar::SetCapacity(), Scrollbar::SetCapacityFromWidget(), VEH_TRAIN, WID_D_MATRIX, and NWidgetCore::widget_data.

virtual bool DepotWindow::OnRightClick | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[inline, virtual]`

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

Parameters:

  | pt | the point inside the window that has been clicked.
  | widget | the clicked widget.

Returns:
  true if the click was actually handled, i.e. do not show a tooltip if tooltip-on-right-click is enabled.

Reimplemented from Window.

Definition at line 782 of file depot_gui.cpp.

References _ctrl_pressed, Vehicle::engine_type, GuiShowTooltips(), lastof, Vehicle::Next(), NUM_CARGO, NWidgetBase::pos_x, NWidgetBase::pos_y, SetDParam(), VEH_TRAIN, and WID_D_MATRIX.

virtual bool DepotWindow::OnVehicleSelect | ( | const Vehicle * | v | ) | `[inline, virtual]`

Clones a vehicle.

Parameters:

  | v | the original vehicle to clone

Returns:
  Always true.

Definition at line 843 of file depot_gui.cpp.

References _ctrl_pressed, CcCloneVehicle(), CMD_CLONE_VEHICLE, CMD_MSG, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, and Window::window_number.

void DepotWindow::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 366 of file depot_gui.cpp.

References GetDepotIndex(), GetStationIndex(), SetDParam(), VEH_AIRCRAFT, WID_D_CAPTION, and Window::window_number.

void DepotWindow::SetupWidgetData | ( | VehicleType | type | ) | `[inline]`

Function to set up vehicle specific widgets (mainly sprites and strings).

Only use this function to if the widget is used for several vehicle types and each has different text/sprites. If the widget is only used for a single vehicle type, or the same text/sprites are used every time, use the nested widget array to initialize the widget.

Definition at line 535 of file depot_gui.cpp.

References SetDataTip(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

virtual void DepotWindow::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 596 of file depot_gui.cpp.

References EIT_IN_DEPOT, VehicleCellSize::extend_left, VehicleCellSize::extend_right, FONT_HEIGHT_NORMAL, GetDigitWidth(), GetStringBoundingBox(), GetVehicleImageCellSize(), VehicleCellSize::height, Sprite::height, SetDParam(), SetDParamMaxValue(), ST_NORMAL, UnScaleByZoom(), VEH_ROAD, VEH_TRAIN, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_MATRIX_TOP, WD_PAR_VSEP_NORMAL, WID_D_MATRIX, Sprite::width, and ZOOM_LVL_GUI.

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

- src/depot_gui.cpp