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 /* some stuff for inset locking */
76 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
78 lyxerr.debug() << "Inset Button Press x=" << x
79 << ", y=" << y << ", button=" << button << endl;
83 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
85 lyxerr.debug() << "Inset Button Release x=" << x
86 << ", y=" << y << ", button=" << button << endl;
90 void UpdatableInset::InsetKeyPress(XKeyEvent *)
92 lyxerr.debug() << "Inset Keypress" << endl;
96 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
98 lyxerr.debug() << "Inset Motion Notify x=" << x
99 << ", y=" << y << ", state=" << state << endl;
103 void UpdatableInset::InsetUnlock(BufferView *)
105 lyxerr.debug() << "Inset Unlock" << endl;
109 // An updatable inset is highly editable by definition
110 Inset::EDITABLE UpdatableInset::Editable() const
112 return HIGHLY_EDITABLE;
116 void UpdatableInset::ToggleInsetCursor(BufferView *)
121 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
127 mx_scx = abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
131 void UpdatableInset::draw(Painter &, LyXFont const &,
132 int baseline, float & x) const
134 if (scx) x += float(scx);
136 top_baseline = baseline;
140 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
145 /// An updatable inset could handle lyx editing commands
147 UpdatableInset::RESULT
148 UpdatableInset::LocalDispatch(BufferView *,
149 int action, string const & arg)
151 UpdatableInset::RESULT
152 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
156 if (action==LFUN_SCROLL_INSET)
159 sscanf(arg.c_str(), "%f", &xx);
168 int UpdatableInset::getMaxWidth(Painter & pain) const
171 return owner_->getMaxWidth(pain);
172 return pain.paperWidth();