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"
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
InsetError::InsetError(string const & str, bool)
|
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-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)
|
|
|
|
|
{
|
|
|
|
|
dispatch_result result = UNDISPATCHED;
|
|
|
|
|
|
|
|
|
|
switch (cmd.action) {
|
2003-05-16 07:44:00 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
|
|
|
|
case LFUN_INSET_EDIT:
|
|
|
|
|
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-05-19 17:03:12 +00:00
|
|
|
|
void InsetError::dimension(BufferView *, LyXFont const & font,
|
|
|
|
|
Dimension & dim) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
|
|
|
|
LyXFont efont;
|
|
|
|
|
efont.setSize(font.size()).decSize();
|
2003-05-19 17:03:12 +00:00
|
|
|
|
dim.a = font_metrics::maxAscent(efont) + 1;
|
|
|
|
|
dim.d = font_metrics::maxDescent(efont) + 1;
|
|
|
|
|
dim.w = 6 + font_metrics::width(_("Error"), efont);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
|
void InsetError::draw(BufferView * bv, LyXFont const & font,
|
2003-03-17 01:34:36 +00:00
|
|
|
|
int baseline, float & x) const
|
2000-02-10 17:53:36 +00:00
|
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
|
lyx::Assert(bv);
|
|
|
|
|
cache(bv);
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
|
Painter & pain = bv->painter();
|
2000-02-10 17:53:36 +00:00
|
|
|
|
LyXFont efont;
|
|
|
|
|
efont.setSize(font.size()).decSize();
|
|
|
|
|
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;
|
2000-07-05 14:57:48 +00:00
|
|
|
|
pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
|
|
|
|
|
width(bv, font) - 2,
|
|
|
|
|
ascent(bv, font) + descent(bv, font) - 2,
|
2000-02-10 17:53:36 +00:00
|
|
|
|
LColor::insetbg);
|
2000-07-05 14:57:48 +00:00
|
|
|
|
pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
|
|
|
|
|
width(bv, font) - 2,
|
|
|
|
|
ascent(bv, font) + descent(bv, font) - 2,
|
2000-02-10 17:53:36 +00:00
|
|
|
|
LColor::error);
|
|
|
|
|
pain.text(int(x + 2), baseline, _("Error"), efont);
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
|
x += width(bv, font) - 1;
|
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");
|
|
|
|
|
}
|