]> git.lyx.org Git - lyx.git/blob - src/PainterBase.h
Remove unused font variable which caused a warning.
[lyx.git] / src / PainterBase.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1998-2001 The LyX Team
8  *
9  *======================================================*/
10
11 #ifndef PAINTERBASE_H
12 #define PAINTERBASE_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "LString.h"
19 #include "LColor.h"
20
21 class WorkArea;
22 class LyXFont;
23 class LyXImage;
24
25 /** A painter class to encapsulate all graphics parameters and operations
26    
27     Every graphics operation in LyX should be made by this class. It will 
28     be initialized and managed by the Screen class, and will be passed
29     as a parameter to inset.
30  
31     It hides low level windows system parameters so insets and other
32     clients don't have to worry about them and we can control graphics and
33     GUI toolkit dependent drawing functions inside this single class.
34  
35  */
36 class PainterBase {
37 protected:
38         ///
39         static int dummy1;
40         ///
41         static int dummy2;
42         ///
43         static int dummy3;
44 public:
45         ///
46         enum line_width {
47                 ///
48                 line_thin,
49                 ///
50                 line_thick
51         };
52
53         ///
54         enum line_style {
55                 ///
56                 line_solid,
57                 ///
58                 line_doubledash,
59                 ///
60                 line_onoffdash
61         };
62
63         ///
64         explicit PainterBase(WorkArea & wa) : owner(wa) {}
65         
66         ///
67         virtual ~PainterBase() {}
68
69         /* Screen geometry */
70         ///
71         int paperMargin() const;
72         ///
73         int paperWidth() const;
74         ///
75         int paperHeight() const;
76         
77         /// Draw a line from point to point
78         virtual PainterBase & line(
79                 int x1, int y1, int x2, int y2, 
80                 LColor::color = LColor::foreground,
81                 enum line_style = line_solid,
82                 enum line_width = line_thin) = 0;
83
84         /** Draw the lines between the lines in xp and yp.
85             xp and yp are arrays of points, and np is the
86             number of them. */
87         virtual PainterBase & lines(
88                 int const * xp, int const * yp, int np,
89                 LColor::color = LColor::foreground,
90                 enum line_style = line_solid,
91                 enum line_width = line_thin) = 0;
92
93         /// Here xp and yp are arrays of points
94         virtual PainterBase & fillPolygon(
95                 int const * xp, int const * yp,
96                 int np,
97                 LColor::color = LColor::foreground) = 0;
98
99         /// Draw lines from x1,y1 to x2,y2. They are arrays
100         virtual PainterBase & segments(
101                 int const * x1, int const * y1, 
102                 int const * x2, int const * y2, int ns,
103                 LColor::color = LColor::foreground,
104                 enum line_style = line_solid,
105                 enum line_width = line_thin) = 0;
106         
107         /// Draw a rectangle 
108         virtual PainterBase & rectangle(
109                 int x, int y, int w, int h,
110                 LColor::color = LColor::foreground,
111                 enum line_style = line_solid,
112                 enum line_width = line_thin) = 0;
113         
114         /// Draw a circle, d is the diameter, not the radious
115         virtual PainterBase & circle(
116                 int x, int y, unsigned int d,
117                 LColor::color = LColor::foreground);
118
119         /// Draw an ellipse
120         virtual PainterBase & ellipse(
121                 int x, int y,
122                 unsigned int w, unsigned int h,
123                 LColor::color = LColor::foreground);
124         
125         /// Draw an arc
126         virtual PainterBase & arc(
127                 int x, int y,
128                 unsigned int w, unsigned int h, 
129                 int a1, int a2,
130                 LColor::color = LColor::foreground) = 0;
131         
132         /// Draw a pixel
133         virtual PainterBase & point(
134                 int x, int y,
135                 LColor::color = LColor::foreground) = 0;
136         
137         /// Fill a rectangle
138         virtual PainterBase & fillRectangle(
139                 int x, int y, int w, int h,
140                 LColor::color) = 0;
141         
142         /// A filled rectangle with the shape of a 3D button
143         virtual PainterBase & button(int x, int y, int w, int h);
144
145         /// 
146         virtual PainterBase & buttonFrame(int x, int y, int w, int h);
147         
148         
149         // For the figure inset
150         virtual PainterBase & image(int x, int y, int w, int h, LyXImage const * image) = 0;
151
152         
153         /// Draw a string at position x, y (y is the baseline)
154         virtual PainterBase & text(int x, int y,
155                                    string const & str, LyXFont const & f) = 0;
156
157         /** Draw a string at position x, y (y is the baseline)
158             This is just for fast drawing */
159         virtual PainterBase & text(int x, int y, char const * str, size_t l,
160                        LyXFont const & f) = 0;
161
162         /// Draw a char at position x, y (y is the baseline)
163         virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
164
165 #if 0
166         /** Draws a string and encloses it inside a rectangle. Returns
167             the size of the rectangle. If draw is false, we only calculate
168             the size. */
169         virtual PainterBase & rectText(int x, int baseline, 
170                            string const & string, 
171                            LyXFont const & font,
172                            LColor::color back,
173                            LColor::color frame, bool draw = true,
174                            int & width = PainterBase::dummy1,
175                            int & ascent = PainterBase::dummy2, 
176                            int & descent = PainterBase::dummy3);
177
178         /** Draw a string and encloses it inside a button frame. Returns
179             the size of the frame. If draw is false, we only calculate
180             the size. */
181         virtual PainterBase & buttonText(int x, int baseline, string const & s,
182                              LyXFont const & font, bool draw = true,
183                              int & width = PainterBase::dummy1,
184                              int & ascent = PainterBase::dummy2, 
185                              int & descent = PainterBase::dummy3);
186 #else
187         /** Draws a string and encloses it inside a rectangle. Returns
188             the size of the rectangle. If draw is false, we only calculate
189             the size. */
190         PainterBase & rectText(int x, int baseline, 
191                            string const & string, 
192                            LyXFont const & font,
193                            LColor::color back,
194                                LColor::color frame);
195
196         /** Draw a string and encloses it inside a button frame. Returns
197             the size of the frame. If draw is false, we only calculate
198             the size. */
199         PainterBase & buttonText(int x, int baseline, string const & s,
200                                  LyXFont const & font);
201 #endif
202 protected:
203         ///
204         WorkArea & owner;
205 };
206
207 #endif