3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "insetbase.h"
16 #include "BufferView.h"
20 #include "dimension.h"
21 #include "dispatchresult.h"
24 #include "metricsinfo.h"
26 #include "frontends/Painter.h"
30 DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
32 return priv_dispatch(cur, cmd);
36 DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
38 return DispatchResult(false);
42 void InsetBase::edit(LCursor &, bool)
44 lyxerr << "InsetBase: edit left/right" << std::endl;
48 void InsetBase::edit(LCursor & cur, int, int)
50 lyxerr << "InsetBase: edit xy" << std::endl;
55 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
58 lyxerr << "illegal row: " << row << std::endl;
60 lyxerr << "illegal col: " << col << std::endl;
65 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
67 return from <= idx && idx <= to;
71 bool InsetBase::idxUpDown(LCursor &, bool) const
77 bool InsetBase::idxUpDown2(LCursor &, bool) const
83 int InsetBase::plaintext(Buffer const &,
84 std::ostream &, OutputParams const &) const
90 int InsetBase::linuxdoc(Buffer const &,
91 std::ostream &, OutputParams const &) const
97 int InsetBase::docbook(Buffer const &,
98 std::ostream &, OutputParams const &) const
104 bool InsetBase::directWrite() const
110 InsetBase::EDITABLE InsetBase::editable() const
116 bool InsetBase::autoDelete() const
122 std::string const InsetBase::editMessage() const
124 return _("Opened inset");
128 std::string const & InsetBase::getInsetName() const
130 static std::string const name = "unknown";
135 int InsetBase::getCell(int x, int y) const
137 for (int i = 0, n = numParagraphs(); i < n; ++i) {
138 LyXText * text = getText(i);
139 //lyxerr << "### text: " << text << " i: " << i
140 // << " xo: " << text->xo_ << "..." << text->xo_ + text->width
141 // << " yo: " << text->yo_
142 // << " yo: " << text->yo_ - text->ascent() << "..."
143 // << text->yo_ + text->descent()
146 && x <= text->xo_ + text->width
148 && y <= text->yo_ + text->height)
150 lyxerr << "### found text # " << i << std::endl;
158 void InsetBase::markErased()
162 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
164 lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
170 void InsetBase::metricsMarkers(Dimension & dim, int) const
177 void InsetBase::metricsMarkers2(Dimension & dim, int) const
185 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
187 if (!editing(pi.base.bv))
189 int const t = x + width() - 1;
190 int const d = y + descent();
191 pi.pain.line(x, d - 3, x, d, LColor::mathframe);
192 pi.pain.line(t, d - 3, t, d, LColor::mathframe);
193 pi.pain.line(x, d, x + 3, d, LColor::mathframe);
194 pi.pain.line(t - 3, d, t, d, LColor::mathframe);
195 setPosCache(pi, x, y);
199 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
201 if (!editing(pi.base.bv))
203 drawMarkers(pi, x, y);
204 int const t = x + width() - 1;
205 int const a = y - ascent();
206 pi.pain.line(x, a + 3, x, a, LColor::mathframe);
207 pi.pain.line(t, a + 3, t, a, LColor::mathframe);
208 pi.pain.line(x, a, x + 3, a, LColor::mathframe);
209 pi.pain.line(t - 3, a, t, a, LColor::mathframe);
210 setPosCache(pi, x, y);
214 bool InsetBase::editing(BufferView * bv) const
216 return bv->cursor().isInside(this);
220 bool InsetBase::covers(int x, int y) const
223 && x <= xo() + width()
224 && y >= yo() - ascent()
225 && y <= yo() + descent();
229 void InsetBase::dump() const
231 Buffer buf("foo", 1);
236 /////////////////////////////////////////
238 bool isEditableInset(InsetBase const * inset)
240 return inset && inset->editable();
244 bool isHighlyEditableInset(InsetBase const * inset)
246 return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;