OpenTTD
geometry_type.hpp
Go to the documentation of this file.
1 /* $Id$ */
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 GEOMETRY_TYPE_HPP
13 #define GEOMETRY_TYPE_HPP
14 
15 #if defined(__APPLE__)
16  /* Mac OS X already has both Rect and Point declared */
17  #define Rect OTTD_Rect
18  #define Point OTTD_Point
19 #endif /* __APPLE__ */
20 
21 
23 struct Point {
24  int x;
25  int y;
26 };
27 
29 struct Dimension {
30  uint width;
31  uint height;
32 
33  Dimension(uint w = 0, uint h = 0) : width(w), height(h) {};
34 
35  bool operator< (const Dimension &other) const
36  {
37  int x = (*this).width - other.width;
38  if (x != 0) return x < 0;
39  return (*this).height < other.height;
40  }
41 
42  bool operator== (const Dimension &other) const
43  {
44  return (*this).width == other.width && (*this).height == other.height;
45  }
46 };
47 
49 struct Rect {
50  int left;
51  int top;
52  int right;
53  int bottom;
54 };
55 
61  int x;
62  int y;
63  int width;
64  int height;
65 };
66 
68 struct Pair {
69  int a;
70  int b;
71 };
72 
73 #endif /* GEOMETRY_TYPE_HPP */
bool operator==(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Compare two MultiMap iterators.
Definition: multimap.hpp:205
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height...
Coordinates of a point in 2D.
Specification of a rectangle with absolute coordinates of all edges.
Dimensions (a width and height) of a rectangle in 2D.
A pair of two integers.