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