]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/XPainter.h
Painter and scrollbar API patches
[lyx.git] / src / frontends / xforms / XPainter.h
1 // -*- C++ -*-
2 /**
3  * \file XPainter.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author unknown
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11 #ifndef XPAINTER_H
12 #define XPAINTER_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <config.h>
19  
20 #include "frontends/Painter.h"
21 #include "LString.h"
22
23 #include <X11/Xlib.h>
24
25
26 class LyXFont;
27 class WorkArea;
28
29 /**
30  * XPainter - a painter implementation for Xlib
31  */
32 class XPainter : public Painter {
33 public:
34         XPainter(WorkArea &);
35         
36         /// return the width of the work area in pixels
37         virtual int paperWidth() const;
38         /// return the height of the work area in pixels
39         virtual int paperHeight() const;
40
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                 grfx::GImage 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         /// draw a char at position x, y (y is the baseline)
113         virtual Painter & text(int x, int y,
114                 char c, LyXFont const & f);
115
116         /// draw a wide string at position x, y
117         Painter & text(int x, int y, 
118                 XChar2b const * str, size_t l,
119                 LyXFont const & f);
120  
121 private:
122         /// our owner who we paint upon
123         WorkArea & owner_;
124 };
125
126 #endif // XPAINTER_H