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