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