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 bool InsetBase::getStatus(LCursor &, FuncRequest const &, FuncStatus &)
49 void InsetBase::edit(LCursor &, bool)
51 lyxerr << "InsetBase: edit left/right" << std::endl;
55 InsetBase * InsetBase::editXY(LCursor &, int x, int y)
57 lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl;
62 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
65 lyxerr << "illegal row: " << row << std::endl;
67 lyxerr << "illegal col: " << col << std::endl;
72 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
74 return from <= idx && idx <= to;
78 bool InsetBase::idxUpDown(LCursor &, bool) const
84 bool InsetBase::idxUpDown2(LCursor &, bool) const
90 int InsetBase::plaintext(Buffer const &,
91 std::ostream &, OutputParams const &) const
97 int InsetBase::linuxdoc(Buffer const &,
98 std::ostream &, OutputParams const &) const
104 int InsetBase::docbook(Buffer const &,
105 std::ostream &, OutputParams const &) const
111 bool InsetBase::directWrite() const
117 InsetBase::EDITABLE InsetBase::editable() const
123 bool InsetBase::autoDelete() const
129 std::string const InsetBase::editMessage() const
131 return _("Opened inset");
135 std::string const & InsetBase::getInsetName() const
137 static std::string const name = "unknown";
142 void InsetBase::markErased()
146 void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
148 lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
154 void InsetBase::metricsMarkers(Dimension & dim, int) const
161 void InsetBase::metricsMarkers2(Dimension & dim, int) const
169 void InsetBase::drawMarkers(PainterInfo & pi, int x, int y) const
171 if (!editing(pi.base.bv))
173 int const t = x + width() - 1;
174 int const d = y + descent();
175 pi.pain.line(x, d - 3, x, d, LColor::mathframe);
176 pi.pain.line(t, d - 3, t, d, LColor::mathframe);
177 pi.pain.line(x, d, x + 3, d, LColor::mathframe);
178 pi.pain.line(t - 3, d, t, d, LColor::mathframe);
179 setPosCache(pi, x, y);
183 void InsetBase::drawMarkers2(PainterInfo & pi, int x, int y) const
185 if (!editing(pi.base.bv))
187 drawMarkers(pi, x, y);
188 int const t = x + width() - 1;
189 int const a = y - ascent();
190 pi.pain.line(x, a + 3, x, a, LColor::mathframe);
191 pi.pain.line(t, a + 3, t, a, LColor::mathframe);
192 pi.pain.line(x, a, x + 3, a, LColor::mathframe);
193 pi.pain.line(t - 3, a, t, a, LColor::mathframe);
194 setPosCache(pi, x, y);
198 bool InsetBase::editing(BufferView * bv) const
200 return bv->cursor().isInside(this);
204 bool InsetBase::covers(int x, int y) const
207 && x <= xo() + width()
208 && y >= yo() - ascent()
209 && y <= yo() + descent();
213 void InsetBase::dump() const
215 Buffer buf("foo", 1);
220 /////////////////////////////////////////
222 bool isEditableInset(InsetBase const * inset)
224 return inset && inset->editable();
228 bool isHighlyEditableInset(InsetBase const * inset)
230 return inset && inset->editable() == InsetBase::HIGHLY_EDITABLE;