1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
1999-10-02 16:21:10 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 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
|
|
|
|
#endif
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
#include "BufferView.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
#include "font.h"
|
2000-09-22 15:09:51 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "inseterror.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
2000-04-04 00:19:15 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* Error, used for the LaTeX-Error Messages */
|
|
|
|
|
1999-11-04 01:40:20 +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
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetError::ascent(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
|
|
|
LyXFont efont;
|
|
|
|
efont.setSize(font.size()).decSize();
|
2000-04-04 00:19:15 +00:00
|
|
|
return lyxfont::maxAscent(efont) + 1;
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetError::descent(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
|
|
|
LyXFont efont;
|
|
|
|
efont.setSize(font.size()).decSize();
|
2000-04-04 00:19:15 +00:00
|
|
|
return lyxfont::maxDescent(efont) + 1;
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetError::width(BufferView *, LyXFont const & font) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
|
|
|
LyXFont efont;
|
|
|
|
efont.setSize(font.size()).decSize();
|
2000-04-04 00:19:15 +00:00
|
|
|
return 6 + lyxfont::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,
|
2000-06-23 15:02:46 +00:00
|
|
|
int baseline, float & x, bool) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
string const InsetError::editMessage() const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
|
|
|
return _("Opened error");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetError::edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-09-22 15:09:51 +00:00
|
|
|
bv->owner()->getDialogs()->showError( this );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|