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"
31 A text inset is like a TeX box to write full text
32 (including styles and other insets) in a given space.
34 class InsetText : public Inset {
37 explicit InsetText(Buffer const & buffer);
41 InsetText(InsetText const &);
43 void initParagraphs(Buffer const & buffer);
46 Dimension const dimension(BufferView const &) const;
48 /// empty inset to empty par
51 void read(Lexer & lex);
53 void write(std::ostream & os) const;
55 void metrics(MetricsInfo & mi, Dimension & dim) const;
57 void draw(PainterInfo & pi, int x, int y) const;
59 docstring editMessage() const;
61 EDITABLE editable() const { return HIGHLY_EDITABLE; }
63 bool canTrackChanges() const { return true; }
65 InsetText * asInsetText() { return this; }
67 InsetText const * asInsetText() const { return this; }
69 int latex(odocstream &, OutputParams const &) const;
71 int plaintext(odocstream &, OutputParams const &) const;
73 int docbook(odocstream &, OutputParams const &) const;
75 void validate(LaTeXFeatures & features) const;
77 /// return x,y of given position relative to the inset's baseline
78 void cursorPos(BufferView const & bv, CursorSlice const & sl,
79 bool boundary, int & x, int & y) const;
81 InsetCode lyxCode() const { return TEXT_CODE; }
83 void setText(docstring const &, Font const &, bool trackChanges);
85 void setAutoBreakRows(bool);
87 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
89 void setDrawFrame(bool);
91 ColorCode frameColor() const;
93 void setFrameColor(ColorCode);
95 bool showInsetDialog(BufferView *) const;
97 Text * getText(int i) const {
98 return (i == 0) ? const_cast<Text*>(&text_) : 0;
101 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
103 /// set the change for the entire inset
104 void setChange(Change const & change);
105 /// accept the changes within the inset
106 void acceptChanges(BufferParams const & bparams);
107 /// reject the changes within the inset
108 void rejectChanges(BufferParams const & bparams);
110 /// append text onto the existing text
111 void appendParagraphs(ParagraphList &);
114 void addPreview(graphics::PreviewLoader &) const;
117 void edit(Cursor & cur, bool front, EntryDirection entry_from);
119 Inset * editXY(Cursor & cur, int x, int y);
121 /// number of cells in this inset
122 size_t nargs() const { return 1; }
124 ParagraphList & paragraphs();
126 ParagraphList const & paragraphs() const;
128 bool insetAllowed(InsetCode) const { return true; }
130 bool allowSpellCheck() const { return true; }
131 /// should paragraph indendation be ommitted in any case?
132 bool neverIndent() const;
134 virtual bool isMacroScope() const { return true; }
136 virtual bool allowMultiPar() const { return true; }
138 // Update the counters of this inset and of its contents
139 void updateLabels(ParIterator const &);
141 Inset * clone() const { return new InsetText(*this); }
143 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
146 bool completionSupported(Cursor const &) const;
148 bool inlineCompletionSupported(Cursor const & cur) const;
150 bool automaticInlineCompletion() const;
152 bool automaticPopupCompletion() const;
154 CompletionList const * createCompletionList(Cursor const & cur) const;
156 docstring completionPrefix(Cursor const & cur) const;
158 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
160 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;
175 docstring previousWord(CursorSlice const & sl) const;