]> git.lyx.org Git - lyx.git/blob - src/frontends/Painter.h
Switch from SigC signals to boost::signals
[lyx.git] / src / frontends / Painter.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 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         /// Draw a line from point to point
73         virtual PainterBase & line(
74                 int x1, int y1, int x2, int y2,
75                 LColor::color = LColor::foreground,
76                 enum line_style = line_solid,
77                 enum line_width = line_thin) = 0;
78
79         /** Draw the lines between the lines in xp and yp.
80             xp and yp are arrays of points, and np is the
81             number of them. */
82         virtual PainterBase & lines(
83                 int const * xp, int const * yp, int np,
84                 LColor::color = LColor::foreground,
85                 enum line_style = line_solid,
86                 enum line_width = line_thin) = 0;
87
88         /// Here xp and yp are arrays of points
89         virtual PainterBase & fillPolygon(
90                 int const * xp, int const * yp,
91                 int np,
92                 LColor::color = LColor::foreground) = 0;
93
94         /// Draw lines from x1,y1 to x2,y2. They are arrays
95         virtual PainterBase & segments(
96                 int const * x1, int const * y1,
97                 int const * x2, int const * y2, int ns,
98                 LColor::color = LColor::foreground,
99                 enum line_style = line_solid,
100                 enum line_width = line_thin) = 0;
101
102         /// Draw a rectangle
103         virtual PainterBase & rectangle(
104                 int x, int y, int w, int h,
105                 LColor::color = LColor::foreground,
106                 enum line_style = line_solid,
107                 enum line_width = line_thin) = 0;
108
109         /// Draw a circle, d is the diameter, not the radious
110         virtual PainterBase & circle(
111                 int x, int y, unsigned int d,
112                 LColor::color = LColor::foreground);
113
114         /// Draw an ellipse
115         virtual PainterBase & ellipse(
116                 int x, int y,
117                 unsigned int w, unsigned int h,
118                 LColor::color = LColor::foreground);
119
120         /// Draw an arc
121         virtual PainterBase & arc(
122                 int x, int y,
123                 unsigned int w, unsigned int h,
124                 int a1, int a2,
125                 LColor::color = LColor::foreground) = 0;
126
127         /// Draw a pixel
128         virtual PainterBase & point(
129                 int x, int y,
130                 LColor::color = LColor::foreground) = 0;
131
132         /// Fill a rectangle
133         virtual PainterBase & fillRectangle(
134                 int x, int y, int w, int h,
135                 LColor::color) = 0;
136
137         /// A filled rectangle with the shape of a 3D button
138         virtual PainterBase & button(int x, int y, int w, int h);
139
140         ///
141         virtual PainterBase & buttonFrame(int x, int y, int w, int h);
142
143
144         // For the figure inset
145         virtual PainterBase & image(int x, int y, int w, int h,
146                                     grfx::GImage const & image) = 0;
147
148         /// Draw a string at position x, y (y is the baseline)
149         virtual PainterBase & text(int x, int y,
150                                    string const & str, LyXFont const & f) = 0;
151
152         /** Draw a string at position x, y (y is the baseline)
153             This is just for fast drawing */
154         virtual PainterBase & text(int x, int y, char const * str, size_t l,
155                                    LyXFont const & f) = 0;
156
157         /// Draw a char at position x, y (y is the baseline)
158         virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
159
160         /** Draws a string and encloses it inside a rectangle. */
161         PainterBase & rectText(int x, int baseline,
162                                string const & string,
163                                LyXFont const & font,
164                                LColor::color back,
165                                LColor::color frame);
166
167         /** Draw a string and encloses it inside a button frame. */
168         PainterBase & buttonText(int x, int baseline, string const & s,
169                                  LyXFont const & font);
170 protected:
171         ///
172         WorkArea & owner;
173 };
174
175 // VERY temporary
176 #include "xforms/XPainter.h"
177
178 #endif