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