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 &);
53 InsetText(InsetText const &);
55 virtual std::auto_ptr<InsetBase> clone() const;
57 void operator=(InsetText const & it);
58 /// empty inset to empty par, or just mark as erased
59 void clear(bool just_mark_erased);
61 void read(Buffer const & buf, LyXLex & lex);
63 void write(Buffer const & buf, std::ostream & os) const;
65 void metrics(MetricsInfo & mi, Dimension & dim) const;
67 void draw(PainterInfo & pi, int x, int y) const;
68 /// draw inset selection
69 void drawSelection(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 void setFont(BufferView *, LyXFont const &,
94 bool toggleall = false,
95 bool selectall = false);
97 void setText(std::string const &, LyXFont const &);
99 void setAutoBreakRows(bool);
101 bool getAutoBreakRows() const { return autoBreakRows_; }
103 void setDrawFrame(DrawFrame);
105 LColor_color frameColor() const;
107 void setFrameColor(LColor_color);
109 void setViewCache(BufferView const * bv) const;
111 bool showInsetDialog(BufferView *) const;
112 /// Appends \c list with all labels found within this inset.
113 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
115 LyXText * getText(int) const;
117 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
119 /// mark as erased for change tracking
120 void markErased() { clear(true); }
122 * Mark as new. Used when pasting in tabular, and adding rows
123 * or columns. Note that pasting will ensure that tracking already
124 * happens, and this just resets the changes for the copied text,
125 * whereas for row/col add, we need to start tracking changes
126 * for the (empty) paragraph contained.
128 void markNew(bool track_changes = false);
130 /// append text onto the existing text
131 void appendParagraphs(Buffer * bp, ParagraphList &);
134 void addPreview(lyx::graphics::PreviewLoader &) const;
137 void edit(LCursor & cur, bool left);
139 InsetBase * editXY(LCursor & cur, int x, int y);
141 /// number of cells in this inset
142 size_t nargs() const { return 1; }
144 ParagraphList & paragraphs() const;
146 bool insetAllowed(Code) const { return true; }
150 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
153 void updateLocal(LCursor &);
156 // If the inset is empty set the language of the current font to the
157 // language to the surronding text (if different).
158 void sanitizeEmptyText(BufferView &);
160 void setCharFont(Buffer const &, int pos, LyXFont const & font);
162 void removeNewlines();
164 void drawFrame(Painter &, int x, int y) const;
166 void clearInset(Painter &, int x, int y) const;
171 DrawFrame drawFrame_;
172 /** We store the LColor::color value as an int to get LColor.h out
173 * of the header file.
177 mutable lyx::par_type old_par;
180 mutable LyXText text_;
182 mutable LyXFont font_;