]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiPainter.h
Move Color::color enum to ColorCode.h
[features.git] / src / frontends / qt4 / GuiPainter.h
1 // -*- C++ -*-
2 /**
3  * \file GuiPainter.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 GUIPAINTER_H
14 #define GUIPAINTER_H
15
16 #include "frontends/Painter.h"
17
18 #include <QPainter>
19
20 class QString;
21
22 namespace lyx {
23
24 class Font;
25
26 namespace frontend {
27
28 /**
29  * GuiPainter - a painter implementation for Qt4
30  */
31 class GuiPainter : public QPainter, public Painter {
32 public:
33         GuiPainter(QPaintDevice *);
34         virtual ~GuiPainter();
35
36         /// draw a line from point to point
37         virtual void line(
38                 int x1, int y1,
39                 int x2, int y2,
40                 ColorCode,
41                 line_style = line_solid,
42                 line_width = line_thin);
43
44         /**
45          * lines -  draw a set of lines
46          * @param xp array of points' x co-ords
47          * @param yp array of points' y co-ords
48          * @param np size of the points array
49          */
50         virtual void lines(
51                 int const * xp,
52                 int const * yp,
53                 int np,
54                 ColorCode,
55                 line_style = line_solid,
56                 line_width = line_thin);
57
58         /// draw a rectangle
59         virtual void rectangle(
60                 int x, int y,
61                 int w, int h,
62                 ColorCode,
63                 line_style = line_solid,
64                 line_width = line_thin);
65
66         /// draw a filled rectangle
67         virtual void fillRectangle(
68                 int x, int y,
69                 int w, int h,
70                 ColorCode);
71
72         /// draw an arc
73         virtual void arc(
74                 int x, int y,
75                 unsigned int w, unsigned int h,
76                 int a1, int a2,
77                 ColorCode);
78
79         /// draw a pixel
80         virtual void point(
81                 int x, int y,
82                 ColorCode);
83
84         /// draw an image from the image cache
85         virtual void image(int x, int y,
86                 int w, int h,
87                 lyx::graphics::Image const & image);
88
89         /// draw a string at position x, y (y is the baseline)
90         virtual int text(int x, int y,
91                 docstring const & str, Font const & f);
92
93         /// draw a char at position x, y (y is the baseline)
94         virtual int text(int x, int y, char_type c, Font const & f);
95
96 private:
97         /// draw small caps text
98         /**
99         \return width of the drawn text.
100         */
101         int smallCapsText(int x, int y,
102                 QString const & str, Font const & f);
103
104         /// set pen parameters
105         void setQPainterPen(ColorCode col,
106                 line_style ls = line_solid,
107                 line_width lw = line_thin);
108
109         ColorCode current_color_;
110         Painter::line_style current_ls_;
111         Painter::line_width current_lw_;
112 };
113
114 } // namespace frontend
115 } // namespace lyx
116
117 #endif // GUIPAINTER_H