]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
"Inter-word Space"
[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
30 // Initialization of the counter for the inset id's,
31 unsigned int Inset::inset_id = 0;
32
33 Inset::Inset()
34         : InsetBase(),
35         top_x(0), top_baseline(0), scx(0),
36         id_(inset_id++), owner_(0), par_owner_(0),
37         background_color_(LColor::inherit)
38 {}
39
40
41 Inset::Inset(Inset const & in)
42         : InsetBase(),
43         top_x(0), top_baseline(0), scx(0), owner_(0),
44         name_(in.name_), background_color_(in.background_color_)
45 {
46         id_ = inset_id++;
47 }
48
49
50 bool Inset::directWrite() const
51 {
52         return false;
53 }
54
55
56 Inset::EDITABLE Inset::editable() const
57 {
58         return NOT_EDITABLE;
59 }
60
61
62 void Inset::validate(LaTeXFeatures &) const
63 {}
64
65
66 bool Inset::autoDelete() const
67 {
68         return false;
69 }
70
71
72 #if 0
73 LyXFont const Inset::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 Inset::editMessage() const
85 {
86         return _("Opened inset");
87 }
88
89
90 LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
91 {
92         if (owner())
93                 return owner()->getLyXText(bv, false);
94         else
95                 return bv->text;
96 }
97
98
99 void Inset::setBackgroundColor(LColor::color color)
100 {
101         background_color_ = color;
102 }
103
104
105 LColor::color Inset::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 Inset::id() const
118 {
119         return id_;
120 }
121
122 void Inset::id(int id_arg)
123 {
124         id_ = id_arg;
125 }
126
127 void Inset::setFont(BufferView *, LyXFont const &, bool, bool)
128 {}
129
130
131 bool Inset::forceDefaultParagraphs(Inset const * inset) const
132 {
133         if (owner())
134                 return owner()->forceDefaultParagraphs(inset);
135         return false;
136 }
137
138 int Inset::latexTextWidth(BufferView * bv) const
139 {
140         if (owner())
141                 return (owner()->latexTextWidth(bv));
142         return bv->workWidth();
143 }
144
145
146 int Inset::ascent(BufferView * bv, LyXFont const & font) const
147 {
148         Dimension dim;
149         dimension(bv, font, dim);
150         return dim.ascent();
151 }
152
153
154 int Inset::descent(BufferView * bv, LyXFont const & font) const
155 {
156         Dimension dim;
157         dimension(bv, font, dim);
158         return dim.descent();
159 }
160
161
162 int Inset::width(BufferView * bv, LyXFont const & font) const
163 {
164         Dimension dim;
165         dimension(bv, font, dim);
166         return dim.width();
167 }