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 "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.
39 class InsetText : public UpdatableInset {
51 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(LCursor const & cur, int & x, int & y) 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 LyXText * getText(int) const;
119 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
121 /// mark as erased for change tracking
122 void markErased() { clear(true); }
124 * Mark as new. Used when pasting in tabular, and adding rows
125 * or columns. Note that pasting will ensure that tracking already
126 * happens, and this just resets the changes for the copied text,
127 * whereas for row/col add, we need to start tracking changes
128 * for the (empty) paragraph contained.
130 void markNew(bool track_changes = false);
132 /// append text onto the existing text
133 void appendParagraphs(Buffer * bp, ParagraphList &);
136 void addPreview(lyx::graphics::PreviewLoader &) const;
139 void edit(LCursor & cur, bool left);
141 InsetBase * editXY(LCursor & cur, int x, int y);
143 /// number of cells in this inset
144 size_t nargs() const { return 1; }
146 ParagraphList & paragraphs();
148 ParagraphList const & paragraphs() const;
150 bool insetAllowed(Code) const { return true; }
152 bool allowSpellCheck() const { return true; }
156 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
159 void updateLocal(LCursor &);
162 // If the inset is empty set the language of the current font to the
163 // language to the surronding text (if different).
164 void sanitizeEmptyText(BufferView &);
166 void setCharFont(Buffer const &, int pos, LyXFont const & font);
168 void removeNewlines();
170 void drawFrame(Painter &, int x, int y) const;
172 void clearInset(Painter &, int x, int y) const;
177 DrawFrame drawFrame_;
178 /** We store the LColor::color value as an int to get LColor.h out
179 * of the header file.
183 mutable lyx::par_type old_par;
186 mutable LyXText text_;
188 mutable LyXFont font_;