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