3 * Copyright 1998-2002 the LyX Team
4 * Read the file COPYING
7 * \author John Levon <moz@compsoc.man.ac.uk>
13 #pragma implementation
19 #include "frontends/font_metrics.h"
23 Painter & Painter::button(int x, int y, int w, int h)
25 fillRectangle(x, y, w, h, LColor::buttonbg);
26 buttonFrame(x, y, w, h);
31 Painter & Painter::buttonFrame(int x, int y, int w, int h)
33 // Width of a side of the button
36 fillRectangle(x, y, w, d, LColor::top);
37 fillRectangle(x, (y + h - d), w, d, LColor::bottom);
39 // Now a couple of trapezoids
42 x1[0] = x + d; y1[0] = y + d;
43 x1[1] = x + d; y1[1] = (y + h - d);
44 x1[2] = x; y1[2] = y + h;
46 fillPolygon(x1, y1, 4, LColor::left);
48 x1[0] = (x + w - d); y1[0] = y + d;
49 x1[1] = (x + w - d); y1[1] = (y + h - d);
50 x1[2] = x + w; y1[2] = (y + h - d);
51 x1[3] = x + w; y1[3] = y;
52 fillPolygon(x1, y1, 4, LColor::right);
58 Painter & Painter::rectText(int x, int baseline,
68 font_metrics::rectText(str, font, width, ascent, descent);
70 if (frame != LColor::none) {
71 rectangle(x, baseline - ascent, width, ascent + descent, frame);
74 if (back != LColor::none) {
75 fillRectangle(x + 1, baseline - ascent + 1, width - 1,
76 ascent + descent - 1, back);
79 text(x + 3, baseline, str, font);
84 Painter & Painter::buttonText(int x, int baseline,
92 font_metrics::buttonText(str, font, width, ascent, descent);
94 button(x, baseline - ascent, width, descent + ascent);
95 text(x + 4, baseline, str, font);
100 void Painter::underline(LyXFont const & f, int x, int y, int width)
102 int const below = max(font_metrics::maxDescent(f) / 2, 2);
103 int const height = max((font_metrics::maxDescent(f) / 4) - 1, 1);
106 line(x, y + below, x + width, y + below, f.color());
108 fillRectangle(x, y + below, width, below + height,