2009-06-17 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / thickness.h
blob9927dc8dbd2bd7c64d3285e1045b7ceec9d09dcf
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);
77 // FromStr
78 // Parses @s and return a new Thickness in @t. Returns
79 // true if this was successful, false otherwise.
81 static bool FromStr (const char *s, Thickness *t);
84 #endif /* __MOON_THICKNESS_H__ */