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