2000-06-12 11:27:15 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 2000-2001 The LyX Team.
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#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"
|
2001-05-04 10:36:36 +00:00
|
|
|
#include "support/LAssert.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "lyxfont.h"
|
2001-07-24 09:12:20 +00:00
|
|
|
#include "font.h"
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetButton::ascent(BufferView * bv, LyXFont const &) const
|
2000-06-12 11:27:15 +00:00
|
|
|
{
|
2001-05-04 10:36:36 +00:00
|
|
|
lyx::Assert(bv);
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
int width;
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
string const s = getScreenLabel();
|
2001-07-24 09:12:20 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-06-28 10:25:20 +00:00
|
|
|
if (editable()) {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
} else {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
2001-07-24 09:12:20 +00:00
|
|
|
#else
|
|
|
|
if (editable()) {
|
|
|
|
lyxfont::buttonText(s, font, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
lyxfont::rectText(s, font, width, ascent, descent);
|
|
|
|
}
|
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
return ascent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetButton::descent(BufferView * bv, LyXFont const &) const
|
2000-06-12 11:27:15 +00:00
|
|
|
{
|
2001-05-04 10:36:36 +00:00
|
|
|
lyx::Assert(bv);
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
int width;
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
string const s = getScreenLabel();
|
2001-07-24 09:12:20 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-06-28 10:25:20 +00:00
|
|
|
if (editable()) {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
} else {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
2001-07-24 09:12:20 +00:00
|
|
|
#else
|
|
|
|
if (editable()) {
|
|
|
|
lyxfont::buttonText(s, font, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
lyxfont::rectText(s, font, width, ascent, descent);
|
|
|
|
}
|
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
return descent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetButton::width(BufferView * bv, LyXFont const &) const
|
2000-06-12 11:27:15 +00:00
|
|
|
{
|
2001-05-04 10:36:36 +00:00
|
|
|
lyx::Assert(bv);
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
font.decSize();
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
int width;
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
string const s = getScreenLabel();
|
2001-07-24 09:12:20 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-06-28 10:25:20 +00:00
|
|
|
if (editable()) {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().buttonText(0, 0, s, font,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
} else {
|
2000-07-05 14:57:48 +00:00
|
|
|
bv->painter().rectText(0, 0, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
false, width, ascent, descent);
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|
2001-07-24 09:12:20 +00:00
|
|
|
#else
|
|
|
|
if (editable()) {
|
|
|
|
lyxfont::buttonText(s, font, width, ascent, descent);
|
|
|
|
} else {
|
|
|
|
lyxfont::rectText(s, font, width, ascent, descent);
|
|
|
|
}
|
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
return width + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
void InsetButton::draw(BufferView * bv, LyXFont const &,
|
2000-06-23 15:02:46 +00:00
|
|
|
int baseline, float & x, bool) const
|
2000-06-12 11:27:15 +00:00
|
|
|
{
|
2001-05-04 10:36:36 +00:00
|
|
|
lyx::Assert(bv);
|
|
|
|
|
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();
|
|
|
|
|
2001-05-04 10:36:36 +00:00
|
|
|
string const s = getScreenLabel();
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-07-24 09:12:20 +00:00
|
|
|
#if 0
|
|
|
|
int width;
|
2001-06-28 10:25:20 +00:00
|
|
|
if (editable()) {
|
2001-05-04 10:36:36 +00:00
|
|
|
pain.buttonText(int(x) + 2, baseline, s, font, true, width);
|
2000-06-12 11:27:15 +00:00
|
|
|
} else {
|
2001-05-04 10:36:36 +00:00
|
|
|
pain.rectText(int(x) + 2, baseline, s, font,
|
2000-06-12 11:27:15 +00:00
|
|
|
LColor::commandbg, LColor::commandframe,
|
|
|
|
true, width);
|
|
|
|
}
|
2001-07-24 09:12:20 +00:00
|
|
|
#else
|
|
|
|
if (editable()) {
|
|
|
|
pain.buttonText(int(x) + 2, baseline, s, font);
|
|
|
|
} else {
|
|
|
|
pain.rectText(int(x) + 2, baseline, s, font,
|
|
|
|
LColor::commandbg, LColor::commandframe);
|
|
|
|
}
|
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2001-07-24 09:12:20 +00:00
|
|
|
#if 0
|
2000-06-12 11:27:15 +00:00
|
|
|
x += width + 4;
|
2001-07-24 09:12:20 +00:00
|
|
|
#else
|
|
|
|
x += width(bv, font);
|
|
|
|
#endif
|
2000-06-12 11:27:15 +00:00
|
|
|
}
|