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"
22 #include "support/LAssert.h"
26 /* Error, used for the LaTeX-Error Messages */
28 InsetError::InsetError(string const & str, bool)
33 InsetError::~InsetError()
36 view()->owner()->getDialogs().hide("error");
40 int InsetError::ascent(BufferView *, LyXFont const & font) const
43 efont.setSize(font.size()).decSize();
44 return font_metrics::maxAscent(efont) + 1;
48 int InsetError::descent(BufferView *, LyXFont const & font) const
51 efont.setSize(font.size()).decSize();
52 return font_metrics::maxDescent(efont) + 1;
56 int InsetError::width(BufferView *, LyXFont const & font) const
59 efont.setSize(font.size()).decSize();
60 return 6 + font_metrics::width(_("Error"), efont);
64 void InsetError::draw(BufferView * bv, LyXFont const & font,
65 int baseline, float & x, bool) const
70 Painter & pain = bv->painter();
72 efont.setSize(font.size()).decSize();
73 efont.setColor(LColor::error);
75 // Draw as "Error" in a framed box
77 pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
79 ascent(bv, font) + descent(bv, font) - 2,
81 pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
83 ascent(bv, font) + descent(bv, font) - 2,
85 pain.text(int(x + 2), baseline, _("Error"), efont);
87 x += width(bv, font) - 1;
91 string const InsetError::editMessage() const
93 return _("Opened error");
97 void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
99 bv->owner()->getDialogs().show("error", getContents(), this);
103 void InsetError::edit(BufferView * bv, bool)
105 edit(bv, 0, 0, mouse_button::none);