2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995-2000 The LyX Team
9 * ======================================================*/
21 // This is only included to provide stuff for the non-public sections
25 #include "PainterBase.h"
31 /** An inplementation for the X Window System. Xlib.
33 Classes similar to this one can be made for gtk+, Qt, etc.
35 class Painter : public PainterBase {
38 explicit Painter(WorkArea &);
43 /**@Basic drawing routines */
44 /// Draw a line from point to point
45 PainterBase & line(int x1, int y1, int x2, int y2,
46 LColor::color = LColor::foreground,
47 enum line_style = line_solid,
48 enum line_width = line_thin);
50 /// Here xp and yp are arrays of points
51 PainterBase & lines(int const * xp, int const * yp, int np,
52 LColor::color = LColor::foreground,
53 enum line_style = line_solid,
54 enum line_width = line_thin);
56 /// Here xp and yp are arrays of points
57 PainterBase & fillPolygon(int const * xp, int const * yp, int np,
58 LColor::color = LColor::foreground);
60 /// Draw lines from x1,y1 to x2,y2. They are arrays
61 PainterBase & segments(int const * x1, int const * y1,
62 int const * x2, int const * y2, int ns,
63 LColor::color = LColor::foreground,
64 enum line_style = line_solid,
65 enum line_width = line_thin);
68 PainterBase & rectangle(int x, int y, int w, int h,
69 LColor::color = LColor::foreground,
70 enum line_style = line_solid,
71 enum line_width = line_thin);
74 PainterBase & arc(int x, int y, unsigned int w, unsigned int h,
76 LColor::color = LColor::foreground);
79 PainterBase & point(int x, int y, LColor::color = LColor::foreground);
82 PainterBase & fillRectangle(int x, int y, int w, int h,
83 LColor::color = LColor::background);
87 /// For the figure inset
88 PainterBase & pixmap(int x, int y, int w, int h, Pixmap bitmap);
90 /**@String functions */
92 /// Draw a string at position x, y (y is the baseline)
93 PainterBase & text(int x, int y,
94 string const & str, LyXFont const & f);
96 /** Draw a string at position x, y (y is the baseline)
97 This is just for fast drawing */
98 PainterBase & text(int x, int y, char const * str, int l,
101 /// Draw a char at position x, y (y is the baseline)
102 PainterBase & text(int x, int y, char c, LyXFont const & f);
105 /**@Support for X only, by now */
106 friend class WorkArea;
108 PainterBase & setDisplay(Display * d) { display = d; return *this; }
110 /// Get foreground color in ordinary GC
111 GC getGCForeground(LColor::color c);
113 /// Set up GC according to line style
114 GC getGCLinepars(enum line_style, enum line_width, LColor::color c);
116 /// Check the font, and if set, draw an underline
117 void underline(LyXFont const & f, int x, int y, int width);
119 /**@Low level X parameters */
124 Drawable drawable() const;
129 /// Caching of ordinary color GCs
130 GC colorGCcache[LColor::ignore + 1];
131 /// Caching of GCs used for lines
132 typedef std::map<int, GC> LineGCCache;
134 LineGCCache lineGCcache;