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