2000-06-12 11:27:15 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetbutton.h"
|
|
|
|
#include "debug.h"
|
2000-06-21 15:07:57 +00:00
|
|
|
#include "BufferView.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "Painter.h"
|
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
InsetButton::InsetButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsetButton::ascent(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
|
|
|
int width, ascent, descent;
|
|
|
|
string s = getScreenLabel();
|
|
|
|
|
|
|
|
if (Editable()) {
|
|
|
|
pain.buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
pain.rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
}
|
|
|
|
return ascent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetButton::descent(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
|
|
|
int width, ascent, descent;
|
|
|
|
string s = getScreenLabel();
|
|
|
|
|
|
|
|
if (Editable()) {
|
|
|
|
pain.buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
pain.rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
}
|
|
|
|
return descent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetButton::width(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
|
|
|
int width, ascent, descent;
|
|
|
|
string s = getScreenLabel();
|
|
|
|
|
|
|
|
if (Editable()) {
|
|
|
|
pain.buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
pain.rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
|
|
|
}
|
|
|
|
return width + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
void InsetButton::draw(BufferView * bv, LyXFont const &,
|
2000-06-12 11:27:15 +00:00
|
|
|
int baseline, float & x) const
|
|
|
|
{
|
2000-06-21 15:07:57 +00:00
|
|
|
Painter & pain = bv->painter();
|
2000-06-12 11:27:15 +00:00
|
|
|
// Draw it as a box with the LaTeX text
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.setColor(LColor::command).decSize();
|
|
|
|
|
|
|
|
int width;
|
|
|
|
string s = getScreenLabel();
|
|
|
|
|
|
|
|
if (Editable()) {
|
|
|
|
pain.buttonText(int(x)+2, baseline, s, font, true, width);
|
|
|
|
} else {
|
|
|
|
pain.rectText(int(x)+2, baseline, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
true, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
x += width + 4;
|
|
|
|
}
|