~ubuntu-branches/ubuntu/karmic/moon/karmic

« back to all changes in this revision

Viewing changes to src/thickness.h

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
/*
 
3
 * thickness.h:
 
4
 *
 
5
 * Copyright 2007 Novell, Inc. (http://www.novell.com)
 
6
 *
 
7
 * See the LICENSE file included with the distribution for details.
 
8
 * 
 
9
 */
 
10
 
 
11
#ifndef __MOON_THICKNESS_H__
 
12
#define __MOON_THICKNESS_H__
 
13
 
 
14
#include <glib.h>
 
15
 
 
16
/* @IncludeInKinds */
 
17
struct Thickness {
 
18
        double left;
 
19
        double top;
 
20
        double right;
 
21
        double bottom;
 
22
        
 
23
        Thickness ()
 
24
          : left (0), top (0),
 
25
            right (0), bottom (0)
 
26
        {
 
27
        }
 
28
 
 
29
        Thickness (double uniform)
 
30
        {
 
31
                bottom = uniform;
 
32
                right = uniform;
 
33
                left = uniform;
 
34
                top = uniform;
 
35
        }
 
36
        
 
37
        Thickness (double hori, double vert)
 
38
        {
 
39
                bottom = vert;
 
40
                right = hori;
 
41
                left = hori;
 
42
                top = vert;
 
43
        }
 
44
        
 
45
        Thickness (double left, double top, double right, double bottom)
 
46
        {
 
47
                this->bottom = bottom;
 
48
                this->right = right;
 
49
                this->left = left;
 
50
                this->top = top;
 
51
        }
 
52
        
 
53
        Thickness (const Thickness &thickness)
 
54
        {
 
55
                bottom = thickness.bottom;
 
56
                right = thickness.right;
 
57
                left = thickness.left;
 
58
                top = thickness.top;
 
59
        }
 
60
 
 
61
        Thickness operator- ()
 
62
        {
 
63
                return Thickness (-left, -top, -right, -bottom);
 
64
        }
 
65
 
 
66
        Thickness operator+ (const Thickness &th)
 
67
        {
 
68
                return Thickness (left + th.left, top + th.top, right + th.right, bottom + th.bottom);
 
69
        }
 
70
 
 
71
        Thickness operator- (const Thickness &th)
 
72
        {
 
73
                return Thickness (left - th.left, top - th.top, right - th.right, bottom - th.bottom);
 
74
        }
 
75
 
 
76
        //
 
77
        // FromStr
 
78
        //   Parses @s and return a new Thickness in @t.  Returns
 
79
        //   true if this was successful, false otherwise.
 
80
        //
 
81
        static bool FromStr (const char *s, Thickness *t);
 
82
};
 
83
 
 
84
#endif /* __MOON_THICKNESS_H__ */