Dillo
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dw
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
19
class
Iterator
:
public
lout::object::Object
,
public
lout::misc::Comparable
20
{
21
protected
:
22
Iterator
(
Widget
*
widget
,
Content::Type
mask
,
bool
atEnd);
23
Iterator
(
Iterator
&it);
24
~Iterator
();
25
26
Content
content
;
27
28
private
:
29
Widget
*
widget
;
30
Content::Type
mask
;
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
:
98
EmptyIterator
(
EmptyIterator
&it);
99
100
public
:
101
EmptyIterator
(
Widget
*
widget
,
Content::Type
mask
,
bool
atEnd);
102
103
lout::object::Object
*
clone
();
104
int
compareTo
(
lout::misc::Comparable
*other);
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
123
TextIterator
(
TextIterator
&it);
124
125
public
:
126
TextIterator
(
Widget
*
widget
,
Content::Type
mask
,
bool
atEnd,
127
const
char
*
text
);
128
129
int
compareTo
(
lout::misc::Comparable
*other);
130
131
bool
next
();
132
bool
prev
();
133
void
getAllocation
(
int
start,
int
end,
Allocation
*allocation);
134
};
135
136
145
class
DeepIterator
:
public
lout::object::Object
,
public
lout::misc::Comparable
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
158
Stack
stack
;
159
160
static
Iterator
*
searchDownward
(
Iterator
*it,
Content::Type
mask
,
161
bool
fromEnd);
162
static
Iterator
*
searchSideward
(
Iterator
*it,
Content::Type
mask
,
163
bool
fromEnd);
164
165
Content::Type
mask
;
166
Content
content
;
167
bool
hasContents
;
168
169
inline
DeepIterator
() { }
170
171
public
:
172
DeepIterator
(
Iterator
*it);
173
~DeepIterator
();
174
175
lout::object::Object
*
clone
();
176
177
DeepIterator
*
createVariant
(
Iterator
*it);
178
inline
Iterator
*
getTopIterator
() {
return
stack
.
getTop
(); }
179
inline
Content
*
getContent
() {
return
&
content
; }
180
181
bool
isEmpty
();
182
183
bool
next
();
184
bool
prev
();
185
inline
DeepIterator
*
cloneDeepIterator
() {
return
(
DeepIterator
*)
clone
(); }
186
int
compareTo
(
lout::misc::Comparable
*other);
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
219
class
CharIterator
:
public
lout::object::Object
,
public
lout::misc::Comparable
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
:
227
DeepIterator
*
it
;
228
int
pos
,
ch
;
229
230
CharIterator
();
231
232
public
:
233
CharIterator
(
Widget
*widget);
234
~CharIterator
();
235
236
lout::object::Object
*
clone
();
237
int
compareTo
(
lout::misc::Comparable
*other);
238
239
bool
next
();
240
bool
prev
();
241
inline
int
getChar
() {
return
ch
; }
242
inline
CharIterator
*
cloneCharIterator
() {
return
(
CharIterator
*)
clone
(); }
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 dw
256
}
// namespace core
257
258
#endif // __ITERATOR_HH__
Generated on Mon Nov 5 2012 02:16:32 for Dillo by
1.8.2