]> git.lyx.org Git - lyx.git/blob - src/InsetList.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / InsetList.h
1 // -*- C++ -*-
2 /**
3  * \file InsetList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_LIST_H
13 #define INSET_LIST_H
14
15 #include "insets/InsetCode.h"
16
17 #include "support/types.h"
18
19 #include <vector>
20
21
22 namespace lyx {
23
24 class Inset;
25 class Buffer;
26
27 ///
28 class InsetList {
29 public:
30         ///
31         InsetList() {}
32         ///
33         InsetList(InsetList const &);
34         /// Partial copy constructor.
35         /// Copy the InsetList contents from \p beg to \p end (without end).
36         InsetList(InsetList const &, pos_type beg, pos_type end);
37         ///
38         void setBuffer(Buffer &);
39         ///
40         void resetBuffer();
41
42         ///
43         class Element {
44         public:
45                 ///
46                 Element(pos_type p, Inset * i) : pos(p), inset(i) {}
47                 ///
48                 pos_type pos;
49                 ///
50                 Inset * inset;
51         };
52         ///
53         typedef std::vector<Element> List;
54         ///
55         typedef List::iterator iterator;
56         ///
57         typedef List::const_iterator const_iterator;
58
59         ///
60         ~InsetList();
61         ///
62         iterator begin() { return list_.begin(); }
63         ///
64         iterator end() { return list_.end(); }
65         ///
66         const_iterator begin() const { return list_.begin(); }
67         ///
68         const_iterator end() const { return list_.end(); }
69         ///
70         bool empty() const { return list_.empty(); }
71         ///
72         iterator insetIterator(pos_type pos);
73         ///
74         const_iterator insetIterator(pos_type pos) const;
75         ///
76         void insert(Inset * inset, pos_type pos);
77         ///
78         void erase(pos_type pos);
79         ///
80         Inset * release(pos_type);
81         ///
82         Inset * get(pos_type pos) const;
83         ///
84         void increasePosAfterPos(pos_type pos);
85         ///
86         void decreasePosAfterPos(pos_type pos);
87
88         /// search for next occurence of an \c Inset type.
89         /// \return the position of the found inset.
90         /// \retval -1 if no \c Inset is found.
91         pos_type find(
92                 InsetCode code, ///< Code of inset to find.
93                 pos_type startpos = 0 ///< start position for the search.
94                 ) const;
95
96         /// count occurrences of an \c Inset type.
97         /// \return the number of found inset(s).
98         int count(
99                 InsetCode code, ///< Code of inset type to count.
100                 pos_type startpos = 0 ///< start position for the counting.
101                 ) const;
102
103 private:
104         ///
105         List list_;
106 };
107
108
109 } // namespace lyx
110
111 #endif