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 {
42 explicit InsetText(BufferParams const &);
45 /// empty inset to empty par, or just mark as erased
46 void clear(bool just_mark_erased);
48 void read(Buffer const & buf, LyXLex & lex);
50 void write(Buffer const & buf, std::ostream & os) const;
52 void metrics(MetricsInfo & mi, Dimension & dim) const;
54 void draw(PainterInfo & pi, int x, int y) const;
55 /// draw inset selection
56 void drawSelection(PainterInfo & pi, int x, int y) const;
58 std::string const editMessage() const;
60 bool isTextInset() const { return true; }
62 int latex(Buffer const &, std::ostream &,
63 OutputParams const &) const;
65 int plaintext(Buffer const &, std::ostream &,
66 OutputParams const &) const;
68 int linuxdoc(Buffer const &, std::ostream &,
69 OutputParams const &) const;
71 int docbook(Buffer const &, std::ostream &,
72 OutputParams const &) const;
74 void validate(LaTeXFeatures & features) const;
76 /// return x,y of given position relative to the inset's baseline
77 void getCursorPos(CursorSlice const & sl, int & x, int & y) const;
79 Code lyxCode() const { return TEXT_CODE; }
81 void setFont(BufferView *, LyXFont const &,
82 bool toggleall = false,
83 bool selectall = false);
85 void setText(std::string const &, LyXFont const &);
87 void setAutoBreakRows(bool);
89 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
91 void setDrawFrame(bool);
93 LColor_color frameColor() const;
95 void setFrameColor(LColor_color);
97 void setViewCache(BufferView const * bv) const;
99 bool showInsetDialog(BufferView *) const;
100 /// Appends \c list with all labels found within this inset.
101 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
103 LyXText * getText(int) const;
105 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
107 /// mark as erased for change tracking
108 void markErased() { clear(true); }
110 * Mark as new. Used when pasting in tabular, and adding rows
111 * or columns. Note that pasting will ensure that tracking already
112 * happens, and this just resets the changes for the copied text,
113 * whereas for row/col add, we need to start tracking changes
114 * for the (empty) paragraph contained.
116 void markNew(bool track_changes = false);
118 /// append text onto the existing text
119 void appendParagraphs(Buffer * bp, ParagraphList &);
122 void addPreview(lyx::graphics::PreviewLoader &) const;
125 void edit(LCursor & cur, bool left);
127 InsetBase * editXY(LCursor & cur, int x, int y) const;
129 /// number of cells in this inset
130 size_t nargs() const { return 1; }
132 ParagraphList & paragraphs();
134 ParagraphList const & paragraphs() const;
136 bool insetAllowed(Code) const { return true; }
138 bool allowSpellCheck() const { return true; }
141 InsetText(InsetText const &);
143 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
145 virtual std::auto_ptr<InsetBase> doClone() const;
148 void updateLocal(LCursor &);
152 void setCharFont(Buffer const &, int pos, LyXFont const & font);
154 void removeNewlines();
156 void drawFrame(Painter &, int x, int y) const;
158 void clearInset(Painter &, int x, int y) const;
162 /** We store the LColor::color value as an int to get LColor.h out
163 * of the header file.
167 mutable lyx::pit_type old_pit;
172 mutable LyXText text_;
174 mutable LyXFont font_;