]> git.lyx.org Git - lyx.git/blob - src/PainterBase.h
Forgot to add this files.
[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;
39         ///
40         static int dummy2;
41         ///
42         static int dummy3;
43 public:
44         ///
45         enum line_width {
46                 ///
47                 line_thin,
48                 ///
49                 line_thick
50         };
51
52         ///
53         enum line_style {
54                 ///
55                 line_solid,
56                 ///
57                 line_doubledash,
58                 ///
59                 line_onoffdash
60         };
61
62         ///
63         explicit PainterBase(WorkArea & wa) : owner(wa) {}
64         
65         ///
66         virtual ~PainterBase() {}
67
68         /* Screen geometry */
69         ///
70         int paperMargin() const;
71         ///
72         int paperWidth() const;
73         ///
74         int paperHeight() const;
75         
76         /// Draw a line from point to point
77         virtual PainterBase & line(
78                 int x1, int y1, int x2, int y2, 
79                 LColor::color = LColor::foreground,
80                 enum line_style = line_solid,
81                 enum line_width = line_thin) = 0;
82
83         /** Draw the lines between the lines in xp and yp.
84             xp and yp are arrays of points, and np is the
85             number of them. */
86         virtual PainterBase & lines(
87                 int const * xp, int const * yp, int np,
88                 LColor::color = LColor::foreground,
89                 enum line_style = line_solid,
90                 enum line_width = line_thin) = 0;
91
92         /// Here xp and yp are arrays of points
93         virtual PainterBase & fillPolygon(
94                 int const * xp, int const * yp,
95                 int np,
96                 LColor::color =LColor::foreground) = 0;
97
98         /// Draw lines from x1,y1 to x2,y2. They are arrays
99         virtual PainterBase & segments(
100                 int const * x1, int const * y1, 
101                 int const * x2, int const * y2, int ns,
102                 LColor::color = LColor::foreground,
103                 enum line_style = line_solid,
104                 enum line_width = line_thin) = 0;
105         
106         /// Draw a rectangle 
107         virtual PainterBase & rectangle(
108                 int x, int y, int w, int h,
109                 LColor::color = LColor::foreground,
110                 enum line_style = line_solid,
111                 enum line_width = line_thin) = 0;
112         
113         /// Draw a circle, d is the diameter, not the radious
114         virtual PainterBase & circle(
115                 int x, int y, unsigned int d,
116                 LColor::color = LColor::foreground);
117
118         /// Draw an ellipse
119         virtual PainterBase & ellipse(
120                 int x, int y,
121                 unsigned int w, unsigned int h,
122                 LColor::color = LColor::foreground);
123         
124         /// Draw an arc
125         virtual PainterBase & arc(
126                 int x, int y,
127                 unsigned int w, unsigned int h, 
128                 int a1, int a2,
129                 LColor::color = LColor::foreground) = 0;
130         
131         /// Draw a pixel
132         virtual PainterBase & point(
133                 int x, int y,
134                 LColor::color = LColor::foreground) = 0;
135         
136         /// Fill a rectangle
137         virtual PainterBase & fillRectangle(
138                 int x, int y, int w, int h,
139                 LColor::color = LColor::background) = 0;
140         
141         /// A filled rectangle with the shape of a 3D button
142         virtual PainterBase & button(int x, int y, int w, int h);
143
144         /// 
145         virtual PainterBase & buttonFrame(int x, int y, int w, int h);
146         
147         
148         // For the figure inset
149         // This can't be part of the base since we don't know what window
150         // system we will be useing, or if are going to use pixmaps at all.
151         //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
152
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         ///
188         WorkArea & owner;
189 };
190
191 #endif