]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QLPainter.h
Rename EnumLColor as LColor_color.
[features.git] / src / frontends / qt2 / 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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QLPAINTER_H
13 #define QLPAINTER_H
14
15
16 #include "Painter.h"
17 #include "support/std_string.h"
18
19 #include <boost/scoped_ptr.hpp>
20
21 class LyXFont;
22 class QWorkArea;
23 class QPainter;
24 class QString;
25
26 /**
27  * QLPainter - a painter implementation for Xlib
28  */
29 class QLPainter : public Painter {
30 public:
31         QLPainter(QWorkArea &);
32
33         /// begin painting
34         virtual void start();
35
36         /// end painting
37         virtual void end();
38
39         /// return the width of the work area in pixels
40         virtual int paperWidth() const;
41         /// return the height of the work area in pixels
42         virtual int paperHeight() const;
43
44         /// draw a line from point to point
45         virtual Painter & line(
46                 int x1, int y1,
47                 int x2, int y2,
48                 LColor_color,
49                 line_style = line_solid,
50                 line_width = line_thin);
51
52         /**
53          * lines -  draw a set of lines
54          * @param xp array of points' x co-ords
55          * @param yp array of points' y co-ords
56          * @param np size of the points array
57          */
58         virtual Painter & lines(
59                 int const * xp,
60                 int const * yp,
61                 int np,
62                 LColor_color,
63                 line_style = line_solid,
64                 line_width = line_thin);
65
66         /// draw a rectangle
67         virtual Painter & rectangle(
68                 int x, int y,
69                 int w, int h,
70                 LColor_color,
71                 line_style = line_solid,
72                 line_width = line_thin);
73
74         /// draw a filled rectangle
75         virtual Painter & fillRectangle(
76                 int x, int y,
77                 int w, int h,
78                 LColor_color);
79
80         /// draw a filled (irregular) polygon
81         virtual Painter & fillPolygon(
82                 int const * xp,
83                 int const * yp,
84                 int np,
85                 LColor_color);
86
87         /// draw an arc
88         virtual Painter & arc(
89                 int x, int y,
90                 unsigned int w, unsigned int h,
91                 int a1, int a2,
92                 LColor_color);
93
94         /// draw a pixel
95         virtual Painter & point(
96                 int x, int y,
97                 LColor_color);
98
99         /// draw an image from the image cache
100         virtual Painter & image(int x, int y,
101                 int w, int h,
102                 lyx::graphics::Image const & image);
103
104         /// draw a string at position x, y (y is the baseline)
105         virtual Painter & text(int x, int y,
106                 string const & str, LyXFont const & f);
107
108         /** Draw a string at position x, y (y is the baseline)
109          *  This is just for fast drawing
110          */
111         virtual Painter & text(int x, int y,
112                 char const * str, size_t l,
113                 LyXFont const & f);
114
115         /// draw a char at position x, y (y is the baseline)
116         virtual Painter & text(int x, int y,
117                 char c, LyXFont const & f);
118 private:
119         /// draw small caps text
120         void smallCapsText(int x, int y,
121                 QString const & str, LyXFont const & f);
122
123         /// set pen parameters
124         QPainter & setPen(LColor_color c,
125                 line_style ls = line_solid,
126                 line_width lw = line_thin);
127
128         /// our owner who we paint upon
129         QWorkArea & owner_;
130
131         /// our qt painter
132         boost::scoped_ptr<QPainter> qp_;
133
134         /// recursion check
135         int paint_check_;
136 };
137
138 #endif // QLPAINTER_H