]> git.lyx.org Git - features.git/blob - src/frontends/gtk/GPainter.h
Replace LString.h with support/std_string.h,
[features.git] / src / frontends / gtk / GPainter.h
1 // -*- C++ -*-
2 /**
3  * \file GPainter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Huang Ying
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GPAINTER_H
13 #define GPAINTER_H
14
15 #include <config.h>
16 #include <X11/Xft/Xft.h>
17
18 #include <map>
19 #include "frontends/Painter.h"
20 #include "support/std_string.h"
21
22 class LyXFont;
23 class GWorkArea;
24
25 /**
26  * GPainter - a painter implementation for Gtkmm
27  */
28 class GPainter : public Painter {
29 public:
30         GPainter(GWorkArea &);
31
32         /// return the width of the work area in pixels
33         virtual int paperWidth() const;
34         /// return the height of the work area in pixels
35         virtual int paperHeight() const;
36
37         void setForeground(Glib::RefPtr<Gdk::GC> gc, LColor::color clr);
38         void setLineParam(Glib::RefPtr<Gdk::GC> gc,
39                           line_style ls, line_width lw);
40         XftColor * getXftColor(LColor::color clr);
41         /// draw a line from point to point
42         virtual Painter & line(
43                 int x1, int y1,
44                 int x2, int y2,
45                 LColor::color = LColor::foreground,
46                 line_style = line_solid,
47                 line_width = line_thin);
48
49         /**
50          * lines -  draw a set of lines
51          * @param xp array of points' x co-ords
52          * @param yp array of points' y co-ords
53          * @param np size of the points array
54          */
55         virtual Painter & lines(
56                 int const * xp,
57                 int const * yp,
58                 int np,
59                 LColor::color = LColor::foreground,
60                 line_style = line_solid,
61                 line_width = line_thin);
62
63         /// draw a rectangle
64         virtual Painter & rectangle(
65                 int x, int y,
66                 int w, int h,
67                 LColor::color = LColor::foreground,
68                 line_style = line_solid,
69                 line_width = line_thin);
70
71         /// draw a filled rectangle
72         virtual Painter & fillRectangle(
73                 int x, int y,
74                 int w, int h,
75                 LColor::color);
76
77         /// draw a filled (irregular) polygon
78         virtual Painter & fillPolygon(
79                 int const * xp,
80                 int const * yp,
81                 int np,
82                 LColor::color = LColor::foreground);
83
84         /// draw an arc
85         virtual Painter & arc(
86                 int x, int y,
87                 unsigned int w, unsigned int h,
88                 int a1, int a2,
89                 LColor::color = LColor::foreground);
90
91         /// draw a pixel
92         virtual Painter & point(
93                 int x, int y,
94                 LColor::color = LColor::foreground);
95
96         /// draw an image from the image cache
97         virtual Painter & image(int x, int y,
98                 int w, int h,
99                 lyx::graphics::Image const & image);
100
101         /// draw a string at position x, y (y is the baseline)
102         virtual Painter & text(int x, int y,
103                 string const & str, LyXFont const & f);
104
105         /** Draw a string at position x, y (y is the baseline)
106          *  This is just for fast drawing
107          */
108         virtual Painter & text(int x, int y,
109                 char const * str, size_t l,
110                 LyXFont const & f);
111
112         virtual Painter & text(int x, int y, wchar_t const * str, int l,
113                                LyXFont const & f);
114
115         /// draw a char at position x, y (y is the baseline)
116         virtual Painter & text(int x, int y,
117                                char c, LyXFont const & f);
118
119         /// draw a wide string at position x, y
120         Painter & text(int x, int y,
121                 XChar2b const * str, size_t l,
122                 LyXFont const & f);
123
124 private:
125         /// our owner who we paint upon
126         GWorkArea & owner_;
127 };
128
129 #endif // XPAINTER_H