]> git.lyx.org Git - lyx.git/blob - src/PainterBase.C
ws cleanup
[lyx.git] / src / PainterBase.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *          Copyright 1998-2001 The LyX Team
7  *
8  *======================================================*/
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "PainterBase.h"
17 #include "lyxfont.h"
18 #include "WorkArea.h"
19 #include "font.h"
20
21
22 int PainterBase::paperMargin() const
23 {
24         return 20;
25 }
26
27
28 int PainterBase::paperWidth() const
29 {
30         return owner.workWidth();
31 }
32
33
34 int PainterBase::paperHeight() const
35 {
36         return owner.height();
37 }
38
39
40 PainterBase & PainterBase::circle(int x, int y, unsigned int d,
41                                   LColor::color col)
42 {
43         return ellipse(x, y, d, d, col);
44 }
45
46
47 PainterBase & PainterBase::ellipse(int x, int y,
48                                    unsigned int w, unsigned int h,
49                                    LColor::color col)
50 {
51         return arc(x, y, w, h, 0, 0, col);
52 }
53
54
55 PainterBase & PainterBase::button(int x, int y, int w, int h)
56 {
57         fillRectangle(x, y, w, h, LColor::buttonbg);
58         buttonFrame(x, y, w, h);
59         return * this;
60 }
61
62
63 PainterBase & PainterBase::buttonFrame(int x, int y, int w, int h)
64 {
65         //  Width of a side of the button
66         int d = 2;
67
68         fillRectangle(x, y, w, d, LColor::top);
69         fillRectangle(x, (y+h-d), w, d, LColor::bottom);
70
71         // Now a couple of trapezoids
72         int x1[4], y1[4];
73
74         x1[0] = x + d;   y1[0] = y + d;
75         x1[1] = x + d;   y1[1] = (y + h - d);
76         x1[2] = x;     y1[2] = y + h;
77         x1[3] = x;     y1[3] = y;
78         fillPolygon(x1, y1, 4, LColor::left);
79
80         x1[0] = (x + w - d); y1[0] = y + d;
81         x1[1] = (x + w - d); y1[1] = (y + h - d);
82         x1[2] = x + w; y1[2] = (y + h - d);
83         x1[3] = x + w; y1[3] = y;
84         fillPolygon(x1, y1, 4, LColor::right);
85
86         return *this;
87 }
88
89
90 PainterBase & PainterBase::rectText(int x, int baseline,
91                                     string const & str,
92                                     LyXFont const & font,
93                                     LColor::color back,
94                                     LColor::color frame)
95 {
96         int width;
97         int ascent;
98         int descent;
99
100         lyxfont::rectText(str, font, width, ascent, descent);
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 + 3, baseline, str, font);
105         return *this;
106 }
107
108
109 PainterBase & PainterBase::buttonText(int x, int baseline,
110                                       string const & str,
111                                       LyXFont const & font)
112 {
113         int width;
114         int ascent;
115         int descent;
116
117         lyxfont::buttonText(str, font, width, ascent, descent);
118         button(x, baseline - ascent, width, descent + ascent);
119         text(x + 4, baseline, str, font);
120         return *this;
121 }