1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998-2000 The LyX Team
8 *======================================================*/
13 #pragma implementation
16 #include "PainterBase.h"
21 int PainterBase::dummy1 = 0;
22 int PainterBase::dummy2 = 0;
23 int PainterBase::dummy3 = 0;
25 int PainterBase::paperMargin() const
31 int PainterBase::paperWidth() const
33 return owner.workWidth();
37 PainterBase & PainterBase::circle(int x, int y, unsigned int d,
40 return ellipse(x, y, d, d, col);
44 PainterBase & PainterBase::ellipse(int x, int y,
45 unsigned int w, unsigned int h,
48 return arc(x, y, w, h, 0, 0, col);
52 PainterBase & PainterBase::button(int x, int y, int w, int h)
54 fillRectangle(x, y, w, h, LColor::buttonbg);
55 buttonFrame(x, y, w, h);
60 PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
62 // Width of a side of the button
65 fillRectangle(x, y, w, d, LColor::top);
66 fillRectangle(x, (y+h-d), w, d, LColor::bottom);
68 // Now a couple of trapezoids
71 x1[0] = x+d; y1[0] = y+d;
72 x1[1] = x+d; y1[1] = (y+h-d);
73 x1[2] = x; y1[2] = y+h;
75 fillPolygon(x1, y1, 4, LColor::left);
77 x1[0] = (x+w-d); y1[0] = y+d;
78 x1[1] = (x+w-d); y1[1] = (y+h-d);
79 x1[2] = x+w; y1[2] = (y+h-d);
80 x1[3] = x+w; y1[3] = y;
81 fillPolygon(x1, y1, 4, LColor::right);
87 PainterBase & PainterBase::rectText(int x, int baseline,
91 LColor::color frame, bool draw,
92 int & width, int & ascent, int & descent)
94 static int const d = 2;
95 width = lyxfont::width(str, font) + d * 2 + 2;
96 ascent = lyxfont::maxAscent(font) + d;
97 descent = lyxfont::maxDescent(font) + d;
99 if (!draw) return *this;
101 rectangle(x, baseline - ascent, width, ascent + descent, frame);
102 fillRectangle(x + 1, baseline - ascent + 1, width - 1,
103 ascent + descent - 1, back);
104 text(x + d, baseline, str, font);
109 PainterBase & PainterBase::buttonText(int x, int baseline,
111 LyXFont const & font, bool draw,
112 int & width, int & ascent, int & descent)
114 width = lyxfont::width(str, font) + 8;
115 ascent = lyxfont::maxAscent(font) + 3;
116 descent = lyxfont::maxDescent(font) + 3;
118 if (!draw) return *this;
120 button(x, baseline - ascent, width, descent + ascent);
121 text(x + 4, baseline, str, font);