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