]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
Andre's s/getTextClass/textClass/ cleanup.
[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 #include <set>
23
24 namespace lyx {
25
26 class Buffer;
27 class BufferParams;
28 class BufferView;
29 class CursorSlice;
30 class Dimension;
31 class ParagraphList;
32 class InsetTabular;
33
34 class WordList : public std::set<docstring> {};
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         InsetText(InsetText const &);
48
49         ///
50         Dimension const dimension(BufferView const &) const;
51
52         /// empty inset to empty par
53         void clear();
54         ///
55         void read(Buffer const & buf, Lexer & lex);
56         ///
57         void write(Buffer const & buf, std::ostream & os) const;
58         ///
59         void metrics(MetricsInfo & mi, Dimension & dim) const;
60         ///
61         void draw(PainterInfo & pi, int x, int y) const;
62         ///
63         virtual docstring const editMessage() const;
64         ///
65         EDITABLE editable() const { return HIGHLY_EDITABLE; }
66         ///
67         bool canTrackChanges() const { return true; }
68         ///
69         InsetText * asInsetText() { return this; }
70         ///
71         InsetText const * asInsetText() const { return this; }
72         ///
73         int latex(Buffer const &, odocstream &, OutputParams const &) const;
74         ///
75         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
76         ///
77         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
78         ///
79         void validate(LaTeXFeatures & features) const;
80
81         /// return x,y of given position relative to the inset's baseline
82         void cursorPos(BufferView const & bv, CursorSlice const & sl,
83                 bool boundary, int & x, int & y) const;
84         ///
85         InsetCode lyxCode() const { return TEXT_CODE; }
86         ///
87         void setText(docstring const &, Font const &, bool trackChanges);
88         ///
89         void setAutoBreakRows(bool);
90         ///
91         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
92         ///
93         void setDrawFrame(bool);
94         ///
95         ColorCode frameColor() const;
96         ///
97         void setFrameColor(ColorCode);
98         ///
99         bool showInsetDialog(BufferView *) const;
100         ///
101         Text * getText(int i) const {
102                 return (i == 0) ? const_cast<Text*>(&text_) : 0;
103         }
104         ///
105         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
106
107         /// set the change for the entire inset
108         void setChange(Change const & change);
109         /// accept the changes within the inset
110         void acceptChanges(BufferParams const & bparams);
111         /// reject the changes within the inset
112         void rejectChanges(BufferParams const & bparams);
113
114         /// append text onto the existing text
115         void appendParagraphs(Buffer * bp, ParagraphList &);
116
117         ///
118         void addPreview(graphics::PreviewLoader &) const;
119
120         ///
121         void edit(Cursor & cur, bool front, EntryDirection entry_from);
122         ///
123         Inset * editXY(Cursor & cur, int x, int y);
124
125         /// number of cells in this inset
126         size_t nargs() const { return 1; }
127         ///
128         ParagraphList & paragraphs();
129         ///
130         ParagraphList const & paragraphs() const;
131         ///
132         bool insetAllowed(InsetCode) const { return true; }
133         ///
134         bool allowSpellCheck() const { return true; }
135         /// should paragraph indendation be ommitted in any case?
136         bool neverIndent(Buffer const &) const;
137         ///
138         virtual bool isMacroScope(Buffer const &) const { return true; }
139         ///
140         virtual bool allowMultiPar() const { return true; }
141
142         // Update the counters of this inset and of its contents
143         virtual void updateLabels(Buffer const &, ParIterator const &);
144         ///
145         virtual Inset * clone() const;
146
147         ///
148         bool completionSupported(Cursor const &) const;
149         ///
150         bool inlineCompletionSupported(Cursor const & cur) const;
151         ///
152         bool automaticInlineCompletion() const;
153         ///
154         bool automaticPopupCompletion() const;
155         ///
156         CompletionList const * createCompletionList(Cursor const & cur) const;
157         ///
158         docstring completionPrefix(Cursor const & cur) const;
159         ///
160         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
161         ///
162         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
163
164 protected:
165         ///
166         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
167
168 private:
169         ///
170         void setParagraphOwner();
171         ///
172         bool drawFrame_;
173         ///
174         ColorCode frame_color_;
175         ///
176         mutable pit_type old_pit;
177         ///
178         docstring previousWord(Buffer const & buffer, CursorSlice const & sl) const;
179
180 public:
181         ///
182         mutable Text text_;
183 };
184
185 } // namespace lyx
186
187 #endif