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"
20 #include "support/types.h"
22 #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 std::string const editMessage() const;
58 EDITABLE editable() const { return HIGHLY_EDITABLE; }
60 bool canTrackChanges() const { return true; }
62 InsetText * asTextInset() const { return const_cast<InsetText *>(this); }
64 int latex(Buffer const &, std::ostream &,
65 OutputParams const &) const;
67 int plaintext(Buffer const &, std::ostream &,
68 OutputParams const &) const;
70 int linuxdoc(Buffer const &, std::ostream &,
71 OutputParams const &) const;
73 int docbook(Buffer const &, std::ostream &,
74 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(CursorSlice const & sl, bool boundary, int & x, int & y) const;
81 Code lyxCode() const { return TEXT_CODE; }
83 void setText(std::string const &, LyXFont const &);
85 void setAutoBreakRows(bool);
87 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
89 void setDrawFrame(bool);
91 LColor_color frameColor() const;
93 void setFrameColor(LColor_color);
95 void setViewCache(BufferView const * bv) const;
97 bool showInsetDialog(BufferView *) const;
99 LyXText * getText(int i) const {
100 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
103 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
105 /// mark as erased for change tracking
106 void markErased(bool erased);
109 * Mark as new. Used when pasting in tabular, and adding rows
110 * or columns. Note that pasting will ensure that tracking already
111 * happens, and this just resets the changes for the copied text,
112 * whereas for row/col add, we need to start tracking changes
113 * for the (empty) paragraph contained.
115 void markNew(bool track_changes = false);
117 /// append text onto the existing text
118 void appendParagraphs(Buffer * bp, ParagraphList &);
121 void addPreview(lyx::graphics::PreviewLoader &) const;
124 void edit(LCursor & cur, bool left);
126 InsetBase * editXY(LCursor & cur, int x, int y);
128 /// number of cells in this inset
129 size_t nargs() const { return 1; }
131 ParagraphList & paragraphs();
133 ParagraphList const & paragraphs() const;
135 bool insetAllowed(Code) const { return true; }
137 bool allowSpellCheck() const { return true; }
138 /// should paragraph indendation be ommitted in any case?
139 bool neverIndent() const;
141 InsetText(InsetText const &);
143 bool & Wide() const { return wide_inset_; }
145 bool const Tall() const;
149 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
153 virtual std::auto_ptr<InsetBase> doClone() const;
159 /** We store the LColor::color value as an int to get LColor.h out
160 * of the header file.
164 mutable lyx::pit_type old_pit;
168 mutable bool wide_inset_;
171 mutable LyXText text_;
173 mutable LyXFont font_;