]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
The speed patch: redraw only rows that have changed
[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 ParagraphList;
31
32
33 /**
34  A text inset is like a TeX box to write full text
35  (including styles and other insets) in a given space.
36  */
37 class InsetText : public InsetOld {
38 public:
39         ///
40         explicit InsetText(BufferParams const &);
41         ///
42         InsetText();
43         /// empty inset to empty par
44         void clear();
45         ///
46         void read(Buffer const & buf, LyXLex & lex);
47         ///
48         void write(Buffer const & buf, std::ostream & os) const;
49         ///
50         void metrics(MetricsInfo & mi, Dimension & dim) const;
51         ///
52         void draw(PainterInfo & pi, int x, int y) const;
53         /// draw inset selection
54         void drawSelection(PainterInfo & pi, int x, int y) const;
55         ///
56         std::string const editMessage() const;
57         ///
58         EDITABLE editable() const { return HIGHLY_EDITABLE; }
59         ///
60         bool isTextInset() const { return true; }
61         ///
62         int latex(Buffer const &, std::ostream &,
63                   OutputParams const &) const;
64         ///
65         int plaintext(Buffer const &, std::ostream &,
66                   OutputParams const &) const;
67         ///
68         int linuxdoc(Buffer const &, std::ostream &,
69                      OutputParams const &) const;
70         ///
71         int docbook(Buffer const &, std::ostream &,
72                     OutputParams const &) const;
73         ///
74         void validate(LaTeXFeatures & features) const;
75
76         /// return x,y of given position relative to the inset's baseline
77         void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
78         ///
79         Code lyxCode() const { return TEXT_CODE; }
80         ///
81         void setFont(BufferView *, LyXFont const &,
82                      bool toggleall = false,
83                      bool selectall = false);
84         ///
85         void setText(std::string const &, LyXFont const &);
86         ///
87         void setAutoBreakRows(bool);
88         ///
89         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
90         ///
91         void setDrawFrame(bool);
92         ///
93         LColor_color frameColor() const;
94         ///
95         void setFrameColor(LColor_color);
96         ///
97         void setViewCache(BufferView const * bv) const;
98         ///
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;
102         ///
103         LyXText * getText(int i) const {
104                 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
105         }
106         ///
107         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
108
109         /// mark as erased for change tracking
110         void markErased(bool erased);
111
112         /**
113          * Mark as new. Used when pasting in tabular, and adding rows
114          * or columns. Note that pasting will ensure that tracking already
115          * happens, and this just resets the changes for the copied text,
116          * whereas for row/col add, we need to start tracking changes
117          * for the (empty) paragraph contained.
118          */
119         void markNew(bool track_changes = false);
120
121         /// append text onto the existing text
122         void appendParagraphs(Buffer * bp, ParagraphList &);
123
124         ///
125         void addPreview(lyx::graphics::PreviewLoader &) const;
126
127         ///
128         void edit(LCursor & cur, bool left);
129         ///
130         InsetBase * editXY(LCursor & cur, int x, int y);
131
132         /// number of cells in this inset
133         size_t nargs() const { return 1; }
134         ///
135         ParagraphList & paragraphs();
136         ///
137         ParagraphList const & paragraphs() const;
138         ///
139         bool insetAllowed(Code) const { return true; }
140         ///
141         bool allowSpellCheck() const { return true; }
142         /// should paragraph indendation be ommitted in any case?
143         bool neverIndent() const;
144         ///
145         InsetText(InsetText const &);
146
147 protected:
148         ///
149         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
150
151 private:
152         ///
153         virtual std::auto_ptr<InsetBase> doClone() const;
154         ///
155         void init();
156
157         ///
158         bool drawFrame_;
159         /** We store the LColor::color value as an int to get LColor.h out
160          *  of the header file.
161          */
162         int frame_color_;
163         ///
164         mutable lyx::pit_type old_pit;
165         ///
166         static int border_;
167 public:
168         ///
169         mutable LyXText text_;
170         ///
171         mutable LyXFont font_;
172 };
173 #endif