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