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/FontMetrics.h"
29 void Painter::button(int x, int y, int w, int h)
31 fillRectangle(x, y, w, h, LColor::buttonbg);
32 buttonFrame(x, y, w, h);
36 void Painter::buttonFrame(int x, int y, int w, int h)
38 // Width of a side of the button
41 fillRectangle(x, y, w, d, LColor::top);
42 fillRectangle(x, y + h - d, w, d, LColor::bottom);
44 for (int i = 0 ; i < d ; ++i) {
46 x + i, y + h - 1 - i, LColor::left);
47 line(x + w - 1 - i, y + i + 1,
48 x + w - 1 - i, y + h - 1 - i, LColor::right);
53 void Painter::rectText(int x, int y,
54 docstring const & str,
63 FontMetrics const & fm = theFontMetrics(font);
64 fm.rectText(str, width, ascent, descent);
66 if (back != LColor::none)
67 fillRectangle(x + 1, y - ascent + 1, width - 1,
68 ascent + descent - 1, back);
70 if (frame != LColor::none)
71 rectangle(x, y - ascent, width, ascent + descent, frame);
73 text(x + 3, y, str, font);
77 void Painter::buttonText(int x, int y, docstring const & str, LyXFont const & font)
83 FontMetrics const & fm = theFontMetrics(font);
84 fm.buttonText(str, width, ascent, descent);
86 button(x, y - ascent, width, descent + ascent);
87 text(x + 4, y, str, font);
91 void Painter::underline(LyXFont const & f, int x, int y, int width)
93 FontMetrics const & fm = theFontMetrics(f);
95 int const below = max(fm.maxDescent() / 2, 2);
96 int const height = max((fm.maxDescent() / 4) - 1, 1);
99 line(x, y + below, x + width, y + below, f.color());
101 fillRectangle(x, y + below, width, below + height, f.color());
104 } // namespace frontend