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 "frontends/font_metrics.h"
30 void InsetButton::dimension(BufferView * bv, LyXFont const &,
31 Dimension & dim) const
35 LyXFont font(LyXFont::ALL_SANE);
38 string const s = getScreenLabel(bv->buffer());
41 font_metrics::buttonText(s, font, dim.w, dim.a, dim.d);
43 font_metrics::rectText(s, font, dim.w, dim.a, dim.d);
49 void InsetButton::draw(BufferView * bv, LyXFont const &,
50 int baseline, float & x) const
55 Painter & pain = bv->painter();
56 // Draw it as a box with the LaTeX text
57 LyXFont font(LyXFont::ALL_SANE);
58 font.setColor(LColor::command).decSize();
60 string const s = getScreenLabel(bv->buffer());
63 pain.buttonText(int(x) + 2, baseline, s, font);
65 pain.rectText(int(x) + 2, baseline, s, font,
66 LColor::commandbg, LColor::commandframe);
73 void InsetButton::cache(BufferView * bv) const
75 view_ = bv->owner()->view();
79 #warning Shouldnt this really return a shared_ptr<BufferView>? (Lgb)
80 BufferView * InsetButton::view() const
82 return view_.lock().get();
86 dispatch_result InsetButton::localDispatch(FuncRequest const & cmd)
88 return Inset::localDispatch(cmd);