summaryrefslogtreecommitdiff
path: root/src/cargodest_gui.h
blob: 4c7915ea0da4952539445a3829b71ce6ebcc8616 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* $Id$ */

/*
 * This file is part of OpenTTD.
 * 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.
 * 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.
 * 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/>.
 */

/** @file cargodest_gui.h Functions/types related to the cargodest GUI. */

#ifndef CARGODEST_GUI_H
#define CARGODEST_GUI_H

#include "cargodest_base.h"
#include "sortlist_type.h"

/** Helper encapsulating a #CargoLink. */
struct GUICargoLink {
	CargoID         cid;   ///< Cargo ID of this link.
	const CargoLink *link; ///< Pointer to the link.

	GUICargoLink(CargoID c, const CargoLink *l) : cid(c), link(l) {}
};

/** Sorted list of demand destinations for displaying. */
class CargoDestinationList
{
private:
	const CargoSourceSink *obj;      ///< The object which destinations are displayed.
	GUIList<GUICargoLink> link_list; ///< Sorted list of destinations.

	void RebuildList();
	void SortList();

public:
	CargoDestinationList(const CargoSourceSink *o);

	void InvalidateData();
	void Resort();

	uint GetListHeight() const;
	uint DrawList(uint left, uint right, uint y) const;

	void OnClick(uint y) const;
};

#endif /* CARGODEST_GUI_H */