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