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
13 #include "inseterror.h"
15 #include "BufferView.h"
16 #include "dimension.h"
17 #include "funcrequest.h"
21 #include "frontends/Dialogs.h"
22 #include "frontends/font_metrics.h"
23 #include "frontends/LyXView.h"
24 #include "frontends/Painter.h"
26 #include "support/LAssert.h"
31 InsetError::InsetError(string const & str)
36 // InsetError::InsetError(string const & str, bool)
41 InsetError::~InsetError()
43 Dialogs::hide("error", this);
47 dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
49 // UNUSED: dispatch_result result = UNDISPATCHED;
52 case LFUN_MOUSE_RELEASE:
54 cmd.view()->owner()->getDialogs().show("error", getContents(), this);
58 return Inset::localDispatch(cmd);
63 void InsetError::dimension(BufferView *, LyXFont const & font,
64 Dimension & dim) const
67 efont.setSize(font.size()).decSize();
68 dim.asc = font_metrics::maxAscent(efont) + 1;
69 dim.des = font_metrics::maxDescent(efont) + 1;
70 dim.wid = 6 + font_metrics::width(_("Error"), efont);
74 void InsetError::draw(BufferView * bv, LyXFont const & font,
75 int baseline, float & x) const
80 Painter & pain = bv->painter();
82 efont.setSize(font.size()).decSize();
83 efont.setColor(LColor::error);
85 // Draw as "Error" in a framed box
87 pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
89 ascent(bv, font) + descent(bv, font) - 2,
91 pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
93 ascent(bv, font) + descent(bv, font) - 2,
95 pain.text(int(x + 2), baseline, _("Error"), efont);
97 x += width(bv, font) - 1;
101 string const InsetError::editMessage() const
103 return _("Opened error");