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