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()
31 int PainterBase::paperWidth()
33 return owner.workWidth();
37 int PainterBase::width(string const & s, LyXFont const & f)
39 return f.stringWidth(s);
43 int PainterBase::width(char const * s, int l, LyXFont const & f)
45 return f.textWidth(s, l);
49 int PainterBase::width(char c, LyXFont const & f)
55 PainterBase & PainterBase::circle(int x, int y, unsigned int d,
58 return ellipse(x, y, d, d, col);
62 PainterBase & PainterBase::ellipse(int x, int y,
63 unsigned int w, unsigned int h,
66 return arc(x, y, w, h, 0, 0, col);
70 PainterBase & PainterBase::button(int x, int y, int w, int h)
72 fillRectangle(x, y, w, h, LColor::buttonbg);
73 buttonFrame(x, y, w, h);
78 PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
80 // Width of a side of the button
83 fillRectangle(x, y, w, d, LColor::top);
84 fillRectangle(x, (y+h-d), w, d, LColor::bottom);
86 // Now a couple of trapezoids
89 x1[0] = x+d; y1[0] = y+d;
90 x1[1] = x+d; y1[1] = (y+h-d);
91 x1[2] = x; y1[2] = y+h;
93 fillPolygon(x1, y1, 4, LColor::left);
95 x1[0] = (x+w-d); y1[0] = y+d;
96 x1[1] = (x+w-d); y1[1] = (y+h-d);
97 x1[2] = x+w; y1[2] = (y+h-d);
98 x1[3] = x+w; y1[3] = y;
99 fillPolygon(x1, y1, 4, LColor::right);
105 PainterBase & PainterBase::rectText(int x, int baseline,
107 LyXFont const & font,
109 LColor::color frame, bool draw,
110 int & width, int & ascent, int & descent)
112 static int const d = 2;
113 width = this->width(str, font) + d * 2 + 2;
114 ascent = font.maxAscent() + d;
115 descent = font.maxDescent() + d;
117 if (!draw) return *this;
119 rectangle(x, baseline - ascent, width, ascent + descent, frame);
120 fillRectangle(x + 1, baseline - ascent + 1, width - 1,
121 ascent + descent - 1, back);
122 text(x + d, baseline, str, font);
127 PainterBase & PainterBase::buttonText(int x, int baseline,
129 LyXFont const & font, bool draw,
130 int & width, int & ascent, int & descent)
132 width = this->width(str, font) + 8;
133 ascent = font.maxAscent() + 3;
134 descent = font.maxDescent() + 3;
136 if (!draw) return *this;
138 button(x, baseline - ascent, width, descent + ascent);
139 text(x + 4, baseline, str, font);