]> git.lyx.org Git - features.git/blob - src/frontends/qt4/QLPainter.h
Added initial qt4 work by Abdelrazak Younes
[features.git] / src / frontends / qt4 / 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  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QLPAINTER_H
14 #define QLPAINTER_H
15
16 #include "Painter.h"
17
18 #include <boost/scoped_ptr.hpp>
19
20 class LyXFont;
21 class QPaintDevice;
22 class QPainter;
23 class QString;
24 class QPixmap;
25 class QWorkArea;
26
27 /**
28  * QLPainter - a painter implementation for Qt4
29  */
30 class QLPainter : public Painter {
31 public:
32         QLPainter(QWorkArea *);
33
34         ~QLPainter();
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
122         /// draw a pixmap from the image cache
123         virtual void pixmap(int x, int y, QPixmap const & pixmap);
124
125 private:
126         /// draw small caps text
127         void smallCapsText(int x, int y,
128                 QString const & str, LyXFont const & f);
129
130         /// set pen parameters
131         QPainter & setQPainterPen(QPainter & qp, LColor_color c,
132                 line_style ls = line_solid,
133                 line_width lw = line_thin);
134
135         /// our qt painter
136         boost::scoped_ptr<QPainter> qp_;
137
138         /// recursion check
139         int paint_check_;
140
141         /// the working area
142         QWorkArea * qwa_;
143 };
144
145 #endif // QLPAINTER_H