# VehicleGroupWindow Class Reference

Inheritance diagram for VehicleGroupWindow:

## Public Member Functions
| VehicleGroupWindow (const WindowDesc *desc, WindowNumber window_number)
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)
| Some data on this window has become invalid.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
virtual void | OnPaint ()
| The window must be repainted.
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
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 | OnDragDrop (Point pt, int widget)
| A dragged 'object' has been released.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
virtual void | OnResize ()
| Called after the window got resized.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnTick ()
| Called once per (game) tick.
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
void | ShowRenameGroupWindow (GroupID group, bool empty)
void | UnselectVehicle (VehicleID vehicle)
| Tests whether a given vehicle is selected in the window, and unselects it if necessary.
## Private Member Functions
void | BuildGroupList (Owner owner)
| (Re)Build the group list.
## Static Private Member Functions
static int CDECL | GroupNameSorter (const Group *const *a, const Group *const *b)
| Sort the groups by their name.
## Private Attributes
GroupID | group_sel
| Selected group.
VehicleID | vehicle_sel
| Selected vehicle.
GroupID | group_rename
| Group being renamed, INVALID_GROUP if none.
GUIGroupList | groups
| List of groups.
uint | tiny_step_height
| Step height for the group list.

## Detailed Description

Definition at line 144 of file group_gui.cpp.

## Member Function Documentation

void VehicleGroupWindow::BuildGroupList | ( | Owner | owner | ) | `[inline, private]`

(Re)Build the group list.

Parameters:

  | owner | The owner of the window

Definition at line 157 of file group_gui.cpp.

References SmallVector< T, S >::Append(), SmallVector< T, S >::Clear(), SmallVector< T, S >::Compact(), groups, GUIList< T, F >::NeedRebuild(), Group::owner, GUIList< T, F >::RebuildDone(), and Group::vehicle_type.

Referenced by OnPaint().

virtual void VehicleGroupWindow::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 393 of file group_gui.cpp.

References Window::DrawSortButtonState(), DrawString(), BaseVehicleListWindow::DrawVehicleListItems(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), group_sel, groups, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsAllGroupID(), GUIList< T, F >::IsDescSortOrder(), SmallVector< T, S >::Length(), max(), min(), Group::num_vehicle, Group::owner, Window::resize, SA_RIGHT, SBS_DOWN, SBS_UP, SetDParam(), ResizeInfo::step_height, tiny_step_height, vehicle_sel, BaseVehicleListWindow::vehicles, Window::vscroll2, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

virtual void VehicleGroupWindow::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 437 of file group_gui.cpp.

References CcCreateGroup(), CMD_CREATE_GROUP, CMD_DELETE_GROUP, CMD_MASS_START_STOP, CMD_MSG, CMD_SET_GROUP_REPLACE_PROTECTION, DEFAULT_GROUP, DIR_W, DoCommandP(), GUIList< T, F >::ForceRebuild(), Scrollbar::GetCapacity(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), Vehicle::GetImage(), Scrollbar::GetPosition(), GetVehiclePalette(), group_sel, groups, HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, IsAllGroupID(), SmallVector< T, S >::Length(), Group::replace_protection, Window::resize, Window::SetDirty(), ShowDropDownMenu(), ShowGroupActionDropdown(), GUIList< T, F >::SortType(), ResizeInfo::step_height, tiny_step_height, GUIList< T, F >::ToggleSortOrder(), VEH_ROAD, VEH_TRAIN, CursorVars::vehchain, vehicle_sel, BaseVehicleListWindow::vehicle_type, BaseVehicleListWindow::vehicles, Window::vscroll, and Window::vscroll2.

virtual void VehicleGroupWindow::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 545 of file group_gui.cpp.

References CMD_ADD_VEHICLE_GROUP, CMD_MSG, DEFAULT_GROUP, DoCommandP(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), groups, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, SmallVector< T, S >::Length(), Window::resize, Window::SetDirty(), ShowVehicleViewWindow(), ResizeInfo::step_height, tiny_step_height, CursorVars::vehchain, vehicle_sel, BaseVehicleListWindow::vehicles, Window::vscroll, and Window::vscroll2.

virtual void VehicleGroupWindow::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 616 of file group_gui.cpp.

References CMD_ADD_SHARED_VEHICLE_GROUP, CMD_MSG, CMD_REMOVE_ALL_VEHICLES_GROUP, DEPOT_MASS_SEND, DEPOT_SERVICE, DoCommandP(), group_sel, IsAllGroupID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), SmallVector< T, S >::Length(), Window::SetDirty(), GUIList< T, F >::SetSortType(), BaseVehicleListWindow::vehicle_type, and BaseVehicleListWindow::vehicles.

virtual void VehicleGroupWindow::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 287 of file group_gui.cpp.

References DeleteWindowByClass(), GUIList< T, F >::ForceRebuild(), GUIList< T, F >::ForceResort(), group_rename, group_sel, groups, HideDropDownMenu(), IsAllGroupID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), Window::SetDirty(), and BaseVehicleListWindow::vehicles.

virtual void VehicleGroupWindow::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 336 of file group_gui.cpp.

References BuildGroupList(), Window::DrawWidgets(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), group_sel, GroupNameSorter(), groups, HideDropDownMenu(), IsAllGroupID(), Window::IsWidgetLowered(), SmallVector< T, S >::Length(), Window::RaiseWidget(), Scrollbar::SetCount(), Window::SetWidgetsDisabledState(), GUIList< T, F >::Sort(), GUIList< T, F >::SortType(), BaseVehicleListWindow::vehicle_type, BaseVehicleListWindow::vehicles, Window::vscroll, Window::vscroll2, and WIDGET_LIST_END.

virtual void VehicleGroupWindow::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 599 of file group_gui.cpp.

References CMD_MSG, CMD_RENAME_GROUP, DoCommandP(), and group_rename.

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

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 605 of file group_gui.cpp.

References NWidgetBase::current_y, Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, Scrollbar::SetCapacity(), Scrollbar::SetCapacityFromWidget(), Window::vscroll, Window::vscroll2, and NWidgetCore::widget_data.

virtual void VehicleGroupWindow::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 309 of file group_gui.cpp.

References GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), group_sel, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsAllGroupID(), SmallVector< T, S >::Length(), Group::num_vehicle, SetDParam(), BaseVehicleListWindow::vehicle_type, and BaseVehicleListWindow::vehicles.

void VehicleGroupWindow::UnselectVehicle | ( | VehicleID | vehicle | ) | `[inline]`

Tests whether a given vehicle is selected in the window, and unselects it if necessary.

Called when the vehicle is deleted.

Parameters:

  | vehicle | Vehicle that is going to be deleted

Definition at line 692 of file group_gui.cpp.

References vehicle_sel.

Referenced by DeleteGroupHighlightOfVehicle().

virtual void VehicleGroupWindow::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 244 of file group_gui.cpp.

References endof, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), GetVehicleListHeight(), max(), maxdim(), tiny_step_height, BaseVehicleListWindow::vehicle_type, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_MATRIX_TOP, WD_SORTBUTTON_ARROW_WIDTH, and Window::width.

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

- src/group_gui.cpp