]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
send UpdatableInset down the way of the Dodo
[lyx.git] / src / insets / insettext.h
1 // -*- C++ -*-
2 /**
3  * \file insettext.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETTEXT_H
13 #define INSETTEXT_H
14
15 #include "inset.h"
16 #include "RowList_fwd.h"
17 #include "lyxfont.h"
18 #include "lyxtext.h"
19
20 #include "support/types.h"
21
22 #include "frontends/mouse_state.h"
23
24 class Buffer;
25 class BufferParams;
26 class BufferView;
27 class CursorSlice;
28 class Dimension;
29 class LColor_color;
30 class Painter;
31 class ParagraphList;
32 class Row;
33
34
35 /**
36  A text inset is like a TeX box to write full text
37  (including styles and other insets) in a given space.
38  */
39 class InsetText : public InsetOld {
40 public:
41         ///
42         explicit InsetText(BufferParams const &);
43         ///
44         InsetText();
45         /// empty inset to empty par, or just mark as erased
46         void clear(bool just_mark_erased);
47         ///
48         void read(Buffer const & buf, LyXLex & lex);
49         ///
50         void write(Buffer const & buf, std::ostream & os) const;
51         ///
52         void metrics(MetricsInfo & mi, Dimension & dim) const;
53         ///
54         void draw(PainterInfo & pi, int x, int y) const;
55         /// draw inset selection
56         void drawSelection(PainterInfo & pi, int x, int y) const;
57         ///
58         std::string const editMessage() const;
59         ///
60         EDITABLE editable() const { return HIGHLY_EDITABLE; }
61         ///
62         bool isTextInset() const { return true; }
63         ///
64         int latex(Buffer const &, std::ostream &,
65                   OutputParams const &) const;
66         ///
67         int plaintext(Buffer const &, std::ostream &,
68                   OutputParams const &) const;
69         ///
70         int linuxdoc(Buffer const &, std::ostream &,
71                      OutputParams const &) const;
72         ///
73         int docbook(Buffer const &, std::ostream &,
74                     OutputParams const &) const;
75         ///
76         void validate(LaTeXFeatures & features) const;
77
78         /// return x,y of given position relative to the inset's baseline
79         void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
80         ///
81         Code lyxCode() const { return TEXT_CODE; }
82         ///
83         void setFont(BufferView *, LyXFont const &,
84                      bool toggleall = false,
85                      bool selectall = false);
86         ///
87         void setText(std::string const &, LyXFont const &);
88         ///
89         void setAutoBreakRows(bool);
90         ///
91         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
92         ///
93         void setDrawFrame(bool);
94         ///
95         LColor_color frameColor() const;
96         ///
97         void setFrameColor(LColor_color);
98         ///
99         void setViewCache(BufferView const * bv) const;
100         ///
101         bool showInsetDialog(BufferView *) const;
102         /// Appends \c list with all labels found within this inset.
103         void getLabelList(Buffer const &, std::vector<std::string> & list) const;
104         ///
105         LyXText * getText(int) const;
106         ///
107         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
108
109         /// mark as erased for change tracking
110         void markErased() { clear(true); }
111         /**
112          * Mark as new. Used when pasting in tabular, and adding rows
113          * or columns. Note that pasting will ensure that tracking already
114          * happens, and this just resets the changes for the copied text,
115          * whereas for row/col add, we need to start tracking changes
116          * for the (empty) paragraph contained.
117          */
118         void markNew(bool track_changes = false);
119
120         /// append text onto the existing text
121         void appendParagraphs(Buffer * bp, ParagraphList &);
122
123         ///
124         void addPreview(lyx::graphics::PreviewLoader &) const;
125
126         ///
127         void edit(LCursor & cur, bool left);
128         ///
129         InsetBase * editXY(LCursor & cur, int x, int y);
130
131         /// number of cells in this inset
132         size_t nargs() const { return 1; }
133         ///
134         ParagraphList & paragraphs();
135         ///
136         ParagraphList const & paragraphs() const;
137         ///
138         bool insetAllowed(Code) const { return true; }
139         ///
140         bool allowSpellCheck() const { return true; }
141         ///
142         InsetText(InsetText const &);
143
144 protected:
145         ///
146         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
147 private:
148         virtual std::auto_ptr<InsetBase> doClone() const;
149
150         ///
151         void updateLocal(LCursor &);
152         ///
153         void init();
154         ///
155         void setCharFont(Buffer const &, int pos, LyXFont const & font);
156         ///
157         void removeNewlines();
158         ///
159         void drawFrame(Painter &, int x, int y) const;
160         ///
161         void clearInset(Painter &, int x, int y) const;
162
163         ///
164         bool drawFrame_;
165         /** We store the LColor::color value as an int to get LColor.h out
166          *  of the header file.
167          */
168         int frame_color_;
169         ///
170         mutable lyx::pit_type old_pit;
171         ///
172         static int border_;
173 public:
174         ///
175         mutable LyXText text_;
176         ///
177         mutable LyXFont font_;
178 };
179 #endif