]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
24db8ed9465b8f8c926bd46a5b9caa0fbcac64be
[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         lyxerr << "inset id: " << id_ << std::endl;
52 }
53
54
55 bool InsetOld::directWrite() const
56 {
57         return false;
58 }
59
60
61 InsetOld::EDITABLE InsetOld::editable() const
62 {
63         return NOT_EDITABLE;
64 }
65
66
67 bool InsetOld::autoDelete() const
68 {
69         return false;
70 }
71
72
73 #if 0
74 LyXFont const InsetOld::convertFont(LyXFont const & font) const
75 {
76 #if 1
77         return font;
78 #else
79         return LyXFont(font);
80 #endif
81 }
82 #endif
83
84
85 string const InsetOld::editMessage() const
86 {
87         return _("Opened inset");
88 }
89
90
91 LyXText * InsetOld::getLyXText(BufferView const * bv, bool /*recursive*/) const
92 {
93         if (owner())
94                 return owner()->getLyXText(bv, false);
95         else
96                 return bv->text;
97 }
98
99
100 void InsetOld::setBackgroundColor(LColor::color color)
101 {
102         background_color_ = color;
103 }
104
105
106 LColor::color InsetOld::backgroundColor() const
107 {
108         if (background_color_ == LColor::inherit) {
109                 if (owner())
110                         return owner()->backgroundColor();
111                 else
112                         return LColor::background;
113         } else
114                 return background_color_;
115 }
116
117
118 int InsetOld::id() const
119 {
120         return id_;
121 }
122
123 void InsetOld::id(int id_arg)
124 {
125         id_ = id_arg;
126 }
127
128 void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
129 {}
130
131
132 bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
133 {
134         if (owner())
135                 return owner()->forceDefaultParagraphs(inset);
136         return false;
137 }
138
139 int InsetOld::latexTextWidth(BufferView * bv) const
140 {
141         if (owner())
142                 return (owner()->latexTextWidth(bv));
143         return bv->workWidth();
144 }
145
146
147 int InsetOld::ascent() const
148 {
149         return dim_.asc;
150 }
151
152
153 int InsetOld::descent() const
154 {
155         return dim_.des;
156 }
157
158
159 int InsetOld::width() const
160 {
161         return dim_.wid;
162 }