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