]> Dogcows Code - chaz/openbox/blob - src/Geometry.h
added first revision of the BestFit placement type.
[chaz/openbox] / src / Geometry.h
1 // Geometry.h for Openbox
2 // Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22 #ifndef __geometry_h
23 #define __geometry_h
24
25 class Point{
26 int m_x, m_y;
27 public:
28 Point();
29 Point(const Point &point);
30 Point(const int x, const int y);
31
32 void setX(const int x);
33 inline int x() const {
34 return m_x;
35 }
36
37 void setY(const int y);
38 inline int y() const {
39 return m_y;
40 }
41 };
42
43 class Size{
44 int m_w, m_h;
45 public:
46 Size();
47 Size(const Size &size);
48 Size(const int w, const int h);
49
50 void setW(const int w);
51 inline int w() const {
52 return m_w;
53 }
54
55 void setH(const int h);
56 inline int h() const {
57 return m_h;
58 }
59 };
60
61 class Rect{
62 Point m_origin;
63 Size m_size;
64 public:
65 Rect();
66 Rect(const Point &origin, const Size &size);
67 Rect(const int x, const int y, const int w, const int h);
68
69 void setSize(const Size &size);
70 inline const Size &size() const {
71 return const_cast<const Size &>(m_size);
72 }
73
74 void setOrigin(const Point &origin);
75 inline const Point &origin() const {
76 return const_cast<const Point &>(m_origin);
77 }
78
79 void setX(const int x);
80 inline int x() const {
81 return m_origin.x();
82 }
83
84 void setY(const int y);
85 inline int y() const {
86 return m_origin.y();
87 }
88
89 void setW(const int w);
90 inline int w() const {
91 return m_size.w();
92 }
93
94 void setH(const int h);
95 inline int h() const {
96 return m_size.h();
97 }
98
99 bool Intersect(const Rect &r) const;
100 };
101
102 #endif // __geometry_h
This page took 0.035731 seconds and 4 git commands to generate.