Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
iterator.hh
Go to the documentation of this file.
1#ifndef __ITERATOR_HH__
2#define __ITERATOR_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
20{
21protected:
23 Iterator(Iterator &it);
24 ~Iterator();
25
27
28private:
31
32public:
33 bool equals (Object *other);
35
36 inline Widget *getWidget () { return widget; }
37 inline Content *getContent () { return &content; }
38 inline Content::Type getMask () { return mask; }
39
40 virtual void unref ();
41
47 virtual bool next () = 0;
48
54 virtual bool prev () = 0;
55
64 virtual void highlight (int start, int end, HighlightLayer layer) = 0;
65
74 virtual void unhighlight (int direction, HighlightLayer layer) = 0;
75
83 virtual void getAllocation (int start, int end, Allocation *allocation) = 0;
84
85 inline Iterator *cloneIterator () { return (Iterator*)clone(); }
86
87 static void scrollTo (Iterator *it1, Iterator *it2, int start, int end,
88 HPosition hpos, VPosition vpos);
89};
90
91
97{
98private:
100
101public:
103
106 bool next ();
107 bool prev ();
108 void highlight (int start, int end, HighlightLayer layer);
109 void unhighlight (int direction, HighlightLayer layer);
110 void getAllocation (int start, int end, Allocation *allocation);
111};
112
113
119{
120private:
122 const char *text;
123
125
126public:
128 const char *text);
129
131
132 bool next ();
133 bool prev ();
134 void getAllocation (int start, int end, Allocation *allocation);
135};
136
137
147{
148private:
149 class Stack: public lout::container::typed::Vector<Iterator>
150 {
151 public:
152 inline Stack (): lout::container::typed::Vector<Iterator> (4, false) { }
153 ~Stack ();
154 inline Iterator *getTop () { return get (size () - 1); }
155 inline void push (Iterator *it) { put(it, -1); }
156 inline void pop() { getTop()->unref (); remove (size () - 1); }
157 };
158
160
162 bool fromEnd);
164 bool fromEnd);
165
169
170 inline DeepIterator () { }
171
174 return getRespectiveParent (widget, mask);
175 }
176
177 static int getRespectiveLevel (Widget *widget, Content::Type mask);
178 inline int getRespectiveLevel (Widget *widget) {
179 return getRespectiveLevel (widget, mask);
180 }
181
182public:
185
187
189 inline Iterator *getTopIterator () { return stack.getTop(); }
190 inline Content *getContent () { return &content; }
191
192 bool isEmpty ();
193
194 bool next ();
195 bool prev ();
198
207 inline void highlight (int start, int end, HighlightLayer layer)
208 { stack.getTop()->highlight (start, end, layer); }
209
217 inline void getAllocation (int start, int end, Allocation *allocation)
218 { stack.getTop()->getAllocation (start, end, allocation); }
219
220 inline void unhighlight (int direction, HighlightLayer layer)
221 { stack.getTop()->unhighlight (direction, layer); }
222
223 inline static void scrollTo (DeepIterator *it1, DeepIterator *it2,
224 int start, int end,
225 HPosition hpos, VPosition vpos)
226 { Iterator::scrollTo(it1->stack.getTop(), it2->stack.getTop(),
227 start, end, hpos, vpos); }
228};
229
231{
232public:
233 // START and END must not clash with any char value
234 // neither for signed nor unsigned char.
235 enum { START = 257, END = 258 };
236
237private:
239 int pos, ch;
240
241 CharIterator ();
242
243public:
244 CharIterator (Widget *widget, bool followReferences);
245 ~CharIterator ();
246
249
250 bool next ();
251 bool prev ();
252 inline int getChar() { return ch; }
254
255 static void highlight (CharIterator *it1, CharIterator *it2,
256 HighlightLayer layer);
257 static void unhighlight (CharIterator *it1, CharIterator *it2,
258 HighlightLayer layer);
259
260 inline static void scrollTo (CharIterator *it1, CharIterator *it2,
261 HPosition hpos, VPosition vpos)
262 { DeepIterator::scrollTo(it1->it, it2->it, it1->pos, it2->pos,
263 hpos, vpos); }
264};
265
266} // namespace core
267} // namespace dw
268
269#endif // __ITERATOR_HH__
static void highlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
Definition iterator.cc:857
CharIterator * cloneCharIterator()
Definition iterator.hh:253
int compareTo(lout::object::Comparable *other)
Compare two objects, this and other.
Definition iterator.cc:772
static void unhighlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
Definition iterator.cc:887
DeepIterator * it
Definition iterator.hh:238
static void scrollTo(CharIterator *it1, CharIterator *it2, HPosition hpos, VPosition vpos)
Definition iterator.hh:260
lout::object::Object * clone()
Return an exact copy of the object.
Definition iterator.cc:763
void push(Iterator *it)
Definition iterator.hh:155
A stack of iterators, to iterate recursively through a widget tree.
Definition iterator.hh:147
static Iterator * searchDownward(Iterator *it, Content::Type mask, bool fromEnd)
Definition iterator.cc:356
static Iterator * searchSideward(Iterator *it, Content::Type mask, bool fromEnd)
Definition iterator.cc:403
DeepIterator * cloneDeepIterator()
Definition iterator.hh:196
static int getRespectiveLevel(Widget *widget, Content::Type mask)
Definition iterator.cc:475
Content::Type mask
Definition iterator.hh:166
DeepIterator * createVariant(Iterator *it)
Definition iterator.cc:656
void highlight(int start, int end, HighlightLayer layer)
Highlight a part of the current content.
Definition iterator.hh:207
int compareTo(lout::object::Comparable *other)
Compare two objects, this and other.
Definition iterator.cc:610
Content * getContent()
Definition iterator.hh:190
bool prev()
Move iterator backward and store content it.
Definition iterator.cc:704
Widget * getRespectiveParent(Widget *widget)
Definition iterator.hh:173
lout::object::Object * clone()
Return an exact copy of the object.
Definition iterator.cc:596
static Widget * getRespectiveParent(Widget *widget, Content::Type mask)
Definition iterator.cc:462
bool next()
Move iterator forward and store content it.
Definition iterator.cc:671
void getAllocation(int start, int end, Allocation *allocation)
Return the shape, which a part of the item, the iterator points on, allocates.
Definition iterator.hh:217
static void scrollTo(DeepIterator *it1, DeepIterator *it2, int start, int end, HPosition hpos, VPosition vpos)
Definition iterator.hh:223
int getRespectiveLevel(Widget *widget)
Definition iterator.hh:178
Iterator * getTopIterator()
Definition iterator.hh:189
void unhighlight(int direction, HighlightLayer layer)
Definition iterator.hh:220
This implementation of dw::core::Iterator can be used by widgets with no contents.
Definition iterator.hh:97
bool next()
Move iterator forward and store content it.
Definition iterator.cc:238
lout::object::Object * clone()
Return an exact copy of the object.
Definition iterator.cc:221
void unhighlight(int direction, HighlightLayer layer)
Shrink highlighted region to no longer contain the current content.
Definition iterator.cc:254
int compareTo(lout::object::Comparable *other)
Compare two objects, this and other.
Definition iterator.cc:226
void getAllocation(int start, int end, Allocation *allocation)
Return the shape, which a part of the item, the iterator points on, allocates.
Definition iterator.cc:258
bool prev()
Move iterator backward and store content it.
Definition iterator.cc:244
void highlight(int start, int end, HighlightLayer layer)
Extend highlighted region to contain part of the current content.
Definition iterator.cc:250
Iterators are used to iterate through the contents of a widget.
Definition iterator.hh:20
Widget * getWidget()
Definition iterator.hh:36
virtual void highlight(int start, int end, HighlightLayer layer)=0
Extend highlighted region to contain part of the current content.
virtual void getAllocation(int start, int end, Allocation *allocation)=0
Return the shape, which a part of the item, the iterator points on, allocates.
virtual void unref()
Delete the iterator.
Definition iterator.cc:82
static void scrollTo(Iterator *it1, Iterator *it2, int start, int end, HPosition hpos, VPosition vpos)
Scrolls the viewport, so that the region between it1 and it2 is seen, according to hpos and vpos.
Definition iterator.cc:98
void intoStringBuffer(lout::misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition iterator.cc:58
virtual bool next()=0
Move iterator forward and store content it.
Content * getContent()
Definition iterator.hh:37
virtual bool prev()=0
Move iterator backward and store content it.
bool equals(Object *other)
Returns, whether two objects are equal.
Definition iterator.cc:50
virtual void unhighlight(int direction, HighlightLayer layer)=0
Shrink highlighted region to no longer contain the current content.
Iterator * cloneIterator()
Definition iterator.hh:85
Content::Type getMask()
Definition iterator.hh:38
Content::Type mask
Definition iterator.hh:30
This implementation of dw::core::Iterator can be used by widgets having one text word as contents.
Definition iterator.hh:119
const char * text
May be NULL, in this case, the next is skipped.
Definition iterator.hh:122
bool next()
Move iterator forward and store content it.
Definition iterator.cc:304
bool prev()
Move iterator backward and store content it.
Definition iterator.cc:316
void getAllocation(int start, int end, Allocation *allocation)
Return the shape, which a part of the item, the iterator points on, allocates.
Definition iterator.cc:328
int compareTo(lout::object::Comparable *other)
Compare two objects, this and other.
Definition iterator.cc:278
The base class of all dillo widgets.
Definition widget.hh:44
Typed version of container::untyped::Vector.
Definition container.hh:447
void put(Iterator *newElement, int newPos=-1)
Definition container.hh:452
Vector(int initSize, bool ownerOfObjects)
Definition container.hh:449
A class for fast concatenation of a large number of strings.
Definition misc.hh:567
Instances of a sub class of may be compared (less, greater).
Definition object.hh:42
This is the base class for many other classes, which defines very common virtual methods.
Definition object.hh:25
virtual Object * clone()
Return an exact copy of the object.
Definition object.cc:69
HighlightLayer
Definition types.hh:43
VPosition
Definition types.hh:26
HPosition
Definition types.hh:16
Dw is in this namespace, or sub namespaces of this one.
Represents the allocation, i.e.
Definition types.hh:164