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
44 bool Inset::IsTextInset() const
46 return ((LyxCode() == TEXT_CODE) ||
47 (LyxCode() == ERT_CODE) ||
48 (LyxCode() == FOOT_CODE) ||
49 (LyxCode() == MARGIN_CODE));
52 void Inset::Validate(LaTeXFeatures &) const
57 bool Inset::AutoDelete() const
63 void Inset::Edit(BufferView *, int, int, unsigned int)
68 LyXFont Inset::ConvertFont(LyXFont font)
74 char const * Inset::EditMessage() const
76 return _("Opened inset");
79 /* some stuff for inset locking */
81 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
83 lyxerr.debug() << "Inset Button Press x=" << x
84 << ", y=" << y << ", button=" << button << endl;
88 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
90 lyxerr.debug() << "Inset Button Release x=" << x
91 << ", y=" << y << ", button=" << button << endl;
95 void UpdatableInset::InsetKeyPress(XKeyEvent *)
97 lyxerr.debug() << "Inset Keypress" << endl;
101 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
103 lyxerr.debug() << "Inset Motion Notify x=" << x
104 << ", y=" << y << ", state=" << state << endl;
108 void UpdatableInset::InsetUnlock(BufferView *)
110 lyxerr.debug() << "Inset Unlock" << endl;
114 // An updatable inset is highly editable by definition
115 Inset::EDITABLE UpdatableInset::Editable() const
117 return HIGHLY_EDITABLE;
121 void UpdatableInset::ToggleInsetCursor(BufferView *)
126 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
132 mx_scx = abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
136 void UpdatableInset::draw(Painter &, LyXFont const &,
137 int baseline, float & x) const
139 if (scx) x += float(scx);
141 top_baseline = baseline;
145 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
150 /// An updatable inset could handle lyx editing commands
152 UpdatableInset::RESULT
153 UpdatableInset::LocalDispatch(BufferView *,
154 int action, string const & arg)
156 UpdatableInset::RESULT
157 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
161 if (action==LFUN_SCROLL_INSET)
164 sscanf(arg.c_str(), "%f", &xx);
173 int UpdatableInset::getMaxWidth(Painter & pain) const
176 return owner_->getMaxWidth(pain);
177 return pain.paperWidth();