|
1 /* |
|
2 This file is part of the KDE libraries |
|
3 |
|
4 Copyright (C) 2005, 2006 Apple Computer, Inc. |
|
5 |
|
6 This library is free software; you can redistribute it and/or |
|
7 modify it under the terms of the GNU Library General Public |
|
8 License as published by the Free Software Foundation; either |
|
9 version 2 of the License, or (at your option) any later version. |
|
10 |
|
11 This library is distributed in the hope that it will be useful, |
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 Library General Public License for more details. |
|
15 |
|
16 You should have received a copy of the GNU Library General Public License |
|
17 along with this library; see the file COPYING.LIB. If not, write to |
|
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
|
20 |
|
21 |
|
22 Some useful definitions needed for laying out elements |
|
23 */ |
|
24 |
|
25 #ifndef GapRects_h |
|
26 #define GapRects_h |
|
27 |
|
28 #include "IntRect.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 struct GapRects { |
|
33 const IntRect& left() const { return m_left; } |
|
34 const IntRect& center() const { return m_center; } |
|
35 const IntRect& right() const { return m_right; } |
|
36 |
|
37 void uniteLeft(const IntRect& r) { m_left.unite(r); } |
|
38 void uniteCenter(const IntRect& r) { m_center.unite(r); } |
|
39 void uniteRight(const IntRect& r) { m_right.unite(r); } |
|
40 void unite(const GapRects& o) { uniteLeft(o.left()); uniteCenter(o.center()); uniteRight(o.right()); } |
|
41 |
|
42 operator IntRect() const |
|
43 { |
|
44 IntRect result = m_left; |
|
45 result.unite(m_center); |
|
46 result.unite(m_right); |
|
47 return result; |
|
48 } |
|
49 |
|
50 bool operator==(const GapRects& other) |
|
51 { |
|
52 return m_left == other.left() && m_center == other.center() && m_right == other.right(); |
|
53 } |
|
54 bool operator!=(const GapRects& other) { return !(*this == other); } |
|
55 |
|
56 private: |
|
57 IntRect m_left; |
|
58 IntRect m_center; |
|
59 IntRect m_right; |
|
60 }; |
|
61 |
|
62 } // namespace WebCore |
|
63 |
|
64 #endif // GapRects_h |