Public Member Functions | Data Fields

RefitWindow Struct Reference

Refit cargo window. More...

Inheritance diagram for RefitWindow:
Window ZeroedMemoryAllocator

Public Member Functions

void BuildRefitList ()
 Collects all (cargo, subcargo) refit options of a vehicle chain.
RefitOptionGetRefitOption ()
 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.
RefitOptioncargo
 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 cargos in the information panel.
Scrollbarvscroll
 The main scrollbar.
Scrollbarhscroll
 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 373 of file vehicle_gui.cpp.


Member Function Documentation

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 607 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 486 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]
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 875 of file vehicle_gui.cpp.

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

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

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

virtual void RefitWindow::OnInvalidateData ( int  data = 0,
bool  gui_scope = true 
) [inline, virtual]
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 862 of file vehicle_gui.cpp.

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

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 557 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]
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 596 of file vehicle_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), SetDParam(), 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 578 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, and Window::window_number.


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