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"
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.
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 &, LyXLex &);
64 void write(Buffer const &, std::ostream &) const;
66 void metrics(MetricsInfo &, Dimension &) const;
68 void draw(PainterInfo & pi, int x, int y) const;
70 std::string const editMessage() const;
72 bool isTextInset() const { return true; }
74 int latex(Buffer const &, std::ostream &,
75 OutputParams const &) const;
77 int plaintext(Buffer const &, std::ostream &,
78 OutputParams const &) const;
80 int linuxdoc(Buffer const &, std::ostream &,
81 OutputParams const &) const ;
83 int docbook(Buffer const &, std::ostream &,
84 OutputParams const &) const ;
86 void validate(LaTeXFeatures & features) const;
88 InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
90 void getCursorPos(int & x, int & y) const;
92 int insetInInsetY() const;
94 bool insertInset(BufferView *, InsetOld *);
96 bool insetAllowed(InsetOld::Code) const;
98 void setFont(BufferView *, LyXFont const &,
99 bool toggleall = false,
100 bool selectall = false);
102 void writeParagraphData(Buffer const &, std::ostream &) const;
104 void setText(std::string const &, LyXFont const &);
106 void setAutoBreakRows(bool);
108 bool getAutoBreakRows() const { return autoBreakRows_; }
110 void setDrawFrame(DrawFrame);
112 LColor_color frameColor() const;
114 void setFrameColor(LColor_color);
116 void setViewCache(BufferView const * bv) const;
118 bool showInsetDialog(BufferView *) const;
119 /// Appends \c list with all labels found within this inset.
120 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
122 int scroll(bool recursive = true) const;
124 void scroll(BufferView * bv, float sx) const {
125 UpdatableInset::scroll(bv, sx);
128 void scroll(BufferView * bv, int offset) const {
129 UpdatableInset::scroll(bv, offset);
132 void clearSelection(BufferView * bv);
134 ParagraphList * getParagraphs(int) const;
136 LyXText * getText(int) const;
138 /// mark as erased for change tracking
139 void markErased() { clear(true); };
141 * Mark as new. Used when pasting in tabular, and adding rows
142 * or columns. Note that pasting will ensure that tracking already
143 * happens, and this just resets the changes for the copied text,
144 * whereas for row/col add, we need to start tracking changes
145 * for the (empty) paragraph contained.
147 void markNew(bool track_changes = false);
150 bool checkInsertChar(LyXFont &);
152 void getDrawFont(LyXFont &) const;
153 /// append text onto the existing text
154 void appendParagraphs(Buffer * bp, ParagraphList &);
157 void addPreview(lyx::graphics::PreviewLoader &) const;
160 void edit(BufferView *, bool);
162 void edit(BufferView *, int, int);
165 int numParagraphs() const { return 1; }
167 mutable ParagraphList paragraphs;
171 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
173 void updateLocal(BufferView *, bool mark_dirty);
178 // If the inset is empty set the language of the current font to the
179 // language to the surronding text (if different).
180 void sanitizeEmptyText(BufferView *);
182 void setCharFont(Buffer const &, int pos, LyXFont const & font);
184 void removeNewlines();
186 lyx::pos_type cpos() const;
188 ParagraphList::iterator cpar() const;
190 RowList::iterator crow() const;
192 void drawFrame(Painter &, int x) const;
194 void clearInset(BufferView *, int start_x, int baseline) const;
196 void collapseParagraphs(BufferView *);
198 /* Private structures and variables */
202 DrawFrame drawFrame_;
203 /** We store the LColor::color value as an int to get LColor.h out
204 * of the header file.
210 mutable lyx::paroffset_type old_par;
212 /** to remember old painted frame dimensions to clear it on
215 mutable bool in_insetAllowed;
218 mutable LyXText text_;
220 mutable int textwidth_;