1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 10:58:38 +00:00
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2000-03-16 04:29:22 +00:00
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "lyxinset.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lyxinset.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
#include "BufferView.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "Painter.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* Insets default methods */
|
|
|
|
|
|
|
|
bool Inset::Deletable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Inset::DirectWrite() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
Inset::EDITABLE Inset::Editable() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-08 13:52:57 +00:00
|
|
|
return NOT_EDITABLE;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void Inset::Validate(LaTeXFeatures &) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Inset::AutoDelete() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
void Inset::Edit(BufferView *, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXFont Inset::ConvertFont(LyXFont font)
|
|
|
|
{
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* some stuff for inset locking */
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Inset Button Press x=" << x
|
|
|
|
<< ", y=" << y << ", button=" << button << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Inset Button Release x=" << x
|
|
|
|
<< ", y=" << y << ", button=" << button << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdatableInset::InsetKeyPress(XKeyEvent *)
|
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Inset Keypress" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Inset Motion Notify x=" << x
|
|
|
|
<< ", y=" << y << ", state=" << state << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdatableInset::InsetUnlock(BufferView *)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Inset Unlock" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// An updatable inset is highly editable by definition
|
2000-03-08 13:52:57 +00:00
|
|
|
Inset::EDITABLE UpdatableInset::Editable() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-08 13:52:57 +00:00
|
|
|
return HIGHLY_EDITABLE;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdatableInset::ToggleInsetCursor(BufferView *)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
}
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2000-02-29 02:19:17 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
|
|
|
|
{
|
2000-03-06 02:42:40 +00:00
|
|
|
LyXFont font;
|
2000-03-02 18:30:01 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
scx = 0;
|
|
|
|
|
2000-03-14 23:33:15 +00:00
|
|
|
mx_scx = abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdatableInset::draw(Painter &, LyXFont const &,
|
|
|
|
int baseline, float & x) const
|
|
|
|
{
|
|
|
|
if (scx) x += float(scx);
|
|
|
|
top_x = int(x);
|
|
|
|
top_baseline = baseline;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 16:05:26 +00:00
|
|
|
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
/// An updatable inset could handle lyx editing commands
|
|
|
|
#ifdef SCROLL_INSET
|
2000-02-25 13:35:38 +00:00
|
|
|
UpdatableInset::RESULT
|
|
|
|
UpdatableInset::LocalDispatch(BufferView *,
|
|
|
|
int action, string const & arg)
|
2000-02-25 12:06:15 +00:00
|
|
|
#else
|
2000-02-25 13:35:38 +00:00
|
|
|
UpdatableInset::RESULT
|
|
|
|
UpdatableInset::LocalDispatch(BufferView *, int, string const &)
|
2000-02-25 12:06:15 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef SCROLL_INSET
|
|
|
|
if (action==LFUN_SCROLL_INSET)
|
|
|
|
{
|
|
|
|
float xx;
|
|
|
|
sscanf(arg.c_str(), "%f", &xx);
|
|
|
|
scroll(xx);
|
|
|
|
|
|
|
|
return DISPATCHED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return UNDISPATCHED;
|
|
|
|
}
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
int UpdatableInset::getMaxWidth(Painter & pain) const
|
|
|
|
{
|
|
|
|
if (owner_)
|
|
|
|
return owner_->getMaxWidth(pain);
|
|
|
|
return pain.paperWidth();
|
|
|
|
}
|
|
|
|
|