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 bool Inset::IsTextInset() const
47 return ((LyxCode() == TEXT_CODE) ||
48 (LyxCode() == ERT_CODE) ||
49 (LyxCode() == FOOT_CODE) ||
50 (LyxCode() == MARGIN_CODE));
54 void Inset::Validate(LaTeXFeatures &) const
59 bool Inset::AutoDelete() const
65 void Inset::Edit(BufferView *, int, int, unsigned int)
70 LyXFont Inset::ConvertFont(LyXFont font)
76 char const * Inset::EditMessage() const
78 return _("Opened inset");
81 /* some stuff for inset locking */
83 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
85 lyxerr.debug() << "Inset Button Press x=" << x
86 << ", y=" << y << ", button=" << button << endl;
90 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
92 lyxerr.debug() << "Inset Button Release x=" << x
93 << ", y=" << y << ", button=" << button << endl;
97 void UpdatableInset::InsetKeyPress(XKeyEvent *)
99 lyxerr.debug() << "Inset Keypress" << endl;
103 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
105 lyxerr.debug() << "Inset Motion Notify x=" << x
106 << ", y=" << y << ", state=" << state << endl;
110 void UpdatableInset::InsetUnlock(BufferView *)
112 lyxerr.debug() << "Inset Unlock" << endl;
116 // An updatable inset is highly editable by definition
117 Inset::EDITABLE UpdatableInset::Editable() const
119 return HIGHLY_EDITABLE;
123 void UpdatableInset::ToggleInsetCursor(BufferView *)
128 void UpdatableInset::ShowInsetCursor(BufferView *)
133 void UpdatableInset::HideInsetCursor(BufferView *)
138 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
144 mx_scx = abs((width(bv->painter(), font) - bv->paperWidth()) / 2);
148 void UpdatableInset::draw(Painter &, LyXFont const &,
149 int /* baseline */, float & x) const
151 if (scx) x += float(scx);
152 // ATTENTION: don't do the following here!!!
154 // top_baseline = baseline;
158 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
163 /// An updatable inset could handle lyx editing commands
165 UpdatableInset::RESULT
166 UpdatableInset::LocalDispatch(BufferView *,
167 int action, string const & arg)
169 UpdatableInset::RESULT
170 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
174 if (action==LFUN_SCROLL_INSET)
177 sscanf(arg.c_str(), "%f", &xx);
187 int UpdatableInset::getMaxWidth(Painter & pain, UpdatableInset const *) const
190 return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain, this);
191 return pain.paperWidth();