]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
7be51ddd0113ad3336041db572ab0397081ed4d8
[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 "Inset.h"
16
17 #include "ColorCode.h"
18 #include "Text.h"
19
20 namespace lyx {
21
22 class Buffer;
23 class BufferParams;
24 class BufferView;
25 class CompletionList;
26 class CursorSlice;
27 class Dimension;
28 class ParagraphList;
29 class InsetTabular;
30
31 /**
32  A text inset is like a TeX box to write full text
33  (including styles and other insets) in a given space.
34  */
35 class InsetText : public Inset {
36 public:
37         ///
38         explicit InsetText(Buffer const & buffer);
39         ///
40         InsetText();
41         ///
42         InsetText(InsetText const &);
43         ///
44         void initParagraphs(Buffer const & buffer);
45         ///
46         void setBuffer(Buffer &);
47
48         ///
49         Dimension const dimension(BufferView const &) const;
50
51         /// empty inset to empty par
52         void clear();
53         ///
54         void read(Lexer & lex);
55         ///
56         void write(std::ostream & os) const;
57         ///
58         void metrics(MetricsInfo & mi, Dimension & dim) const;
59         ///
60         void draw(PainterInfo & pi, int x, int y) const;
61         ///
62         docstring editMessage() const;
63         ///
64         EDITABLE editable() const { return HIGHLY_EDITABLE; }
65         ///
66         bool canTrackChanges() const { return true; }
67         ///
68         InsetText * asInsetText() { return this; }
69         ///
70         InsetText const * asInsetText() const { return this; }
71         ///
72         int latex(odocstream &, OutputParams const &) const;
73         ///
74         int plaintext(odocstream &, OutputParams const &) const;
75         ///
76         int docbook(odocstream &, OutputParams const &) const;
77         ///
78         void validate(LaTeXFeatures & features) const;
79
80         /// return x,y of given position relative to the inset's baseline
81         void cursorPos(BufferView const & bv, CursorSlice const & sl,
82                 bool boundary, int & x, int & y) const;
83         ///
84         InsetCode lyxCode() const { return TEXT_CODE; }
85         ///
86         void setText(docstring const &, Font const &, bool trackChanges);
87         ///
88         void setAutoBreakRows(bool);
89         ///
90         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
91         ///
92         void setDrawFrame(bool);
93         ///
94         ColorCode frameColor() const;
95         ///
96         void setFrameColor(ColorCode);
97         ///
98         bool showInsetDialog(BufferView *) const;
99         ///
100         Text * getText(int i) const {
101                 return (i == 0) ? const_cast<Text*>(&text_) : 0;
102         }
103         ///
104         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
105
106         /// set the change for the entire inset
107         void setChange(Change const & change);
108         /// accept the changes within the inset
109         void acceptChanges(BufferParams const & bparams);
110         /// reject the changes within the inset
111         void rejectChanges(BufferParams const & bparams);
112
113         /// append text onto the existing text
114         void appendParagraphs(ParagraphList &);
115
116         ///
117         void addPreview(graphics::PreviewLoader &) const;
118
119         ///
120         void edit(Cursor & cur, bool front, EntryDirection entry_from);
121         ///
122         Inset * editXY(Cursor & cur, int x, int y);
123
124         /// number of cells in this inset
125         size_t nargs() const { return 1; }
126         ///
127         ParagraphList & paragraphs();
128         ///
129         ParagraphList const & paragraphs() const;
130         ///
131         bool insetAllowed(InsetCode) const { return true; }
132         ///
133         bool allowSpellCheck() const { return true; }
134         ///
135         virtual bool isMacroScope() const { return false; }
136         ///
137         virtual bool allowMultiPar() const { return true; }
138
139         // Update the counters of this inset and of its contents
140         void updateLabels(ParIterator const &);
141         ///
142         void addToToc(DocIterator const &);
143         ///
144         Inset * clone() const { return new InsetText(*this); }
145         ///
146         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
147
148         ///
149         bool completionSupported(Cursor const &) const;
150         ///
151         bool inlineCompletionSupported(Cursor const & cur) const;
152         ///
153         bool automaticInlineCompletion() const;
154         ///
155         bool automaticPopupCompletion() const;
156         ///
157         bool showCompletionCursor() const;
158         ///
159         CompletionList const * createCompletionList(Cursor const & cur) const;
160         ///
161         docstring completionPrefix(Cursor const & cur) const;
162         ///
163         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
164         ///
165         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
166
167         ///
168         virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
169         ///
170         void doDispatch(Cursor & cur, FuncRequest & cmd);
171 private:
172         ///
173         void setParagraphOwner();
174         ///
175         bool drawFrame_;
176         ///
177         ColorCode frame_color_;
178         ///
179         mutable pit_type old_pit;
180
181 public:
182         ///
183         mutable Text text_;
184 };
185
186 } // namespace lyx
187
188 #endif