2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file inset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "inset.h"
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#include "BufferView.h"
|
2002-08-07 08:11:41 +00:00
|
|
|
|
#include "funcrequest.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
|
#include "gettext.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "lyxfont.h"
|
2001-07-06 15:57:54 +00:00
|
|
|
|
#include "lyxtext.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
|
#include "dimension.h"
|
2003-06-02 10:03:27 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
#include "frontends/mouse_state.h"
|
|
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
// Initialization of the counter for the inset id's,
|
|
|
|
|
unsigned int Inset::inset_id = 0;
|
|
|
|
|
|
2001-07-24 15:07:09 +00:00
|
|
|
|
Inset::Inset()
|
2003-03-22 17:26:03 +00:00
|
|
|
|
: InsetBase(),
|
|
|
|
|
top_x(0), top_baseline(0), scx(0),
|
|
|
|
|
id_(inset_id++), owner_(0), par_owner_(0),
|
|
|
|
|
background_color_(LColor::inherit)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
Inset::Inset(Inset const & in)
|
2003-03-22 17:26:03 +00:00
|
|
|
|
: InsetBase(),
|
|
|
|
|
top_x(0), top_baseline(0), scx(0), owner_(0),
|
|
|
|
|
name_(in.name_), background_color_(in.background_color_)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{
|
2003-05-26 09:13:55 +00:00
|
|
|
|
id_ = inset_id++;
|
2001-07-24 15:07:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool Inset::directWrite() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-04-04 20:34:04 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
Inset::EDITABLE Inset::editable() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-04-04 20:34:04 +00:00
|
|
|
|
return NOT_EDITABLE;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-18 13:26:04 +00:00
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool Inset::autoDelete() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-04-04 20:34:04 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#if 0
|
2001-06-28 10:25:20 +00:00
|
|
|
|
LyXFont const Inset::convertFont(LyXFont const & font) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#if 1
|
|
|
|
|
return font;
|
|
|
|
|
#else
|
2001-04-04 20:34:04 +00:00
|
|
|
|
return LyXFont(font);
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
string const Inset::editMessage() const
|
2000-04-04 00:19:15 +00:00
|
|
|
|
{
|
2001-04-04 20:34:04 +00:00
|
|
|
|
return _("Opened inset");
|
2000-04-04 00:19:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-07 15:00:56 +00:00
|
|
|
|
|
2001-02-22 14:09:20 +00:00
|
|
|
|
LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
|
2000-07-07 15:00:56 +00:00
|
|
|
|
{
|
2001-04-04 20:34:04 +00:00
|
|
|
|
if (owner())
|
|
|
|
|
return owner()->getLyXText(bv, false);
|
|
|
|
|
else
|
|
|
|
|
return bv->text;
|
2000-07-07 15:00:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
void Inset::setBackgroundColor(LColor::color color)
|
|
|
|
|
{
|
|
|
|
|
background_color_ = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LColor::color Inset::backgroundColor() const
|
|
|
|
|
{
|
|
|
|
|
if (background_color_ == LColor::inherit) {
|
|
|
|
|
if (owner())
|
|
|
|
|
return owner()->backgroundColor();
|
|
|
|
|
else
|
|
|
|
|
return LColor::background;
|
|
|
|
|
} else
|
|
|
|
|
return background_color_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
int Inset::id() const
|
|
|
|
|
{
|
|
|
|
|
return id_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Inset::id(int id_arg)
|
|
|
|
|
{
|
|
|
|
|
id_ = id_arg;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
void Inset::setFont(BufferView *, LyXFont const &, bool, bool)
|
2001-08-01 15:42:53 +00:00
|
|
|
|
{}
|
|
|
|
|
|
2002-01-08 14:24:49 +00:00
|
|
|
|
|
2003-05-16 07:44:00 +00:00
|
|
|
|
bool Inset::forceDefaultParagraphs(Inset const * inset) const
|
2002-01-08 14:24:49 +00:00
|
|
|
|
{
|
|
|
|
|
if (owner())
|
2003-05-16 07:44:00 +00:00
|
|
|
|
return owner()->forceDefaultParagraphs(inset);
|
2002-01-08 14:24:49 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-19 17:05:24 +00:00
|
|
|
|
int Inset::latexTextWidth(BufferView * bv) const
|
|
|
|
|
{
|
|
|
|
|
if (owner())
|
|
|
|
|
return (owner()->latexTextWidth(bv));
|
|
|
|
|
return bv->workWidth();
|
|
|
|
|
}
|
2002-01-08 14:24:49 +00:00
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
|
|
|
|
int Inset::ascent(BufferView * bv, LyXFont const & font) const
|
|
|
|
|
{
|
|
|
|
|
Dimension dim;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
MetricsInfo mi;
|
|
|
|
|
mi.base.bv = bv;
|
|
|
|
|
mi.base.font = font;
|
|
|
|
|
metrics(mi, dim);
|
2003-05-19 17:03:12 +00:00
|
|
|
|
return dim.ascent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Inset::descent(BufferView * bv, LyXFont const & font) const
|
|
|
|
|
{
|
|
|
|
|
Dimension dim;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
MetricsInfo mi;
|
|
|
|
|
mi.base.bv = bv;
|
|
|
|
|
mi.base.font = font;
|
|
|
|
|
metrics(mi, dim);
|
2003-05-19 17:03:12 +00:00
|
|
|
|
return dim.descent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Inset::width(BufferView * bv, LyXFont const & font) const
|
|
|
|
|
{
|
|
|
|
|
Dimension dim;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
MetricsInfo mi;
|
|
|
|
|
mi.base.bv = bv;
|
|
|
|
|
mi.base.font = font;
|
|
|
|
|
metrics(mi, dim);
|
2003-05-19 17:03:12 +00:00
|
|
|
|
return dim.width();
|
|
|
|
|
}
|