]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XPainter.h
fix crash with "save as"
[lyx.git] / src / frontends / xforms / XPainter.h
1 // -*- C++ -*-
2 /**
3  * \file XPainter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon 
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef XPAINTER_H
14 #define XPAINTER_H
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 #include <config.h>
21  
22 #include "frontends/Painter.h"
23 #include "LString.h"
24
25 #include <X11/Xlib.h>
26
27
28 class LyXFont;
29 class XWorkArea;
30
31 /**
32  * XPainter - a painter implementation for Xlib
33  */
34 class XPainter : public Painter {
35 public:
36         XPainter(XWorkArea &);
37         
38         /// return the width of the work area in pixels
39         virtual int paperWidth() const;
40         /// return the height of the work area in pixels
41         virtual int paperHeight() const;
42
43         /// draw a line from point to point
44         virtual Painter & line(
45                 int x1, int y1, 
46                 int x2, int y2,
47                 LColor::color = LColor::foreground,
48                 line_style = line_solid,
49                 line_width = line_thin);
50
51         /**
52          * lines -  draw a set of lines
53          * @param xp array of points' x co-ords
54          * @param yp array of points' y co-ords
55          * @param np size of the points array
56          */
57         virtual Painter & lines(
58                 int const * xp, 
59                 int const * yp, 
60                 int np,
61                 LColor::color = LColor::foreground,
62                 line_style = line_solid,
63                 line_width = line_thin);
64
65         /// draw a rectangle
66         virtual Painter & rectangle(
67                 int x, int y,
68                 int w, int h,
69                 LColor::color = LColor::foreground,
70                 line_style = line_solid,
71                 line_width = line_thin);
72         
73         /// draw a filled rectangle
74         virtual Painter & fillRectangle(
75                 int x, int y,
76                 int w, int h,
77                 LColor::color);
78         
79         /// draw a filled (irregular) polygon
80         virtual Painter & fillPolygon(
81                 int const * xp, 
82                 int const * yp, 
83                 int np,
84                 LColor::color = LColor::foreground); 
85  
86         /// draw an arc
87         virtual Painter & arc(
88                 int x, int y,
89                 unsigned int w, unsigned int h,
90                 int a1, int a2,
91                 LColor::color = LColor::foreground);
92  
93         /// draw a pixel
94         virtual Painter & point(
95                 int x, int y,
96                 LColor::color = LColor::foreground);
97         
98         /// draw an image from the image cache
99         virtual Painter & image(int x, int y,
100                 int w, int h,
101                 grfx::Image const & image);
102         
103         /// draw a string at position x, y (y is the baseline)
104         virtual Painter & text(int x, int y,
105                 string const & str, LyXFont const & f);
106
107         /** Draw a string at position x, y (y is the baseline)
108          *  This is just for fast drawing
109          */
110         virtual Painter & text(int x, int y,
111                 char const * str, size_t 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         XWorkArea & owner_;
126 };
127
128 #endif // XPAINTER_H