]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
Rename LatexRunParams::fragile as moving_arg.
[lyx.git] / src / insets / inset.C
1 /**
2  * \file inset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  * \author Matthias Ettrich
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #include <config.h>
15
16 #include "inset.h"
17 #include "BufferView.h"
18 #include "funcrequest.h"
19 #include "gettext.h"
20 #include "lyxfont.h"
21 #include "lyxtext.h"
22 #include "dimension.h"
23
24 #include "frontends/Painter.h"
25 #include "frontends/mouse_state.h"
26
27 #include "support/lstrings.h"
28
29 using std::endl;
30
31
32 // Initialization of the counter for the inset id's,
33 unsigned int Inset::inset_id = 0;
34
35 Inset::Inset()
36         : InsetBase(),
37         top_x(0), top_baseline(0), scx(0),
38         id_(inset_id++), owner_(0), par_owner_(0),
39         background_color_(LColor::inherit)
40 {}
41
42
43 Inset::Inset(Inset const & in, bool same_id)
44         : InsetBase(),
45         top_x(0), top_baseline(0), scx(0), owner_(0),
46         name_(in.name_), background_color_(in.background_color_)
47 {
48         if (same_id)
49                 id_ = in.id();
50         else
51                 id_ = inset_id++;
52 }
53
54
55 bool Inset::directWrite() const
56 {
57         return false;
58 }
59
60
61 Inset::EDITABLE Inset::editable() const
62 {
63         return NOT_EDITABLE;
64 }
65
66
67 void Inset::validate(LaTeXFeatures &) const
68 {}
69
70
71 bool Inset::autoDelete() const
72 {
73         return false;
74 }
75
76
77 #if 0
78 LyXFont const Inset::convertFont(LyXFont const & font) const
79 {
80 #if 1
81         return font;
82 #else
83         return LyXFont(font);
84 #endif
85 }
86 #endif
87
88
89 string const Inset::editMessage() const
90 {
91         return _("Opened inset");
92 }
93
94
95 LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
96 {
97         if (owner())
98                 return owner()->getLyXText(bv, false);
99         else
100                 return bv->text;
101 }
102
103
104 void Inset::setBackgroundColor(LColor::color color)
105 {
106         background_color_ = color;
107 }
108
109
110 LColor::color Inset::backgroundColor() const
111 {
112         if (background_color_ == LColor::inherit) {
113                 if (owner())
114                         return owner()->backgroundColor();
115                 else
116                         return LColor::background;
117         } else
118                 return background_color_;
119 }
120
121
122 int Inset::id() const
123 {
124         return id_;
125 }
126
127 void Inset::id(int id_arg)
128 {
129         id_ = id_arg;
130 }
131
132 void Inset::setFont(BufferView *, LyXFont const &, bool, bool)
133 {}
134
135
136 bool Inset::forceDefaultParagraphs(Inset const * inset) const
137 {
138         if (owner())
139                 return owner()->forceDefaultParagraphs(inset);
140         return false;
141 }
142
143 int Inset::latexTextWidth(BufferView * bv) const
144 {
145         if (owner())
146                 return (owner()->latexTextWidth(bv));
147         return bv->workWidth();
148 }
149
150
151 int Inset::ascent(BufferView * bv, LyXFont const & font) const
152 {
153         Dimension dim;
154         dimension(bv, font, dim);
155         return dim.ascent();
156 }
157
158
159 int Inset::descent(BufferView * bv, LyXFont const & font) const
160 {
161         Dimension dim;
162         dimension(bv, font, dim);
163         return dim.descent();
164 }
165
166
167 int Inset::width(BufferView * bv, LyXFont const & font) const
168 {
169         Dimension dim;
170         dimension(bv, font, dim);
171         return dim.width();
172 }
173