]> git.lyx.org Git - lyx.git/blob - src/Painter.h
Fix fuer #209
[lyx.git] / src / Painter.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995-2001 The LyX Team
8  *
9  * ======================================================*/
10
11 #ifndef PAINTER_H
12 #define PAINTER_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "LString.h"
19
20 // This is only included to provide stuff for the non-public sections
21 #include <X11/Xlib.h>
22
23 #include "PainterBase.h"
24
25 class LyXFont;
26 class WorkArea;
27
28 /** An inplementation for the X Window System. Xlib.
29     
30     Classes similar to this one can be made for gtk+, Qt, etc.
31 */
32 class Painter : public PainterBase {
33 public:
34         /// Constructor 
35         explicit Painter(WorkArea &);
36         
37         /// Draw a line from point to point
38         PainterBase & line(int x1, int y1, int x2, int y2, 
39                            LColor::color = LColor::foreground,
40                            enum line_style = line_solid,
41                            enum line_width = line_thin);
42         
43         /// Here xp and yp are arrays of points
44         PainterBase & lines(int const * xp, int const * yp, int np,
45                             LColor::color = LColor::foreground,
46                             enum line_style = line_solid,
47                             enum line_width = line_thin);
48         
49         /// Here xp and yp are arrays of points
50         PainterBase & fillPolygon(int const * xp, int const * yp, int np,
51                                   LColor::color = LColor::foreground);
52         
53         /// Draw lines from x1,y1 to x2,y2. They are arrays
54         PainterBase & segments(int const * x1, int const * y1, 
55                                int const * x2, int const * y2, int ns,
56                                LColor::color = LColor::foreground,
57                                enum line_style = line_solid,
58                                enum line_width = line_thin);
59         
60         /// Draw a rectangle 
61         PainterBase & rectangle(int x, int y, int w, int h,
62                                 LColor::color = LColor::foreground,
63                                 enum line_style = line_solid,
64                                 enum line_width = line_thin);
65         
66         /// Draw an arc
67         PainterBase & arc(int x, int y, unsigned int w, unsigned int h, 
68                           int a1, int a2,
69                           LColor::color = LColor::foreground);
70         
71         /// Draw a pixel
72         PainterBase & point(int x, int y, LColor::color = LColor::foreground);
73         
74         /// Fill a rectangle
75         PainterBase & fillRectangle(int x, int y, int w, int h,
76                                     LColor::color);
77         
78         /// For the graphics inset.
79         PainterBase & image(int x, int y, int w, int h, LyXImage const * image);
80         
81         /// For the figinset
82         PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
83         
84         /// Draw a string at position x, y (y is the baseline)
85         PainterBase & text(int x, int y,
86                            string const & str, LyXFont const & f);
87         
88         /** Draw a string at position x, y (y is the baseline)
89             This is just for fast drawing */
90         PainterBase & text(int x, int y, char const * str, size_t l,
91                            LyXFont const & f);
92         
93         /// Draw a char at position x, y (y is the baseline)
94         PainterBase & text(int x, int y, char c, LyXFont const & f);
95
96         /// Draw a wide string at position x, y
97         PainterBase & text(int x, int y, XChar2b const * str, int l,
98                    LyXFont const & f);  
99 private:
100         /// Check the font, and if set, draw an underline
101         void underline(LyXFont const & f, int x, int y, int width);
102         
103         ///
104         Display * display;
105 };
106
107 #endif