]> git.lyx.org Git - lyx.git/blob - src/insets/InsetText.h
Rename insets/insetxxx to insets/InsetXxx, part 2
[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 "RowList_fwd.h"
17 #include "lyxfont.h"
18 #include "lyxtext.h"
19 #include "ParagraphList_fwd.h"
20
21 #include "support/types.h"
22
23 #include "frontends/mouse_state.h"
24
25
26 namespace lyx {
27
28 class Buffer;
29 class BufferParams;
30 class BufferView;
31 class CursorSlice;
32 class Dimension;
33 class LColor_color;
34
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 InsetOld {
41 public:
42         ///
43         explicit InsetText(BufferParams const &);
44         ///
45         InsetText();
46         ///
47         virtual ~InsetText() {}
48
49         /// empty inset to empty par
50         void clear();
51         ///
52         void read(Buffer const & buf, LyXLex & lex);
53         ///
54         void write(Buffer const & buf, std::ostream & os) const;
55         ///
56         bool metrics(MetricsInfo & mi, Dimension & dim) const;
57         ///
58         void draw(PainterInfo & pi, int x, int y) const;
59         /// draw inset selection
60         void drawSelection(PainterInfo & pi, int x, int y) const;
61         /// are we inside the area covered by the inset?
62         virtual bool covers(BufferView const & bv, int x, int y) const;
63         ///
64         virtual docstring const editMessage() const;
65         ///
66         EDITABLE editable() const { return HIGHLY_EDITABLE; }
67         ///
68         bool canTrackChanges() const { return true; }
69         ///
70         InsetText const * asTextInset() const { return this; }
71         ///
72         int latex(Buffer const &, odocstream &, OutputParams const &) const;
73         ///
74         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
75         ///
76         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
77         ///
78         void validate(LaTeXFeatures & features) const;
79
80         /// return x,y of given position relative to the inset's baseline
81         void cursorPos(BufferView const & bv, CursorSlice const & sl,
82                 bool boundary, int & x, int & y) const;
83         ///
84         Code lyxCode() const { return TEXT_CODE; }
85         ///
86         void setText(docstring const &, LyXFont const &, bool trackChanges);
87         ///
88         void setAutoBreakRows(bool);
89         ///
90         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
91         ///
92         void setDrawFrame(bool);
93         ///
94         LColor_color frameColor() const;
95         ///
96         void setFrameColor(LColor_color);
97         ///
98         bool showInsetDialog(BufferView *) const;
99         ///
100         LyXText * getText(int i) const {
101                 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
102         }
103         ///
104         virtual bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
105
106         /// set the change for the entire inset
107         void setChange(Change const & change);
108         /// accept the changes within the inset
109         void acceptChanges(BufferParams const & bparams);
110         /// reject the changes within the inset
111         void rejectChanges(BufferParams const & bparams);
112
113         /// append text onto the existing text
114         void appendParagraphs(Buffer * bp, ParagraphList &);
115
116         ///
117         void addPreview(graphics::PreviewLoader &) const;
118
119         ///
120         void edit(LCursor & cur, bool left);
121         ///
122         InsetBase * editXY(LCursor & cur, int x, int y);
123
124         /// number of cells in this inset
125         size_t nargs() const { return 1; }
126         ///
127         ParagraphList & paragraphs();
128         ///
129         ParagraphList const & paragraphs() const;
130         ///
131         bool insetAllowed(Code) const { return true; }
132         ///
133         bool allowSpellCheck() const { return true; }
134         /// should paragraph indendation be ommitted in any case?
135         bool neverIndent(Buffer const &) const;
136         ///
137         InsetText(InsetText const &);
138         ///
139         virtual bool wide() const { return wide_inset_; }
140         ///
141         void setWide(bool wide_inset) { wide_inset_ = wide_inset; }
142
143 protected:
144         ///
145         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
146
147 private:
148         ///
149         virtual std::auto_ptr<InsetBase> doClone() const;
150         ///
151         void init();
152
153         ///
154         bool drawFrame_;
155         /** We store the LColor::color value as an int to get LColor.h out
156          *  of the header file.
157          */
158         int frame_color_;
159         ///
160         mutable pit_type old_pit;
161         ///
162         bool wide_inset_;
163 public:
164         ///
165         mutable LyXText text_;
166         ///
167         mutable LyXFont font_;
168         ///
169         static int border_;
170 };
171
172 } // namespace lyx
173
174 #endif