#include <config.h>
-
#include "insetbutton.h"
#include "debug.h"
+#include "dimension.h"
#include "BufferView.h"
+#include "funcrequest.h"
#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "support/LAssert.h"
using std::endl;
-int InsetButton::ascent(BufferView * bv, LyXFont const &) const
-{
- lyx::Assert(bv);
-
- LyXFont font(LyXFont::ALL_SANE);
- font.decSize();
-
- int width;
- int ascent;
- int descent;
- string const s = getScreenLabel(bv->buffer());
-
- if (editable()) {
- font_metrics::buttonText(s, font, width, ascent, descent);
- } else {
- font_metrics::rectText(s, font, width, ascent, descent);
- }
-
- return ascent;
-}
-
-
-int InsetButton::descent(BufferView * bv, LyXFont const &) const
-{
- lyx::Assert(bv);
-
- LyXFont font(LyXFont::ALL_SANE);
- font.decSize();
-
- int width;
- int ascent;
- int descent;
- string const s = getScreenLabel(bv->buffer());
-
- if (editable()) {
- font_metrics::buttonText(s, font, width, ascent, descent);
- } else {
- font_metrics::rectText(s, font, width, ascent, descent);
- }
-
- return descent;
-}
-
-
-int InsetButton::width(BufferView * bv, LyXFont const &) const
+void InsetButton::dimension(BufferView * bv, LyXFont const &,
+ Dimension & dim) const
{
lyx::Assert(bv);
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
- int width;
- int ascent;
- int descent;
string const s = getScreenLabel(bv->buffer());
- if (editable()) {
- font_metrics::buttonText(s, font, width, ascent, descent);
- } else {
- font_metrics::rectText(s, font, width, ascent, descent);
- }
+ if (editable())
+ font_metrics::buttonText(s, font, dim.w, dim.a, dim.d);
+ else
+ font_metrics::rectText(s, font, dim.w, dim.a, dim.d);
- return width + 4;
+ dim.w += 4;
}
void InsetButton::draw(BufferView * bv, LyXFont const &,
- int baseline, float & x, bool) const
+ int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);
}
+#warning Shouldnt this really return a shared_ptr<BufferView>? (Lgb)
BufferView * InsetButton::view() const
{
- return view_.get();
+ return view_.lock().get();
+}
+
+
+dispatch_result InsetButton::localDispatch(FuncRequest const & cmd)
+{
+ return Inset::localDispatch(cmd);
}