1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation "lyxinset.h"
19 #include "BufferView.h"
20 #include "support/lstrings.h"
25 /* Insets default methods */
27 bool Inset::Deletable() const
33 bool Inset::DirectWrite() const
39 Inset::EDITABLE Inset::Editable() const
45 void Inset::Validate(LaTeXFeatures &) const
50 bool Inset::AutoDelete() const
56 void Inset::Edit(BufferView *, int, int, unsigned int)
61 LyXFont Inset::ConvertFont(LyXFont const & font) const
67 char const * Inset::EditMessage() const
69 return _("Opened inset");
73 LyXText * Inset::getLyXText(BufferView * bv) const
76 return owner()->getLyXText(bv);
82 /* some stuff for inset locking */
84 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
86 lyxerr.debug() << "Inset Button Press x=" << x
87 << ", y=" << y << ", button=" << button << endl;
91 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
93 lyxerr.debug() << "Inset Button Release x=" << x
94 << ", y=" << y << ", button=" << button << endl;
98 void UpdatableInset::InsetKeyPress(XKeyEvent *)
100 lyxerr.debug() << "Inset Keypress" << endl;
104 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
106 lyxerr.debug() << "Inset Motion Notify x=" << x
107 << ", y=" << y << ", state=" << state << endl;
111 void UpdatableInset::InsetUnlock(BufferView *)
113 lyxerr.debug() << "Inset Unlock" << endl;
117 // An updatable inset is highly editable by definition
118 Inset::EDITABLE UpdatableInset::Editable() const
120 return HIGHLY_EDITABLE;
124 void UpdatableInset::ToggleInsetCursor(BufferView *)
129 void UpdatableInset::ShowInsetCursor(BufferView *)
134 void UpdatableInset::HideInsetCursor(BufferView *)
139 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
145 mx_scx = abs((width(bv, font) - bv->workWidth()) / 2);
149 void UpdatableInset::draw(BufferView *, LyXFont const &,
150 int /* baseline */, float & x, bool/*cleared*/) const
152 if (scx) x += float(scx);
153 // ATTENTION: don't do the following here!!!
155 // top_baseline = baseline;
159 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
164 /// An updatable inset could handle lyx editing commands
166 UpdatableInset::RESULT
167 UpdatableInset::LocalDispatch(BufferView *,
168 int action, string const & arg)
170 UpdatableInset::RESULT
171 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
175 if (action==LFUN_SCROLL_INSET)
178 sscanf(arg.c_str(), "%f", &xx);
188 int UpdatableInset::getMaxWidth(Painter & pain, UpdatableInset const *) const
191 return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain, this);
192 return pain.paperWidth();