]> git.lyx.org Git - features.git/blob - src/frontends/qt3/QLPainter.h
fad5060cd9bc3093da3127aae4daeaac45f554a8
[features.git] / src / frontends / qt3 / QLPainter.h
1 // -*- C++ -*-
2 /**
3  * \file QLPainter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QLPAINTER_H
13 #define QLPAINTER_H
14
15 #include "frontends/Painter.h"
16
17 #include <boost/scoped_ptr.hpp>
18
19
20 class LyXFont;
21 class QPainter;
22 class QString;
23
24 namespace lyx {
25 namespace frontend {
26
27 class QWorkArea;
28
29 /**
30  * QLPainter - a painter implementation for Xlib
31  */
32 class QLPainter : public lyx::frontend::Painter {
33 public:
34         QLPainter(QWorkArea &);
35
36         /// begin painting
37         virtual void start();
38
39         /// end painting
40         virtual void end();
41
42         /// return the width of the work area in pixels
43         virtual int paperWidth() const;
44         /// return the height of the work area in pixels
45         virtual int paperHeight() const;
46
47         /// draw a line from point to point
48         virtual void line(
49                 int x1, int y1,
50                 int x2, int y2,
51                 LColor_color,
52                 line_style = line_solid,
53                 line_width = line_thin);
54
55         /**
56          * lines -  draw a set of lines
57          * @param xp array of points' x co-ords
58          * @param yp array of points' y co-ords
59          * @param np size of the points array
60          */
61         virtual void lines(
62                 int const * xp,
63                 int const * yp,
64                 int np,
65                 LColor_color,
66                 line_style = line_solid,
67                 line_width = line_thin);
68
69         /// draw a rectangle
70         virtual void rectangle(
71                 int x, int y,
72                 int w, int h,
73                 LColor_color,
74                 line_style = line_solid,
75                 line_width = line_thin);
76
77         /// draw a filled rectangle
78         virtual void fillRectangle(
79                 int x, int y,
80                 int w, int h,
81                 LColor_color);
82
83         /// draw a filled (irregular) polygon
84         virtual void fillPolygon(
85                 int const * xp,
86                 int const * yp,
87                 int np,
88                 LColor_color);
89
90         /// draw an arc
91         virtual void arc(
92                 int x, int y,
93                 unsigned int w, unsigned int h,
94                 int a1, int a2,
95                 LColor_color);
96
97         /// draw a pixel
98         virtual void point(
99                 int x, int y,
100                 LColor_color);
101
102         /// draw an image from the image cache
103         virtual void image(int x, int y,
104                 int w, int h,
105                 lyx::graphics::Image const & image);
106
107         /// draw a string at position x, y (y is the baseline)
108         virtual void text(int x, int y,
109                 std::string const & str, LyXFont const & f);
110
111         /** Draw a string at position x, y (y is the baseline)
112          *  This is just for fast drawing
113          */
114         virtual void text(int x, int y,
115                 char const * str, size_t l,
116                 LyXFont const & f);
117
118         /// draw a char at position x, y (y is the baseline)
119         virtual void text(int x, int y,
120                 char c, LyXFont const & f);
121 private:
122         /// draw small caps text
123         void smallCapsText(int x, int y,
124                 QString const & str, LyXFont const & f);
125
126         /// set pen parameters
127         QPainter & setPen(LColor_color c,
128                 line_style ls = line_solid,
129                 line_width lw = line_thin);
130
131         /// our owner who we paint upon
132         QWorkArea & owner_;
133
134         /// our qt painter
135         boost::scoped_ptr<QPainter> qp_;
136
137         /// recursion check
138         int paint_check_;
139 };
140
141 } // namespace frontend
142 } // namespace lyx
143
144 #endif // QLPAINTER_H