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