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"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
|
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"
|
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
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
|
|
|
|
|
2001-04-04 20:34:04 +00:00
|
|
|
|
// Insets default methods
|
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-02-17 17:12:50 +00:00
|
|
|
|
: InsetBase(),
|
|
|
|
|
top_x(0), topx_set(false), top_baseline(0), scx(0),
|
2001-12-12 09:56:03 +00:00
|
|
|
|
id_(inset_id++), owner_(0), par_owner_(0),
|
|
|
|
|
background_color_(LColor::inherit)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inset::Inset(Inset const & in, bool same_id)
|
2003-02-17 17:12:50 +00:00
|
|
|
|
: InsetBase(),
|
|
|
|
|
top_x(0), topx_set(false), top_baseline(0), scx(0), owner_(0),
|
2001-08-07 15:07:36 +00:00
|
|
|
|
name_(in.name_), background_color_(in.background_color_)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{
|
|
|
|
|
if (same_id)
|
|
|
|
|
id_ = in.id();
|
|
|
|
|
else
|
|
|
|
|
id_ = inset_id++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2002-08-19 10:11:13 +00:00
|
|
|
|
void Inset::edit(BufferView *, int, int, mouse_button::state)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void Inset::validate(LaTeXFeatures &) const
|
2001-04-04 20:34:04 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-19 10:11:13 +00:00
|
|
|
|
void Inset::edit(BufferView *, bool)
|
2001-04-04 20:34:04 +00:00
|
|
|
|
{}
|
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
|
|
|
|
|
|
|
|
|
bool Inset::forceDefaultParagraphs(Inset const * in) const
|
|
|
|
|
{
|
|
|
|
|
if (owner())
|
|
|
|
|
return owner()->forceDefaultParagraphs(in);
|
|
|
|
|
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
|
|
|
|
|