tbx  0.7.6
margin.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_MARGIN_H_
26 #define TBX_MARGIN_H_
27 
28 namespace tbx
29 {
30 
34 class Margin
35 {
36 public:
40  Margin() : left(0), top(0), right(0), bottom(0) {}
46  Margin(int all) : left(all), top(all), right(all), bottom(all) {}
53  Margin(int x, int y) : left(x), top(y), right(x), bottom(y) {}
62  Margin(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
63 
69  Margin(const Margin &other) : left(other.left), top(other.top),
70  right(other.right), bottom(other.bottom) {}
71 
75  int left;
79  int top;
83  int right;
87  int bottom;
88 
94  Margin &operator=(const Margin &other) {left=other.left; top=other.top; right=other.right; bottom=other.bottom; return *this;}
101  bool operator==(const Margin &other) const {return (left==other.left) && (top==other.top) && (right==other.right) && (bottom==other.bottom);}
108  bool operator!=(const Margin &other) const {return (left!=other.left) || (top!=other.top) || (right!=other.right) || (bottom!=other.bottom);}
109 };
110 
111 }
112 
113 #endif /* MARGIN_H_ */
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::Margin::operator!=
bool operator!=(const Margin &other) const
Check if this margin contains differing values from another margin.
Definition: margin.h:108
tbx::Margin::operator=
Margin & operator=(const Margin &other)
Assign this margin with the values of another.
Definition: margin.h:94
tbx::Margin::Margin
Margin(int x, int y)
Construct a margin with the left = right and top = bottom.
Definition: margin.h:53
tbx::Margin::right
int right
Right margin.
Definition: margin.h:83
tbx::Margin::top
int top
Top margin.
Definition: margin.h:79
tbx::Margin::bottom
int bottom
Bottom margin.
Definition: margin.h:87
tbx::Margin::Margin
Margin(const Margin &other)
Copy constructor.
Definition: margin.h:69
tbx::Margin::operator==
bool operator==(const Margin &other) const
Check if this margin contains the same values as another margin.
Definition: margin.h:101
tbx::Margin::Margin
Margin()
Construct a margin with 0 for all measurements.
Definition: margin.h:40
tbx::Margin::Margin
Margin(int all)
Construct a margin with all measurements equal.
Definition: margin.h:46
tbx::Margin::left
int left
Left margin.
Definition: margin.h:75
tbx::Margin::Margin
Margin(int l, int t, int r, int b)
Construct a margin with all measurements specified.
Definition: margin.h:62
tbx::Margin
Class to represent a margin around an area.
Definition: margin.h:35