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