2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file inseterror.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 Lars Gullik Bj<EFBFBD>nnes
|
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>
|
|
|
|
|
|
2003-03-09 09:38:47 +00:00
|
|
|
|
#include "inseterror.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
|
#include "BufferView.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
|
#include "dimension.h"
|
2003-03-09 09:38:47 +00:00
|
|
|
|
#include "funcrequest.h"
|
2000-09-22 15:09:51 +00:00
|
|
|
|
#include "gettext.h"
|
2003-03-09 09:38:47 +00:00
|
|
|
|
#include "lyxfont.h"
|
2003-05-30 06:48:24 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2003-03-09 09:38:47 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
|
#include "frontends/font_metrics.h"
|
2002-05-23 12:08:47 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2002-05-23 09:21:32 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2003-03-09 09:38:47 +00:00
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
#include "support/LAssert.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
|
|
|
|
|
|
using std::ostream;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetError::InsetError(string const & str)
|
2000-09-22 15:09:51 +00:00
|
|
|
|
: contents(str)
|
2000-07-15 23:51:46 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
// InsetError::InsetError(string const & str, bool)
|
|
|
|
|
// : contents(str)
|
|
|
|
|
// {}
|
|
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
InsetError::~InsetError()
|
|
|
|
|
{
|
2003-03-12 22:17:50 +00:00
|
|
|
|
Dialogs::hide("error", this);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-09 09:38:47 +00:00
|
|
|
|
dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
|
|
|
|
|
{
|
2003-05-23 07:44:09 +00:00
|
|
|
|
// UNUSED: dispatch_result result = UNDISPATCHED;
|
2003-03-09 09:38:47 +00:00
|
|
|
|
|
|
|
|
|
switch (cmd.action) {
|
2003-05-21 21:20:50 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
|
|
|
|
case LFUN_INSET_EDIT:
|
2003-05-16 07:44:00 +00:00
|
|
|
|
cmd.view()->owner()->getDialogs().show("error", getContents(), this);
|
|
|
|
|
return DISPATCHED;
|
2003-03-09 09:38:47 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2003-05-16 07:44:00 +00:00
|
|
|
|
return Inset::localDispatch(cmd);
|
2003-03-09 09:38:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void InsetError::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont efont;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
efont.setSize(mi.base.font.size()).decSize();
|
|
|
|
|
dim_.asc = font_metrics::maxAscent(efont) + 1;
|
|
|
|
|
dim_.des = font_metrics::maxDescent(efont) + 1;
|
|
|
|
|
dim_.wid = 6 + font_metrics::width(_("Error"), efont);
|
|
|
|
|
dim = dim_;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetError::draw(PainterInfo & pi, int x, int y) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2003-05-30 06:48:24 +00:00
|
|
|
|
lyx::Assert(pi.base.bv);
|
|
|
|
|
cache(pi.base.bv);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
LyXFont efont;
|
2003-05-30 06:48:24 +00:00
|
|
|
|
efont.setSize(pi.base.font.size()).decSize();
|
2000-02-10 17:53:36 +00:00
|
|
|
|
efont.setColor(LColor::error);
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
// Draw as "Error" in a framed box
|
|
|
|
|
x += 1;
|
2003-05-30 06:48:24 +00:00
|
|
|
|
Dimension dim;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
MetricsInfo mi;
|
|
|
|
|
mi.base.bv = pi.base.bv;
|
|
|
|
|
mi.base.font = pi.base.font;
|
|
|
|
|
metrics(mi, dim);
|
|
|
|
|
dim_ = dim;
|
2003-05-30 06:48:24 +00:00
|
|
|
|
pi.pain.fillRectangle(x, y - dim.asc + 1,
|
|
|
|
|
dim.wid - 2, dim.asc + dim.des - 2, LColor::insetbg);
|
|
|
|
|
pi.pain.rectangle(x, y - dim.asc + 1,
|
|
|
|
|
dim.wid - 2, dim.asc + dim.des - 2, LColor::error);
|
|
|
|
|
pi.pain.text(x + 2, y, _("Error"), efont);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
string const InsetError::editMessage() const
|
2000-04-04 00:19:15 +00:00
|
|
|
|
{
|
|
|
|
|
return _("Opened error");
|
|
|
|
|
}
|