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 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(BufferView *, int & x, int & y) const;
94 int insetInInsetY() const;
96 void fitInsetCursor(BufferView *) const;
98 bool insertInset(BufferView *, InsetOld *);
100 bool insetAllowed(InsetOld::Code) const;
102 void setFont(BufferView *, LyXFont const &,
103 bool toggleall = false,
104 bool selectall = false);
106 void writeParagraphData(Buffer const &, std::ostream &) const;
108 void setText(std::string const &, LyXFont const &);
110 void setAutoBreakRows(bool);
112 bool getAutoBreakRows() const { return autoBreakRows_; }
114 void setDrawFrame(DrawFrame);
116 LColor_color frameColor() const;
118 void setFrameColor(LColor_color);
120 void setViewCache(BufferView const * bv) const;
122 void deleteLyXText(BufferView *) const;
124 bool showInsetDialog(BufferView *) const;
125 /// Appends \c list with all labels found within this inset.
126 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
128 int scroll(bool recursive = true) const;
130 void scroll(BufferView * bv, float sx) const {
131 UpdatableInset::scroll(bv, sx);
134 void scroll(BufferView * bv, int offset) const {
135 UpdatableInset::scroll(bv, offset);
138 void clearSelection(BufferView * bv);
140 ParagraphList * getParagraphs(int) const;
142 LyXText * getText(int) const;
144 /// mark as erased for change tracking
145 void markErased() { clear(true); };
147 * Mark as new. Used when pasting in tabular, and adding rows
148 * or columns. Note that pasting will ensure that tracking already
149 * happens, and this just resets the changes for the copied text,
150 * whereas for row/col add, we need to start tracking changes
151 * for the (empty) paragraph contained.
153 void markNew(bool track_changes = false);
156 bool checkInsertChar(LyXFont &);
158 void getDrawFont(LyXFont &) const;
159 /// append text onto the existing text
160 void appendParagraphs(Buffer * bp, ParagraphList &);
163 void addPreview(lyx::graphics::PreviewLoader &) const;
166 void edit(BufferView *, bool);
168 void edit(BufferView *, int, int);
171 int numParagraphs() const { return 1; }
173 mutable ParagraphList paragraphs;
177 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
179 void updateLocal(BufferView *, bool mark_dirty);
185 void lfunMousePress(FuncRequest const &);
187 void lfunMouseMotion(FuncRequest const &);
189 void lfunMouseRelease(FuncRequest const &);
190 // If the inset is empty set the language of the current font to the
191 // language to the surronding text (if different).
192 void sanitizeEmptyText(BufferView *);
195 DispatchResult moveRight(BufferView *);
197 DispatchResult moveLeft(BufferView *);
199 DispatchResult moveRightIntern(BufferView *, bool front,
200 bool activate_inset = true,
201 bool selecting = false);
203 DispatchResult moveLeftIntern(BufferView *, bool front,
204 bool activate_inset = true,
205 bool selecting = false);
208 DispatchResult moveUp(BufferView *);
210 DispatchResult moveDown(BufferView *);
212 void setCharFont(Buffer const &, int pos, LyXFont const & font);
214 bool checkAndActivateInset(BufferView * bv, bool front);
216 bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0);
218 void removeNewlines();
224 lyx::pos_type cpos() const;
226 ParagraphList::iterator cpar() const;
228 RowList::iterator crow() const;
230 void drawFrame(Painter &, int x) const;
232 void clearInset(BufferView *, int start_x, int baseline) const;
234 void collapseParagraphs(BufferView *);
236 /* Private structures and variables */
240 DrawFrame drawFrame_;
241 /** We store the LColor::color value as an int to get LColor.h out
242 * of the header file.
248 mutable lyx::paroffset_type old_par;
251 // to remember old painted frame dimensions to clear it on the right spot!
253 mutable bool in_insetAllowed;
255 // these are used to check for mouse movement in Motion selection code
261 mutable LyXText text_;
263 mutable int textwidth_;