]> git.lyx.org Git - lyx.git/blob - src/PainterBase.h
Remove debug message
[lyx.git] / src / PainterBase.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1998-2000 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 = LColor::background) = 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         /** Draws a string and encloses it inside a rectangle. Returns
166             the size of the rectangle. If draw is false, we only calculate
167             the size. */
168         virtual PainterBase & rectText(int x, int baseline, 
169                            string const & string, 
170                            LyXFont const & font,
171                            LColor::color back,
172                            LColor::color frame, bool draw = true,
173                            int & width = PainterBase::dummy1,
174                            int & ascent = PainterBase::dummy2, 
175                            int & descent = PainterBase::dummy3);
176
177         /** Draw a string and encloses it inside a button frame. Returns
178             the size of the frame. If draw is false, we only calculate
179             the size. */
180         virtual PainterBase & buttonText(int x, int baseline, string const & s,
181                              LyXFont const & font, bool draw = true,
182                              int & width = PainterBase::dummy1,
183                              int & ascent = PainterBase::dummy2, 
184                              int & descent = PainterBase::dummy3);
185 protected:
186         ///
187         WorkArea & owner;
188 };
189
190 #endif