]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
more latin1..utf8 schanges. all of src/* should be utf8 now
[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 namespace lyx {
21
22 class Buffer;
23 class BufferParams;
24 class BufferView;
25 class CompletionList;
26 class CursorSlice;
27 class Dimension;
28 class ParagraphList;
29 class InsetTabular;
30
31 /**
32  A text inset is like a TeX box to write full text
33  (including styles and other insets) in a given space.
34  */
35 class InsetText : public Inset {
36 public:
37         ///
38         explicit InsetText(Buffer const & buffer);
39         ///
40         InsetText(InsetText const &);
41         ///
42         void setBuffer(Buffer &);
43
44         ///
45         Dimension const dimension(BufferView const &) const;
46
47         /// empty inset to empty par
48         void clear();
49         ///
50         void read(Lexer & lex);
51         ///
52         void write(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         docstring 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         Text & text() { return text_; }
69         Text const & text() const { return text_; }
70         ///
71         int latex(odocstream &, OutputParams const &) const;
72         ///
73         int plaintext(odocstream &, OutputParams const &) const;
74         ///
75         int docbook(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         InsetCode 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         ColorCode frameColor() const;
94         ///
95         void setFrameColor(ColorCode);
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(ParagraphList &);
114
115         ///
116         void addPreview(graphics::PreviewLoader &) const;
117
118         ///
119         void edit(Cursor & cur, bool front, EntryDirection entry_from);
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(InsetCode) const { return true; }
131         ///
132         bool allowSpellCheck() const { return true; }
133         ///
134         virtual bool isMacroScope() const { return false; }
135         ///
136         virtual bool allowMultiPar() const { return true; }
137
138         // Update the counters of this inset and of its contents
139         void updateLabels(ParIterator const &);
140         ///
141         void addToToc(DocIterator const &);
142         ///
143         Inset * clone() const { return new InsetText(*this); }
144         ///
145         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
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         bool showCompletionCursor() const;
157         ///
158         CompletionList const * createCompletionList(Cursor const & cur) const;
159         ///
160         docstring completionPrefix(Cursor const & cur) const;
161         ///
162         bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
163         ///
164         void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
165
166         ///
167         virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
168         ///
169         void doDispatch(Cursor & cur, FuncRequest & cmd);
170 private:
171         ///
172         void initParagraphs();
173         ///
174         void setParagraphOwner();
175         ///
176         bool drawFrame_;
177         ///
178         ColorCode frame_color_;
179         ///
180         mutable pit_type old_pit;
181         ///
182         mutable Text text_;
183 };
184
185 } // namespace lyx
186
187 #endif