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"
15 #include "BufferView.h"
19 #include "dimension.h"
20 #include "dispatchresult.h"
23 #include "metricsinfo.h"
25 #include "frontends/Painter.h"
29 DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
31 return priv_dispatch(cur, cmd);
35 DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
37 return DispatchResult(false);
41 void InsetBase::edit(LCursor &, bool)
43 lyxerr << "InsetBase: edit left/right" << std::endl;
47 void InsetBase::edit(LCursor & cur, int, int)
49 lyxerr << "InsetBase: edit xy" << std::endl;
54 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
57 lyxerr << "illegal row: " << row << std::endl;
59 lyxerr << "illegal col: " << col << std::endl;
64 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
66 return from <= idx && idx <= to;
70 bool InsetBase::idxUpDown(LCursor &, bool) const
76 bool InsetBase::idxUpDown2(LCursor &, bool) const
82 int InsetBase::plaintext(Buffer const &,
83 std::ostream &, OutputParams const &) const
89 int InsetBase::linuxdoc(Buffer const &,
90 std::ostream &, OutputParams const &) const
96 int InsetBase::docbook(Buffer const &,
97 std::ostream &, OutputParams const &) const
103 bool InsetBase::directWrite() const
109 InsetBase::EDITABLE InsetBase::editable() const
115 bool InsetBase::autoDelete() const
121 std::string const InsetBase::editMessage() const
123 return _("Opened inset");
127 std::string const & InsetBase::getInsetName() const
129 static std::string const name = "unknown";
134 int InsetBase::getCell(int x, int y) const
136 for (int i = 0, n = numParagraphs(); i < n; ++i) {
137 LyXText * text = getText(i);
138 //lyxerr << "### text: " << text << " i: " << i
139 // << " xo: " << text->xo_ << "..." << text->xo_ + text->width
140 // << " yo: " << text->yo_
141 // << " yo: " << text->yo_ - text->ascent() << "..."
142 // << text->yo_ + text->descent()
145 && x <= text->xo_ + text->width
147 && y <= text->yo_ + text->height)
149 lyxerr << "### found text # " << i << std::endl;
157 void InsetBase::markErased()
161 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
163 lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
169 void InsetBase::metricsMarkers(Dimension & dim, int) const
176 void InsetBase::metricsMarkers2(Dimension & dim, int) const
184 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
186 if (!editing(pi.base.bv))
188 int const t = x + width() - 1;
189 int const d = y + descent();
190 pi.pain.line(x, d - 3, x, d, LColor::mathframe);
191 pi.pain.line(t, d - 3, t, d, LColor::mathframe);
192 pi.pain.line(x, d, x + 3, d, LColor::mathframe);
193 pi.pain.line(t - 3, d, t, d, LColor::mathframe);
194 setPosCache(pi, x, y);
198 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
200 if (!editing(pi.base.bv))
202 drawMarkers(pi, x, y);
203 int const t = x + width() - 1;
204 int const a = y - ascent();
205 pi.pain.line(x, a + 3, x, a, LColor::mathframe);
206 pi.pain.line(t, a + 3, t, a, LColor::mathframe);
207 pi.pain.line(x, a, x + 3, a, LColor::mathframe);
208 pi.pain.line(t - 3, a, t, a, LColor::mathframe);
209 setPosCache(pi, x, y);
213 bool InsetBase::editing(BufferView * bv) const
215 return bv->cursor().isInside(this);
219 bool InsetBase::covers(int x, int y) const
222 && x <= xo() + width()
223 && y >= yo() - ascent()
224 && y <= yo() + descent();
228 /////////////////////////////////////////
230 bool isEditableInset(InsetBase const * inset)
232 return inset && inset->editable();
236 bool isHighlyEditableInset(InsetBase const * inset)
238 return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;