]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLPainter.h
The initial merge of the Qt frontend, and the necessary compile fixes.
[lyx.git] / src / frontends / qt2 / QLPainter.h
1 // -*- C++ -*-
2 /**
3  * \file QLPainter.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author John Levon <moz@compsoc.man.ac.uk>
8  */
9
10 #ifndef QLPAINTER_H
11 #define QLPAINTER_H
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include <config.h>
18 #include <boost/smart_ptr.hpp>
19  
20 #include "Painter.h"
21 #include "LString.h"
22 #include "LColor.h"
23
24 class LyXFont;
25 class QWorkArea;
26 class QPainter;
27
28 /**
29  * QLPainter - a painter implementation for Xlib
30  */
31 class QLPainter : public Painter {
32 public:
33         QLPainter(QWorkArea &);
34         
35         /// begin painting
36         virtual void start();
37
38         /// end painting
39         virtual void end();
40  
41         /// return the width of the work area in pixels
42         virtual int paperWidth() const;
43         /// return the height of the work area in pixels
44         virtual int paperHeight() const;
45
46         /// draw a line from point to point
47         virtual Painter & line(
48                 int x1, int y1, 
49                 int x2, int y2,
50                 LColor::color = LColor::foreground,
51                 line_style = line_solid,
52                 line_width = line_thin);
53
54         /**
55          * lines -  draw a set of lines
56          * @param xp array of points' x co-ords
57          * @param yp array of points' y co-ords
58          * @param np size of the points array
59          */
60         virtual Painter & lines(
61                 int const * xp, 
62                 int const * yp, 
63                 int np,
64                 LColor::color = LColor::foreground,
65                 line_style = line_solid,
66                 line_width = line_thin);
67
68         /// draw a rectangle
69         virtual Painter & rectangle(
70                 int x, int y,
71                 int w, int h,
72                 LColor::color = LColor::foreground,
73                 line_style = line_solid,
74                 line_width = line_thin);
75         
76         /// draw a filled rectangle
77         virtual Painter & fillRectangle(
78                 int x, int y,
79                 int w, int h,
80                 LColor::color);
81         
82         /// draw a filled (irregular) polygon
83         virtual Painter & fillPolygon(
84                 int const * xp, 
85                 int const * yp, 
86                 int np,
87                 LColor::color = LColor::foreground); 
88  
89         /// draw an arc
90         virtual Painter & arc(
91                 int x, int y,
92                 unsigned int w, unsigned int h,
93                 int a1, int a2,
94                 LColor::color = LColor::foreground);
95  
96         /// draw a pixel
97         virtual Painter & point(
98                 int x, int y,
99                 LColor::color = LColor::foreground);
100         
101         /// draw an image from the image cache
102         virtual Painter & image(int x, int y,
103                 int w, int h,
104                 grfx::GImage const & image);
105         
106         /// draw a string at position x, y (y is the baseline)
107         virtual Painter & text(int x, int y,
108                 string const & str, LyXFont const & f);
109
110         /** Draw a string at position x, y (y is the baseline)
111          *  This is just for fast drawing
112          */
113         virtual Painter & text(int x, int y,
114                 char const * str, size_t l,
115                 LyXFont const & f);
116
117         /// draw a char at position x, y (y is the baseline)
118         virtual Painter & text(int x, int y,
119                 char c, LyXFont const & f);
120
121 private:
122         /// draw small caps text
123         void smallCapsText(int x, int y,
124                 char const * str, size_t l,
125                 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