]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.C
* insettabular.[Ch]: remove remains of the 'update' mechanism,
[lyx.git] / src / insets / insetbase.C
1 /**
2  * \file insetbase.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetbase.h"
14
15 #include "buffer.h"
16 #include "BufferView.h"
17 #include "LColor.h"
18 #include "cursor.h"
19 #include "debug.h"
20 #include "dimension.h"
21 #include "dispatchresult.h"
22 #include "gettext.h"
23 #include "lyxtext.h"
24 #include "metricsinfo.h"
25
26 #include "frontends/Painter.h"
27
28
29
30 void InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
31 {
32         priv_dispatch(cur, cmd);
33 }
34
35
36 void InsetBase::priv_dispatch(LCursor & cur, FuncRequest const &)
37 {
38         cur.noupdate();
39         cur.notdispatched();
40 }
41
42
43 void InsetBase::edit(LCursor &, bool)
44 {
45         lyxerr << "InsetBase: edit left/right" << std::endl;
46 }
47
48
49 InsetBase * InsetBase::editXY(LCursor &, int x, int y)
50 {
51         lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl;
52         return this;
53 }
54
55
56 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
57 {
58         if (row != 0)
59                 lyxerr << "illegal row: " << row << std::endl;
60         if (col != 0)
61                 lyxerr << "illegal col: " << col << std::endl;
62         return 0;
63 }
64
65
66 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
67 {
68         return from <= idx && idx <= to;
69 }
70
71
72 bool InsetBase::idxUpDown(LCursor &, bool) const
73 {
74         return false;
75 }
76
77
78 bool InsetBase::idxUpDown2(LCursor &, bool) const
79 {
80         return false;
81 }
82
83
84 int InsetBase::plaintext(Buffer const &,
85         std::ostream &, OutputParams const &) const
86 {
87         return 0;
88 }
89
90
91 int InsetBase::linuxdoc(Buffer const &,
92         std::ostream &, OutputParams const &) const
93 {
94         return 0;
95 }
96
97
98 int InsetBase::docbook(Buffer const &,
99         std::ostream &, OutputParams const &) const
100 {
101         return 0;
102 }
103
104
105 bool InsetBase::directWrite() const
106 {
107         return false;
108 }
109
110
111 InsetBase::EDITABLE InsetBase::editable() const
112 {
113         return NOT_EDITABLE;
114 }
115
116
117 bool InsetBase::autoDelete() const
118 {
119         return false;
120 }
121
122
123 std::string const InsetBase::editMessage() const
124 {
125         return _("Opened inset");
126 }
127
128
129 std::string const & InsetBase::getInsetName() const
130 {
131         static std::string const name = "unknown";
132         return name;
133 }
134
135
136 void InsetBase::markErased()
137 {}
138
139
140 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
141 {
142         lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
143         x = 100;
144         y = 100;
145 }
146
147
148 void InsetBase::metricsMarkers(Dimension & dim, int) const
149 {
150         dim.wid += 2;
151         dim.asc += 1;
152 }
153
154
155 void InsetBase::metricsMarkers2(Dimension & dim, int) const
156 {
157         dim.wid += 2;
158         dim.asc += 1;
159         dim.des += 1;
160 }
161
162
163 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
164 {
165         if (!editing(pi.base.bv))
166                 return;
167         int const t = x + width() - 1;
168         int const d = y + descent();
169         pi.pain.line(x, d - 3, x, d, LColor::mathframe);
170         pi.pain.line(t, d - 3, t, d, LColor::mathframe);
171         pi.pain.line(x, d, x + 3, d, LColor::mathframe);
172         pi.pain.line(t - 3, d, t, d, LColor::mathframe);
173         setPosCache(pi, x, y);
174 }
175
176
177 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
178 {
179         if (!editing(pi.base.bv))
180                 return;
181         drawMarkers(pi, x, y);
182         int const t = x + width() - 1;
183         int const a = y - ascent();
184         pi.pain.line(x, a + 3, x, a, LColor::mathframe);
185         pi.pain.line(t, a + 3, t, a, LColor::mathframe);
186         pi.pain.line(x, a, x + 3, a, LColor::mathframe);
187         pi.pain.line(t - 3, a, t, a, LColor::mathframe);
188         setPosCache(pi, x, y);
189 }
190
191
192 bool InsetBase::editing(BufferView * bv) const
193 {
194         return bv->cursor().isInside(this);
195 }
196
197
198 bool InsetBase::covers(int x, int y) const
199 {
200         return x >= xo()
201                         && x <= xo() + width()
202                         && y >= yo() - ascent()
203                         && y <= yo() + descent();
204 }
205
206
207 void InsetBase::dump() const
208 {
209         Buffer buf("foo", 1);
210         write(buf, lyxerr);
211 }
212
213
214 /////////////////////////////////////////
215
216 bool isEditableInset(InsetBase const * inset)
217 {
218         return inset && inset->editable();
219 }
220
221
222 bool isHighlyEditableInset(InsetBase const * inset)
223 {
224         return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;
225 }
226
227