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, bool mouseHover)
32 fillRectangle(x, y, w, h, LColor::buttonhoverbg);
34 fillRectangle(x, y, w, h, LColor::buttonbg);
35 buttonFrame(x, y, w, h);
39 void Painter::buttonFrame(int x, int y, int w, int h)
41 line(x, y, x, y + h - 1, LColor::buttonframe);
42 line(x - 1 + w, y, x - 1 + w, y + h - 1, LColor::buttonframe);
43 line(x, y - 1, x - 1 + w, y - 1, LColor::buttonframe);
44 line(x, y + h - 1, x - 1 + w, y + h - 1, LColor::buttonframe);
48 void Painter::rectText(int x, int y,
49 docstring const & str,
58 FontMetrics const & fm = theFontMetrics(font);
59 fm.rectText(str, width, ascent, descent);
61 if (back != LColor::none)
62 fillRectangle(x + 1, y - ascent + 1, width - 1,
63 ascent + descent - 1, back);
65 if (frame != LColor::none)
66 rectangle(x, y - ascent, width, ascent + descent, frame);
68 text(x + 3, y, str, font);
72 void Painter::buttonText(int x, int y, docstring const & str,
73 LyXFont const & font, bool mouseHover)
79 FontMetrics const & fm = theFontMetrics(font);
80 fm.buttonText(str, width, ascent, descent);
82 button(x, y - ascent, width, descent + ascent, mouseHover);
83 text(x + 3, y - 1, str, font);
87 void Painter::underline(LyXFont const & f, int x, int y, int width)
89 FontMetrics const & fm = theFontMetrics(f);
91 int const below = max(fm.maxDescent() / 2, 2);
92 int const height = max((fm.maxDescent() / 4) - 1, 1);
95 line(x, y + below, x + width, y + below, f.color());
97 fillRectangle(x, y + below, width, below + height, f.color());
100 } // namespace frontend