]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QLPainter.h
enable Font cache only for MacOSX and inline width() for other platform.
[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 "Painter.h"
17
18 #include <boost/scoped_ptr.hpp>
19
20 class LyXFont;
21 class QPaintDevice;
22 class QPainter;
23 class QString;
24 class QPixmap;
25 class QImage;
26
27 namespace lyx {
28 namespace frontend {
29
30 class GuiWorkArea;
31
32 /**
33  * QLPainter - a painter implementation for Qt4
34  */
35 class QLPainter : public Painter {
36 public:
37         QLPainter(GuiWorkArea *);
38
39         ~QLPainter();
40
41         /// begin painting
42         virtual void start();
43
44         /// end painting
45         virtual void end();
46
47         /// return the width of the work area in pixels
48         virtual int paperWidth() const;
49         /// return the height of the work area in pixels
50         virtual int paperHeight() const;
51
52         /// draw a line from point to point
53         virtual void line(
54                 int x1, int y1,
55                 int x2, int y2,
56                 LColor_color,
57                 line_style = line_solid,
58                 line_width = line_thin);
59
60         /**
61          * lines -  draw a set of lines
62          * @param xp array of points' x co-ords
63          * @param yp array of points' y co-ords
64          * @param np size of the points array
65          */
66         virtual void lines(
67                 int const * xp,
68                 int const * yp,
69                 int np,
70                 LColor_color,
71                 line_style = line_solid,
72                 line_width = line_thin);
73
74         /// draw a rectangle
75         virtual void rectangle(
76                 int x, int y,
77                 int w, int h,
78                 LColor_color,
79                 line_style = line_solid,
80                 line_width = line_thin);
81
82         /// draw a filled rectangle
83         virtual void fillRectangle(
84                 int x, int y,
85                 int w, int h,
86                 LColor_color);
87
88         /// draw an arc
89         virtual void arc(
90                 int x, int y,
91                 unsigned int w, unsigned int h,
92                 int a1, int a2,
93                 LColor_color);
94
95         /// draw a pixel
96         virtual void point(
97                 int x, int y,
98                 LColor_color);
99
100         /// draw an image from the image cache
101         virtual void 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 void text(int x, int y,
107                 lyx::docstring 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 void text(int x, int y,
113                 lyx::char_type const * str, size_t l,
114                 LyXFont const & f);
115
116         /// draw a char at position x, y (y is the baseline)
117         virtual void text(int x, int y,
118                 lyx::char_type c, LyXFont const & f);
119
120         /// draw a pixmap from the image cache
121         virtual void drawPixmap(int x, int y, QPixmap const & pixmap);
122
123         /// draw a pixmap from the image cache
124         virtual void drawImage(int x, int y, QImage const & image);
125
126 private:
127         /// draw small caps text
128         void smallCapsText(int x, int y,
129                 QString const & str, LyXFont const & f);
130
131         /// set pen parameters
132         void setQPainterPen(LColor_color col,
133                 line_style ls = line_solid,
134                 line_width lw = line_thin);
135
136         /// our qt painter
137         boost::scoped_ptr<QPainter> qp_;
138
139         /// the working area
140         GuiWorkArea * qwa_;
141
142         LColor::color current_color_;
143         Painter::line_style current_ls_;
144         Painter::line_width current_lw_;
145 };
146
147 } // namespace frontend
148 } // namespace lyx
149
150 #endif // QLPAINTER_H