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"
33 A text inset is like a TeX box to write full text
34 (including styles and other insets) in a given space.
36 class InsetText : public Inset {
43 /// \param useplain whether to use the plain layout
44 /// This is needed because we cannot call the virtual function
45 /// usePlainLayout() from within the constructor.
46 explicit InsetText(Buffer const & buffer, UsePlain type = DefaultLayout);
48 InsetText(InsetText const &);
50 void setBuffer(Buffer &);
53 Dimension const dimension(BufferView const &) const;
55 /// empty inset to empty par
58 void read(Lexer & lex);
60 void write(std::ostream & os) const;
62 void metrics(MetricsInfo & mi, Dimension & dim) const;
64 void draw(PainterInfo & pi, int x, int y) const;
66 docstring editMessage() const;
68 bool editable() const { return true; }
70 bool canTrackChanges() const { return true; }
72 InsetText * asInsetText() { return this; }
74 InsetText const * asInsetText() const { return this; }
76 Text & text() { return text_; }
77 Text const & text() const { return text_; }
79 int latex(odocstream &, OutputParams const &) const;
81 int plaintext(odocstream &, OutputParams const &) const;
83 int docbook(odocstream &, OutputParams const &) const;
85 docstring xhtml(odocstream &, OutputParams const &) const;
87 void validate(LaTeXFeatures & features) const;
89 /// return x,y of given position relative to the inset's baseline
90 void cursorPos(BufferView const & bv, CursorSlice const & sl,
91 bool boundary, int & x, int & y) const;
93 InsetCode lyxCode() const { return TEXT_CODE; }
95 void setText(docstring const &, Font const &, bool trackChanges);
97 void setAutoBreakRows(bool);
99 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
101 void setDrawFrame(bool);
103 ColorCode frameColor() const;
105 void setFrameColor(ColorCode);
107 bool showInsetDialog(BufferView *) const;
109 Text * getText(int i) const {
110 return (i == 0) ? const_cast<Text*>(&text_) : 0;
113 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
115 /// set the change for the entire inset
116 void setChange(Change const & change);
117 /// accept the changes within the inset
118 void acceptChanges(BufferParams const & bparams);
119 /// reject the changes within the inset
120 void rejectChanges(BufferParams const & bparams);
122 /// append text onto the existing text
123 void appendParagraphs(ParagraphList &);
126 void addPreview(graphics::PreviewLoader &) const;
129 void edit(Cursor & cur, bool front, EntryDirection entry_from);
131 Inset * editXY(Cursor & cur, int x, int y);
133 /// number of cells in this inset
134 size_t nargs() const { return 1; }
136 ParagraphList & paragraphs();
138 ParagraphList const & paragraphs() const;
140 bool insetAllowed(InsetCode) const { return true; }
142 bool allowSpellCheck() const { return true; }
144 virtual bool isMacroScope() const { return false; }
146 virtual bool allowMultiPar() const { return true; }
148 /// Update the counters of this inset and of its contents
149 virtual void updateLabels(ParIterator const &);
151 void addToToc(DocIterator const &);
153 Inset * clone() const { return new InsetText(*this); }
155 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
158 bool completionSupported(Cursor const &) const;
160 bool inlineCompletionSupported(Cursor const & cur) const;
162 bool automaticInlineCompletion() const;
164 bool automaticPopupCompletion() const;
166 bool showCompletionCursor() const;
168 CompletionList const * createCompletionList(Cursor const & cur) const;
170 docstring completionPrefix(Cursor const & cur) const;
172 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
174 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
177 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
179 void doDispatch(Cursor & cur, FuncRequest & cmd);
182 InsetCaption const * getCaptionInset() const;
184 docstring getCaptionText(OutputParams const &) const;
186 docstring getCaptionHTML(OutputParams const &) const;
189 void initParagraphs(UsePlain type);
191 void setParagraphOwner();
195 ColorCode frame_color_;
197 mutable pit_type old_pit;