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"
20 #include "metricsinfo.h"
22 #include "frontends/Dialogs.h"
23 #include "frontends/font_metrics.h"
24 #include "frontends/LyXView.h"
25 #include "frontends/Painter.h"
27 #include "support/LAssert.h"
32 InsetError::InsetError(string const & str)
37 // InsetError::InsetError(string const & str, bool)
42 InsetError::~InsetError()
44 Dialogs::hide("error", this);
48 dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
50 // UNUSED: dispatch_result result = UNDISPATCHED;
53 case LFUN_MOUSE_RELEASE:
55 cmd.view()->owner()->getDialogs().show("error", getContents(), this);
59 return Inset::localDispatch(cmd);
64 void InsetError::metrics(MetricsInfo & mi, Dimension & dim) const
67 efont.setSize(mi.base.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);
75 void InsetError::draw(PainterInfo & pi, int x, int y) const
77 lyx::Assert(pi.base.bv);
81 efont.setSize(pi.base.font.size()).decSize();
82 efont.setColor(LColor::error);
84 // Draw as "Error" in a framed box
88 mi.base.bv = pi.base.bv;
89 mi.base.font = pi.base.font;
92 pi.pain.fillRectangle(x, y - dim.asc + 1,
93 dim.wid - 2, dim.asc + dim.des - 2, LColor::insetbg);
94 pi.pain.rectangle(x, y - dim.asc + 1,
95 dim.wid - 2, dim.asc + dim.des - 2, LColor::error);
96 pi.pain.text(x + 2, y, _("Error"), efont);
100 string const InsetError::editMessage() const
102 return _("Opened error");