# vehicle_gui_base.h

Go to the documentation of this file.

    00001 /* $Id: vehicle_gui_base.h 25287 2013-05-26 19:23:42Z frosch $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef VEHICLE_GUI_BASE_H
    00013 #define VEHICLE_GUI_BASE_H
    00014
    00015 #include "sortlist_type.h"
    00016 #include "vehiclelist.h"
    00017 #include "window_gui.h"
    00018 #include "widgets/dropdown_type.h"
    00019
    00020 typedef GUIList<const Vehicle*> GUIVehicleList;
    00021
    00022 struct BaseVehicleListWindow : public Window {
    00023   GUIVehicleList vehicles;
    00024   Listing *sorting;
    00025   byte unitnumber_digits;
    00026   Scrollbar *vscroll;
    00027   VehicleListIdentifier vli;
    00028
    00029   enum ActionDropdownItem {
    00030     ADI_REPLACE,
    00031     ADI_SERVICE,
    00032     ADI_DEPOT,
    00033     ADI_ADD_SHARED,
    00034     ADI_REMOVE_ALL,
    00035   };
    00036
    00037   static const StringID vehicle_depot_name[];
    00038   static const StringID vehicle_sorter_names[];
    00039   static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
    00040
    00041   BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(wno)
    00042   {
    00043     this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
    00044   }
    00045
    00046   void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
    00047   void SortVehicleList();
    00048   void BuildVehicleList();
    00049   Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
    00050   DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
    00051 };
    00052
    00053 uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
    00054
    00055 struct Sorting {
    00056   Listing aircraft;
    00057   Listing roadveh;
    00058   Listing ship;
    00059   Listing train;
    00060 };
    00061
    00062 extern Sorting _sorting;
    00063
    00064 #endif /* VEHICLE_GUI_BASE_H */