]> git.lyx.org Git - lyx.git/blob - src/Painter.h
forgot two files
[lyx.git] / src / Painter.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1999-2000 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 "config.h"
19 #include "LString.h"
20
21 // This is only included to provide stuff for the non-public sections
22 #include <X11/Xlib.h>
23
24 #include <map>
25 #include "PainterBase.h"
26 #include "LColor.h"
27
28 using std::less;
29
30 class LyXFont;
31 class WorkArea;
32
33 /** An inplementation for the X Window System. Xlib.
34     
35     Classes similar to this one can be made for gtk+, Qt, etc.
36 */
37 class Painter : public PainterBase {
38 public:
39         /// Constructor 
40         Painter(WorkArea &);
41         
42         /// Destructor
43         ~Painter();
44         
45         /**@Basic drawing routines */
46         /// Draw a line from point to point
47         PainterBase & line(int x1, int y1, int x2, int y2, 
48                            LColor::color = LColor::foreground,
49                            enum line_style = line_solid,
50                            enum line_width = line_thin);
51         
52         /// Here xp and yp are arrays of points
53         PainterBase & lines(int const * xp, int const * yp, int np,
54                             LColor::color = LColor::foreground,
55                             enum line_style = line_solid,
56                             enum line_width = line_thin);
57         
58         /// Here xp and yp are arrays of points
59         PainterBase & fillPolygon(int const * xp, int const * yp, int np,
60                                   LColor::color = LColor::foreground);
61         
62         /// Draw lines from x1,y1 to x2,y2. They are arrays
63         PainterBase & segments(int const * x1, int const * y1, 
64                                int const * x2, int const * y2, int ns,
65                                LColor::color = LColor::foreground,
66                                enum line_style = line_solid,
67                                enum line_width = line_thin);
68         
69         /// Draw a rectangle 
70         PainterBase & rectangle(int x, int y, int w, int h,
71                                 LColor::color = LColor::foreground,
72                                 enum line_style = line_solid,
73                                 enum line_width = line_thin);
74         
75         /// Draw an arc
76         PainterBase & arc(int x, int y, unsigned int w, unsigned int h, 
77                           int a1, int a2,
78                           LColor::color = LColor::foreground);
79         
80         /// Draw a pixel
81         PainterBase & point(int x, int y, LColor::color = LColor::foreground);
82         
83         /// Fill a rectangle
84         PainterBase & fillRectangle(int x, int y, int w, int h,
85                                     LColor::color = LColor::background);
86         
87         /**@Image stuff */
88         
89         /// For the figure inset
90         PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
91         
92         /**@String functions */
93         
94         /// Draw a string at position x, y (y is the baseline)
95         PainterBase & text(int x, int y,
96                            string const & str, LyXFont const & f);
97         
98         /** Draw a string at position x, y (y is the baseline)
99             This is just for fast drawing */
100         PainterBase & text(int x, int y, char const * str, int l,
101                            LyXFont const & f);
102         
103         /// Draw a char at position x, y (y is the baseline)
104         PainterBase & text(int x, int y, char c, LyXFont const & f);
105         
106 protected:
107         /**@Support for X only, by now */
108         friend class WorkArea;
109         ///
110         PainterBase & setDisplay(Display * d) { display = d; return *this; }
111         
112         /// Get foreground color in ordinary GC
113         GC getGCForeground(LColor::color c);
114         
115         /// Set up GC according to line style
116         GC getGCLinepars(enum line_style, enum line_width, LColor::color c);
117         
118         /// Check the font, and if set, draw an underline
119         void underline(LyXFont const & f, int x, int y, int width);
120         
121         /**@Low level X parameters */
122         ///
123         Display * display;
124
125         ///
126         Drawable drawable() const;
127                 
128         ///
129         Colormap colormap;
130         
131         /// Caching of ordinary color GCs
132         GC colorGCcache[LColor::ignore + 1];
133         /// Caching of GCs used for lines
134         typedef map<int, GC, less<int> > LineGCCache;
135         ///
136         LineGCCache lineGCcache;
137 };
138 #endif