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;
186 };
187 
189 {
190 public:
193 
194  WidgetReference (Widget *widget) { parentRef = -1; this->widget = widget; }
195 };
196 
197 struct Content
198 {
199  enum Type {
200  START = 1 << 0,
201  END = 1 << 1,
202  TEXT = 1 << 2,
203 
207  WIDGET_IN_FLOW = 1 << 3,
208 
212  WIDGET_OOF_CONT = 1 << 4,
213 
217  WIDGET_OOF_REF = 1 << 5,
218  BREAK = 1 << 6,
219 
222  INVALID = 1 << 7,
223 
224  ALL = 0xff,
225  REAL_CONTENT = 0xff ^ (START | END),
226  SELECTION_CONTENT = TEXT | BREAK, // WIDGET_* must be set additionally
228  };
229 
230  /* Content is embedded in struct Word therefore we
231  * try to be space efficient.
232  */
233  short type;
234  bool space;
235  union {
236  const char *text;
240  };
241 
242  static Content::Type maskForSelection (bool followReferences);
243 
244  static void intoStringBuffer(Content *content, lout::misc::StringBuffer *sb);
245  static void maskIntoStringBuffer(Type mask, lout::misc::StringBuffer *sb);
246  static void print (Content *content);
247  static void printMask (Type mask);
248 
249  inline Widget *getWidget () {
250  assert (type & ANY_WIDGET);
251  return type == WIDGET_OOF_REF ? widgetReference->widget : widget;
252  }
253 };
254 
262 {
263 private:
266 
267 public:
269  widgetsProcessedAsInterruption =
271  TypedPointer<Widget> > (true);
272  }
273 
275  { delete widgetsProcessedAsInterruption; }
276 
279  return widgetsProcessedAsInterruption->contains (&key);
280  }
281 
285  return widgetsProcessedAsInterruption->put (key);
286  }
287 };
288 
295 {
296 private:
298 
299 public:
300  inline DrawingContext (Rectangle *toplevelArea) {
301  this->toplevelArea = *toplevelArea;
302  }
303 
304  inline Rectangle *getToplevelArea () { return &toplevelArea; }
305 };
306 
313 {
314 };
315 
316 } // namespace core
317 } // namespace dw
318 
319 #endif // __DW_TYPES_HH__
Base class for dw::core::DrawingContext and dw::core::GettingWidgetAtPointContext.
Definition: types.hh:261
int x
Definition: types.hh:165
static void intoStringBuffer(Content *content, lout::misc::StringBuffer *sb)
Definition: types.cc:279
Definition: types.hh:36
Definition: types.hh:18
const char * text
Definition: types.hh:236
short type
Definition: types.hh:233
Definition: types.hh:32
int parentRef
Definition: types.hh:192
Definition: types.hh:20
static void maskIntoStringBuffer(Type mask, lout::misc::StringBuffer *sb)
Definition: types.cc:327
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition: types.cc:41
Set at the top when getting the widget at the point.
Definition: types.hh:312
Definition: types.hh:224
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
Abstract interface for different shapes.
Definition: types.hh:58
~Polygon()
Definition: types.cc:131
int zOfVectorProduct(int x1, int y1, int x2, int y2)
Return the z-coordinate of the vector product of two vectors, whose z-coordinate is 0 (so that x and ...
Definition: types.hh:115
int y
Definition: types.hh:93
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
static Content::Type maskForSelection(bool followReferences)
Definition: types.cc:271
Definition: types.hh:28
Type
Definition: types.hh:199
void addWidgetProcessedAsInterruption(Widget *widget)
Definition: types.hh:282
WidgetReference * widgetReference
Definition: types.hh:238
int maxy
Definition: types.hh:108
dw::core::Shape implemtation for polygons.
Definition: types.hh:104
int minWidth
Definition: types.hh:181
reference to a widget out of flow (OOF); this widget (containing this content) is only the generator ...
Definition: types.hh:217
lout::misc::SimpleVector< Point > * points
Definition: types.hh:107
Definition: types.hh:27
int maxWidth
Definition: types.hh:182
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
virtual bool isPointWithin(int x, int y)=0
int y
Definition: types.hh:52
int x
Definition: types.hh:72
Definition: types.hh:45
bool linesCross(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
Return, whether the line, limited by (ax1, ay1) and (ax2, ay2), crosses the line, limited by (bx1...
Definition: types.cc:189
dw::core::Shape implemtation for simple circles.
Definition: types.hh:90
bool space
Definition: types.hh:234
int x
Definition: types.hh:93
Definition: types.hh:22
Iterator< T > iterator()
Definition: container.hh:416
int minWidthIntrinsic
Definition: types.hh:183
Definition: types.hh:201
widget in normal flow, so that this widget (containing this content) is both container (parent) and g...
Definition: types.hh:207
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Definition: types.cc:53
widget out of flow (OOF); this widget (containing this content) is only the container (parent)...
Definition: types.hh:212
Definition: types.hh:37
Definition: types.hh:36
StackingProcessingContext()
Definition: types.hh:268
Definition: types.hh:36
can be used internally, but should never be exposed, e. g. by iterators
Definition: types.hh:222
Widget * widget
Definition: types.hh:191
DrawingContext(Rectangle *toplevelArea)
Definition: types.hh:300
Definition: types.hh:218
int width
Definition: types.hh:174
Typed version of container::untyped::HashSet.
Definition: container.hh:492
bool isEmpty()
Definition: types.hh:84
int adjustmentWidth
Definition: types.hh:185
Definition: style.hh:613
virtual void draw(core::View *view, core::style::Style *style, int x, int y)=0
int width
Definition: types.hh:167
Definition: types.hh:172
Definition: types.hh:227
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
HPosition
Definition: types.hh:15
static void print(Content *content)
Definition: types.cc:344
Definition: types.hh:225
Definition: types.hh:140
VPosition
Definition: types.hh:25
int x
Definition: types.hh:51
Rectangle toplevelArea
Definition: types.hh:297
bool isSubsetOf(Rectangle *otherRect)
Definition: types.cc:78
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition: types.cc:106
int minx
Definition: types.hh:108
Polygon()
Definition: types.cc:124
Rectangle * getToplevelArea()
Definition: types.hh:304
lout::container::typed::Iterator< Rectangle > rectangles()
Definition: types.hh:153
The base class of all dillo widgets.
Definition: widget.hh:23
bool isPointWithin(int x, int y)
Definition: types.cc:87
Set at the top when drawing.
Definition: types.hh:294
bool isPointWithin(int x, int y)
Definition: types.cc:115
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector...
Definition: misc.hh:93
bool linesCross0(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
Return, whether the line, limited by (ax1, ay1) and (ax2, ay2), crosses the unlimited line...
Definition: types.cc:173
Definition: types.hh:226
Definition: types.hh:35
Definition: types.hh:197
Widget * getWidget()
Definition: types.hh:249
WidgetReference(Widget *widget)
Definition: types.hh:194
Definition: types.hh:179
int radius
Definition: types.hh:93
lout::container::typed::HashSet< lout::object::TypedPointer< Widget > > * widgetsProcessedAsInterruption
Definition: types.hh:265
Definition: types.hh:200
int ascent
Definition: types.hh:168
HighlightLayer
Definition: types.hh:42
static void printMask(Type mask)
Definition: types.cc:351
int height
Definition: types.hh:75
Definition: types.hh:44
int maxWidthIntrinsic
Definition: types.hh:184
Definition: types.hh:35
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition: types.cc:139
int breakSpace
Definition: types.hh:239
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
Definition: types.hh:37
void addPoint(int x, int y)
Definition: types.cc:156
bool hasWidgetBeenProcessedAsInterruption(Widget *widget)
Definition: types.hh:277
Definition: types.hh:17
Definition: types.hh:35
Definition: types.hh:46
int descent
Definition: types.hh:176
Definition: types.hh:29
int width
Definition: types.hh:74
void clear()
Definition: types.hh:149
Definition: types.hh:37
Typed version of container::untyped::Iterator.
Definition: container.hh:373
Definition: types.hh:49
Widget * widget
Definition: types.hh:237
int maxx
Definition: types.hh:108
int descent
Definition: types.hh:169
ScrollCommand
Definition: types.hh:35
Rectangle()
Definition: types.hh:77
void clear()
Definition: container.hh:469
Region()
Definition: types.cc:223
Definition: types.hh:30
lout::container::typed::List< Rectangle > * rectangleList
Definition: types.hh:143
int y
Definition: types.hh:73
Definition: types.hh:19
~Region()
Definition: types.cc:228
void addRectangle(Rectangle *r)
Add a rectangle to the region and combine it with existing rectangles if possible. The number of rectangles is forced to be less than 16 by combining excessive rectangles.
Definition: types.cc:239
Definition: types.hh:188
Typed version of container::untyped::List.
Definition: container.hh:463
bool isPointWithin(int x, int y)
Definition: types.cc:200
A typed version of object::Pointer.
Definition: object.hh:115
~StackingProcessingContext()
Definition: types.hh:274
int ascent
Definition: types.hh:175
Definition: types.hh:202
Definition: types.hh:37
int miny
Definition: types.hh:108
int y
Definition: types.hh:166
Circle(int x, int y, int radius)
Definition: types.cc:96