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
|
|
|
}
|
|
|
|
|
2000-05-18 13:26:04 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
char const * Inset::EditMessage() const
|
|
|
|
{
|
|
|
|
return _("Opened inset");
|
|
|
|
}
|
|
|
|
|
2000-07-07 15:00:56 +00:00
|
|
|
|
|
|
|
LyXText * Inset::getLyXText(BufferView * bv) const
|
|
|
|
{
|
|
|
|
if (owner())
|
|
|
|
return owner()->getLyXText(bv);
|
|
|
|
else
|
|
|
|
return bv->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* 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-05-18 13:26:04 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
void UpdatableInset::ShowInsetCursor(BufferView *)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
2000-04-19 14:42:19 +00:00
|
|
|
void UpdatableInset::HideInsetCursor(BufferView *)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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-07-05 14:57:48 +00:00
|
|
|
mx_scx = abs((width(bv, font) - bv->workWidth()) / 2);
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
void UpdatableInset::draw(BufferView *, LyXFont const &,
|
2000-06-26 15:10:49 +00:00
|
|
|
int /* baseline */, float & x, bool/*cleared*/) const
|
2000-02-25 12:06:15 +00:00
|
|
|
{
|
|
|
|
if (scx) x += float(scx);
|
2000-05-15 14:49:36 +00:00
|
|
|
// ATTENTION: don't do the following here!!!
|
2000-04-20 13:48:34 +00:00
|
|
|
// top_x = int(x);
|
|
|
|
// top_baseline = baseline;
|
2000-02-25 12:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
2000-05-15 14:49:36 +00:00
|
|
|
int UpdatableInset::getMaxWidth(Painter & pain, UpdatableInset const *) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2000-04-19 14:42:19 +00:00
|
|
|
if (owner())
|
2000-05-15 14:49:36 +00:00
|
|
|
return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain, this);
|
2000-03-08 13:52:57 +00:00
|
|
|
return pain.paperWidth();
|
|
|
|
}
|