Public Member Functions | Data Fields

# RefitWindow Struct Reference

Refit cargo window. More...

Inheritance diagram for RefitWindow:

## Public Member Functions
void | BuildRefitList ()
| Collects all (cargo, subcargo) refit options of a vehicle chain.
RefitOption * | GetRefitOption ()
| Gets the RefitOption placed in the selected index.
| RefitWindow (const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit)
virtual void | OnInit ()
| Notification that the nested widget tree gets initialized.
virtual void | OnPaint ()
| The window must be repainted.
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.
StringID | GetCapacityString (RefitOption *option) const
| Gets the StringID to use for displaying capacity.
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
virtual void | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
int | GetClickPosition (int click_x)
void | SetSelectedVehicles (int drag_x)
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 | 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 | OnResize ()
| Called after the window got resized.
## Data Fields
int | sel
| Index in refit options, `-1` if nothing is selected.
RefitOption * | cargo
| Refit option selected by sel.
SubtypeList | list [NUM_CARGO]
| List of refit subtypes available for each sorted cargo.
VehicleOrderID | order
| If not INVALID_VEH_ORDER_ID, selection is part of a refit order (rather than execute directly).
uint | information_width
| Width required for correctly displaying all cargoes in the information panel.
Scrollbar * | vscroll
| The main scrollbar.
Scrollbar * | hscroll
| Only used for long vehicles.
int | vehicle_width
| Width of the vehicle being drawn.
int | sprite_left
| Left position of the vehicle sprite.
int | sprite_right
| Right position of the vehicle sprite.
uint | vehicle_margin
| Margin to use while selecting vehicles when the vehicle image is centered.
int | click_x
| Position of the first click while dragging.
VehicleID | selected_vehicle
| First vehicle in the current selection.
uint8 | num_vehicles
| Number of selected vehicles.
bool | auto_refit
| Select cargo for auto-refitting.

## Detailed Description

Refit cargo window.

Definition at line 357 of file vehicle_gui.cpp.

## Member Function Documentation

virtual void RefitWindow::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 625 of file vehicle_gui.cpp.

References _current_text_dir, cargo, Clamp(), SmallVector< T, S >::Contains(), DrawFrameRect(), DrawStringMultiLine(), DrawVehicleImage(), DrawVehicleRefitWindow(), EIT_IN_DETAILS, FR_BORDERONLY, SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), GetCapacityString(), Scrollbar::GetPosition(), GetVehicleSet(), hscroll, INVALID_STRING_ID, INVALID_VEH_ORDER_ID, INVALID_VEHICLE, Window::left, max(), SpecializedVehicle< T, Type >::Next(), num_vehicles, Window::resize, sel, selected_vehicle, sprite_left, sprite_right, ResizeInfo::step_height, TD_RTL, BaseVehicle::type, VEH_TRAIN, vehicle_margin, vscroll, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WID_VR_INFO, WID_VR_MATRIX, WID_VR_VEHICLE_PANEL_DISPLAY, Window::width, and Window::window_number.

StringID RefitWindow::GetCapacityString | ( | RefitOption * | option | ) | const`[inline]`

Gets the StringID to use for displaying capacity.

Parameters:

  | Cargo | and cargo subtype to check for capacity.

Returns:
  INVALID_STRING_ID if there is no capacity. StringID to use in any other case.

Postcondition:
  String parameters have been set.

Definition at line 591 of file vehicle_gui.cpp.

References _current_company, _local_company, _returned_mail_refit_capacity, _returned_refit_capacity, RefitOption::cargo, DC_QUERY_COST, DoCommand(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), CommandCost::GetCost(), INVALID_STRING_ID, SetDParam(), RefitOption::subtype, Vehicle::tile, BaseVehicle::type, and Window::window_number.

Referenced by DrawWidget(), and OnInvalidateData().

RefitOption* RefitWindow::GetRefitOption | ( |  | ) | `[inline]`

Gets the RefitOption placed in the selected index.

Returns:
  Pointer to the RefitOption currently in use.

Definition at line 470 of file vehicle_gui.cpp.

References SmallVector< T, S >::Length(), and sel.

Referenced by OnInvalidateData().

virtual void RefitWindow::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 814 of file vehicle_gui.cpp.

References _ctrl_pressed, cargo, CMD_ORDER_REFIT, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetScrolledRowFromWidget(), HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEH_ORDER_ID, Window::InvalidateData(), num_vehicles, NWidgetBase::pos_x, sel, selected_vehicle, Window::SetWidgetDirty(), Window::SetWidgetDisabledState(), SPR_CURSOR_MOUSE, Vehicle::tile, vscroll, WID_VR_MATRIX, WID_VR_REFIT, WID_VR_VEHICLE_PANEL_DISPLAY, and Window::window_number.

virtual void RefitWindow::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 870 of file vehicle_gui.cpp.

References INVALID_VEH_ORDER_ID, Window::InvalidateData(), NWidgetBase::pos_x, and WID_VR_VEHICLE_PANEL_DISPLAY.

virtual void RefitWindow::OnInit | ( |  | ) | `[inline, virtual]`

Notification that the nested widget tree gets initialized.

The event can be used to perform general computations.

Note:
  nested_root and/or nested_array (normally accessed via GetWidget()) may not exist during this call.

Reimplemented from Window.

Definition at line 509 of file vehicle_gui.cpp.

References BuildRefitList(), cargo, SmallVector< T, S >::Length(), OnInvalidateData(), Scrollbar::ScrollTowards(), sel, Window::SetWidgetDisabledState(), vscroll, and WID_VR_REFIT.

virtual void RefitWindow::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 707 of file vehicle_gui.cpp.

References BuildRefitList(), cargo, EIT_IN_DETAILS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetCapacityString(), GetRefitOption(), GetStringBoundingBox(), GetVehicleWidth(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, information_width, INVALID_STRING_ID, SmallVector< T, S >::Length(), max(), num_vehicles, Window::ReInit(), selected_vehicle, vehicle_width, and Window::window_number.

Referenced by OnInit().

virtual void RefitWindow::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 857 of file vehicle_gui.cpp.

References INVALID_VEH_ORDER_ID, NWidgetBase::pos_x, Window::SetWidgetDirty(), and WID_VR_VEHICLE_PANEL_DISPLAY.

virtual void RefitWindow::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 541 of file vehicle_gui.cpp.

References _current_text_dir, NWidgetBase::current_x, Window::DrawWidgets(), hscroll, max(), NWidgetBase::pos_x, Scrollbar::SetCount(), sprite_left, sprite_right, TD_RTL, vehicle_margin, and vehicle_width.

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

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 883 of file vehicle_gui.cpp.

References EIT_IN_DETAILS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), GetVehicleWidth(), hscroll, MAT_COL_START, Scrollbar::SetCapacityFromWidget(), vehicle_width, vscroll, WID_VR_MATRIX, WID_VR_VEHICLE_PANEL_DISPLAY, and Window::window_number.

virtual void RefitWindow::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 580 of file vehicle_gui.cpp.

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

virtual void RefitWindow::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 562 of file vehicle_gui.cpp.

References FONT_HEIGHT_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetVehicleHeight(), information_width, WD_FRAMERECT_LEFT, WD_MATRIX_TOP, WID_VR_INFO, WID_VR_MATRIX, WID_VR_VEHICLE_PANEL_DISPLAY, and Window::window_number.

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

- src/vehicle_gui.cpp