# ReplaceVehicleWindow Class Reference

Window for the autoreplacing of vehicles. More...

Inheritance diagram for ReplaceVehicleWindow:

## Public Member Functions

| ReplaceVehicleWindow (const WindowDesc *desc, VehicleType vehicletype, GroupID id_g)
virtual void | OnPaint ()
| This window is currently being repainted.
virtual void | OnClick (Point pt, int widget)
| A click with the left mouse button has been made on the window.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnResize (Point new_size, Point delta)
| Called when the window got resized.
virtual void | OnInvalidateData (int data)
| Some data on this window has become invalid.

## Private Member Functions

bool | GenerateReplaceRailList (EngineID e, bool draw_left, bool show_engines)
| Figure out if an engine should be added to a list.
void | GenerateReplaceVehList (Window *w, bool draw_left)
| Generate a list.
void | GenerateLists ()
| Generate the lists.

## Private Attributes

byte | sel_index [2]
EngineID | sel_engine [2]
uint16 | count [2]
bool | wagon_btnstate
| true means engine is selected
GUIEngineList | list [2]
bool | update_left
bool | update_right
bool | init_lists
GroupID | sel_group

## Static Private Attributes

static RailType | sel_railtype = RAILTYPE_RAIL

## Detailed Description

Window for the autoreplacing of vehicles.

Definition at line 89 of file autoreplace_gui.cpp.

## Member Function Documentation

bool ReplaceVehicleWindow::GenerateReplaceRailList | ( | EngineID | e,
|  | bool | draw_left,
|  | bool | show_engines |
| ) |  |  | `[inline, private]`

Figure out if an engine should be added to a list.

Parameters:

  | e | The EngineID
  | draw_left | If true, then the left list is drawn (the engines specific to the railtype you selected)
  | show_engines | if truem then locomotives are drawn, else wagons (never both)

Returns:
  true if the engine should be in the list (based on this check)

Definition at line 107 of file autoreplace_gui.cpp.

References RAILVEH_WAGON.

Referenced by GenerateReplaceVehList().

void ReplaceVehicleWindow::GenerateReplaceVehList | ( | Window * | w,
|  | bool | draw_left |
| ) |  |  | `[inline, private]`

Generate a list.

Parameters:

  | w | Window, that contains the list
  | draw_left | true if generating the left list, otherwise false

Definition at line 126 of file autoreplace_gui.cpp.

References CheckAutoreplaceValidity(), EngineReplacementForCompany(), EngList_Sort(), GenerateReplaceRailList(), GetGroupNumEngines(), wagon_btnstate, and Window::window_number.

Referenced by GenerateLists().

virtual void ReplaceVehicleWindow::OnClick | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[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.

Reimplemented from Window.

Definition at line 335 of file autoreplace_gui.cpp.

References CMD_SET_AUTOREPLACE, DoCommandP(), GetRailTypeInfo(), HasBit(), RailtypeInfo::label, RAILTYPE_BEGIN, RAILTYPE_END, RailtypeInfo::replace_text, Window::resize, Window::SetDirty(), ShowDropDownList(), ResizeInfo::step_height, RailtypeInfo::strings, wagon_btnstate, and Point::y.

virtual void ReplaceVehicleWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 399 of file autoreplace_gui.cpp.

References Scrollbar::pos, Window::SetDirty(), Window::vscroll, and Window::vscroll2.

virtual void ReplaceVehicleWindow::OnResize | ( | Point | new_size,
|  | Point | delta |
| ) |  |  | `[inline, virtual]`

Called when the window got resized.

Parameters:

  | new_size | the new size of the window.
  | delta | the amount of which the window size changed.

Reimplemented from Window.

Definition at line 414 of file autoreplace_gui.cpp.

References Scrollbar::cap, Widget::data, Widget::left, Window::resize, ResizeButtons(), Widget::right, ResizeInfo::step_height, Window::vscroll, Window::vscroll2, Point::x, and Point::y.

virtual void ReplaceVehicleWindow::OnInvalidateData | ( | int | data | ) | `[inline, virtual]`

Some data on this window has become invalid.

Parameters:

  | data | information about the changed data.

Reimplemented from Window.

Definition at line 438 of file autoreplace_gui.cpp.

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

- src/autoreplace_gui.cpp