]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
remove Inset::getParagraphs()
[lyx.git] / src / insets / insettext.h
1 // -*- C++ -*-
2 /**
3  * \file insettext.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETTEXT_H
13 #define INSETTEXT_H
14
15 #include "updatableinset.h"
16 #include "ParagraphList_fwd.h"
17 #include "RowList_fwd.h"
18 #include "lyxfont.h"
19 #include "lyxtext.h"
20
21 #include "support/types.h"
22
23 #include "frontends/mouse_state.h"
24
25
26 class Buffer;
27 class BufferParams;
28 class BufferView;
29 class Dimension;
30 class LColor_color;
31 class LyXCursor;
32 class Painter;
33 class Paragraph;
34 class Row;
35
36 /**
37  A text inset is like a TeX box to write full text
38  (including styles and other insets) in a given space.
39  @author: Jürgen Vigna
40  */
41 class InsetText : public UpdatableInset {
42 public:
43         ///
44         enum DrawFrame {
45                 ///
46                 NEVER = 0,
47                 ///
48                 LOCKED,
49                 ///
50                 ALWAYS
51         };
52         ///
53         explicit InsetText(BufferParams const &);
54         ///
55         InsetText(InsetText const &);
56         ///
57         virtual std::auto_ptr<InsetBase> clone() const;
58         ///
59         void operator=(InsetText const & it);
60         /// empty inset to empty par, or just mark as erased
61         void clear(bool just_mark_erased);
62         ///
63         void read(Buffer const & buf, LyXLex & lex);
64         ///
65         void write(Buffer const & buf, std::ostream & os) const;
66         ///
67         void metrics(MetricsInfo & mi, Dimension & dim) const;
68         ///
69         void draw(PainterInfo & pi, int x, int y) const;
70         ///
71         std::string const editMessage() const;
72         ///
73         bool isTextInset() const { return true; }
74         ///
75         int latex(Buffer const &, std::ostream &,
76                   OutputParams const &) const;
77         ///
78         int plaintext(Buffer const &, std::ostream &,
79                   OutputParams const &) const;
80         ///
81         int linuxdoc(Buffer const &, std::ostream &,
82                      OutputParams const &) const ;
83         ///
84         int docbook(Buffer const &, std::ostream &,
85                     OutputParams const &) const ;
86         ///
87         void validate(LaTeXFeatures & features) const;
88         ///
89         InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
90         /// FIXME, document
91         void getCursorPos(int & x, int & y) const;
92         ///
93         bool insertInset(BufferView *, InsetOld *);
94         ///
95         bool insetAllowed(InsetOld::Code) const;
96         ///
97         void setFont(BufferView *, LyXFont const &,
98                      bool toggleall = false,
99                      bool selectall = false);
100         ///
101         void setText(std::string const &, LyXFont const &);
102         ///
103         void setAutoBreakRows(bool);
104         ///
105         bool getAutoBreakRows() const { return autoBreakRows_; }
106         ///
107         void setDrawFrame(DrawFrame);
108         ///
109         LColor_color frameColor() const;
110         ///
111         void setFrameColor(LColor_color);
112         ///
113         void setViewCache(BufferView const * bv) const;
114         ///
115         bool showInsetDialog(BufferView *) const;
116         /// Appends \c list with all labels found within this inset.
117         void getLabelList(Buffer const &, std::vector<std::string> & list) const;
118         ///
119         int scroll(bool recursive = true) const;
120         ///
121         void scroll(BufferView * bv, float sx) const {
122                 UpdatableInset::scroll(bv, sx);
123         }
124         ///
125         void scroll(BufferView * bv, int offset) const {
126                 UpdatableInset::scroll(bv, offset);
127         }
128         ///
129         LyXText * getText(int) const;
130
131         /// mark as erased for change tracking
132         void markErased() { clear(true); };
133         /**
134          * Mark as new. Used when pasting in tabular, and adding rows
135          * or columns. Note that pasting will ensure that tracking already
136          * happens, and this just resets the changes for the copied text,
137          * whereas for row/col add, we need to start tracking changes
138          * for the (empty) paragraph contained.
139          */
140         void markNew(bool track_changes = false);
141
142         /// append text onto the existing text
143         void appendParagraphs(Buffer * bp, ParagraphList &);
144
145         ///
146         void addPreview(lyx::graphics::PreviewLoader &) const;
147
148         ///
149         void edit(BufferView *, bool);
150         ///
151         void edit(BufferView *, int, int);
152
153         ///
154         int numParagraphs() const { return 1; }
155         ///
156         ParagraphList & paragraphs() const;
157
158 private:
159         ///
160         DispatchResult
161         priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
162         ///
163         void updateLocal(BufferView *);
164         ///
165         void init();
166         // If the inset is empty set the language of the current font to the
167         // language to the surronding text (if different).
168         void sanitizeEmptyText(BufferView *);
169         ///
170         void setCharFont(Buffer const &, int pos, LyXFont const & font);
171         ///
172         void removeNewlines();
173         ///
174         void drawFrame(Painter &, int x) const;
175         ///
176         void clearInset(Painter &, int x, int y) const;
177         ///
178         void collapseParagraphs(BufferView *);
179
180         /* Private structures and variables */
181         ///
182         bool autoBreakRows_;
183         ///
184         DrawFrame drawFrame_;
185         /** We store the LColor::color value as an int to get LColor.h out
186          *  of the header file.
187          */
188         int frame_color_;
189         ///
190         mutable lyx::paroffset_type old_par;
191
192         /** to remember old painted frame dimensions to clear it on
193          *  the right spot!
194          */
195         mutable bool in_insetAllowed;
196 public:
197         ///
198         mutable LyXText text_;
199         ///
200         mutable LyXFont font_;
201 };
202 #endif