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