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