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