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 lyxerr << "InsetBase::priv_dispatch" << std::endl;
39 return DispatchResult(false);
43 void InsetBase::edit(LCursor &, bool)
45 lyxerr << "InsetBase: edit left/right" << std::endl;
49 InsetBase * InsetBase::editXY(LCursor & cur, int, int)
51 lyxerr << "InsetBase: edit xy" << std::endl;
56 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
59 lyxerr << "illegal row: " << row << std::endl;
61 lyxerr << "illegal col: " << col << std::endl;
66 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
68 return from <= idx && idx <= to;
72 bool InsetBase::idxUpDown(LCursor &, bool) const
78 bool InsetBase::idxUpDown2(LCursor &, bool) const
84 int InsetBase::plaintext(Buffer const &,
85 std::ostream &, OutputParams const &) const
91 int InsetBase::linuxdoc(Buffer const &,
92 std::ostream &, OutputParams const &) const
98 int InsetBase::docbook(Buffer const &,
99 std::ostream &, OutputParams const &) const
105 bool InsetBase::directWrite() const
111 InsetBase::EDITABLE InsetBase::editable() const
117 bool InsetBase::autoDelete() const
123 std::string const InsetBase::editMessage() const
125 return _("Opened inset");
129 std::string const & InsetBase::getInsetName() const
131 static std::string const name = "unknown";
136 int InsetBase::getCell(int x, int y) const
138 for (int i = 0, n = numParagraphs(); i < n; ++i) {
139 LyXText * text = getText(i);
140 //lyxerr << "### text: " << text << " i: " << i
141 // << " xo: " << text->xo_ << "..." << text->xo_ + text->width
142 // << " yo: " << text->yo_
143 // << " yo: " << text->yo_ - text->ascent() << "..."
144 // << text->yo_ + text->descent()
147 && x <= text->xo_ + text->width
149 && y <= text->yo_ + text->height)
151 lyxerr << "### found text # " << i << std::endl;
159 void InsetBase::markErased()
163 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
165 lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
171 void InsetBase::metricsMarkers(Dimension & dim, int) const
178 void InsetBase::metricsMarkers2(Dimension & dim, int) const
186 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
188 if (!editing(pi.base.bv))
190 int const t = x + width() - 1;
191 int const d = y + descent();
192 pi.pain.line(x, d - 3, x, d, LColor::mathframe);
193 pi.pain.line(t, d - 3, t, d, LColor::mathframe);
194 pi.pain.line(x, d, x + 3, d, LColor::mathframe);
195 pi.pain.line(t - 3, d, t, d, LColor::mathframe);
196 setPosCache(pi, x, y);
200 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
202 if (!editing(pi.base.bv))
204 drawMarkers(pi, x, y);
205 int const t = x + width() - 1;
206 int const a = y - ascent();
207 pi.pain.line(x, a + 3, x, a, LColor::mathframe);
208 pi.pain.line(t, a + 3, t, a, LColor::mathframe);
209 pi.pain.line(x, a, x + 3, a, LColor::mathframe);
210 pi.pain.line(t - 3, a, t, a, LColor::mathframe);
211 setPosCache(pi, x, y);
215 bool InsetBase::editing(BufferView * bv) const
217 return bv->cursor().isInside(this);
221 bool InsetBase::covers(int x, int y) const
224 && x <= xo() + width()
225 && y >= yo() - ascent()
226 && y <= yo() + descent();
230 void InsetBase::dump() const
232 Buffer buf("foo", 1);
237 /////////////////////////////////////////
239 bool isEditableInset(InsetBase const * inset)
241 return inset && inset->editable();
245 bool isHighlyEditableInset(InsetBase const * inset)
247 return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;