]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
* Inset:
[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 "Font.h"
17 #include "Text.h"
18
19 #include "support/types.h"
20
21 #include "frontends/mouse_state.h"
22
23
24 namespace lyx {
25
26 class Buffer;
27 class BufferParams;
28 class BufferView;
29 class CursorSlice;
30 class Dimension;
31 class Color_color;
32 class ParagraphList;
33 class InsetTabular;
34
35
36 /**
37  A text inset is like a TeX box to write full text
38  (including styles and other insets) in a given space.
39  */
40 class InsetText : public Inset {
41 public:
42         ///
43         explicit InsetText(BufferParams const &);
44         ///
45         InsetText();
46
47         ///
48         Dimension const dimension(BufferView const &) const;
49
50         /// empty inset to empty par
51         void clear();
52         ///
53         void read(Buffer const & buf, Lexer & lex);
54         ///
55         void write(Buffer const & buf, std::ostream & os) const;
56         ///
57         void metrics(MetricsInfo & mi, Dimension & dim) const;
58         ///
59         void draw(PainterInfo & pi, int x, int y) const;
60         ///
61         virtual docstring const editMessage() const;
62         ///
63         EDITABLE editable() const { return HIGHLY_EDITABLE; }
64         ///
65         bool canTrackChanges() const { return true; }
66         ///
67         InsetText * asTextInset() { return this; }
68         ///
69         InsetText const * asTextInset() const { return this; }
70         ///
71         int latex(Buffer const &, odocstream &, OutputParams const &) const;
72         ///
73         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
74         ///
75         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
76         ///
77         void validate(LaTeXFeatures & features) const;
78
79         /// return x,y of given position relative to the inset's baseline
80         void cursorPos(BufferView const & bv, CursorSlice const & sl,
81                 bool boundary, int & x, int & y) const;
82         ///
83         Code lyxCode() const { return TEXT_CODE; }
84         ///
85         void setText(docstring const &, Font const &, bool trackChanges);
86         ///
87         void setAutoBreakRows(bool);
88         ///
89         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
90         ///
91         void setDrawFrame(bool);
92         ///
93         Color_color frameColor() const;
94         ///
95         void setFrameColor(Color_color);
96         ///
97         bool showInsetDialog(BufferView *) const;
98         ///
99         Text * getText(int i) const {
100                 return (i == 0) ? const_cast<Text*>(&text_) : 0;
101         }
102         ///
103         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
104
105         /// set the change for the entire inset
106         void setChange(Change const & change);
107         /// accept the changes within the inset
108         void acceptChanges(BufferParams const & bparams);
109         /// reject the changes within the inset
110         void rejectChanges(BufferParams const & bparams);
111
112         /// append text onto the existing text
113         void appendParagraphs(Buffer * bp, ParagraphList &);
114
115         ///
116         void addPreview(graphics::PreviewLoader &) const;
117
118         ///
119         void edit(Cursor & cur, bool left);
120         ///
121         Inset * editXY(Cursor & cur, int x, int y);
122
123         /// number of cells in this inset
124         size_t nargs() const { return 1; }
125         ///
126         ParagraphList & paragraphs();
127         ///
128         ParagraphList const & paragraphs() const;
129         ///
130         bool insetAllowed(Code) const { return true; }
131         ///
132         bool allowSpellCheck() const { return true; }
133         /// should paragraph indendation be ommitted in any case?
134         bool neverIndent(Buffer const &) const;
135         ///
136         InsetText(InsetText const &);
137
138         // Update the counters of this inset and of its contents
139         virtual void updateLabels(Buffer const &, ParIterator const &);
140         ///
141         virtual Inset * clone() const;
142
143 protected:
144         ///
145         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
146
147 private:
148         ///
149         void init();
150
151         ///
152         bool drawFrame_;
153         /** We store the Color::color value as an int to get Color.h out
154          *  of the header file.
155          */
156         int frame_color_;
157         ///
158         mutable pit_type old_pit;
159
160 public:
161         ///
162         mutable Text text_;
163 };
164
165 } // namespace lyx
166
167 #endif