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 void InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
32 priv_dispatch(cur, cmd);
36 void InsetBase::priv_dispatch(LCursor & cur, FuncRequest const &)
43 void InsetBase::edit(LCursor &, bool)
45 lyxerr << "InsetBase: edit left/right" << std::endl;
49 InsetBase * InsetBase::editXY(LCursor &, int x, int y)
51 lyxerr << "InsetBase: editXY x:" << x << " y: " << y << 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 void InsetBase::markErased()
140 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
142 lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
148 void InsetBase::metricsMarkers(Dimension & dim, int) const
155 void InsetBase::metricsMarkers2(Dimension & dim, int) const
163 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
165 if (!editing(pi.base.bv))
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);
177 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
179 if (!editing(pi.base.bv))
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);
192 bool InsetBase::editing(BufferView * bv) const
194 return bv->cursor().isInside(this);
198 bool InsetBase::covers(int x, int y) const
201 && x <= xo() + width()
202 && y >= yo() - ascent()
203 && y <= yo() + descent();
207 void InsetBase::dump() const
209 Buffer buf("foo", 1);
214 /////////////////////////////////////////
216 bool isEditableInset(InsetBase const * inset)
218 return inset && inset->editable();
222 bool isHighlyEditableInset(InsetBase const * inset)
224 return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;