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"
21 #include "support/types.h"
23 #include "frontends/mouse_state.h"
37 A text inset is like a TeX box to write full text
38 (including styles and other insets) in a given space.
41 class InsetText : public UpdatableInset {
53 explicit InsetText(BufferParams const &);
55 InsetText(InsetText const &);
57 virtual std::auto_ptr<InsetBase> clone() const;
59 void operator=(InsetText const & it);
60 /// empty inset to empty par, or just mark as erased
61 void clear(bool just_mark_erased);
63 void read(Buffer const & buf, LyXLex & lex);
65 void write(Buffer const & buf, std::ostream & os) const;
67 void metrics(MetricsInfo & mi, Dimension & dim) const;
69 void draw(PainterInfo & pi, int x, int y) const;
70 /// draw inset selection
71 void drawSelection(PainterInfo & pi, int x, int y) const;
73 std::string const editMessage() const;
75 bool isTextInset() const { return true; }
77 int latex(Buffer const &, std::ostream &,
78 OutputParams const &) const;
80 int plaintext(Buffer const &, std::ostream &,
81 OutputParams const &) const;
83 int linuxdoc(Buffer const &, std::ostream &,
84 OutputParams const &) const ;
86 int docbook(Buffer const &, std::ostream &,
87 OutputParams const &) const ;
89 void validate(LaTeXFeatures & features) const;
91 InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
93 void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
95 bool insetAllowed(InsetOld::Code) const;
97 void setFont(BufferView *, LyXFont const &,
98 bool toggleall = false,
99 bool selectall = false);
101 void setText(std::string const &, LyXFont const &);
103 void setAutoBreakRows(bool);
105 bool getAutoBreakRows() const { return autoBreakRows_; }
107 void setDrawFrame(DrawFrame);
109 LColor_color frameColor() const;
111 void setFrameColor(LColor_color);
113 void setViewCache(BufferView const * bv) const;
115 bool showInsetDialog(BufferView *) const;
116 /// Appends \c list with all labels found within this inset.
117 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
119 int scroll(bool recursive = true) const;
121 void scroll(BufferView & bv, float sx) const {
122 UpdatableInset::scroll(bv, sx);
125 void scroll(BufferView & bv, int offset) const {
126 UpdatableInset::scroll(bv, offset);
129 LyXText * getText(int) const;
131 /// mark as erased for change tracking
132 void markErased() { clear(true); };
134 * Mark as new. Used when pasting in tabular, and adding rows
135 * or columns. Note that pasting will ensure that tracking already
136 * happens, and this just resets the changes for the copied text,
137 * whereas for row/col add, we need to start tracking changes
138 * for the (empty) paragraph contained.
140 void markNew(bool track_changes = false);
142 /// append text onto the existing text
143 void appendParagraphs(Buffer * bp, ParagraphList &);
146 void addPreview(lyx::graphics::PreviewLoader &) const;
149 void edit(LCursor & cur, bool);
151 void edit(LCursor & cur, int, int);
154 int numParagraphs() const { return 1; }
156 ParagraphList & paragraphs() const;
160 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
162 void updateLocal(LCursor &);
165 // If the inset is empty set the language of the current font to the
166 // language to the surronding text (if different).
167 void sanitizeEmptyText(BufferView &);
169 void setCharFont(Buffer const &, int pos, LyXFont const & font);
171 void removeNewlines();
173 void drawFrame(Painter &, int x) const;
175 void clearInset(Painter &, int x, int y) const;
177 /* Private structures and variables */
181 DrawFrame drawFrame_;
182 /** We store the LColor::color value as an int to get LColor.h out
183 * of the header file.
187 mutable lyx::paroffset_type old_par;
189 /** to remember old painted frame dimensions to clear it on
192 mutable bool in_insetAllowed;
195 mutable LyXText text_;
197 mutable LyXFont font_;