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