3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup Nielsen
8 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS
15 #include "insetbutton.h"
17 #include "dimension.h"
18 #include "BufferView.h"
19 #include "funcrequest.h"
20 #include "frontends/LyXView.h"
21 #include "frontends/Painter.h"
22 #include "support/LAssert.h"
24 #include "metricsinfo.h"
25 #include "frontends/font_metrics.h"
31 void InsetButton::metrics(MetricsInfo & mi, Dimension & dim) const
33 lyx::Assert(mi.base.bv);
35 LyXFont font(LyXFont::ALL_SANE);
38 string const s = getScreenLabel(mi.base.bv->buffer());
41 font_metrics::buttonText(s, font, dim.wid, dim.asc, dim.des);
43 font_metrics::rectText(s, font, dim.wid, dim.asc, dim.des);
49 void InsetButton::draw(PainterInfo & pi, int x, int y) const
51 lyx::Assert(pi.base.bv);
54 // Draw it as a box with the LaTeX text
55 LyXFont font(LyXFont::ALL_SANE);
56 font.setColor(LColor::command).decSize();
58 string const s = getScreenLabel(pi.base.bv->buffer());
61 pi.pain.buttonText(x + 2, y, s, font);
63 pi.pain.rectText(x + 2, y, s, font,
64 LColor::commandbg, LColor::commandframe);
69 void InsetButton::cache(BufferView * bv) const
71 view_ = bv->owner()->view();
75 #warning Shouldnt this really return a shared_ptr<BufferView>? (Lgb)
76 BufferView * InsetButton::view() const
78 return view_.lock().get();
82 dispatch_result InsetButton::localDispatch(FuncRequest const & cmd)
84 return Inset::localDispatch(cmd);