4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include "ColorCode.h"
20 #include "insets/InsetLayout.h"
32 A text inset is like a TeX box to write full text
33 (including styles and other insets) in a given space.
35 class InsetText : public Inset {
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 * buffer, UsePlain type = DefaultLayout);
47 InsetText(InsetText const &);
49 void setBuffer(Buffer &);
52 Dimension const dimension(BufferView const &) const;
54 /// empty inset to empty par
57 void read(Lexer & lex);
59 void write(std::ostream & os) const;
61 void metrics(MetricsInfo & mi, Dimension & dim) const;
63 void draw(PainterInfo & pi, int x, int y) const;
65 bool editable() const { return true; }
67 bool canTrackChanges() const { return true; }
69 InsetText * asInsetText() { return this; }
71 InsetText const * asInsetText() const { return this; }
73 Text & text() { return text_; }
74 Text const & text() const { return text_; }
76 int latex(odocstream &, OutputParams const &) const;
78 int plaintext(odocstream &, OutputParams const &) const;
80 int docbook(odocstream &, OutputParams const &) const;
82 docstring xhtml(XHTMLStream &, OutputParams const &) const;
92 docstring insetAsXHTML(XHTMLStream &, OutputParams const &,
95 void validate(LaTeXFeatures & features) const;
97 /// return x,y of given position relative to the inset's baseline
98 void cursorPos(BufferView const & bv, CursorSlice const & sl,
99 bool boundary, int & x, int & y) const;
101 InsetCode lyxCode() const { return TEXT_CODE; }
103 void setText(docstring const &, Font const &, bool trackChanges);
105 void setAutoBreakRows(bool);
107 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
109 void setDrawFrame(bool);
111 ColorCode frameColor() const;
113 void setFrameColor(ColorCode);
115 bool showInsetDialog(BufferView *) const;
117 Text * getText(int i) const {
118 return (i == 0) ? const_cast<Text*>(&text_) : 0;
121 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
124 void fixParagraphsFont();
126 /// set the change for the entire inset
127 void setChange(Change const & change);
128 /// accept the changes within the inset
129 void acceptChanges();
130 /// reject the changes within the inset
131 void rejectChanges();
133 /// append text onto the existing text
134 void appendParagraphs(ParagraphList &);
137 void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
140 void edit(Cursor & cur, bool front, EntryDirection entry_from);
142 Inset * editXY(Cursor & cur, int x, int y);
144 /// number of cells in this inset
145 size_t nargs() const { return 1; }
147 ParagraphList & paragraphs();
149 ParagraphList const & paragraphs() const;
151 bool insetAllowed(InsetCode) const { return !getLayout().isPassThru(); }
152 /// Allow spellchecking, except for insets with latex_language
153 bool allowSpellCheck() const { return !getLayout().isPassThru(); }
155 virtual bool isMacroScope() const { return false; }
157 virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
159 /// should paragraphs be forced to use the empty layout?
160 virtual bool forcePlainLayout(idx_type = 0) const
161 { return getLayout().forcePlainLayout(); }
162 /// should the user be allowed to customize alignment, etc.?
163 virtual bool allowParagraphCustomization(idx_type = 0) const
164 { return getLayout().allowParagraphCustomization(); }
166 /// Update the counters of this inset and of its contents
167 virtual void updateLabels(ParIterator const &, UpdateType);
168 /// the string that is passed to the TOC
169 void tocString(odocstream &) const;
171 void addToToc(DocIterator const &);
173 Inset * clone() const { return new InsetText(*this); }
175 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
178 bool completionSupported(Cursor const &) const;
180 bool inlineCompletionSupported(Cursor const & cur) const;
182 bool automaticInlineCompletion() const;
184 bool automaticPopupCompletion() const;
186 bool showCompletionCursor() const;
188 CompletionList const * createCompletionList(Cursor const & cur) const;
190 docstring completionPrefix(Cursor const & cur) const;
192 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
194 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
197 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
199 void doDispatch(Cursor & cur, FuncRequest & cmd);
202 InsetCaption const * getCaptionInset() const;
204 docstring getCaptionText(OutputParams const &) const;
206 docstring getCaptionHTML(OutputParams const &) const;
211 ColorCode frame_color_;
213 mutable pit_type old_pit;
219 InsetText::XHTMLOptions operator|(InsetText::XHTMLOptions a1, InsetText::XHTMLOptions a2);