dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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 
8 namespace dw {
9 namespace core {
10 
20 {
21 protected:
22  Iterator(Widget *widget, Content::Type mask, bool atEnd);
23  Iterator(Iterator &it);
24  ~Iterator();
25 
27 
28 private:
31 
32 public:
33  bool equals (Object *other);
34 
35  inline Widget *getWidget () { return widget; }
36  inline Content *getContent () { return &content; }
37  inline Content::Type getMask () { return mask; }
38 
39  virtual void unref ();
40 
46  virtual bool next () = 0;
47 
53  virtual bool prev () = 0;
54 
63  virtual void highlight (int start, int end, HighlightLayer layer) = 0;
64 
73  virtual void unhighlight (int direction, HighlightLayer layer) = 0;
74 
82  virtual void getAllocation (int start, int end, Allocation *allocation) = 0;
83 
84  inline Iterator *cloneIterator () { return (Iterator*)clone(); }
85 
86  static void scrollTo (Iterator *it1, Iterator *it2, int start, int end,
87  HPosition hpos, VPosition vpos);
88 };
89 
90 
95 class EmptyIterator: public Iterator
96 {
97 private:
99 
100 public:
101  EmptyIterator (Widget *widget, Content::Type mask, bool atEnd);
102 
105  bool next ();
106  bool prev ();
107  void highlight (int start, int end, HighlightLayer layer);
108  void unhighlight (int direction, HighlightLayer layer);
109  void getAllocation (int start, int end, Allocation *allocation);
110 };
111 
112 
117 class TextIterator: public Iterator
118 {
119 private:
121  const char *text;
122 
124 
125 public:
127  const char *text);
128 
130 
131  bool next ();
132  bool prev ();
133  void getAllocation (int start, int end, Allocation *allocation);
134 };
135 
136 
146 {
147 private:
148  class Stack: public lout::container::typed::Vector<Iterator>
149  {
150  public:
151  inline Stack (): lout::container::typed::Vector<Iterator> (4, false) { }
152  ~Stack ();
153  inline Iterator *getTop () { return get (size () - 1); }
154  inline void push (Iterator *it) { put(it, -1); }
155  inline void pop() { getTop()->unref (); remove (size () - 1); }
156  };
157 
159 
161  bool fromEnd);
163  bool fromEnd);
164 
168 
169  inline DeepIterator () { }
170 
171 public:
172  DeepIterator(Iterator *it);
173  ~DeepIterator();
174 
176 
178  inline Iterator *getTopIterator () { return stack.getTop(); }
179  inline Content *getContent () { return &content; }
180 
181  bool isEmpty ();
182 
183  bool next ();
184  bool prev ();
187 
196  inline void highlight (int start, int end, HighlightLayer layer)
197  { stack.getTop()->highlight (start, end, layer); }
198 
206  inline void getAllocation (int start, int end, Allocation *allocation)
207  { stack.getTop()->getAllocation (start, end, allocation); }
208 
209  inline void unhighlight (int direction, HighlightLayer layer)
210  { stack.getTop()->unhighlight (direction, layer); }
211 
212  inline static void scrollTo (DeepIterator *it1, DeepIterator *it2,
213  int start, int end,
214  HPosition hpos, VPosition vpos)
215  { Iterator::scrollTo(it1->stack.getTop(), it2->stack.getTop(),
216  start, end, hpos, vpos); }
217 };
218 
220 {
221 public:
222  // START and END must not clash with any char value
223  // neither for signed nor unsigned char.
224  enum { START = 257, END = 258 };
225 
226 private:
228  int pos, ch;
229 
230  CharIterator ();
231 
232 public:
233  CharIterator (Widget *widget);
234  ~CharIterator ();
235 
238 
239  bool next ();
240  bool prev ();
241  inline int getChar() { return ch; }
243 
244  static void highlight (CharIterator *it1, CharIterator *it2,
245  HighlightLayer layer);
246  static void unhighlight (CharIterator *it1, CharIterator *it2,
247  HighlightLayer layer);
248 
249  inline static void scrollTo (CharIterator *it1, CharIterator *it2,
250  HPosition hpos, VPosition vpos)
251  { DeepIterator::scrollTo(it1->it, it2->it, it1->pos, it2->pos,
252  hpos, vpos); }
253 };
254 
255 } // namespace core
256 } // namespace dw
257 
258 #endif // __ITERATOR_HH__
dw::core::DeepIterator::Stack::getTop
Iterator * getTop()
Definition: iterator.hh:153
dw::core::HPosition
HPosition
Definition: types.hh:15
dw::core::Iterator::next
virtual bool next()=0
Move iterator forward and store content it.
dw::core::TextIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: iterator.cc:260
dw::core::DeepIterator::isEmpty
bool isEmpty()
Definition: iterator.cc:566
dw::core::DeepIterator::getContent
Content * getContent()
Definition: iterator.hh:179
dw::core::HighlightLayer
HighlightLayer
Definition: types.hh:42
dw::core::CharIterator::cloneCharIterator
CharIterator * cloneCharIterator()
Definition: iterator.hh:242
dw::core::TextIterator::prev
bool prev()
Move iterator backward and store content it.
Definition: iterator.cc:298
dw::core::DeepIterator::Stack::Stack
Stack()
Definition: iterator.hh:151
dw::core::CharIterator::ch
int ch
Definition: iterator.hh:228
dw::core::DeepIterator::prev
bool prev()
Move iterator backward and store content it.
Definition: iterator.cc:608
dw::core::CharIterator::END
Definition: iterator.hh:224
dw::core::DeepIterator::mask
Content::Type mask
Definition: iterator.hh:165
dw::core::DeepIterator::searchDownward
static Iterator * searchDownward(Iterator *it, Content::Type mask, bool fromEnd)
Definition: iterator.cc:338
dw::core::CharIterator::unhighlight
static void unhighlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
Definition: iterator.cc:783
dw::core::Content::Type
Type
Definition: types.hh:187
dw::core::CharIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: iterator.cc:668
dw::core::Iterator::getAllocation
virtual void getAllocation(int start, int end, Allocation *allocation)=0
Return the shape, which a part of the item, the iterator points on, allocates.
dw::core::CharIterator::it
DeepIterator * it
Definition: iterator.hh:227
dw::core::DeepIterator
A stack of iterators, to iterate recursively through a widget tree.
Definition: iterator.hh:145
dw::core::DeepIterator::Stack::~Stack
~Stack()
Definition: iterator.cc:320
dw::core::Iterator
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
dw::core::EmptyIterator::clone
lout::object::Object * clone()
Return an exact copy of the object.
Definition: iterator.cc:203
dw::core::DeepIterator::Stack
Definition: iterator.hh:148
dw::core::CharIterator::next
bool next()
Definition: iterator.cc:678
dw::core::EmptyIterator
This implementation of dw::core::Iterator can be used by widgets with no contents.
Definition: iterator.hh:95
dw::core::DeepIterator::cloneDeepIterator
DeepIterator * cloneDeepIterator()
Definition: iterator.hh:185
dw::core::CharIterator::getChar
int getChar()
Definition: iterator.hh:241
dw::core::TextIterator
This implementation of dw::core::Iterator can be used by widgets having one text word as contents.
Definition: iterator.hh:117
dw::core::DeepIterator::DeepIterator
DeepIterator()
Definition: iterator.hh:169
dw::core::Allocation
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
dw::core::EmptyIterator::next
bool next()
Move iterator forward and store content it.
Definition: iterator.cc:220
dw::core::CharIterator::CharIterator
CharIterator()
Definition: iterator.cc:640
dw::core::CharIterator::pos
int pos
Definition: iterator.hh:228
dw::core::Iterator::highlight
virtual void highlight(int start, int end, HighlightLayer layer)=0
Extend highlighted region to contain part of the current content.
dw::core::DeepIterator::getTopIterator
Iterator * getTopIterator()
Definition: iterator.hh:178
dw::core::TextIterator::getAllocation
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:310
dw::core::DeepIterator::stack
Stack stack
Definition: iterator.hh:158
dw::core::Iterator::getWidget
Widget * getWidget()
Definition: iterator.hh:35
lout::container::typed::Vector
Typed version of container::untyped::Vector.
Definition: container.hh:399
dw::core::CharIterator::scrollTo
static void scrollTo(CharIterator *it1, CharIterator *it2, HPosition hpos, VPosition vpos)
Definition: iterator.hh:249
lout::object::Object::clone
virtual Object * clone()
Return an exact copy of the object.
Definition: object.cc:68
dw::core::Iterator::unhighlight
virtual void unhighlight(int direction, HighlightLayer layer)=0
Shrink highlighted region to no longer contain the current content.
dw::core::Iterator::widget
Widget * widget
Definition: iterator.hh:29
dw::core::CharIterator::START
Definition: iterator.hh:224
dw::core::EmptyIterator::unhighlight
void unhighlight(int direction, HighlightLayer layer)
Shrink highlighted region to no longer contain the current content.
Definition: iterator.cc:236
dw::core::DeepIterator::Stack::pop
void pop()
Definition: iterator.hh:155
dw::core::DeepIterator::hasContents
bool hasContents
Definition: iterator.hh:167
lout::container::typed::Vector< Iterator >::get
Iterator * get(int pos) const
Definition: container.hh:412
lout::object::Object
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
dw::core::DeepIterator::scrollTo
static void scrollTo(DeepIterator *it1, DeepIterator *it2, int start, int end, HPosition hpos, VPosition vpos)
Definition: iterator.hh:212
dw::core::CharIterator
Definition: iterator.hh:219
lout::container::typed::Vector< Iterator >::remove
void remove(int pos)
Definition: container.hh:411
dw::core::CharIterator::~CharIterator
~CharIterator()
Definition: iterator.cc:653
dw::core::TextIterator::next
bool next()
Move iterator forward and store content it.
Definition: iterator.cc:286
dw::core::EmptyIterator::highlight
void highlight(int start, int end, HighlightLayer layer)
Extend highlighted region to contain part of the current content.
Definition: iterator.cc:232
dw::core::Iterator::getContent
Content * getContent()
Definition: iterator.hh:36
dw::core::Iterator::mask
Content::Type mask
Definition: iterator.hh:30
lout
Definition: container.cc:26
dw::core::Iterator::prev
virtual bool prev()=0
Move iterator backward and store content it.
dw::core::Iterator::~Iterator
~Iterator()
Definition: iterator.cc:46
dw::core::Iterator::getMask
Content::Type getMask()
Definition: iterator.hh:37
dw::core::Iterator::equals
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: iterator.cc:50
dw::core::EmptyIterator::EmptyIterator
EmptyIterator(EmptyIterator &it)
Definition: iterator.cc:199
dw::core::EmptyIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: iterator.cc:208
dw::core::Iterator::content
Content content
Definition: iterator.hh:26
dw::core::EmptyIterator::getAllocation
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:240
dw::core::DeepIterator::createVariant
DeepIterator * createVariant(Iterator *it)
Definition: iterator.cc:560
dw::core::DeepIterator::~DeepIterator
~DeepIterator()
Definition: iterator.cc:520
dw::core::DeepIterator::content
Content content
Definition: iterator.hh:166
dw::core::DeepIterator::searchSideward
static Iterator * searchSideward(Iterator *it, Content::Type mask, bool fromEnd)
Definition: iterator.cc:385
dw::core::DeepIterator::clone
lout::object::Object * clone()
Return an exact copy of the object.
Definition: iterator.cc:524
lout::container::typed::Vector< Iterator >::Vector
Vector(int initSize, bool ownerOfObjects)
Definition: container.hh:402
dw::core::CharIterator::clone
lout::object::Object * clone()
Return an exact copy of the object.
Definition: iterator.cc:659
lout::object::Comparable
Instances of a sub class of may be compared (less, greater).
Definition: object.hh:41
dw::core::VPosition
VPosition
Definition: types.hh:25
dw::core::DeepIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: iterator.cc:538
dw::core::Iterator::Iterator
Iterator(Widget *widget, Content::Type mask, bool atEnd)
Definition: iterator.cc:34
dw::core::Content
Definition: types.hh:185
lout::container::typed::Vector< Iterator >::put
void put(Iterator *newElement, int newPos=-1)
Definition: container.hh:405
dw::core::EmptyIterator::prev
bool prev()
Move iterator backward and store content it.
Definition: iterator.cc:226
dw::core::DeepIterator::next
bool next()
Move iterator forward and store content it.
Definition: iterator.cc:575
dw::core::Iterator::cloneIterator
Iterator * cloneIterator()
Definition: iterator.hh:84
dw::core::DeepIterator::unhighlight
void unhighlight(int direction, HighlightLayer layer)
Definition: iterator.hh:209
dw::core::Iterator::unref
virtual void unref()
Delete the iterator.
Definition: iterator.cc:64
dw::core::CharIterator::highlight
static void highlight(CharIterator *it1, CharIterator *it2, HighlightLayer layer)
Definition: iterator.cc:753
dw::core::Widget
The base class of all dillo widgets.
Definition: widget.hh:23
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
dw::core::DeepIterator::getAllocation
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:206
dw::core::CharIterator::prev
bool prev()
Definition: iterator.cc:717
dw::core::DeepIterator::highlight
void highlight(int start, int end, HighlightLayer layer)
Highlight a part of the current content.
Definition: iterator.hh:196
lout::container::typed::Vector< Iterator >::size
int size() const
Definition: container.hh:414
dw::core::Iterator::scrollTo
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:80
dw::core::TextIterator::TextIterator
TextIterator(TextIterator &it)
Definition: iterator.cc:255
dw::core::TextIterator::text
const char * text
Definition: iterator.hh:121
dw::core::DeepIterator::Stack::push
void push(Iterator *it)
Definition: iterator.hh:154