3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "frontends/Painter.h"
16 #include "frontends/Application.h"
17 #include "frontends/FontLoader.h"
18 #include "frontends/FontMetrics.h"
31 void Painter::button(int x, int y, int w, int h)
33 fillRectangle(x, y, w, h, LColor::buttonbg);
34 buttonFrame(x, y, w, h);
38 void Painter::buttonFrame(int x, int y, int w, int h)
40 // Width of a side of the button
43 fillRectangle(x, y, w, d, LColor::top);
44 fillRectangle(x, y + h - d, w, d, LColor::bottom);
46 for (int i = 0 ; i < d ; ++i) {
48 x + i, y + h - 1 - i, LColor::left);
49 line(x + w - 1 - i, y + i + 1,
50 x + w - 1 - i, y + h - 1 - i, LColor::right);
55 void Painter::rectText(int x, int y,
56 docstring const & str,
65 FontMetrics const & fm = theApp->fontLoader().metrics(font);
66 fm.rectText(str, width, ascent, descent);
68 if (back != LColor::none)
69 fillRectangle(x + 1, y - ascent + 1, width - 1,
70 ascent + descent - 1, back);
72 if (frame != LColor::none)
73 rectangle(x, y - ascent, width, ascent + descent, frame);
75 text(x + 3, y, str, font);
79 void Painter::buttonText(int x, int y, docstring const & str, LyXFont const & font)
85 FontMetrics const & fm = theApp->fontLoader().metrics(font);
86 fm.buttonText(str, width, ascent, descent);
88 button(x, y - ascent, width, descent + ascent);
89 text(x + 4, y, str, font);
93 void Painter::underline(LyXFont const & f, int x, int y, int width)
95 FontMetrics const & fm = theApp->fontLoader().metrics(f);
97 int const below = max(fm.maxDescent() / 2, 2);
98 int const height = max((fm.maxDescent() / 4) - 1, 1);
101 line(x, y + below, x + width, y + below, f.color());
103 fillRectangle(x, y + below, width, below + height, f.color());
106 } // namespace frontend