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"
30 A text inset is like a TeX box to write full text
31 (including styles and other insets) in a given space.
33 class InsetText : public Inset {
40 /// \param useplain whether to use the plain layout
41 /// This is needed because we cannot call the virtual function
42 /// usePlainLayout() from within the constructor.
43 explicit InsetText(Buffer const & buffer, UsePlain type = DefaultLayout);
45 InsetText(InsetText const &);
47 void setBuffer(Buffer &);
50 Dimension const dimension(BufferView const &) const;
52 /// empty inset to empty par
55 void read(Lexer & lex);
57 void write(std::ostream & os) const;
59 void metrics(MetricsInfo & mi, Dimension & dim) const;
61 void draw(PainterInfo & pi, int x, int y) const;
63 docstring editMessage() 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(odocstream &, OutputParams const &) const;
84 void validate(LaTeXFeatures & features) const;
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;
90 InsetCode lyxCode() const { return TEXT_CODE; }
92 void setText(docstring const &, Font const &, bool trackChanges);
94 void setAutoBreakRows(bool);
96 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
98 void setDrawFrame(bool);
100 ColorCode frameColor() const;
102 void setFrameColor(ColorCode);
104 bool showInsetDialog(BufferView *) const;
106 Text * getText(int i) const {
107 return (i == 0) ? const_cast<Text*>(&text_) : 0;
110 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
112 /// set the change for the entire inset
113 void setChange(Change const & change);
114 /// accept the changes within the inset
115 void acceptChanges();
116 /// reject the changes within the inset
117 void rejectChanges();
119 /// append text onto the existing text
120 void appendParagraphs(ParagraphList &);
123 void addPreview(graphics::PreviewLoader &) const;
126 void edit(Cursor & cur, bool front, EntryDirection entry_from);
128 Inset * editXY(Cursor & cur, int x, int y);
130 /// number of cells in this inset
131 size_t nargs() const { return 1; }
133 ParagraphList & paragraphs();
135 ParagraphList const & paragraphs() const;
137 bool insetAllowed(InsetCode) const { return true; }
138 /// Allow spellchecking, except for insets with latex_language
139 bool allowSpellCheck() const { return !forceLTR(); }
141 virtual bool isMacroScope() const { return false; }
143 virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
145 /// Update the counters of this inset and of its contents
146 virtual void updateLabels(ParIterator const &);
148 void addToToc(DocIterator const &);
150 Inset * clone() const { return new InsetText(*this); }
152 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
155 bool completionSupported(Cursor const &) const;
157 bool inlineCompletionSupported(Cursor const & cur) const;
159 bool automaticInlineCompletion() const;
161 bool automaticPopupCompletion() const;
163 bool showCompletionCursor() const;
165 CompletionList const * createCompletionList(Cursor const & cur) const;
167 docstring completionPrefix(Cursor const & cur) const;
169 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
171 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
174 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
176 void doDispatch(Cursor & cur, FuncRequest & cmd);
179 InsetCaption const * getCaptionInset() const;
181 docstring getCaptionText(OutputParams const &) const;
183 docstring getCaptionHTML(OutputParams const &) const;
186 void initParagraphs(UsePlain type);
188 void setParagraphOwner();
192 ColorCode frame_color_;
194 mutable pit_type old_pit;