3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS
14 #include "BufferView.h"
15 #include "frontends/font_metrics.h"
18 #include "inseterror.h"
19 #include "frontends/LyXView.h"
20 #include "frontends/Painter.h"
21 #include "frontends/Dialogs.h"
25 /* Error, used for the LaTeX-Error Messages */
27 InsetError::InsetError(string const & str, bool)
32 int InsetError::ascent(BufferView *, LyXFont const & font) const
35 efont.setSize(font.size()).decSize();
36 return font_metrics::maxAscent(efont) + 1;
40 int InsetError::descent(BufferView *, LyXFont const & font) const
43 efont.setSize(font.size()).decSize();
44 return font_metrics::maxDescent(efont) + 1;
48 int InsetError::width(BufferView *, LyXFont const & font) const
51 efont.setSize(font.size()).decSize();
52 return 6 + font_metrics::width(_("Error"), efont);
56 void InsetError::draw(BufferView * bv, LyXFont const & font,
57 int baseline, float & x, bool) const
59 Painter & pain = bv->painter();
61 efont.setSize(font.size()).decSize();
62 efont.setColor(LColor::error);
64 // Draw as "Error" in a framed box
66 pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
68 ascent(bv, font) + descent(bv, font) - 2,
70 pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
72 ascent(bv, font) + descent(bv, font) - 2,
74 pain.text(int(x + 2), baseline, _("Error"), efont);
76 x += width(bv, font) - 1;
80 string const InsetError::editMessage() const
82 return _("Opened error");
86 void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
88 bv->owner()->getDialogs().showError(this);
92 void InsetError::edit(BufferView * bv, bool)
94 edit(bv, 0, 0, mouse_button::none);