1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "BufferView.h"
20 #include "inseterror.h"
23 #include "frontends/Dialogs.h"
27 /* Error, used for the LaTeX-Error Messages */
29 InsetError::InsetError(string const & str)
34 int InsetError::ascent(BufferView *, LyXFont const & font) const
37 efont.setSize(font.size()).decSize();
38 return lyxfont::maxAscent(efont) + 1;
42 int InsetError::descent(BufferView *, LyXFont const & font) const
45 efont.setSize(font.size()).decSize();
46 return lyxfont::maxDescent(efont) + 1;
50 int InsetError::width(BufferView *, LyXFont const & font) const
53 efont.setSize(font.size()).decSize();
54 return 6 + lyxfont::width(_("Error"), efont);
58 void InsetError::draw(BufferView * bv, LyXFont const & font,
59 int baseline, float & x, bool) const
61 Painter & pain = bv->painter();
63 efont.setSize(font.size()).decSize();
64 efont.setColor(LColor::error);
66 // Draw as "Error" in a framed box
68 pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
70 ascent(bv, font) + descent(bv, font) - 2,
72 pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
74 ascent(bv, font) + descent(bv, font) - 2,
76 pain.text(int(x + 2), baseline, _("Error"), efont);
78 x += width(bv, font) - 1;
82 string const InsetError::EditMessage() const
84 return _("Opened error");
88 void InsetError::Edit(BufferView * bv, int, int, unsigned int)
90 bv->owner()->getDialogs()->showError( this );