]> git.lyx.org Git - lyx.git/blob - src/texrow.h
Change the color of the background widget to red.
[lyx.git] / src / texrow.h
1 // -*- C++ -*-
2 /**
3  * \file texrow.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef TEXROW_H
15 #define TEXROW_H
16
17 #include <list>
18
19
20 /// Represents the correspondence between paragraphs and the generated LaTeX file
21 class TexRow {
22 public:
23         ///
24         TexRow() : count(0), lastid(-1), lastpos(-1) {}
25
26         TexRow & operator+= (TexRow const &);
27
28         /// Clears structure
29         void reset();
30
31         /// Define what paragraph and position the next row will represent
32         void start(int id, int pos);
33
34         /// Insert node when line is completed
35         void newline();
36
37         /**
38          * getIdFromRow - find pid and position for a given row
39          * @param row row number to find
40          * @param id set to id if found
41          * @param pos set to paragraph position if found
42          * @return true if found, false otherwise
43          *
44          * If the row could not be found, pos is set to zero and
45          * id is set to -1
46          */
47         bool getIdFromRow(int row, int & id, int & pos) const;
48
49         /// Returns the number of rows contained
50         int rows() const { return count; }
51
52         /// an individual id/pos <=> row mapping
53         class RowItem {
54         public:
55                 RowItem(int id, int pos, int row)
56                         : id_(id), pos_(pos), rownumber_(row)
57                 {}
58
59                 /// paragraph id
60                 int id() const {
61                         return id_;
62                 }
63
64                 /// set paragraph position
65                 void pos(int p) {
66                         pos_ = p;
67                 }
68
69                 /// paragraph position
70                 int pos() const {
71                         return pos_;
72                 }
73
74                 /// row number
75                 int rownumber() const {
76                         return rownumber_;
77                 }
78         private:
79                 int id_;
80                 int pos_;
81                 int rownumber_;
82         };
83         ///
84         typedef std::list<RowItem> RowList;
85 private:
86         /// number of lines
87         unsigned int count;
88         /// container of id/pos <=> row mapping
89         RowList rowlist;
90         /// Last paragraph
91         int lastid;
92         /// Last position
93         int lastpos;
94 };
95
96 #endif // TEXROW_H