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.
19 #include "support/types.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 {
39 explicit InsetText(BufferParams const &);
44 Dimension const dimension(BufferView const &) const;
46 /// empty inset to empty par
49 void read(Buffer const & buf, Lexer & lex);
51 void write(Buffer const & buf, std::ostream & os) const;
53 void metrics(MetricsInfo & mi, Dimension & dim) const;
55 void draw(PainterInfo & pi, int x, int y) const;
57 virtual docstring const editMessage() const;
59 EDITABLE editable() const { return HIGHLY_EDITABLE; }
61 bool canTrackChanges() const { return true; }
63 InsetText * asTextInset() { return this; }
65 InsetText const * asTextInset() const { return this; }
67 int latex(Buffer const &, odocstream &, OutputParams const &) const;
69 int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
71 int docbook(Buffer const &, odocstream &, OutputParams const &) const;
73 void validate(LaTeXFeatures & features) const;
75 /// return x,y of given position relative to the inset's baseline
76 void cursorPos(BufferView const & bv, CursorSlice const & sl,
77 bool boundary, int & x, int & y) const;
79 InsetCode lyxCode() const { return TEXT_CODE; }
81 void setText(docstring const &, Font const &, bool trackChanges);
83 void setAutoBreakRows(bool);
85 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
87 void setDrawFrame(bool);
89 ColorCode frameColor() const;
91 void setFrameColor(ColorCode);
93 bool showInsetDialog(BufferView *) const;
95 Text * getText(int i) const {
96 return (i == 0) ? const_cast<Text*>(&text_) : 0;
99 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
101 /// set the change for the entire inset
102 void setChange(Change const & change);
103 /// accept the changes within the inset
104 void acceptChanges(BufferParams const & bparams);
105 /// reject the changes within the inset
106 void rejectChanges(BufferParams const & bparams);
108 /// append text onto the existing text
109 void appendParagraphs(Buffer * bp, ParagraphList &);
112 void addPreview(graphics::PreviewLoader &) const;
115 void edit(Cursor & cur, bool left);
117 Inset * editXY(Cursor & cur, int x, int y);
119 /// number of cells in this inset
120 size_t nargs() const { return 1; }
122 ParagraphList & paragraphs();
124 ParagraphList const & paragraphs() const;
126 bool insetAllowed(InsetCode) const { return true; }
128 bool allowSpellCheck() const { return true; }
129 /// should paragraph indendation be ommitted in any case?
130 bool neverIndent(Buffer const &) const;
132 virtual bool allowMultiPar() const { return true; }
134 InsetText(InsetText const &);
136 // Update the counters of this inset and of its contents
137 virtual void updateLabels(Buffer const &, ParIterator const &);
139 virtual Inset * clone() const;
143 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
151 /** We store the ColorCode value as an int to get Color.h out
152 * of the header file.
156 mutable pit_type old_pit;