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 & 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;
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 bool insertInset(BufferView *, InsetOld *);
94 bool insetAllowed(InsetOld::Code) const;
96 void setFont(BufferView *, LyXFont const &,
97 bool toggleall = false,
98 bool selectall = false);
100 void writeParagraphData(Buffer const &, std::ostream &) const;
102 void setText(std::string const &, LyXFont const &);
104 void setAutoBreakRows(bool);
106 bool getAutoBreakRows() const { return autoBreakRows_; }
108 void setDrawFrame(DrawFrame);
110 LColor_color frameColor() const;
112 void setFrameColor(LColor_color);
114 void setViewCache(BufferView const * bv) const;
116 bool showInsetDialog(BufferView *) const;
117 /// Appends \c list with all labels found within this inset.
118 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
120 int scroll(bool recursive = true) const;
122 void scroll(BufferView * bv, float sx) const {
123 UpdatableInset::scroll(bv, sx);
126 void scroll(BufferView * bv, int offset) const {
127 UpdatableInset::scroll(bv, offset);
130 ParagraphList * getParagraphs(int) const;
132 LyXText * getText(int) const;
134 /// mark as erased for change tracking
135 void markErased() { clear(true); };
137 * Mark as new. Used when pasting in tabular, and adding rows
138 * or columns. Note that pasting will ensure that tracking already
139 * happens, and this just resets the changes for the copied text,
140 * whereas for row/col add, we need to start tracking changes
141 * for the (empty) paragraph contained.
143 void markNew(bool track_changes = false);
146 void getDrawFont(LyXFont &) const;
147 /// append text onto the existing text
148 void appendParagraphs(Buffer * bp, ParagraphList &);
151 void addPreview(lyx::graphics::PreviewLoader &) const;
154 void edit(BufferView *, bool);
156 void edit(BufferView *, int, int);
159 int numParagraphs() const { return 1; }
161 ParagraphList & paragraphs() const;
166 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
168 void updateLocal(BufferView *);
171 // If the inset is empty set the language of the current font to the
172 // language to the surronding text (if different).
173 void sanitizeEmptyText(BufferView *);
175 void setCharFont(Buffer const &, int pos, LyXFont const & font);
177 void removeNewlines();
179 void drawFrame(Painter &, int x) const;
181 void clearInset(Painter &, int x, int y) const;
183 void collapseParagraphs(BufferView *);
185 /* Private structures and variables */
189 DrawFrame drawFrame_;
190 /** We store the LColor::color value as an int to get LColor.h out
191 * of the header file.
195 mutable lyx::paroffset_type old_par;
197 /** to remember old painted frame dimensions to clear it on
200 mutable bool in_insetAllowed;
203 mutable LyXText text_;