]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QLPainter.h
* src/frontends/qt4/GuiSelection.C
[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 "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 string at position x, y (y is the baseline)
96          *  This is just for fast drawing
97          */
98         virtual int text(int x, int y,
99                 lyx::char_type const * str, size_t l,
100                 LyXFont const & f);
101
102         /// draw a char at position x, y (y is the baseline)
103         virtual int text(int x, int y,
104                 lyx::char_type c, LyXFont const & f);
105
106 private:
107         /// draw small caps text
108         /**
109         \return width of the drawn text.
110         */
111         int smallCapsText(int x, int y,
112                 QString const & str, LyXFont const & f);
113
114         /// set pen parameters
115         void setQPainterPen(LColor_color col,
116                 line_style ls = line_solid,
117                 line_width lw = line_thin);
118
119         LColor::color current_color_;
120         Painter::line_style current_ls_;
121         Painter::line_width current_lw_;
122 };
123
124 } // namespace frontend
125 } // namespace lyx
126
127 #endif // QLPAINTER_H