]> git.lyx.org Git - lyx.git/blob - src/texrow.h
remove broken xpm
[lyx.git] / src / texrow.h
1 // -*- C++ -*-
2 /**
3  * \file texrow.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Matthias Ettrich
8  */
9
10
11 #ifndef TEXROW_H
12 #define TEXROW_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <list>
19
20 class Paragraph;
21
22 /// Represents the correspondence between paragraphs and the generated LaTeX file
23 class TexRow {
24 public:
25         ///
26         TexRow() : count(0), lastpar(0), lastpos(-1) {}
27
28         /// Clears structure
29         void reset();
30
31         /// Define what paragraph and position the next row will represent
32         void start(Paragraph * par, 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         TexRow & operator+= (TexRow const &);
50
51         /// Returns the number of rows contained
52         int rows() const { return count; }
53
54         /// an individual id/pos <=> row mapping
55         class RowItem {
56         public:
57                 RowItem(int id, int pos, int row) 
58                         : id_(id), pos_(pos), rownumber_(row)
59                 {}
60
61                 /// paragraph id
62                 int id() const {
63                         return id_;
64                 }
65  
66                 /// set paragraph position
67                 void pos(int p) {
68                         pos_ = p;
69                 }
70
71                 /// paragraph position
72                 int pos() const {
73                         return pos_;
74                 }
75
76                 /// row number
77                 int rownumber() const {
78                         return rownumber_;
79                 }
80         private:
81                 int id_;
82                 int pos_;
83                 int rownumber_;
84         };
85         ///
86         typedef std::list<RowItem> RowList;
87         /// increment position of all other RowItems
88         /// with same par id, to avoid placing error insets
89         /// at the same position
90         void increasePos(int id, int pos);
91 private:
92         /// number of lines
93         unsigned int count;
94         /// container of id/pos <=> row mapping
95         RowList rowlist;
96         /// Last paragraph
97         Paragraph * lastpar;
98         /// Last position
99         int lastpos;
100 };
101  
102 #endif // TEXROW_H