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"
21 #include "frontends/mouse_state.h"
37 A text inset is like a TeX box to write full text
38 (including styles and other insets) in a given space.
40 class InsetText : public Inset {
43 explicit InsetText(BufferParams 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 bool metrics(MetricsInfo & mi, Dimension & dim) const;
56 void draw(PainterInfo & pi, int x, int y) const;
57 /// draw inset selection
58 void drawSelection(PainterInfo & pi, int x, int y) const;
60 virtual docstring const editMessage() const;
62 EDITABLE editable() const { return HIGHLY_EDITABLE; }
64 bool canTrackChanges() const { return true; }
66 InsetText * asTextInset() { return this; }
68 InsetText const * asTextInset() const { return this; }
70 int latex(Buffer const &, odocstream &, OutputParams const &) const;
72 int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
74 int docbook(Buffer const &, 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 Code 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 Color_color frameColor() const;
94 void setFrameColor(Color_color);
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(Buffer * bp, ParagraphList &);
115 void addPreview(graphics::PreviewLoader &) const;
118 void edit(Cursor & cur, bool left);
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(Code) const { return true; }
131 bool allowSpellCheck() const { return true; }
132 /// should paragraph indendation be ommitted in any case?
133 bool neverIndent(Buffer const &) const;
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;