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.
16 #include "RowList_fwd.h"
19 #include "ParagraphList_fwd.h"
21 #include "support/types.h"
23 #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 InsetOld {
43 explicit InsetText(BufferParams const &);
47 virtual ~InsetText() {}
49 /// empty inset to empty par
52 void read(Buffer const & buf, LyXLex & lex);
54 void write(Buffer const & buf, std::ostream & os) const;
56 bool metrics(MetricsInfo & mi, Dimension & dim) const;
58 void draw(PainterInfo & pi, int x, int y) const;
59 /// draw inset selection
60 void drawSelection(PainterInfo & pi, int x, int y) const;
61 /// are we inside the area covered by the inset?
62 virtual bool covers(BufferView const & bv, int x, int y) const;
64 virtual docstring const editMessage() const;
66 EDITABLE editable() const { return HIGHLY_EDITABLE; }
68 bool canTrackChanges() const { return true; }
70 InsetText const * asTextInset() const { return this; }
72 int latex(Buffer const &, odocstream &, OutputParams const &) const;
74 int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
76 int docbook(Buffer const &, odocstream &, OutputParams const &) const;
78 void validate(LaTeXFeatures & features) const;
80 /// return x,y of given position relative to the inset's baseline
81 void cursorPos(BufferView const & bv, CursorSlice const & sl,
82 bool boundary, int & x, int & y) const;
84 Code lyxCode() const { return TEXT_CODE; }
86 void setText(docstring const &, LyXFont const &, bool trackChanges);
88 void setAutoBreakRows(bool);
90 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
92 void setDrawFrame(bool);
94 LColor_color frameColor() const;
96 void setFrameColor(LColor_color);
98 bool showInsetDialog(BufferView *) const;
100 LyXText * getText(int i) const {
101 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
104 virtual bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
106 /// set the change for the entire inset
107 void setChange(Change const & change);
108 /// accept the changes within the inset
109 void acceptChanges(BufferParams const & bparams);
110 /// reject the changes within the inset
111 void rejectChanges(BufferParams const & bparams);
113 /// append text onto the existing text
114 void appendParagraphs(Buffer * bp, ParagraphList &);
117 void addPreview(graphics::PreviewLoader &) const;
120 void edit(LCursor & cur, bool left);
122 InsetBase * editXY(LCursor & cur, int x, int y);
124 /// number of cells in this inset
125 size_t nargs() const { return 1; }
127 ParagraphList & paragraphs();
129 ParagraphList const & paragraphs() const;
131 bool insetAllowed(Code) const { return true; }
133 bool allowSpellCheck() const { return true; }
134 /// should paragraph indendation be ommitted in any case?
135 bool neverIndent(Buffer const &) const;
137 InsetText(InsetText const &);
139 virtual bool wide() const { return wide_inset_; }
141 void setWide(bool wide_inset) { wide_inset_ = wide_inset; }
145 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
149 virtual std::auto_ptr<InsetBase> doClone() const;
155 /** We store the LColor::color value as an int to get LColor.h out
156 * of the header file.
160 mutable pit_type old_pit;
167 mutable LyXText text_;
169 mutable LyXFont font_;