]> 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 class Buffer;
26 class BufferParams;
27 class BufferView;
28 class CursorSlice;
29 class Dimension;
30 class LColor_color;
31
32
33 /**
34  A text inset is like a TeX box to write full text
35  (including styles and other insets) in a given space.
36  */
37 class InsetText : public InsetOld {
38 public:
39         ///
40         explicit InsetText(BufferParams const &);
41         ///
42         InsetText();
43         /// empty inset to empty par
44         void clear();
45         ///
46         void read(Buffer const & buf, LyXLex & lex);
47         ///
48         void write(Buffer const & buf, std::ostream & os) const;
49         ///
50         void metrics(MetricsInfo & mi, Dimension & dim) const;
51         ///
52         void draw(PainterInfo & pi, int x, int y) const;
53         /// draw inset selection
54         void drawSelection(PainterInfo & pi, int x, int y) const;
55         /// are we inside the area covered by the inset?
56         virtual bool covers(BufferView & bv, int x, int y) const;
57         ///
58         virtual lyx::docstring const editMessage() const;
59         ///
60         EDITABLE editable() const { return HIGHLY_EDITABLE; }
61         ///
62         bool canTrackChanges() const { return true; }
63         ///
64         InsetText const * asTextInset() const { return this; }
65         ///
66         int latex(Buffer const &, lyx::odocstream &,
67                   OutputParams const &) const;
68         ///
69         int plaintext(Buffer const &, lyx::odocstream &,
70                   OutputParams const &) const;
71         ///
72         int docbook(Buffer const &, lyx::odocstream &,
73                     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(lyx::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
108         /// append text onto the existing text
109         void appendParagraphs(Buffer * bp, ParagraphList &);
110
111         ///
112         void addPreview(lyx::graphics::PreviewLoader &) const;
113
114         ///
115         void edit(LCursor & cur, bool left);
116         ///
117         InsetBase * editXY(LCursor & cur, int x, int y);
118
119         /// number of cells in this inset
120         size_t nargs() const { return 1; }
121         ///
122         ParagraphList & paragraphs();
123         ///
124         ParagraphList const & paragraphs() const;
125         ///
126         bool insetAllowed(Code) const { return true; }
127         ///
128         bool allowSpellCheck() const { return true; }
129         /// should paragraph indendation be ommitted in any case?
130         bool neverIndent() const;
131         ///
132         InsetText(InsetText const &);
133         ///
134         bool & Wide() const { return wide_inset_; }
135
136 protected:
137         ///
138         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
139
140 private:
141         ///
142         virtual std::auto_ptr<InsetBase> doClone() const;
143         ///
144         void init();
145
146         ///
147         bool drawFrame_;
148         /** We store the LColor::color value as an int to get LColor.h out
149          *  of the header file.
150          */
151         int frame_color_;
152         ///
153         mutable lyx::pit_type old_pit;
154         ///
155         static int border_;
156         ///
157         mutable bool wide_inset_;
158 public:
159         ///
160         mutable LyXText text_;
161         ///
162         mutable LyXFont font_;
163 };
164 #endif