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 "ParagraphList_fwd.h"
17 #include "RowList_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 UpdatableInset {
52 explicit InsetText(BufferParams const &);
54 InsetText(InsetText const &);
56 virtual std::auto_ptr<InsetBase> clone() const;
58 void operator=(InsetText const & it);
59 /// empty inset to empty par, or just mark as erased
60 void clear(bool just_mark_erased);
62 void read(Buffer const & buf, LyXLex & lex);
64 void write(Buffer const & buf, std::ostream & os) const;
66 void metrics(MetricsInfo & mi, Dimension & dim) const;
68 void draw(PainterInfo & pi, int x, int y) const;
69 /// draw inset selection
70 void drawSelection(PainterInfo & pi, int x, int y) const;
72 std::string const editMessage() const;
74 bool isTextInset() const { return true; }
76 int latex(Buffer const &, std::ostream &,
77 OutputParams const &) const;
79 int plaintext(Buffer const &, std::ostream &,
80 OutputParams const &) const;
82 int linuxdoc(Buffer const &, std::ostream &,
83 OutputParams const &) const ;
85 int docbook(Buffer const &, std::ostream &,
86 OutputParams const &) const ;
88 void validate(LaTeXFeatures & features) const;
90 InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
92 void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
94 bool insetAllowed(InsetOld::Code) const;
96 void setFont(BufferView *, LyXFont const &,
97 bool toggleall = false,
98 bool selectall = false);
100 void setText(std::string const &, LyXFont const &);
102 void setAutoBreakRows(bool);
104 bool getAutoBreakRows() const { return autoBreakRows_; }
106 void setDrawFrame(DrawFrame);
108 LColor_color frameColor() const;
110 void setFrameColor(LColor_color);
112 void setViewCache(BufferView const * bv) const;
114 bool showInsetDialog(BufferView *) const;
115 /// Appends \c list with all labels found within this inset.
116 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
118 int scroll(bool recursive = true) const;
120 void scroll(BufferView & bv, float sx) const {
121 UpdatableInset::scroll(bv, sx);
124 void scroll(BufferView & bv, int offset) const {
125 UpdatableInset::scroll(bv, offset);
128 LyXText * getText(int) const;
130 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
132 /// mark as erased for change tracking
133 void markErased() { clear(true); };
135 * Mark as new. Used when pasting in tabular, and adding rows
136 * or columns. Note that pasting will ensure that tracking already
137 * happens, and this just resets the changes for the copied text,
138 * whereas for row/col add, we need to start tracking changes
139 * for the (empty) paragraph contained.
141 void markNew(bool track_changes = false);
143 /// append text onto the existing text
144 void appendParagraphs(Buffer * bp, ParagraphList &);
147 void addPreview(lyx::graphics::PreviewLoader &) const;
150 void edit(LCursor & cur, bool left);
152 InsetBase * editXY(LCursor & cur, int x, int y);
154 /// number of cells in this inset
155 size_t nargs() const { return 1; }
157 ParagraphList & paragraphs() const;
161 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
163 void updateLocal(LCursor &);
166 // If the inset is empty set the language of the current font to the
167 // language to the surronding text (if different).
168 void sanitizeEmptyText(BufferView &);
170 void setCharFont(Buffer const &, int pos, LyXFont const & font);
172 void removeNewlines();
174 void drawFrame(Painter &, int x, int y) const;
176 void clearInset(Painter &, int x, int y) const;
181 DrawFrame drawFrame_;
182 /** We store the LColor::color value as an int to get LColor.h out
183 * of the header file.
187 mutable lyx::paroffset_type old_par;
189 /** to remember old painted frame dimensions to clear it on
192 mutable bool in_insetAllowed;
195 mutable LyXText text_;
197 mutable LyXFont font_;