]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
If I ever see another licence blurb again, it'll be too soon...
[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 #include "metricsinfo.h"
24
25 #include "insets/updatableinset.h"
26
27 #include "frontends/Painter.h"
28 #include "frontends/mouse_state.h"
29
30 #include "support/lstrings.h"
31
32
33 #include "debug.h"
34
35 // Initialization of the counter for the inset id's,
36 unsigned int InsetOld::inset_id = 0;
37
38 InsetOld::InsetOld()
39         : InsetBase(),
40         top_x(0), top_baseline(0), scx(0),
41         id_(inset_id++), owner_(0), par_owner_(0),
42         background_color_(LColor::inherit)
43 {}
44
45
46 InsetOld::InsetOld(InsetOld const & in)
47         : InsetBase(),
48         top_x(0), top_baseline(0), scx(0), id_(in.id_), owner_(0),
49         name_(in.name_), background_color_(in.background_color_)
50 {
51 }
52
53
54 bool InsetOld::directWrite() const
55 {
56         return false;
57 }
58
59
60 InsetOld::EDITABLE InsetOld::editable() const
61 {
62         return NOT_EDITABLE;
63 }
64
65
66 bool InsetOld::autoDelete() const
67 {
68         return false;
69 }
70
71
72 #if 0
73 LyXFont const InsetOld::convertFont(LyXFont const & font) const
74 {
75 #if 1
76         return font;
77 #else
78         return LyXFont(font);
79 #endif
80 }
81 #endif
82
83
84 string const InsetOld::editMessage() const
85 {
86         return _("Opened inset");
87 }
88
89
90 LyXText * InsetOld::getLyXText(BufferView const * bv, bool /*recursive*/) const
91 {
92         if (owner())
93                 return owner()->getLyXText(bv, false);
94         else
95                 return bv->text;
96 }
97
98
99 void InsetOld::setBackgroundColor(LColor::color color)
100 {
101         background_color_ = color;
102 }
103
104
105 LColor::color InsetOld::backgroundColor() const
106 {
107         if (background_color_ == LColor::inherit) {
108                 if (owner())
109                         return owner()->backgroundColor();
110                 else
111                         return LColor::background;
112         } else
113                 return background_color_;
114 }
115
116
117 int InsetOld::id() const
118 {
119         return id_;
120 }
121
122 void InsetOld::id(int id_arg)
123 {
124         id_ = id_arg;
125 }
126
127 void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
128 {}
129
130
131 bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
132 {
133         if (owner())
134                 return owner()->forceDefaultParagraphs(inset);
135         return false;
136 }
137
138 int InsetOld::latexTextWidth(BufferView * bv) const
139 {
140         if (owner())
141                 return (owner()->latexTextWidth(bv));
142         return bv->workWidth();
143 }
144
145
146 int InsetOld::ascent() const
147 {
148         return dim_.asc;
149 }
150
151
152 int InsetOld::descent() const
153 {
154         return dim_.des;
155 }
156
157
158 int InsetOld::width() const
159 {
160         return dim_.wid;
161 }
162
163
164 bool InsetOld::insetAllowed(InsetOld * in) const
165 {
166         return insetAllowed(in->lyxCode());
167 }
168
169
170 bool InsetOld::checkInsertChar(LyXFont &)
171 {
172         return false;
173 }
174
175
176 bool isEditableInset(InsetOld const * i)
177 {
178         return i && i->editable();
179 }
180
181
182 bool isHighlyEditableInset(InsetOld const * i)
183 {
184         return i && i->editable() == InsetOld::HIGHLY_EDITABLE;
185 }
186