]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
The return value for xhtml() is not going to be needed.
[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         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         docstring editMessage() const;
66         ///
67         bool editable() const { return true; }
68         ///
69         bool canTrackChanges() const { return true; }
70         ///
71         InsetText * asInsetText() { return this; }
72         ///
73         InsetText const * asInsetText() const { return this; }
74         ///
75         Text & text() { return text_; }
76         Text const & text() const { return text_; }
77         ///
78         int latex(odocstream &, OutputParams const &) const;
79         ///
80         int plaintext(odocstream &, OutputParams const &) const;
81         ///
82         int docbook(odocstream &, OutputParams const &) const;
83         ///
84         void xhtml(odocstream &, OutputParams const &) const;
85         ///
86         void validate(LaTeXFeatures & features) const;
87
88         /// return x,y of given position relative to the inset's baseline
89         void cursorPos(BufferView const & bv, CursorSlice const & sl,
90                 bool boundary, int & x, int & y) const;
91         ///
92         InsetCode lyxCode() const { return TEXT_CODE; }
93         ///
94         void setText(docstring const &, Font const &, bool trackChanges);
95         ///
96         void setAutoBreakRows(bool);
97         ///
98         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
99         ///
100         void setDrawFrame(bool);
101         ///
102         ColorCode frameColor() const;
103         ///
104         void setFrameColor(ColorCode);
105         ///
106         bool showInsetDialog(BufferView *) const;
107         ///
108         Text * getText(int i) const {
109                 return (i == 0) ? const_cast<Text*>(&text_) : 0;
110         }
111         ///
112         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
113
114         /// set the change for the entire inset
115         void setChange(Change const & change);
116         /// accept the changes within the inset
117         void acceptChanges(BufferParams const & bparams);
118         /// reject the changes within the inset
119         void rejectChanges(BufferParams const & bparams);
120
121         /// append text onto the existing text
122         void appendParagraphs(ParagraphList &);
123
124         ///
125         void addPreview(graphics::PreviewLoader &) const;
126
127         ///
128         void edit(Cursor & cur, bool front, EntryDirection entry_from);
129         ///
130         Inset * editXY(Cursor & cur, int x, int y);
131
132         /// number of cells in this inset
133         size_t nargs() const { return 1; }
134         ///
135         ParagraphList & paragraphs();
136         ///
137         ParagraphList const & paragraphs() const;
138         ///
139         bool insetAllowed(InsetCode) const { return true; }
140         ///
141         bool allowSpellCheck() const { return true; }
142         ///
143         virtual bool isMacroScope() const { return false; }
144         ///
145         virtual bool allowMultiPar() const { return true; }
146
147         /// Update the counters of this inset and of its contents
148         virtual void updateLabels(ParIterator const &);
149         ///
150         void addToToc(DocIterator const &);
151         ///
152         Inset * clone() const { return new InsetText(*this); }
153         ///
154         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
155
156         ///
157         bool completionSupported(Cursor const &) const;
158         ///
159         bool inlineCompletionSupported(Cursor const & cur) const;
160         ///
161         bool automaticInlineCompletion() const;
162         ///
163         bool automaticPopupCompletion() const;
164         ///
165         bool showCompletionCursor() const;
166         ///
167         CompletionList const * createCompletionList(Cursor const & cur) const;
168         ///
169         docstring completionPrefix(Cursor const & cur) const;
170         ///
171         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
172         ///
173         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
174
175         ///
176         virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
177         ///
178         void doDispatch(Cursor & cur, FuncRequest & cmd);
179 private:
180         ///
181         void initParagraphs(UsePlain type);
182         ///
183         void setParagraphOwner();
184         ///
185         bool drawFrame_;
186         ///
187         ColorCode frame_color_;
188         ///
189         mutable pit_type old_pit;
190         ///
191         mutable Text text_;
192 };
193
194 } // namespace lyx
195
196 #endif