]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
fix #832
[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
17 #include "inset.h"
18
19 #include "BufferView.h"
20 #include "funcrequest.h"
21 #include "gettext.h"
22 #include "lyxfont.h"
23 #include "lyxtext.h"
24
25 #include "frontends/Painter.h"
26 #include "frontends/mouse_state.h"
27
28 #include "support/lstrings.h"
29
30 using std::endl;
31
32
33 // Initialization of the counter for the inset id's,
34 unsigned int Inset::inset_id = 0;
35
36 Inset::Inset()
37         : InsetBase(),
38         top_x(0), top_baseline(0), scx(0),
39         id_(inset_id++), owner_(0), par_owner_(0),
40         background_color_(LColor::inherit)
41 {}
42
43
44 Inset::Inset(Inset const & in, bool same_id)
45         : InsetBase(),
46         top_x(0), top_baseline(0), scx(0), owner_(0),
47         name_(in.name_), background_color_(in.background_color_)
48 {
49         if (same_id)
50                 id_ = in.id();
51         else
52                 id_ = inset_id++;
53 }
54
55
56 bool Inset::directWrite() const
57 {
58         return false;
59 }
60
61
62 Inset::EDITABLE Inset::editable() const
63 {
64         return NOT_EDITABLE;
65 }
66
67
68 void Inset::validate(LaTeXFeatures &) const
69 {}
70
71
72 bool Inset::autoDelete() const
73 {
74         return false;
75 }
76
77
78 #if 0
79 LyXFont const Inset::convertFont(LyXFont const & font) const
80 {
81 #if 1
82         return font;
83 #else
84         return LyXFont(font);
85 #endif
86 }
87 #endif
88
89
90 string const Inset::editMessage() const
91 {
92         return _("Opened inset");
93 }
94
95
96 LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
97 {
98         if (owner())
99                 return owner()->getLyXText(bv, false);
100         else
101                 return bv->text;
102 }
103
104
105 void Inset::setBackgroundColor(LColor::color color)
106 {
107         background_color_ = color;
108 }
109
110
111 LColor::color Inset::backgroundColor() const
112 {
113         if (background_color_ == LColor::inherit) {
114                 if (owner())
115                         return owner()->backgroundColor();
116                 else
117                         return LColor::background;
118         } else
119                 return background_color_;
120 }
121
122
123 int Inset::id() const
124 {
125         return id_;
126 }
127
128 void Inset::id(int id_arg)
129 {
130         id_ = id_arg;
131 }
132
133 void Inset::setFont(BufferView *, LyXFont const &, bool, bool)
134 {}
135
136
137 bool Inset::forceDefaultParagraphs(Inset const * inset) const
138 {
139         if (owner())
140                 return owner()->forceDefaultParagraphs(inset);
141         return false;
142 }
143
144 int Inset::latexTextWidth(BufferView * bv) const
145 {
146         if (owner())
147                 return (owner()->latexTextWidth(bv));
148         return bv->workWidth();
149 }
150