1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998-2001 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 int PainterBase::paperHeight() const
39 return owner.height();
43 PainterBase & PainterBase::circle(int x, int y, unsigned int d,
46 return ellipse(x, y, d, d, col);
50 PainterBase & PainterBase::ellipse(int x, int y,
51 unsigned int w, unsigned int h,
54 return arc(x, y, w, h, 0, 0, col);
58 PainterBase & PainterBase::button(int x, int y, int w, int h)
60 fillRectangle(x, y, w, h, LColor::buttonbg);
61 buttonFrame(x, y, w, h);
66 PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
68 // Width of a side of the button
71 fillRectangle(x, y, w, d, LColor::top);
72 fillRectangle(x, (y+h-d), w, d, LColor::bottom);
74 // Now a couple of trapezoids
77 x1[0] = x+d; y1[0] = y+d;
78 x1[1] = x+d; y1[1] = (y+h-d);
79 x1[2] = x; y1[2] = y+h;
81 fillPolygon(x1, y1, 4, LColor::left);
83 x1[0] = (x+w-d); y1[0] = y+d;
84 x1[1] = (x+w-d); y1[1] = (y+h-d);
85 x1[2] = x+w; y1[2] = (y+h-d);
86 x1[3] = x+w; y1[3] = y;
87 fillPolygon(x1, y1, 4, LColor::right);
94 PainterBase & PainterBase::rectText(int x, int baseline,
98 LColor::color frame, bool draw,
99 int & width, int & ascent, int & descent)
102 static int const d = 2;
103 width = lyxfont::width(str, font) + d * 2 + 2;
104 ascent = lyxfont::maxAscent(font) + d;
105 descent = lyxfont::maxDescent(font) + d;
107 lyxfont::rectText(str, font, width, axcent, descent);
109 if (!draw) return *this;
111 rectangle(x, baseline - ascent, width, ascent + descent, frame);
112 fillRectangle(x + 1, baseline - ascent + 1, width - 1,
113 ascent + descent - 1, back);
115 text(x + d, baseline, str, font);
117 text(x + 2, baseline, str, font);
123 PainterBase & PainterBase::buttonText(int x, int baseline,
125 LyXFont const & font, bool draw,
126 int & width, int & ascent, int & descent)
129 width = lyxfont::width(str, font) + 8;
130 ascent = lyxfont::maxAscent(font) + 3;
131 descent = lyxfont::maxDescent(font) + 3;
133 lyxfont::buttonText(str, font, width, ascent, descent);
135 if (!draw) return *this;
137 button(x, baseline - ascent, width, descent + ascent);
138 text(x + 4, baseline, str, font);
142 PainterBase & PainterBase::rectText(int x, int baseline,
144 LyXFont const & font,
152 lyxfont::rectText(str, font, width, ascent, descent);
153 rectangle(x, baseline - ascent, width, ascent + descent, frame);
154 fillRectangle(x + 1, baseline - ascent + 1, width - 1,
155 ascent + descent - 1, back);
156 text(x + 3, baseline, str, font);
161 PainterBase & PainterBase::buttonText(int x, int baseline,
163 LyXFont const & font)
169 lyxfont::buttonText(str, font, width, ascent, descent);
170 button(x, baseline - ascent, width, descent + ascent);
171 text(x + 4, baseline, str, font);