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.
15 #include "updatableinset.h"
16 #include "RowList_fwd.h"
20 #include "support/types.h"
22 #include "frontends/mouse_state.h"
36 A text inset is like a TeX box to write full text
37 (including styles and other insets) in a given space.
39 class InsetText : public UpdatableInset {
42 explicit InsetText(BufferParams const &);
45 /// empty inset to empty par, or just mark as erased
46 void clear(bool just_mark_erased);
48 void read(Buffer const & buf, LyXLex & lex);
50 void write(Buffer const & buf, std::ostream & os) const;
52 void metrics(MetricsInfo & mi, Dimension & dim) const;
54 void draw(PainterInfo & pi, int x, int y) const;
55 /// draw inset selection
56 void drawSelection(PainterInfo & pi, int x, int y) const;
58 std::string const editMessage() const;
60 bool isTextInset() const { return true; }
62 int latex(Buffer const &, std::ostream &,
63 OutputParams const &) const;
65 int plaintext(Buffer const &, std::ostream &,
66 OutputParams const &) const;
68 int linuxdoc(Buffer const &, std::ostream &,
69 OutputParams const &) const;
71 int docbook(Buffer const &, std::ostream &,
72 OutputParams const &) const;
74 void validate(LaTeXFeatures & features) const;
76 Code lyxCode() const { return TEXT_CODE; }
78 void getCursorPos(LCursor const & cur, int & x, int & y) const;
80 void setFont(BufferView *, LyXFont const &,
81 bool toggleall = false,
82 bool selectall = false);
84 void setText(std::string const &, LyXFont const &);
86 void setAutoBreakRows(bool);
88 bool getAutoBreakRows() const { return autoBreakRows_; }
90 void setDrawFrame(bool);
92 LColor_color frameColor() const;
94 void setFrameColor(LColor_color);
96 void setViewCache(BufferView const * bv) const;
98 bool showInsetDialog(BufferView *) const;
99 /// Appends \c list with all labels found within this inset.
100 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
102 LyXText * getText(int) const;
104 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
106 /// mark as erased for change tracking
107 void markErased() { clear(true); }
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) const;
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; }
140 InsetText(InsetText const &);
142 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
144 virtual std::auto_ptr<InsetBase> doClone() const;
147 void updateLocal(LCursor &);
151 void setCharFont(Buffer const &, int pos, LyXFont const & font);
153 void removeNewlines();
155 void drawFrame(Painter &, int x, int y) const;
157 void clearInset(Painter &, int x, int y) const;
163 /** We store the LColor::color value as an int to get LColor.h out
164 * of the header file.
168 mutable lyx::par_type old_par;
171 mutable LyXText text_;
173 mutable LyXFont font_;