]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
rename priv_dispatch to doDispatch
[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 "updatableinset.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 Dimension;
28 class LColor_color;
29 class CursorSlice;
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 UpdatableInset {
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         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         Code lyxCode() const { return TEXT_CODE; }
77         /// FIXME, document
78         void getCursorPos(LCursor const & cur, int & x, int & y) const;
79         ///
80         void setFont(BufferView *, LyXFont const &,
81                      bool toggleall = false,
82                      bool selectall = false);
83         ///
84         void setText(std::string const &, LyXFont const &);
85         ///
86         void setAutoBreakRows(bool);
87         ///
88         bool getAutoBreakRows() const { return autoBreakRows_; }
89         ///
90         void setDrawFrame(bool);
91         ///
92         LColor_color frameColor() const;
93         ///
94         void setFrameColor(LColor_color);
95         ///
96         void setViewCache(BufferView const * bv) const;
97         ///
98         bool showInsetDialog(BufferView *) const;
99         /// Appends \c list with all labels found within this inset.
100         void getLabelList(Buffer const &, std::vector<std::string> & list) const;
101         ///
102         LyXText * getText(int) const;
103         ///
104         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
105
106         /// mark as erased for change tracking
107         void markErased() { clear(true); }
108         /**
109          * Mark as new. Used when pasting in tabular, and adding rows
110          * or columns. Note that pasting will ensure that tracking already
111          * happens, and this just resets the changes for the copied text,
112          * whereas for row/col add, we need to start tracking changes
113          * for the (empty) paragraph contained.
114          */
115         void markNew(bool track_changes = false);
116
117         /// append text onto the existing text
118         void appendParagraphs(Buffer * bp, ParagraphList &);
119
120         ///
121         void addPreview(lyx::graphics::PreviewLoader &) const;
122
123         ///
124         void edit(LCursor & cur, bool left);
125         ///
126         InsetBase * editXY(LCursor & cur, int x, int y) const;
127
128         /// number of cells in this inset
129         size_t nargs() const { return 1; }
130         ///
131         ParagraphList & paragraphs();
132         ///
133         ParagraphList const & paragraphs() const;
134         ///
135         bool insetAllowed(Code) const { return true; }
136         ///
137         bool allowSpellCheck() const { return true; }
138
139 protected:
140         InsetText(InsetText const &);
141         ///
142         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
143 private:
144         virtual std::auto_ptr<InsetBase> doClone() const;
145
146         ///
147         void updateLocal(LCursor &);
148         ///
149         void init();
150         ///
151         void setCharFont(Buffer const &, int pos, LyXFont const & font);
152         ///
153         void removeNewlines();
154         ///
155         void drawFrame(Painter &, int x, int y) const;
156         ///
157         void clearInset(Painter &, int x, int y) const;
158
159         ///
160         bool autoBreakRows_;
161         ///
162         bool drawFrame_;
163         /** We store the LColor::color value as an int to get LColor.h out
164          *  of the header file.
165          */
166         int frame_color_;
167         ///
168         mutable lyx::pit_type old_par;
169 public:
170         ///
171         mutable LyXText text_;
172         ///
173         mutable LyXFont font_;
174 };
175 #endif