]> git.lyx.org Git - lyx.git/blob - src/FontIterator.h
* some more traces of the signals in CursorSlice
[lyx.git] / src / FontIterator.h
1 // -*- C++ -*-
2 /**
3  * \file src/FontIterator.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alfredo Braunstein
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  *
12  * Calling Text::getFont is slow. While rebreaking we scan a
13  * paragraph from left to right calling getFont for every char.  This
14  * simple class address this problem by hidding an optimization trick
15  * (not mine btw -AB): the font is reused in the whole font span.  The
16  * class handles transparently the "hidden" (not part of the fontlist)
17  * label font (as getFont does).
18  */
19
20 #ifndef FONTITERATOR_H
21 #define FONTITERATOR_H
22
23 #include "Font.h"
24
25 #include "support/types.h"
26
27
28 namespace lyx {
29
30 class Buffer;
31 class Text;
32 class Paragraph;
33
34
35 class FontIterator : std::iterator<std::forward_iterator_tag, Font>
36 {
37 public:
38         ///
39         FontIterator(Buffer const & buffer, Text const & text,
40                 Paragraph const & par, pos_type pos);
41         ///
42         Font const & operator*() const;
43         ///
44         FontIterator & operator++();
45         ///
46         Font * operator->();
47
48 private:
49         ///
50         Buffer const & buffer_;
51         ///
52         Text const & text_;
53         ///
54         Paragraph const & par_;
55         ///
56         pos_type pos_;
57         ///
58         Font font_;
59         ///
60         pos_type endspan_;
61         ///
62         pos_type bodypos_;
63 };
64
65
66 } // namespace lyx
67
68 #endif // FONTITERATOR_H