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