X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetbutton.C;h=b171dc91012285ed9dea6f930bd58abfe237ddad;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=d208918a18a784ec5f3d59ef7cda98d54152a2d1;hpb=666140b7f20ad45d69b6c8aad25ae37f79ef03b1;p=lyx.git diff --git a/src/insets/insetbutton.C b/src/insets/insetbutton.C index d208918a18..b171dc9101 100644 --- a/src/insets/insetbutton.C +++ b/src/insets/insetbutton.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== */ @@ -18,71 +18,76 @@ #include "debug.h" #include "BufferView.h" #include "Painter.h" +#include "support/LAssert.h" +#include "lyxfont.h" +#include "font.h" using std::ostream; using std::endl; -InsetButton::InsetButton() -{ -} - int InsetButton::ascent(BufferView * bv, LyXFont const &) const { + lyx::Assert(bv); + LyXFont font(LyXFont::ALL_SANE); font.decSize(); - int width, ascent, descent; - string s = getScreenLabel(); - - if (Editable()) { - bv->painter().buttonText(0, 0, s, font, - false, width, ascent, descent); + int width; + int ascent; + int descent; + string const s = getScreenLabel(bv->buffer()); + + if (editable()) { + lyxfont::buttonText(s, font, width, ascent, descent); } else { - bv->painter().rectText(0, 0, s, font, - LColor::commandbg, LColor::commandframe, - false, width, ascent, descent); + lyxfont::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, ascent, descent; - string s = getScreenLabel(); - - if (Editable()) { - bv->painter().buttonText(0, 0, s, font, - false, width, ascent, descent); + int width; + int ascent; + int descent; + string const s = getScreenLabel(bv->buffer()); + + if (editable()) { + lyxfont::buttonText(s, font, width, ascent, descent); } else { - bv->painter().rectText(0, 0, s, font, - LColor::commandbg, LColor::commandframe, - false, width, ascent, descent); + lyxfont::rectText(s, font, width, ascent, descent); } + return descent; } int InsetButton::width(BufferView * bv, LyXFont const &) const { + lyx::Assert(bv); + LyXFont font(LyXFont::ALL_SANE); font.decSize(); - int width, ascent, descent; - string s = getScreenLabel(); - - if (Editable()) { - bv->painter().buttonText(0, 0, s, font, - false, width, ascent, descent); + int width; + int ascent; + int descent; + string const s = getScreenLabel(bv->buffer()); + + if (editable()) { + lyxfont::buttonText(s, font, width, ascent, descent); } else { - bv->painter().rectText(0, 0, s, font, - LColor::commandbg, LColor::commandframe, - false, width, ascent, descent); + lyxfont::rectText(s, font, width, ascent, descent); } + return width + 4; } @@ -90,21 +95,21 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const void InsetButton::draw(BufferView * bv, LyXFont const &, int baseline, float & x, bool) const { + lyx::Assert(bv); + Painter & pain = bv->painter(); // Draw it as a box with the LaTeX text LyXFont font(LyXFont::ALL_SANE); font.setColor(LColor::command).decSize(); - int width; - string s = getScreenLabel(); + string const s = getScreenLabel(bv->buffer()); - if (Editable()) { - pain.buttonText(int(x)+2, baseline, s, font, true, width); + if (editable()) { + pain.buttonText(int(x) + 2, baseline, s, font); } else { - pain.rectText(int(x)+2, baseline, s, font, - LColor::commandbg, LColor::commandframe, - true, width); + pain.rectText(int(x) + 2, baseline, s, font, + LColor::commandbg, LColor::commandframe); } - x += width + 4; + x += width(bv, font); }