Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/portals/src/external/ceguilua/ceguilua-0.5.0/package/Basic.pkg @ 8086

Last change on this file since 8086 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
1/***********************************************************************
2    Vector2
3***********************************************************************/
4class Vector2
5{
6    // rename 'd_x' and 'd_y' to just 'x' and 'y'
7    float d_x @ x;
8    float d_y @ y;
9
10    Vector2 operator+ (const Vector2& vec) const;
11    Vector2 operator- (const Vector2& vec) const;
12    Vector2 operator* (const Vector2& vec) const;
13    bool operator== (const Vector2& vec) const;
14
15    Vector2();
16    Vector2(float x, float y);
17};
18
19// do a simple copy of Point to Vector2
20$[
21CEGUI.Point = CEGUI.Vector2
22$]
23
24
25
26/***********************************************************************
27        Size
28***********************************************************************/
29class Size
30{
31        // rename 'd_width' and 'd_height' to just 'width' and 'height'
32        float d_width @ width;
33        float d_height @ height;
34
35        bool operator== (const Size& sz) const;
36
37        Size();
38        Size(float w, float h);
39};
40
41
42
43/***********************************************************************
44        Rect
45***********************************************************************/
46class Rect
47{
48        // remove member variable 'd_' prefix
49        float d_top @ top;
50        float d_bottom @ bottom;
51        float d_left @ left;
52        float d_right @ right;
53
54        Vector2 getPosition() const;
55        float getWidth() const;
56        float getHeight() const;
57        Size getSize() const;
58
59        Rect getIntersection(const Rect& rect) const;
60        bool isPointInRect(const Vector2& p) const;
61
62        void setPosition(const Vector2& p);
63        void setWidth(float w);
64        void setHeight(float h);
65        void setSize(const Size& sz);
66
67        Rect& offset(const Vector2& p);
68        Rect& constrainSizeMax(const Size& sz);
69        Rect& constrainSizeMin(const Size& sz);
70        Rect& constrainSize(const Size& min, const Size& max);
71
72        bool operator== (const Rect& r) const;
73
74        Rect();
75        Rect(float l, float t, float r, float b);
76};
77
78
79
80/***********************************************************************
81        colour
82***********************************************************************/
83class colour
84{
85        float getAlpha() const;
86        float getRed() const;
87        float getGreen() const;
88        float getBlue() const;
89        float getHue() const;
90        float getSaturation() const;
91        float getLumination() const;
92
93        void set(float r, float g, float b, float a);
94        void setAlpha(float a);
95        void setRed(float r);
96        void setGreen(float g);
97        void setBlue(float b);
98        void setRGB(float r, float g, float b);
99        void setHSL(float hue, float saturation, float luminance, float alpha=1);
100
101        colour operator+ (const colour& c) const;
102        colour operator- (const colour& c) const;
103        //colour operator* (const colour& c) const; // gives a warning about argb_t to colour conversion
104        bool operator== (const colour& c) const;
105
106        colour();
107        colour(float r, float g, float b, float a);
108};
109
110
111
112/***********************************************************************
113        ColourRect
114***********************************************************************/
115class ColourRect
116{
117        colour d_top_left @ top_left;
118        colour d_top_right @ top_right;
119        colour d_bottom_left @ bottom_left;
120        colour d_bottom_right @ bottom_right;
121
122        void    setAlpha(float alpha);
123        void    setTopAlpha(float alpha);
124        void    setBottomAlpha(float alpha);
125        void    setLeftAlpha(float alpha);
126        void    setRightAlpha(float alpha);
127        void    modulateAlpha(float alpha);
128
129        void    setColours(const colour& col);
130
131        bool    isMonochromatic() const;
132
133        ColourRect getSubRectangle( float left, float right, float top, float bottom ) const;
134        colour getColourAtPoint( float x, float y ) const;
135
136        //ColourRect& operator*= (const ColourRect& other); // no support for *= operators
137
138        ColourRect();
139        ColourRect(const colour& col);
140        ColourRect(const colour& top_left, const colour& top_right, const colour& bottom_left, const colour& bottom_right);
141};
142
143
144
145/************************************************************************
146    String
147*************************************************************************/
148class String
149{
150    static const unsigned long npos;
151
152    unsigned long size() const;
153    unsigned long length() const;
154    bool empty() const;
155    unsigned long capacity() const;
156
157    unsigned long& operator[] (unsigned long i);
158    unsigned long& at(unsigned long i);
159    string c_str() const;
160
161    void reserve(unsigned long num=0);
162    void resize(unsigned long num);
163    void resize(unsigned long num, unsigned long codepoint);
164
165    void clear();
166    String& erase();
167    // default len is different from usual to handle ambiguity issue
168    String& erase(unsigned long idx, unsigned long len=1);
169
170    String& replace(unsigned long begin, unsigned long len, const String&s);
171    //String& replace(unsigned long begin, unsigned long len, unsigned long codepoint);
172
173    void swap(String& s);
174    String& insert(unsigned long pos, const String& s);
175    //String& insert(unsigned long pos, unsigned long codepoint);
176
177    unsigned long find(unsigned long codepoint, unsigned long idx=0) const;
178    unsigned long rfind(unsigned long codepoint, unsigned long idx=-1) const;
179    unsigned long find(const String& sub, unsigned long idx=0) const;
180    unsigned long rfind(const String& sub, unsigned long idx=-1) const;
181
182    String substr(unsigned long idx=0, unsigned long len=-1) const;
183
184    void push_back(unsigned long codepoint);
185
186    String();
187    String(unsigned long num, unsigned long codepoint);
188    String(string s);
189    String(const String& s);
190};
Note: See TracBrowser for help on using the repository browser.