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"
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 {
38 explicit InsetText(Buffer const & buffer);
42 InsetText(InsetText const &);
44 void initParagraphs(Buffer const & buffer);
46 void setBuffer(Buffer &);
49 Dimension const dimension(BufferView const &) const;
51 /// empty inset to empty par
54 void read(Lexer & lex);
56 void write(std::ostream & os) const;
58 void metrics(MetricsInfo & mi, Dimension & dim) const;
60 void draw(PainterInfo & pi, int x, int y) const;
62 docstring editMessage() const;
64 EDITABLE editable() const { return HIGHLY_EDITABLE; }
66 bool canTrackChanges() const { return true; }
68 InsetText * asInsetText() { return this; }
70 InsetText const * asInsetText() const { return this; }
72 int latex(odocstream &, OutputParams const &) const;
74 int plaintext(odocstream &, OutputParams const &) const;
76 int docbook(odocstream &, OutputParams const &) const;
78 void validate(LaTeXFeatures & features) const;
80 /// return x,y of given position relative to the inset's baseline
81 void cursorPos(BufferView const & bv, CursorSlice const & sl,
82 bool boundary, int & x, int & y) const;
84 InsetCode lyxCode() const { return TEXT_CODE; }
86 void setText(docstring const &, Font const &, bool trackChanges);
88 void setAutoBreakRows(bool);
90 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
92 void setDrawFrame(bool);
94 ColorCode frameColor() const;
96 void setFrameColor(ColorCode);
98 bool showInsetDialog(BufferView *) const;
100 Text * getText(int i) const {
101 return (i == 0) ? const_cast<Text*>(&text_) : 0;
104 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
106 /// set the change for the entire inset
107 void setChange(Change const & change);
108 /// accept the changes within the inset
109 void acceptChanges(BufferParams const & bparams);
110 /// reject the changes within the inset
111 void rejectChanges(BufferParams const & bparams);
113 /// append text onto the existing text
114 void appendParagraphs(ParagraphList &);
117 void addPreview(graphics::PreviewLoader &) const;
120 void edit(Cursor & cur, bool front, EntryDirection entry_from);
122 Inset * editXY(Cursor & cur, int x, int y);
124 /// number of cells in this inset
125 size_t nargs() const { return 1; }
127 ParagraphList & paragraphs();
129 ParagraphList const & paragraphs() const;
131 bool insetAllowed(InsetCode) const { return true; }
133 bool allowSpellCheck() const { return true; }
135 virtual bool isMacroScope() const { return false; }
137 virtual bool allowMultiPar() const { return true; }
139 // Update the counters of this inset and of its contents
140 void updateLabels(ParIterator const &);
142 void addToToc(DocIterator const &);
144 Inset * clone() const { return new InsetText(*this); }
146 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
149 bool completionSupported(Cursor const &) const;
151 bool inlineCompletionSupported(Cursor const & cur) const;
153 bool automaticInlineCompletion() const;
155 bool automaticPopupCompletion() const;
157 bool showCompletionCursor() const;
159 CompletionList const * createCompletionList(Cursor const & cur) const;
161 docstring completionPrefix(Cursor const & cur) const;
163 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
165 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
168 virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
170 void doDispatch(Cursor & cur, FuncRequest & cmd);
173 void setParagraphOwner();
177 ColorCode frame_color_;
179 mutable pit_type old_pit;