]> git.lyx.org Git - lyx.git/blob - src/PainterBase.h
Small fix.
[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
24 /** A painter class to encapsulate all graphics parameters and operations
25    
26     Every graphics operation in LyX should be made by this class. It will 
27     be initialized and managed by the Screen class, and will be passed
28     as a parameter to inset.
29  
30     It hides low level windows system parameters so insets and other
31     clients don't have to worry about them and we can control graphics and
32     GUI toolkit dependent drawing functions inside this single class.
33  
34  */
35 class PainterBase {
36 protected:
37         ///
38         static int dummy1, dummy2, dummy3;
39 public:
40         ///
41         enum line_width {
42                 ///
43                 line_thin,
44                 ///
45                 line_thick
46         };
47
48         ///
49         enum line_style {
50                 ///
51                 line_solid,
52                 ///
53                 line_doubledash,
54                 ///
55                 line_onoffdash
56         };
57
58         ///
59         explicit PainterBase(WorkArea & wa) : owner(wa) {}
60         
61         ///
62         virtual ~PainterBase() {}
63
64         /** Screen geometry */
65         ///
66         int paperMargin() const;
67         ///
68         int paperWidth() const;
69         ///
70         int paperHeight() const;
71         
72         /**@Basic drawing routines */
73         /// Draw a line from point to point
74         virtual PainterBase & line(
75                 int x1, int y1, int x2, int y2, 
76                 LColor::color = LColor::foreground,
77                 enum line_style = line_solid,
78                 enum line_width = line_thin) = 0;
79
80         /** Draw the lines between the lines in xp and yp.
81             xp and yp are arrays of points, and np is the
82             number of them. */
83         virtual PainterBase & lines(
84                 int const * xp, int const * yp, int np,
85                 LColor::color = LColor::foreground,
86                 enum line_style = line_solid,
87                 enum line_width = line_thin) = 0;
88
89         /// Here xp and yp are arrays of points
90         virtual PainterBase & fillPolygon(
91                 int const * xp, int const * yp,
92                 int np,
93                 LColor::color =LColor::foreground) = 0;
94
95         /// Draw lines from x1,y1 to x2,y2. They are arrays
96         virtual PainterBase & segments(
97                 int const * x1, int const * y1, 
98                 int const * x2, int const * y2, int ns,
99                 LColor::color = LColor::foreground,
100                 enum line_style = line_solid,
101                 enum line_width = line_thin) = 0;
102         
103         /// Draw a rectangle 
104         virtual PainterBase & rectangle(
105                 int x, int y, int w, int h,
106                 LColor::color = LColor::foreground,
107                 enum line_style = line_solid,
108                 enum line_width = line_thin) = 0;
109         
110         /// Draw a circle, d is the diameter, not the radious
111         virtual PainterBase & circle(
112                 int x, int y, unsigned int d,
113                 LColor::color = LColor::foreground);
114
115         /// Draw an ellipse
116         virtual PainterBase & ellipse(
117                 int x, int y,
118                 unsigned int w, unsigned int h,
119                 LColor::color = LColor::foreground);
120         
121         /// Draw an arc
122         virtual PainterBase & arc(
123                 int x, int y,
124                 unsigned int w, unsigned int h, 
125                 int a1, int a2,
126                 LColor::color = LColor::foreground) = 0;
127         
128         /// Draw a pixel
129         virtual PainterBase & point(
130                 int x, int y,
131                 LColor::color = LColor::foreground) = 0;
132         
133         /// Fill a rectangle
134         virtual PainterBase & fillRectangle(
135                 int x, int y, int w, int h,
136                 LColor::color = LColor::background) = 0;
137         
138         /// A filled rectangle with the shape of a 3D button
139         virtual PainterBase & button(int x, int y, int w, int h);
140
141         /// 
142         virtual PainterBase & buttonFrame(int x, int y, int w, int h);
143         
144         /**@Image stuff */
145         
146         /// For the figure inset
147         // This can't be part of the base since we don't know what window
148         // system we will be useing, or if are going to use pixmaps at all.
149         //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
150
151         
152         /**@String functions */
153         
154         /// Draw a string at position x, y (y is the baseline)
155         virtual PainterBase & text(int x, int y,
156                                    string const &str, LyXFont const & f) = 0;
157
158         /** Draw a string at position x, y (y is the baseline)
159             This is just for fast drawing */
160         virtual PainterBase & text(int x, int y, char const * str, int l,
161                        LyXFont const & f) = 0;
162
163         /// Draw a char at position x, y (y is the baseline)
164         virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
165         
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 protected:
187         WorkArea & owner;
188 };
189
190 #endif