Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
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
8namespace dw {
9namespace core {
10
11namespace 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 */
48
49struct Point
50{
51 int x;
52 int y;
53};
54
59{
60public:
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
69class Rectangle: public Shape
70{
71public:
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
90class Circle: public Shape
91{
92public:
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
104class Polygon: public Shape
105{
106private:
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
124public:
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
141{
142private:
143 lout::container::typed::List <Rectangle> *rectangleList;
144
145public:
146 Region ();
147 ~Region ();
148
149 void clear () { rectangleList->clear (); };
150
151 void addRectangle (Rectangle *r);
152
153 lout::container::typed::Iterator <Rectangle> rectangles ()
154 {
155 return rectangleList->iterator ();
156 };
157};
158
164{
165 int x;
166 int y;
167 int width;
170};
171
173{
174 int width;
177};
178
187
189{
190public:
193
194 WidgetReference (Widget *widget) { parentRef = -1; this->widget = widget; }
195};
196
198{
199 enum Type {
200 START = 1 << 0,
201 END = 1 << 1,
202 TEXT = 1 << 2,
203
208
213
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);
246 static void print (Content *content);
247 static void printMask (Type mask);
248
249 inline Widget *getWidget () {
250 assert (type & ANY_WIDGET);
252 }
253};
254
288
295{
296private:
298
299public:
301 this->toplevelArea = *toplevelArea;
302 }
303
304 inline Rectangle *getToplevelArea () { return &toplevelArea; }
305};
306
315
316} // namespace core
317} // namespace dw
318
319#endif // __DW_TYPES_HH__
dw::core::Shape implemtation for simple circles.
Definition types.hh:91
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition types.cc:106
bool isPointWithin(int x, int y)
Definition types.cc:115
Set at the top when drawing.
Definition types.hh:295
Rectangle * getToplevelArea()
Definition types.hh:304
DrawingContext(Rectangle *toplevelArea)
Definition types.hh:300
Set at the top when getting the widget at the point.
Definition types.hh:313
dw::core::Shape implemtation for polygons.
Definition types.hh:105
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
bool isPointWithin(int x, int y)
Definition types.cc:200
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
void addPoint(int x, int y)
Definition types.cc:156
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
lout::misc::SimpleVector< Point > * points
Definition types.hh:107
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition types.cc:139
dw::core::Shape implemtation for simple rectangles.
Definition types.hh:70
bool isPointWithin(int x, int y)
Definition types.cc:87
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition types.cc:41
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
Definition types.cc:53
bool isSubsetOf(Rectangle *otherRect)
Definition types.cc:78
Implementation for a point set.
Definition types.hh:141
lout::container::typed::List< Rectangle > * rectangleList
Definition types.hh:143
void addRectangle(Rectangle *r)
Add a rectangle to the region and combine it with existing rectangles if possible.
Definition types.cc:239
lout::container::typed::Iterator< Rectangle > rectangles()
Definition types.hh:153
Abstract interface for different shapes.
Definition types.hh:59
virtual bool isPointWithin(int x, int y)=0
virtual void draw(core::View *view, core::style::Style *style, int x, int y)=0
Base class for dw::core::DrawingContext and dw::core::GettingWidgetAtPointContext.
Definition types.hh:262
bool hasWidgetBeenProcessedAsInterruption(Widget *widget)
Definition types.hh:277
lout::container::typed::HashSet< lout::object::TypedPointer< Widget > > * widgetsProcessedAsInterruption
Definition types.hh:265
void addWidgetProcessedAsInterruption(Widget *widget)
Definition types.hh:282
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
WidgetReference(Widget *widget)
Definition types.hh:194
The base class of all dillo widgets.
Definition widget.hh:44
Typed version of container::untyped::HashSet.
Definition container.hh:514
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition misc.hh:115
A class for fast concatenation of a large number of strings.
Definition misc.hh:570
This is the base class for many other classes, which defines very common virtual methods.
Definition object.hh:25
A typed version of object::Pointer.
Definition object.hh:116
HighlightLayer
Definition types.hh:43
@ HIGHLIGHT_NUM_LAYERS
Definition types.hh:46
@ HIGHLIGHT_SELECTION
Definition types.hh:44
@ HIGHLIGHT_FINDTEXT
Definition types.hh:45
VPosition
Definition types.hh:26
@ VPOS_TOP
Definition types.hh:27
@ VPOS_INTO_VIEW
Definition types.hh:30
@ VPOS_CENTER
Definition types.hh:28
@ VPOS_NO_CHANGE
Definition types.hh:32
@ VPOS_BOTTOM
Definition types.hh:29
HPosition
Definition types.hh:16
@ HPOS_CENTER
Definition types.hh:18
@ HPOS_INTO_VIEW
Definition types.hh:20
@ HPOS_LEFT
Definition types.hh:17
@ HPOS_NO_CHANGE
Definition types.hh:22
@ HPOS_RIGHT
Definition types.hh:19
ScrollCommand
Definition types.hh:35
@ LINE_UP_CMD
Definition types.hh:36
@ BOTTOM_CMD
Definition types.hh:37
@ RIGHT_CMD
Definition types.hh:37
@ NONE_CMD
Definition types.hh:37
@ SCREEN_LEFT_CMD
Definition types.hh:35
@ LEFT_CMD
Definition types.hh:37
@ SCREEN_DOWN_CMD
Definition types.hh:35
@ LINE_DOWN_CMD
Definition types.hh:36
@ SCREEN_UP_CMD
Definition types.hh:35
@ SCREEN_RIGHT_CMD
Definition types.hh:36
@ TOP_CMD
Definition types.hh:37
Dw is in this namespace, or sub namespaces of this one.
Represents the allocation, i.e.
Definition types.hh:164
static void print(Content *content)
Definition types.cc:344
@ WIDGET_OOF_REF
reference to a widget out of flow (OOF); this widget (containing this content) is only the generator ...
Definition types.hh:217
@ INVALID
can be used internally, but should never be exposed, e.
Definition types.hh:222
@ WIDGET_IN_FLOW
widget in normal flow, so that this widget (containing this content) is both container (parent) and g...
Definition types.hh:207
@ WIDGET_OOF_CONT
widget out of flow (OOF); this widget (containing this content) is only the container (parent),...
Definition types.hh:212
const char * text
Definition types.hh:236
Widget * widget
Definition types.hh:237
Widget * getWidget()
Definition types.hh:249
static Content::Type maskForSelection(bool followReferences)
Definition types.cc:271
static void maskIntoStringBuffer(Type mask, lout::misc::StringBuffer *sb)
Definition types.cc:327
static void intoStringBuffer(Content *content, lout::misc::StringBuffer *sb)
Definition types.cc:279
WidgetReference * widgetReference
Definition types.hh:238
static void printMask(Type mask)
Definition types.cc:351