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 int textWidth() const;
70 void draw(PainterInfo & pi, int x, int y) const;
72 std::string const editMessage() const;
74 bool isTextInset() const { return true; }
76 void insetUnlock(BufferView *);
78 bool lockInsetInInset(BufferView *, UpdatableInset *);
80 bool unlockInsetInInset(BufferView *,
81 UpdatableInset *, bool lr = false);
83 int latex(Buffer const &, std::ostream &,
84 OutputParams const &) const;
86 int plaintext(Buffer const &, std::ostream &,
87 OutputParams const &) const;
89 int linuxdoc(Buffer const &, std::ostream &,
90 OutputParams const &) const ;
92 int docbook(Buffer const &, std::ostream &,
93 OutputParams const &) const ;
95 void validate(LaTeXFeatures & features) const;
97 InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
99 void getCursorPos(BufferView *, int & x, int & y) const;
100 /// Get the absolute document x,y of the cursor
101 virtual void getCursor(BufferView &, int &, int &) const;
103 int insetInInsetY() const;
105 void fitInsetCursor(BufferView *) const;
107 bool insertInset(BufferView *, InsetOld *);
109 bool insetAllowed(InsetOld::Code) const;
111 UpdatableInset * getLockingInset() const;
113 UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
115 void setFont(BufferView *, LyXFont const &,
116 bool toggleall = false,
117 bool selectall = false);
119 void writeParagraphData(Buffer const &, std::ostream &) const;
121 void setText(std::string const &, LyXFont const &);
123 void setAutoBreakRows(bool);
125 bool getAutoBreakRows() const { return autoBreakRows_; }
127 void setDrawFrame(DrawFrame);
129 LColor_color frameColor() const;
130 void setFrameColor(LColor_color);
132 LyXText * getLyXText(BufferView const *,
133 bool const recursive = false) const;
135 void setViewCache(BufferView const * bv) const;
137 void deleteLyXText(BufferView *, bool recursive = true) const;
139 bool showInsetDialog(BufferView *) const;
140 /// Appends \c list with all labels found within this inset.
141 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
143 int scroll(bool recursive = true) const;
145 void scroll(BufferView * bv, float sx) const {
146 UpdatableInset::scroll(bv, sx);
149 void scroll(BufferView * bv, int offset) const {
150 UpdatableInset::scroll(bv, offset);
153 void clearSelection(BufferView * bv);
155 ParagraphList * getParagraphs(int) const;
157 LyXText * getText(int) const;
159 LyXCursor const & cursor(BufferView *) const;
161 /// mark as erased for change tracking
162 void markErased() { clear(true); };
164 * Mark as new. Used when pasting in tabular, and adding rows
165 * or columns. Note that pasting will ensure that tracking already
166 * happens, and this just resets the changes for the copied text,
167 * whereas for row/col add, we need to start tracking changes
168 * for the (empty) paragraph contained.
170 void markNew(bool track_changes = false);
173 bool checkInsertChar(LyXFont &);
175 void getDrawFont(LyXFont &) const;
176 /// append text onto the existing text
177 void appendParagraphs(Buffer * bp, ParagraphList &);
180 void addPreview(lyx::graphics::PreviewLoader &) const;
183 void edit(BufferView *, bool);
185 void edit(BufferView *, int, int);
187 UpdatableInset * lockingInset() const { return the_locking_inset; }
190 int numParagraphs() const { return 1; }
192 mutable ParagraphList paragraphs;
197 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
199 void updateLocal(BufferView *, bool mark_dirty);
200 /// set parameters for an initial lock of this inset
201 void lockInset(BufferView *);
202 /// lock an inset inside this one
203 void lockInset(BufferView *, UpdatableInset *);
209 void lfunMousePress(FuncRequest const &);
211 bool lfunMouseRelease(FuncRequest const &);
213 void lfunMouseMotion(FuncRequest const &);
216 DispatchResult moveRight(BufferView *);
218 DispatchResult moveLeft(BufferView *);
220 DispatchResult moveRightIntern(BufferView *, bool front,
221 bool activate_inset = true,
222 bool selecting = false);
224 DispatchResult moveLeftIntern(BufferView *, bool front,
225 bool activate_inset = true,
226 bool selecting = false);
229 DispatchResult moveUp(BufferView *);
231 DispatchResult moveDown(BufferView *);
233 void setCharFont(Buffer const &, int pos, LyXFont const & font);
235 bool checkAndActivateInset(BufferView * bv, bool front);
237 bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0);
239 void removeNewlines();
245 lyx::pos_type cpos() const;
247 ParagraphList::iterator cpar() const;
249 bool cboundary() const;
251 RowList::iterator crow() const;
253 void drawFrame(Painter &, int x) const;
255 void clearInset(BufferView *, int start_x, int baseline) const;
257 void collapseParagraphs(BufferView *);
259 /* Private structures and variables */
263 DrawFrame drawFrame_;
264 /** We store the LColor::color value as an int to get LColor.h out
265 * of the header file.
279 UpdatableInset * the_locking_inset;
281 mutable lyx::paroffset_type old_par;
284 // to remember old painted frame dimensions to clear it on the right spot!
286 mutable bool in_insetAllowed;
288 // these are used to check for mouse movement in Motion selection code
294 mutable LyXText text_;
296 mutable int textwidth_;