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