2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1999-2000 The LyX Team
9 * ======================================================*/
21 // This is only included to provide stuff for the non-public sections
25 #include "PainterBase.h"
33 /** An inplementation for the X Window System. Xlib.
35 Classes similar to this one can be made for gtk+, Qt, etc.
37 class Painter : public PainterBase {
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);
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);
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);
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);
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);
76 PainterBase & arc(int x, int y, unsigned int w, unsigned int h,
78 LColor::color = LColor::foreground);
81 PainterBase & point(int x, int y, LColor::color = LColor::foreground);
84 PainterBase & fillRectangle(int x, int y, int w, int h,
85 LColor::color = LColor::background);
89 /// For the figure inset
90 PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
92 /**@String functions */
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);
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,
103 /// Draw a char at position x, y (y is the baseline)
104 PainterBase & text(int x, int y, char c, LyXFont const & f);
107 /**@Support for X only, by now */
108 friend class WorkArea;
110 PainterBase & setDisplay(Display * d) { display = d; return *this; }
112 /// Get foreground color in ordinary GC
113 GC getGCForeground(LColor::color c);
115 /// Set up GC according to line style
116 GC getGCLinepars(enum line_style, enum line_width, LColor::color c);
118 /// Check the font, and if set, draw an underline
119 void underline(LyXFont const & f, int x, int y, int width);
121 /**@Low level X parameters */
126 Drawable drawable() const;
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;
136 LineGCCache lineGCcache;