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
|
|
|
|
* Copyright 1995-1999 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"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* Insets default methods */
|
|
|
|
|
|
|
|
bool Inset::Deletable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Inset::DirectWrite() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char Inset::Editable() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
unsigned char UpdatableInset::Editable() const
|
|
|
|
{
|
|
|
|
return 2; // and what does "2" siginify? (Lgb)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
|
|
|
|
{
|
|
|
|
LyXFont
|
|
|
|
font;
|
|
|
|
// bview = bv;
|
|
|
|
scx = 0;
|
|
|
|
|
|
|
|
mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth())/2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdatableInset::draw(Painter &, LyXFont const &,
|
|
|
|
int baseline, float & x) const
|
|
|
|
{
|
|
|
|
if (scx) x += float(scx);
|
|
|
|
top_x = int(x);
|
|
|
|
top_baseline = baseline;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdatableInset::SetFont(LyXFont const &, bool )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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;
|
|
|
|
}
|