]> Dogcows Code - chaz/openbox/blob - src/Geometry.h
confine the mouse to the window for button grabs so that alt-click-drag on a window...
[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 unsigned int m_w, m_h;
45 public:
46 Size();
47 Size(const Size &size);
48 Size(const unsigned int w, const unsigned int h);
49
50 void setW(const unsigned int w);
51 inline unsigned int w() const {
52 return m_w;
53 }
54
55 void setH(const unsigned int h);
56 inline unsigned 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 unsigned int w, const unsigned int h);
68
69 void setSize(const Size &size);
70 void setSize(const unsigned int w, const unsigned int h);
71 inline const Size &size() const {
72 return const_cast<const Size &>(m_size);
73 }
74
75 void setOrigin(const Point &origin);
76 void setOrigin(const int x, const int y);
77 inline const Point &origin() const {
78 return const_cast<const Point &>(m_origin);
79 }
80
81 void setX(const int x);
82 inline int x() const {
83 return m_origin.x();
84 }
85
86 void setY(const int y);
87 inline int y() const {
88 return m_origin.y();
89 }
90
91 void setW(const unsigned int w);
92 inline unsigned int w() const {
93 return m_size.w();
94 }
95
96 void setH(const unsigned int h);
97 inline unsigned int h() const {
98 return m_size.h();
99 }
100
101 bool Intersect(const Rect &r) const;
102 // returns a rect that is this rect increased in size by the passed in amount
103 Rect Inflate(const unsigned int i) const;
104 Rect Inflate(const unsigned int iw, const unsigned int ih) const;
105 Rect Inflate(const Size &i) const;
106 // returns a rect that is this rect decreased in size by the passed in amount
107 Rect Deflate(const unsigned int d) const;
108 Rect Deflate(const unsigned int dw, const unsigned int dh) const;
109 Rect Deflate(const Size &d) const;
110 // returns a rect that is moved the amount specified
111 Rect Translate(const int t) const;
112 Rect Translate(const int tx, const int ty) const;
113 Rect Translate(const Point &t) const;
114 };
115
116 #endif // __geometry_h
This page took 0.036385 seconds and 4 git commands to generate.