]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
change tracking:
[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         /// empty inset to empty par
47         void clear();
48         ///
49         void read(Buffer const & buf, LyXLex & lex);
50         ///
51         void write(Buffer const & buf, std::ostream & os) const;
52         ///
53         void metrics(MetricsInfo & mi, Dimension & dim) const;
54         ///
55         void draw(PainterInfo & pi, int x, int y) const;
56         /// draw inset selection
57         void drawSelection(PainterInfo & pi, int x, int y) const;
58         /// are we inside the area covered by the inset?
59         virtual bool covers(BufferView & bv, int x, int y) const;
60         ///
61         virtual docstring const editMessage() const;
62         ///
63         EDITABLE editable() const { return HIGHLY_EDITABLE; }
64         ///
65         bool canTrackChanges() const { return true; }
66         ///
67         InsetText const * asTextInset() const { return this; }
68         ///
69         int latex(Buffer const &, odocstream &, OutputParams const &) const;
70         ///
71         int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
72         ///
73         int docbook(Buffer const &, odocstream &, OutputParams const &) const;
74         ///
75         void validate(LaTeXFeatures & features) const;
76
77         /// return x,y of given position relative to the inset's baseline
78         void cursorPos(BufferView const & bv, CursorSlice const & sl,
79                 bool boundary, int & x, int & y) const;
80         ///
81         Code lyxCode() const { return TEXT_CODE; }
82         ///
83         void setText(docstring const &, LyXFont const &, bool trackChanges);
84         ///
85         void setAutoBreakRows(bool);
86         ///
87         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
88         ///
89         void setDrawFrame(bool);
90         ///
91         LColor_color frameColor() const;
92         ///
93         void setFrameColor(LColor_color);
94         ///
95         void setViewCache(BufferView const * bv) const;
96         ///
97         bool showInsetDialog(BufferView *) const;
98         ///
99         LyXText * getText(int i) const {
100                 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
101         }
102         ///
103         bool getStatus(LCursor & 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();
109         /// reject the changes within the inset
110         void rejectChanges();
111
112         /// append text onto the existing text
113         void appendParagraphs(Buffer * bp, ParagraphList &);
114
115         ///
116         void addPreview(graphics::PreviewLoader &) const;
117
118         ///
119         void edit(LCursor & cur, bool left);
120         ///
121         InsetBase * editXY(LCursor & 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(Code) const { return true; }
131         ///
132         bool allowSpellCheck() const { return true; }
133         /// should paragraph indendation be ommitted in any case?
134         bool neverIndent() const;
135         ///
136         InsetText(InsetText const &);
137         ///
138         bool & Wide() const { return wide_inset_; }
139
140 protected:
141         ///
142         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
143
144 private:
145         ///
146         virtual std::auto_ptr<InsetBase> doClone() const;
147         ///
148         void init();
149
150         ///
151         bool drawFrame_;
152         /** We store the LColor::color value as an int to get LColor.h out
153          *  of the header file.
154          */
155         int frame_color_;
156         ///
157         mutable pit_type old_pit;
158         ///
159         static int border_;
160         ///
161         mutable bool wide_inset_;
162 public:
163         ///
164         mutable LyXText text_;
165         ///
166         mutable LyXFont font_;
167 };
168
169 } // namespace lyx
170
171 #endif