]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GPainter.h
Wrap most of the frontend code up inside namespace lyx::frontend.
[lyx.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 "frontends/Painter.h"
16
17 #include <X11/Xft/Xft.h>
18
19 #include <map>
20
21 class LyXFont;
22
23 namespace lyx {
24 namespace frontend {
25
26 class GWorkArea;
27
28 /**
29  * GPainter - a painter implementation for Gtkmm
30  */
31 class GPainter : public Painter {
32 public:
33         GPainter(GWorkArea &);
34
35         /// return the width of the work area in pixels
36         virtual int paperWidth() const;
37         /// return the height of the work area in pixels
38         virtual int paperHeight() const;
39
40         void setForeground(Glib::RefPtr<Gdk::GC> gc, LColor_color clr);
41         void setLineParam(Glib::RefPtr<Gdk::GC> gc,
42                           line_style ls, line_width lw);
43         XftColor * getXftColor(LColor_color clr);
44         /// draw a line from point to point
45         virtual void line(
46                 int x1, int y1,
47                 int x2, int y2,
48                 LColor_color,
49                 line_style = line_solid,
50                 line_width = line_thin);
51
52         /**
53          * lines -  draw a set of lines
54          * @param xp array of points' x co-ords
55          * @param yp array of points' y co-ords
56          * @param np size of the points array
57          */
58         virtual void lines(
59                 int const * xp,
60                 int const * yp,
61                 int np,
62                 LColor_color,
63                 line_style = line_solid,
64                 line_width = line_thin);
65
66         /// draw a rectangle
67         virtual void rectangle(
68                 int x, int y,
69                 int w, int h,
70                 LColor_color,
71                 line_style = line_solid,
72                 line_width = line_thin);
73
74         /// draw a filled rectangle
75         virtual void fillRectangle(
76                 int x, int y,
77                 int w, int h,
78                 LColor_color);
79
80         /// draw a filled (irregular) polygon
81         virtual void fillPolygon(
82                 int const * xp,
83                 int const * yp,
84                 int np,
85                 LColor_color);
86
87         /// draw an arc
88         virtual void arc(
89                 int x, int y,
90                 unsigned int w, unsigned int h,
91                 int a1, int a2,
92                 LColor_color);
93
94         /// draw a pixel
95         virtual void point(
96                 int x, int y,
97                 LColor_color);
98
99         /// draw an image from the image cache
100         virtual void image(int x, int y,
101                 int w, int h,
102                 graphics::Image const & image);
103
104         /// draw a string at position x, y (y is the baseline)
105         virtual void text(int x, int y,
106                 std::string const & str, LyXFont const & f);
107
108         /** Draw a string at position x, y (y is the baseline)
109          *  This is just for fast drawing
110          */
111         virtual void text(int x, int y,
112                 char const * str, size_t l,
113                 LyXFont const & f);
114
115         virtual void text(int x, int y, wchar_t const * str, int l,
116                                LyXFont const & f);
117
118         /// draw a char at position x, y (y is the baseline)
119         virtual void text(int x, int y,
120                                char c, LyXFont const & f);
121
122         /// draw a wide string at position x, y
123         void text(int x, int y,
124                 XChar2b const * str, size_t l,
125                 LyXFont const & f);
126
127 private:
128         /// our owner who we paint upon
129         GWorkArea & owner_;
130 };
131
132 } // namespace frontend
133 } // namespace lyx
134
135 #endif // XPAINTER_H