OpenTTD
vehicle_gui_base.h
Go to the documentation of this file.
1 /* $Id: vehicle_gui_base.h 27677 2016-11-05 19:16:59Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #ifndef VEHICLE_GUI_BASE_H
13 #define VEHICLE_GUI_BASE_H
14 
15 #include "sortlist_type.h"
16 #include "vehiclelist.h"
17 #include "window_gui.h"
18 #include "widgets/dropdown_type.h"
19 
21 
22 struct BaseVehicleListWindow : public Window {
26  Scrollbar *vscroll;
28 
29  enum ActionDropdownItem {
30  ADI_REPLACE,
31  ADI_SERVICE,
32  ADI_DEPOT,
33  ADI_ADD_SHARED,
34  ADI_REMOVE_ALL,
35  };
36 
37  static const StringID vehicle_depot_name[];
38  static const StringID vehicle_sorter_names[];
39  static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
40 
42  {
43  this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
44  }
45 
46  void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
47  void SortVehicleList();
48  void BuildVehicleList();
49  Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
50  DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
51 };
52 
53 uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
54 
55 struct Sorting {
56  Listing aircraft;
57  Listing roadveh;
58  Listing ship;
59  Listing train;
60 };
61 
62 extern Sorting _sorting;
63 
64 #endif /* VEHICLE_GUI_BASE_H */
Base types for having sorted lists in GUIs.
DropDownList * BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
The information about a vehicle list.
Definition: vehiclelist.h:31
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1843
High level window description.
Definition: window_gui.h:168
Functions and type for generating vehicle lists.
Scrollbar data structure.
Definition: widget_type.h:589
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
GUIVehicleList vehicles
The list of vehicles.
Functions, definitions and such used only by the GUI.
Data structure for an opened window.
Definition: window_gui.h:271
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
Simple vector template class, with automatic delete.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
Definition: vehiclelist.cpp:55
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
uint GetVehicleListHeight(VehicleType type, uint divisor=1)
Get the height of a vehicle in the vehicle list GUIs.
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
Definition: sortlist_type.h:52
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:34
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:695
Specification of a rectangle with absolute coordinates of all edges.
byte unitnumber_digits
The number of digits of the highest unit number.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
Listing * sorting
Pointer to the vehicle type related sorting.
Dimensions (a width and height) of a rectangle in 2D.