Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes

# 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=0, bool gui_scope=true)
| 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.
virtual void | OnMouseDrag (Point pt, int widget)
| An 'object' is being dragged at the provided position, highlight the target if possible.
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 Types
enum | ListColumns { VGC_NAME, VGC_PROTECT, VGC_AUTOREPLACE, VGC_PROFIT, VGC_NUMBER, VGC_END }
## Private Member Functions
void | BuildGroupList (Owner owner)
| (Re)Build the group list.
uint | ComputeGroupInfoSize ()
| Compute tiny_step_height and column_size.
void | DrawGroupInfo (int y, int left, int right, GroupID g_id, bool protection=false) const
| Draw a row in the group list.
void | DirtyHighlightedGroupWidget ()
| Mark the widget containing the currently highlighted group as dirty.
## Static Private Member Functions
static int CDECL | GroupNameSorter (const Group *const *a, const Group *const *b)
| Sort the groups by their name.
## Private Attributes
VehicleID | vehicle_sel
| Selected vehicle.
GroupID | group_rename
| Group being renamed, INVALID_GROUP if none.
GroupID | group_over
| Group over which a vehicle is dragged, INVALID_GROUP if none.
GUIGroupList | groups
| List of groups.
uint | tiny_step_height
| Step height for the group list.
Scrollbar * | group_sb
Dimension | column_size [VGC_END]
| Size of the columns in the group list.

## Detailed Description

Definition at line 93 of file group_gui.cpp.

## Member Enumeration Documentation

enum VehicleGroupWindow::ListColumns`[private]`

Enumerator:

  VGC_NAME | Group name.
  VGC_PROTECT | Autoreplace protect icon.
  VGC_AUTOREPLACE | Autoreplace active icon.
  VGC_PROFIT | Profit icon.
  VGC_NUMBER | Number of vehicles in the group.

Definition at line 96 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 120 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().

uint VehicleGroupWindow::ComputeGroupInfoSize | ( |  | ) | `[inline, private]`

Compute tiny_step_height and column_size.

Returns:
  Total width required for the group list.

Definition at line 164 of file group_gui.cpp.

References ALL_GROUP, column_size, VehicleListIdentifier::company, GroupStatistics::Get(), GetSpriteSize(), GetStringBoundingBox(), Window::height, lengthof, max(), maxdim(), GroupStatistics::num_vehicle, SetDParamMaxValue(), tiny_step_height, VGC_AUTOREPLACE, VGC_NAME, VGC_NUMBER, VGC_PROFIT, VGC_PROTECT, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WD_FRAMERECT_LEFT, and Window::width.

Referenced by UpdateWidgetSize().

void VehicleGroupWindow::DrawGroupInfo | ( | int | y,
|  | int | left,
|  | int | right,
|  | GroupID | g_id,
|  | bool | protection = `false` |
| ) |  |  | const`[inline, private]`

Draw a row in the group list.

Parameters:

  | y | Top of the row.
  | left | Left of the row.
  | right | Right of the row.
  | g_id | Group to list.
  | protection | Whether autoreplace protection is set.

Definition at line 208 of file group_gui.cpp.

References _colour_gradient, _current_text_dir, GroupStatistics::autoreplace_defined, GroupStatistics::autoreplace_finished, column_size, VehicleListIdentifier::company, DrawSprite(), DrawString(), GroupStatistics::Get(), GfxFillRect(), group_over, Window::height, VehicleListIdentifier::index, IsAllGroupID(), NEW_GROUP, GroupStatistics::num_profit_vehicle, GroupStatistics::num_vehicle, PALETTE_CRASH, GroupStatistics::profit_last_year, SA_FORCE, SA_RIGHT, SetDParam(), tiny_step_height, VGC_AUTOREPLACE, VGC_NAME, VGC_NUMBER, VGC_PROFIT, VGC_PROTECT, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_TOP, and Window::width.

Referenced by DrawWidget().

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 491 of file group_gui.cpp.

References ALL_GROUP, DEFAULT_GROUP, DrawGroupInfo(), Window::DrawSortButtonState(), BaseVehicleListWindow::DrawVehicleListItems(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), groups, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, GUIList< T, F >::IsDescSortOrder(), SmallVector< T, S >::Length(), max(), min(), NEW_GROUP, Group::owner, Group::replace_protection, Window::resize, SBS_DOWN, ResizeInfo::step_height, tiny_step_height, vehicle_sel, BaseVehicleListWindow::vehicles, WD_FRAMERECT_TOP, WID_GL_ALL_VEHICLES, WID_GL_DEFAULT_VEHICLES, WID_GL_LIST_GROUP, WID_GL_LIST_VEHICLE, and WID_GL_SORT_BY_ORDER.

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 530 of file group_gui.cpp.

References _current_text_dir, ALL_GROUP, BaseVehicleListWindow::BuildActionDropdownList(), CcCreateGroup(), CMD_CREATE_GROUP, CMD_DELETE_GROUP, CMD_MSG, CMD_SET_GROUP_REPLACE_PROTECTION, DEFAULT_GROUP, DIR_E, DIR_W, DoCommandP(), EIT_IN_LIST, GUIList< T, F >::ForceRebuild(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), Vehicle::GetImage(), Scrollbar::GetScrolledRowFromWidget(), GetVehiclePalette(), groups, HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, VehicleListIdentifier::index, INVALID_TILE, IsAllGroupID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), SmallVector< T, S >::Length(), VehicleListIdentifier::Pack(), Group::replace_protection, Window::SetDirty(), ShowDropDownList(), ShowDropDownMenu(), GUIList< T, F >::SortType(), TD_RTL, GUIList< T, F >::ToggleSortOrder(), VEH_TRAIN, CursorVars::vehchain, vehicle_sel, VehicleClicked(), BaseVehicleListWindow::vehicles, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WID_GL_ALL_VEHICLES, WID_GL_AVAILABLE_VEHICLES, WID_GL_CREATE_GROUP, WID_GL_DEFAULT_VEHICLES, WID_GL_DELETE_GROUP, WID_GL_LIST_GROUP, WID_GL_LIST_VEHICLE, WID_GL_MANAGE_VEHICLES_DROPDOWN, WID_GL_RENAME_GROUP, WID_GL_REPLACE_PROTECTION, WID_GL_SORT_BY_DROPDOWN, WID_GL_SORT_BY_ORDER, WID_GL_START_ALL, and WID_GL_STOP_ALL.

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 629 of file group_gui.cpp.

References _ctrl_pressed, CcAddVehicleNewGroup(), CMD_ADD_VEHICLE_GROUP, CMD_MSG, DEFAULT_GROUP, DoCommandP(), Scrollbar::GetScrolledRowFromWidget(), group_over, groups, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_GROUP, INVALID_VEHICLE, SmallVector< T, S >::Length(), NEW_GROUP, Window::SetDirty(), ShowVehicleViewWindow(), CursorVars::vehchain, vehicle_sel, VehicleClicked(), BaseVehicleListWindow::vehicles, WID_GL_DEFAULT_VEHICLES, WID_GL_LIST_GROUP, and WID_GL_LIST_VEHICLE.

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 690 of file group_gui.cpp.

References CMD_ADD_SHARED_VEHICLE_GROUP, CMD_MSG, CMD_REMOVE_ALL_VEHICLES_GROUP, DEPOT_MASS_SEND, DEPOT_SERVICE, DoCommandP(), VehicleListIdentifier::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), SmallVector< T, S >::Length(), VehicleListIdentifier::Pack(), Window::SetDirty(), GUIList< T, F >::SetSortType(), ShowReplaceGroupVehicleWindow(), BaseVehicleListWindow::vehicles, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WID_GL_MANAGE_VEHICLES_DROPDOWN, and WID_GL_SORT_BY_DROPDOWN.

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

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

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

References DEFAULT_GROUP, DirtyHighlightedGroupWidget(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetScrolledRowFromWidget(), group_over, groups, INVALID_GROUP, INVALID_VEHICLE, SmallVector< T, S >::Length(), NEW_GROUP, vehicle_sel, WID_GL_DEFAULT_VEHICLES, and WID_GL_LIST_GROUP.

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 436 of file group_gui.cpp.

References _local_company, BuildGroupList(), VehicleListIdentifier::company, Window::DrawWidgets(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), GroupNameSorter(), groups, HideDropDownMenu(), VehicleListIdentifier::index, IsAllGroupID(), Window::IsWidgetLowered(), SmallVector< T, S >::Length(), Window::owner, Window::RaiseWidget(), Scrollbar::SetCount(), Window::SetWidgetsDisabledState(), GUIList< T, F >::Sort(), GUIList< T, F >::SortType(), BaseVehicleListWindow::vehicles, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WID_GL_AVAILABLE_VEHICLES, WID_GL_CREATE_GROUP, WID_GL_DELETE_GROUP, WID_GL_MANAGE_VEHICLES_DROPDOWN, WID_GL_RENAME_GROUP, WID_GL_REPLACE_PROTECTION, WID_GL_SORT_BY_DROPDOWN, 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 673 of file group_gui.cpp.

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

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 679 of file group_gui.cpp.

References NWidgetBase::current_y, Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacity(), Scrollbar::SetCapacityFromWidget(), WID_GL_LIST_VEHICLE, 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 409 of file group_gui.cpp.

References VehicleListIdentifier::company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, VehicleListIdentifier::index, IsAllGroupID(), SmallVector< T, S >::Length(), GroupStatistics::num_vehicle, SetDParam(), Group::statistics, BaseVehicleListWindow::vehicles, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WID_GL_AVAILABLE_VEHICLES, and WID_GL_CAPTION.

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 794 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 329 of file group_gui.cpp.

References Ceil(), ComputeGroupInfoSize(), BaseVehicleListWindow::GetActionDropdownSize(), GetSpriteSize(), GetStringBoundingBox(), GetVehicleListHeight(), Window::height, max(), maxdim(), tiny_step_height, BaseVehicleListWindow::vli, VehicleListIdentifier::vtype, WD_SORTBUTTON_ARROW_WIDTH, WID_GL_ALL_VEHICLES, WID_GL_CREATE_GROUP, WID_GL_DEFAULT_VEHICLES, WID_GL_DELETE_GROUP, WID_GL_LIST_GROUP, WID_GL_LIST_VEHICLE, WID_GL_MANAGE_VEHICLES_DROPDOWN, WID_GL_RENAME_GROUP, WID_GL_REPLACE_PROTECTION, and WID_GL_SORT_BY_ORDER.

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

- src/group_gui.cpp