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"
34 A text inset is like a TeX box to write full text
35 (including styles and other insets) in a given space.
37 class InsetText : public Inset {
40 explicit InsetText(BufferParams const &);
45 Dimension const dimension(BufferView const &) const;
47 /// empty inset to empty par
50 void read(Buffer const & buf, Lexer & lex);
52 void write(Buffer const & buf, std::ostream & os) const;
54 void metrics(MetricsInfo & mi, Dimension & dim) const;
56 void draw(PainterInfo & pi, int x, int y) const;
58 virtual docstring const editMessage() const;
60 EDITABLE editable() const { return HIGHLY_EDITABLE; }
62 bool canTrackChanges() const { return true; }
64 InsetText * asTextInset() { return this; }
66 InsetText const * asTextInset() const { return this; }
68 int latex(Buffer const &, odocstream &, OutputParams const &) const;
70 int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
72 int docbook(Buffer const &, 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 Color_color frameColor() const;
92 void setFrameColor(Color_color);
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(Buffer * bp, ParagraphList &);
113 void addPreview(graphics::PreviewLoader &) const;
116 void edit(Cursor & cur, bool left);
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; }
130 /// should paragraph indendation be ommitted in any case?
131 bool neverIndent(Buffer const &) const;
133 virtual bool allowMultiPar() const { return true; }
135 InsetText(InsetText const &);
137 // Update the counters of this inset and of its contents
138 virtual void updateLabels(Buffer const &, ParIterator const &);
140 virtual Inset * clone() const;
144 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
152 /** We store the Color::color value as an int to get Color.h out
153 * of the header file.
157 mutable pit_type old_pit;