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 const & 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 docstring editMessage() const;
67 bool editable() const { return true; }
69 bool canTrackChanges() const { return true; }
71 InsetText * asInsetText() { return this; }
73 InsetText const * asInsetText() const { return this; }
75 Text & text() { return text_; }
76 Text const & text() const { return text_; }
78 int latex(odocstream &, OutputParams const &) const;
80 int plaintext(odocstream &, OutputParams const &) const;
82 int docbook(odocstream &, OutputParams const &) const;
84 docstring xhtml(odocstream &, OutputParams const &) const;
86 void validate(LaTeXFeatures & features) const;
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;
92 InsetCode lyxCode() const { return TEXT_CODE; }
94 void setText(docstring const &, Font const &, bool trackChanges);
96 void setAutoBreakRows(bool);
98 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
100 void setDrawFrame(bool);
102 ColorCode frameColor() const;
104 void setFrameColor(ColorCode);
106 bool showInsetDialog(BufferView *) const;
108 Text * getText(int i) const {
109 return (i == 0) ? const_cast<Text*>(&text_) : 0;
112 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
115 void fixParagraphsFont();
117 /// set the change for the entire inset
118 void setChange(Change const & change);
119 /// accept the changes within the inset
120 void acceptChanges();
121 /// reject the changes within the inset
122 void rejectChanges();
124 /// append text onto the existing text
125 void appendParagraphs(ParagraphList &);
128 void addPreview(graphics::PreviewLoader &) const;
131 void edit(Cursor & cur, bool front, EntryDirection entry_from);
133 Inset * editXY(Cursor & cur, int x, int y);
135 /// number of cells in this inset
136 size_t nargs() const { return 1; }
138 ParagraphList & paragraphs();
140 ParagraphList const & paragraphs() const;
142 bool insetAllowed(InsetCode) const { return true; }
143 /// Allow spellchecking, except for insets with latex_language
144 bool allowSpellCheck() const { return !forceLTR(); }
146 virtual bool isMacroScope() const { return false; }
148 virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
150 /// Update the counters of this inset and of its contents
151 virtual void updateLabels(ParIterator const &);
153 void addToToc(DocIterator const &);
155 Inset * clone() const { return new InsetText(*this); }
157 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
160 bool completionSupported(Cursor const &) const;
162 bool inlineCompletionSupported(Cursor const & cur) const;
164 bool automaticInlineCompletion() const;
166 bool automaticPopupCompletion() const;
168 bool showCompletionCursor() const;
170 CompletionList const * createCompletionList(Cursor const & cur) const;
172 docstring completionPrefix(Cursor const & cur) const;
174 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
176 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
179 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
181 void doDispatch(Cursor & cur, FuncRequest & cmd);
184 InsetCaption const * getCaptionInset() const;
186 docstring getCaptionText(OutputParams const &) const;
188 docstring getCaptionHTML(OutputParams const &) const;
191 void initParagraphs(UsePlain type);
193 void setParagraphOwner();
197 ColorCode frame_color_;
199 mutable pit_type old_pit;