2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1999-2000 The LyX Team
9 * ======================================================*/
23 // This is only included to provide stuff for the non-public sections
27 #include "PainterBase.h"
35 /** An inplementation for the X Window System. Xlib.
37 Classes similar to this one can be made for gtk+, Qt, etc.
39 class Painter : public PainterBase {
47 /**@Basic drawing routines */
48 /// Draw a line from point to point
49 PainterBase & line(int x1, int y1, int x2, int y2,
50 LColor::color = LColor::foreground,
51 enum line_style = line_solid,
52 enum line_width = line_thin);
54 /// Here xp and yp are arrays of points
55 PainterBase & lines(int const * xp, int const * yp, int np,
56 LColor::color = LColor::foreground,
57 enum line_style = line_solid,
58 enum line_width = line_thin);
60 /// Here xp and yp are arrays of points
61 PainterBase & fillPolygon(int const * xp, int const * yp, int np,
62 LColor::color = LColor::foreground);
64 /// Draw lines from x1,y1 to x2,y2. They are arrays
65 PainterBase & segments(int const * x1, int const * y1,
66 int const * x2, int const * y2, int ns,
67 LColor::color = LColor::foreground,
68 enum line_style = line_solid,
69 enum line_width = line_thin);
72 PainterBase & rectangle(int x, int y, int w, int h,
73 LColor::color = LColor::foreground,
74 enum line_style = line_solid,
75 enum line_width = line_thin);
78 PainterBase & arc(int x, int y, unsigned int w, unsigned int h,
80 LColor::color = LColor::foreground);
83 PainterBase & point(int x, int y, LColor::color = LColor::foreground);
86 PainterBase & fillRectangle(int x, int y, int w, int h,
87 LColor::color = LColor::background);
91 /// For the figure inset
92 PainterBase & pixmap(int x, int y, Pixmap bitmap);
94 /**@String functions */
96 /// Draw a string at position x, y (y is the baseline)
97 PainterBase & text(int x, int y, string const & str, LyXFont const & f);
99 /** Draw a string at position x, y (y is the baseline)
100 This is just for fast drawing */
101 PainterBase & text(int x, int y, char const * str, int l,
104 /// Draw a char at position x, y (y is the baseline)
105 PainterBase & text(int x, int y, char c, LyXFont const & f);
108 /**@Support for X only, by now */
109 friend class WorkArea;
111 PainterBase & setDisplay(Display * d) { display = d; return *this; }
114 PainterBase & setDrawable(Drawable d) { drawable = d; return *this; }
116 /// Get foreground color in ordinary GC
117 GC getGCForeground(LColor::color c);
119 /// Set up GC according to line style
120 GC getGCLinepars(enum line_style, enum line_width, LColor::color c);
122 /// Check the font, and if set, draw an underline
123 void underline(LyXFont const & f, int x, int y, int width);
125 /**@Low level X parameters */
133 /// Caching of ordinary color GCs
134 GC colorGCcache[LColor::ignore + 1];
135 /// Caching of GCs used for lines
136 typedef map<int, GC, less<int> > LineGCCache;
138 LineGCCache lineGCcache;