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