regenerated
[moon.git] / src / thickness.h
blob47f59b5659aca543f3fd4fbeffd737ea45c58070
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * thickness.h:
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __MOON_THICKNESS_H__
12 #define __MOON_THICKNESS_H__
14 #include <glib.h>
16 /* @IncludeInKinds */
17 struct Thickness {
18 double left;
19 double top;
20 double right;
21 double bottom;
23 Thickness ()
24 : left (0), top (0),
25 right (0), bottom (0)
29 Thickness (double uniform)
31 bottom = uniform;
32 right = uniform;
33 left = uniform;
34 top = uniform;
37 Thickness (double hori, double vert)
39 bottom = vert;
40 right = hori;
41 left = hori;
42 top = vert;
45 Thickness (double left, double top, double right, double bottom)
47 this->bottom = bottom;
48 this->right = right;
49 this->left = left;
50 this->top = top;
53 Thickness (const Thickness &thickness)
55 bottom = thickness.bottom;
56 right = thickness.right;
57 left = thickness.left;
58 top = thickness.top;
61 Thickness operator- ()
63 return Thickness (-left, -top, -right, -bottom);
66 Thickness operator+ (const Thickness &th)
68 return Thickness (left + th.left, top + th.top, right + th.right, bottom + th.bottom);
71 Thickness operator- (const Thickness &th)
73 return Thickness (left - th.left, top - th.top, right - th.right, bottom - th.bottom);
76 bool operator == (const Thickness &v)
78 return fabs (bottom - v.bottom) < DBL_EPSILON && fabs(right - v.right) < DBL_EPSILON && fabs (left - v.left) < DBL_EPSILON && fabs (top - v.top) < DBL_EPSILON;
81 bool operator != (const Thickness &v)
83 return !(*this == v);
86 // FromStr
87 // Parses @s and return a new Thickness in @t. Returns
88 // true if this was successful, false otherwise.
90 static bool FromStr (const char *s, Thickness *t);
93 #endif /* __MOON_THICKNESS_H__ */