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 /// mark as erased for change tracking
131 void markErased() { clear(true); };
133 * Mark as new. Used when pasting in tabular, and adding rows
134 * or columns. Note that pasting will ensure that tracking already
135 * happens, and this just resets the changes for the copied text,
136 * whereas for row/col add, we need to start tracking changes
137 * for the (empty) paragraph contained.
139 void markNew(bool track_changes = false);
141 /// append text onto the existing text
142 void appendParagraphs(Buffer * bp, ParagraphList &);
145 void addPreview(lyx::graphics::PreviewLoader &) const;
148 void edit(LCursor & cur, bool left);
150 InsetBase * editXY(LCursor & cur, int x, int y);
152 /// number of cells in this inset
153 size_t nargs() const { return 1; }
155 ParagraphList & paragraphs() const;
159 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
161 void updateLocal(LCursor &);
164 // If the inset is empty set the language of the current font to the
165 // language to the surronding text (if different).
166 void sanitizeEmptyText(BufferView &);
168 void setCharFont(Buffer const &, int pos, LyXFont const & font);
170 void removeNewlines();
172 void drawFrame(Painter &, int x, int y) const;
174 void clearInset(Painter &, int x, int y) const;
179 DrawFrame drawFrame_;
180 /** We store the LColor::color value as an int to get LColor.h out
181 * of the header file.
185 mutable lyx::paroffset_type old_par;
187 /** to remember old painted frame dimensions to clear it on
190 mutable bool in_insetAllowed;
193 mutable LyXText text_;
195 mutable LyXFont font_;