2002-09-11 08:26:02 +00:00
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
#include <config.h>
|
2002-06-24 15:51:35 +00:00
|
|
|
|
|
|
|
#include "button_inset.h"
|
|
|
|
#include "math_support.h"
|
2003-03-21 14:20:48 +00:00
|
|
|
#include "metricsinfo.h"
|
2002-06-24 15:51:35 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
using std::max;
|
|
|
|
|
2002-06-24 15:51:35 +00:00
|
|
|
|
|
|
|
ButtonInset::ButtonInset()
|
|
|
|
: MathNestInset(2)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
void ButtonInset::metrics(MetricsInfo & mi) const
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
FontSetChanger dummy(mi.base, "textnormal");
|
2002-06-24 15:51:35 +00:00
|
|
|
if (editing()) {
|
|
|
|
MathNestInset::metrics(mi);
|
2002-08-02 14:29:42 +00:00
|
|
|
dim_.w = cell(0).width() + cell(1).width() + 4;
|
|
|
|
dim_.a = max(cell(0).ascent(), cell(1).ascent());
|
|
|
|
dim_.d = max(cell(0).descent(), cell(1).descent());
|
2002-06-24 15:51:35 +00:00
|
|
|
} else {
|
2002-07-11 11:27:24 +00:00
|
|
|
mathed_string_dim(mi.base.font, screenLabel(), dim_);
|
|
|
|
dim_.w += 10;
|
2002-06-24 15:51:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
void ButtonInset::draw(PainterInfo & pi, int x, int y) const
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
FontSetChanger dummy(pi.base, "textnormal");
|
2002-06-24 15:51:35 +00:00
|
|
|
if (editing()) {
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
|
|
|
cell(1).draw(pi, x + cell(0).width() + 2, y);
|
2002-06-24 15:51:35 +00:00
|
|
|
mathed_draw_framebox(pi, x, y, this);
|
|
|
|
} else {
|
2002-08-02 14:04:16 +00:00
|
|
|
pi.pain.buttonText(x + 2, y, screenLabel(), pi.base.font);
|
2002-06-24 15:51:35 +00:00
|
|
|
}
|
|
|
|
}
|