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;
71 std::string const editMessage() const;
73 bool isTextInset() const { return true; }
75 int latex(Buffer const &, std::ostream &,
76 OutputParams const &) const;
78 int plaintext(Buffer const &, std::ostream &,
79 OutputParams const &) const;
81 int linuxdoc(Buffer const &, std::ostream &,
82 OutputParams const &) const ;
84 int docbook(Buffer const &, std::ostream &,
85 OutputParams const &) const ;
87 void validate(LaTeXFeatures & features) const;
89 InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
91 void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
93 bool insetAllowed(InsetOld::Code) const;
95 void setFont(BufferView *, LyXFont const &,
96 bool toggleall = false,
97 bool selectall = false);
99 void setText(std::string const &, LyXFont const &);
101 void setAutoBreakRows(bool);
103 bool getAutoBreakRows() const { return autoBreakRows_; }
105 void setDrawFrame(DrawFrame);
107 LColor_color frameColor() const;
109 void setFrameColor(LColor_color);
111 void setViewCache(BufferView const * bv) const;
113 bool showInsetDialog(BufferView *) const;
114 /// Appends \c list with all labels found within this inset.
115 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
117 int scroll(bool recursive = true) const;
119 void scroll(BufferView & bv, float sx) const {
120 UpdatableInset::scroll(bv, sx);
123 void scroll(BufferView & bv, int offset) const {
124 UpdatableInset::scroll(bv, offset);
127 LyXText * getText(int) const;
129 /// mark as erased for change tracking
130 void markErased() { clear(true); };
132 * Mark as new. Used when pasting in tabular, and adding rows
133 * or columns. Note that pasting will ensure that tracking already
134 * happens, and this just resets the changes for the copied text,
135 * whereas for row/col add, we need to start tracking changes
136 * for the (empty) paragraph contained.
138 void markNew(bool track_changes = false);
140 /// append text onto the existing text
141 void appendParagraphs(Buffer * bp, ParagraphList &);
144 void addPreview(lyx::graphics::PreviewLoader &) const;
147 void edit(LCursor & cur, bool);
149 void edit(LCursor & cur, int, int);
152 int numParagraphs() const { return 1; }
154 ParagraphList & paragraphs() const;
158 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
160 void updateLocal(LCursor &);
163 // If the inset is empty set the language of the current font to the
164 // language to the surronding text (if different).
165 void sanitizeEmptyText(BufferView &);
167 void setCharFont(Buffer const &, int pos, LyXFont const & font);
169 void removeNewlines();
171 void drawFrame(Painter &, int x) const;
173 void clearInset(Painter &, int x, int y) const;
175 /* Private structures and variables */
179 DrawFrame drawFrame_;
180 /** We store the LColor::color value as an int to get LColor.h out
181 * of the header file.
185 mutable lyx::paroffset_type old_par;
187 /** to remember old painted frame dimensions to clear it on
190 mutable bool in_insetAllowed;
193 mutable LyXText text_;
195 mutable LyXFont font_;