Dillo
types.hh
Go to the documentation of this file.
1 #ifndef __DW_TYPES_HH__
2 #define __DW_TYPES_HH__
3 
4 #ifndef __INCLUDED_FROM_DW_CORE_HH__
5 # error Do not include this file directly, use "core.hh" instead.
6 #endif
7 
8 namespace dw {
9 namespace core {
10 
11 namespace style {
12  class Style;
13 }
14 
16 {
20  HPOS_INTO_VIEW, /* scroll only, until the content in question comes
21  * into view */
23 };
24 
26 {
30  VPOS_INTO_VIEW, /* scroll only, until the content in question comes
31  * into view */
33 };
34 
38 
39 /*
40  * Different "layers" may be highlighted in a widget.
41  */
43 {
47 };
48 
49 struct Point
50 {
51  int x;
52  int y;
53 };
54 
59 {
60 public:
61  virtual bool isPointWithin (int x, int y) = 0;
62  virtual void draw (core::View *view, core::style::Style *style, int x,
63  int y) = 0;
64 };
65 
69 class Rectangle: public Shape
70 {
71 public:
72  int x;
73  int y;
74  int width;
75  int height;
76 
77  inline Rectangle () { }
78  Rectangle (int x, int y, int width, int height);
79 
80  void draw (core::View *view, core::style::Style *style, int x, int y);
81  bool intersectsWith (Rectangle *otherRect, Rectangle *dest);
82  bool isSubsetOf (Rectangle *otherRect);
83  bool isPointWithin (int x, int y);
84  bool isEmpty () { return width <= 0 || height <= 0; };
85 };
86 
90 class Circle: public Shape
91 {
92 public:
93  int x, y, radius;
94 
95  Circle (int x, int y, int radius);
96 
97  void draw (core::View *view, core::style::Style *style, int x, int y);
98  bool isPointWithin (int x, int y);
99 };
100 
104 class Polygon: public Shape
105 {
106 private:
108  int minx, miny, maxx, maxy;
109 
115  inline int zOfVectorProduct(int x1, int y1, int x2, int y2) {
116  return x1 * y2 - x2 * y1;
117  }
118 
119  bool linesCross0(int ax1, int ay1, int ax2, int ay2,
120  int bx1, int by1, int bx2, int by2);
121  bool linesCross(int ax1, int ay1, int ax2, int ay2,
122  int bx1, int by1, int bx2, int by2);
123 
124 public:
125  Polygon ();
126  ~Polygon ();
127 
128  void draw (core::View *view, core::style::Style *style, int x, int y);
129  void addPoint (int x, int y);
130  bool isPointWithin (int x, int y);
131 };
132 
140 class Region
141 {
142 private:
144 
145 public:
146  Region ();
147  ~Region ();
148 
149  void clear () { rectangleList->clear (); };
150 
151  void addRectangle (Rectangle *r);
152 
154  {
155  return rectangleList->iterator ();
156  };
157 };
158 
164 {
165  int x;
166  int y;
167  int width;
168  int ascent;
169  int descent;
170 };
171 
173 {
174  int width;
175  int ascent;
176  int descent;
177 };
178 
179 struct Extremes
180 {
181  int minWidth;
182  int maxWidth;
183 };
184 
185 struct Content
186 {
187  enum Type {
188  START = 1 << 0,
189  END = 1 << 1,
190  TEXT = 1 << 2,
191  WIDGET = 1 << 3,
192  BREAK = 1 << 4,
193  ALL = 0xff,
194  REAL_CONTENT = 0xff ^ (START | END),
196  };
197 
198  /* Content is embedded in struct Word therefore we
199  * try to be space efficient.
200  */
201  short type;
202  bool space;
203  union {
204  const char *text;
207  };
208 };
209 
210 } // namespace dw
211 } // namespace core
212 
213 #endif // __DW_TYPES_HH__