~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to include/lomse_basic.h

  • Committer: cecilios
  • Date: 2010-10-10 13:35:19 UTC
  • Revision ID: git-v1:2b333198c3033525d15763b84eaf79dac9fdab80
Preparing to use CMake. Updating with new code and missing files. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
//
21
21
//-------------------------------------------------------------------------------------
22
22
 
23
 
#ifndef __LOMSE__BASIC_H__
24
 
#define __LOMSE__BASIC_H__
 
23
#ifndef __LOMSE_BASIC_H__
 
24
#define __LOMSE_BASIC_H__
25
25
 
26
26
namespace lomse
27
27
{
32
32
#define textdomain(Domain)
33
33
#define bindtextdomain(Package, Directory)
34
34
 
35
 
// class FloatPoint
36
 
class FloatPoint
 
35
//----------------------------------------------------------------------------------
 
36
struct FloatPoint
37
37
{
38
 
public:
39
 
    // members are public to simplify.
40
 
    float x, y;
 
38
    float x;
 
39
    float y;
41
40
 
42
41
    // constructors
43
42
    FloatPoint() : x(0.0f), y(0.0f) { }
55
54
    FloatPoint& operator-=(const FloatPoint& pt) { x -= pt.x; y -= pt.y; return *this; }
56
55
};
57
56
 
 
57
//----------------------------------------------------------------------------------
 
58
struct FloatSize
 
59
{
 
60
    float width;
 
61
    float height;
 
62
 
 
63
    // constructors
 
64
    FloatSize() : width(0.0f), height(0.0f) {}
 
65
    FloatSize(float w, float h) : width(w), height(h) {}
 
66
 
 
67
    // no copy ctor or assignment operator - the defaults are ok
 
68
 
 
69
    bool operator==(const FloatSize& sz) const { return width == sz.width && height == sz.height; }
 
70
    bool operator!=(const FloatSize& sz) const { return width != sz.width || height != sz.height; }
 
71
 
 
72
    FloatSize operator+(const FloatSize& sz) const { return FloatSize(width + sz.width, height + sz.height); }
 
73
    FloatSize operator-(const FloatSize& sz) const { return FloatSize(width - sz.width, height - sz.height); }
 
74
    FloatSize operator/(float i) const { return FloatSize(width / i, height / i); }
 
75
    FloatSize operator*(float i) const { return FloatSize(width * i, height * i); }
 
76
 
 
77
    FloatSize& operator+=(const FloatSize& sz) { width += sz.width; height += sz.height; return *this; }
 
78
    FloatSize& operator-=(const FloatSize& sz) { width -= sz.width; height -= sz.height; return *this; }
 
79
    FloatSize& operator/=(const float i) { width /= i; height /= i; return *this; }
 
80
    FloatSize& operator*=(const float i) { width *= i; height *= i; return *this; }
 
81
};
 
82
 
58
83
//specific types
59
84
typedef float Tenths;       //relative unit: one tenth of staff interline space
60
85
typedef FloatPoint TPoint;  //point, in Tenths
 
86
typedef FloatSize TSize;    //size, in Tenths
 
87
typedef float LUnits;       //absolute unit (logical unit): one cent of mm
 
88
typedef FloatPoint UPoint;  //point, in LUnits
 
89
typedef FloatSize USize;    //size, in LUnits
61
90
typedef unsigned short int16u;
62
91
 
63
92
//------------------------------------------------------------------------------
74
103
    int16u b;
75
104
    int16u a;
76
105
 
77
 
    enum base_scale_e
 
106
    enum 
78
107
    {
79
 
        base_shift = 16,
80
 
        base_scale = 1 << base_shift,
81
 
        base_mask  = base_scale - 1
 
108
        base_mask  = 255
82
109
    };
83
110
 
84
111
    rgba16() : r(0), g(0), b(0), a(base_mask) {}
92
119
    rgba16(const rgba16& c, unsigned a_) :
93
120
        r(c.r), g(c.g), b(c.b), a(int16u(a_)) {}
94
121
 
 
122
    bool operator == (rgba16 color)
 
123
    {
 
124
        return r == color.r && g == color.g && b == color.b && a == color.a ;
 
125
    }
 
126
 
95
127
    bool operator != (rgba16 color)
96
128
    {
97
129
        return r != color.r || g != color.g || b != color.b || a != color.a ;
110
142
 
111
143
    static rgba16 no_color() { return rgba16(0,0,0,0); }
112
144
 
113
 
 
114
 
 
115
145
};
116
146
 
117
147
 
118
148
}   //namespace lomse
119
149
 
120
 
#endif  // __LOMSE__BASIC_H__
 
150
#endif  // __LOMSE_BASIC_H__
121
151