]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QLPainter.h
* reset color/linestyle/linewidth cache to QPen defaults on QPainter creation
[lyx.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 QImage;
26
27 namespace lyx {
28 namespace frontend {
29
30 class GuiWorkArea;
31
32 /**
33  * QLPainter - a painter implementation for Qt4
34  */
35 class QLPainter : public Painter {
36 public:
37         QLPainter(GuiWorkArea *);
38
39         ~QLPainter();
40
41         /// begin painting
42         virtual void start();
43
44         /// end painting
45         virtual void end();
46
47         /// return the width of the work area in pixels
48         virtual int paperWidth() const;
49         /// return the height of the work area in pixels
50         virtual int paperHeight() const;
51
52         /// draw a line from point to point
53         virtual void line(
54                 int x1, int y1,
55                 int x2, int y2,
56                 LColor_color,
57                 line_style = line_solid,
58                 line_width = line_thin);
59
60         /**
61          * lines -  draw a set of lines
62          * @param xp array of points' x co-ords
63          * @param yp array of points' y co-ords
64          * @param np size of the points array
65          */
66         virtual void lines(
67                 int const * xp,
68                 int const * yp,
69                 int np,
70                 LColor_color,
71                 line_style = line_solid,
72                 line_width = line_thin);
73
74         /// draw a rectangle
75         virtual void rectangle(
76                 int x, int y,
77                 int w, int h,
78                 LColor_color,
79                 line_style = line_solid,
80                 line_width = line_thin);
81
82         /// draw a filled rectangle
83         virtual void fillRectangle(
84                 int x, int y,
85                 int w, int h,
86                 LColor_color);
87
88         /// draw a filled (irregular) polygon
89         virtual void fillPolygon(
90                 int const * xp,
91                 int const * yp,
92                 int np,
93                 LColor_color);
94
95         /// draw an arc
96         virtual void arc(
97                 int x, int y,
98                 unsigned int w, unsigned int h,
99                 int a1, int a2,
100                 LColor_color);
101
102         /// draw a pixel
103         virtual void point(
104                 int x, int y,
105                 LColor_color);
106
107         /// draw an image from the image cache
108         virtual void image(int x, int y,
109                 int w, int h,
110                 lyx::graphics::Image const & image);
111
112         /// draw a string at position x, y (y is the baseline)
113         virtual void text(int x, int y,
114                 std::string const & str, LyXFont const & f);
115
116         /** Draw a string at position x, y (y is the baseline)
117          *  This is just for fast drawing
118          */
119         virtual void text(int x, int y,
120                 char const * str, size_t l,
121                 LyXFont const & f);
122
123         /// draw a char at position x, y (y is the baseline)
124         virtual void text(int x, int y,
125                 char c, LyXFont const & f);
126
127         /// draw a pixmap from the image cache
128         virtual void drawPixmap(int x, int y, QPixmap const & pixmap);
129
130         /// draw a pixmap from the image cache
131         virtual void drawImage(int x, int y, QImage const & image);
132
133 private:
134         /// draw small caps text
135         void smallCapsText(int x, int y,
136                 QString const & str, LyXFont const & f);
137
138         /// set pen parameters
139         void setQPainterPen(LColor_color col,
140                 line_style ls = line_solid,
141                 line_width lw = line_thin);
142
143         /// our qt painter
144         boost::scoped_ptr<QPainter> qp_;
145
146         /// the working area
147         GuiWorkArea * qwa_;
148
149         LColor::color current_color_;
150         Painter::line_style current_ls_;
151         Painter::line_width current_lw_;
152 };
153
154 } // namespace frontend
155 } // namespace lyx
156
157 #endif // QLPAINTER_H