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"
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 InsetOld {
40 explicit InsetText(BufferParams const &);
43 /// empty inset to empty par
46 void read(Buffer const & buf, LyXLex & lex);
48 void write(Buffer const & buf, std::ostream & os) const;
50 void metrics(MetricsInfo & mi, Dimension & dim) const;
52 void draw(PainterInfo & pi, int x, int y) const;
53 /// draw inset selection
54 void drawSelection(PainterInfo & pi, int x, int y) const;
56 virtual lyx::docstring const editMessage() const;
58 EDITABLE editable() const { return HIGHLY_EDITABLE; }
60 bool canTrackChanges() const { return true; }
62 InsetText const * asTextInset() const { return this; }
64 int latex(Buffer const &, std::ostream &,
65 OutputParams const &) const;
67 int plaintext(Buffer const &, lyx::odocstream &,
68 OutputParams const &) const;
70 int docbook(Buffer const &, std::ostream &,
71 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(CursorSlice const & sl, bool boundary, int & x, int & y) const;
78 Code lyxCode() const { return TEXT_CODE; }
80 void setText(lyx::docstring const &, LyXFont const &);
82 void setAutoBreakRows(bool);
84 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
86 void setDrawFrame(bool);
88 LColor_color frameColor() const;
90 void setFrameColor(LColor_color);
92 void setViewCache(BufferView const * bv) const;
94 bool showInsetDialog(BufferView *) const;
96 LyXText * getText(int i) const {
97 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
100 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
102 /// mark as erased for change tracking
103 void markErased(bool erased);
106 * Mark as new. Used when pasting in tabular, and adding rows
107 * or columns. Note that pasting will ensure that tracking already
108 * happens, and this just resets the changes for the copied text,
109 * whereas for row/col add, we need to start tracking changes
110 * for the (empty) paragraph contained.
112 void markNew(bool track_changes = false);
114 /// append text onto the existing text
115 void appendParagraphs(Buffer * bp, ParagraphList &);
118 void addPreview(lyx::graphics::PreviewLoader &) const;
121 void edit(LCursor & cur, bool left);
123 InsetBase * editXY(LCursor & cur, int x, int y);
125 /// number of cells in this inset
126 size_t nargs() const { return 1; }
128 ParagraphList & paragraphs();
130 ParagraphList const & paragraphs() const;
132 bool insetAllowed(Code) const { return true; }
134 bool allowSpellCheck() const { return true; }
135 /// should paragraph indendation be ommitted in any case?
136 bool neverIndent() const;
138 InsetText(InsetText const &);
140 bool & Wide() const { return wide_inset_; }
144 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
148 virtual std::auto_ptr<InsetBase> doClone() const;
154 /** We store the LColor::color value as an int to get LColor.h out
155 * of the header file.
159 mutable lyx::pit_type old_pit;
163 mutable bool wide_inset_;
166 mutable LyXText text_;
168 mutable LyXFont font_;