]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QLPainter.h
* src/frontends/qt4/ui/TextLayoutUi.ui:
[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 "Color.h"
19
20 #include <QPainter>
21
22 class QString;
23
24 namespace lyx {
25
26 class Font;
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                 Color_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                 Color_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                 Color_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                 Color_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                 Color_color);
80
81         /// draw a pixel
82         virtual void point(
83                 int x, int y,
84                 Color_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                 docstring const & str, Font const & f);
94
95         /// draw a char at position x, y (y is the baseline)
96         virtual int text(int x, int y, char_type c, Font const & f);
97
98 private:
99         /// draw small caps text
100         /**
101         \return width of the drawn text.
102         */
103         int smallCapsText(int x, int y,
104                 QString const & str, Font const & f);
105
106         /// set pen parameters
107         void setQPainterPen(Color_color col,
108                 line_style ls = line_solid,
109                 line_width lw = line_thin);
110
111         Color::color current_color_;
112         Painter::line_style current_ls_;
113         Painter::line_width current_lw_;
114 };
115
116 } // namespace frontend
117 } // namespace lyx
118
119 #endif // QLPAINTER_H