4 * Copyright 1998-2002 the LyX Team
5 * Read the file COPYING
8 * \author John Levon <moz@compsoc.man.ac.uk>
28 * Painter - A painter class to encapsulate all graphics parameters and operations
30 * Every graphics operation in LyX should be made by this class. The
31 * painter is used for drawing on the WorkArea, and is passed around
32 * during draw operations.
34 * It hides low level windows system parameters so insets and other
35 * clients don't have to worry about them and we can control graphics and
36 * GUI toolkit dependent drawing functions inside this single class.
38 * The intention for a toolkit is that it uses these methods to paint
39 * onto a backing pixmap. Only when expose events arrive via the event
40 * queue (perhaps generated via Screen::expose), does the copy onto
41 * the actual WorkArea widget take place. Paints are wrapped in (possibly
42 * recursive) calls to start() and end() to facilitate the backing pixmap
45 * Note that the methods return *this for convenience.
49 /// possible line widths
51 line_thin, //< thin line
52 line_thick //< thick line
55 /// possible line styles
57 line_solid, //< solid line
58 line_onoffdash //< dashes with spaces
64 virtual void start() {}
69 /// return the width of the work area in pixels
70 virtual int paperWidth() const = 0;
71 /// return the height of the work area in pixels
72 virtual int paperHeight() const = 0;
74 /// draw a line from point to point
75 virtual Painter & line(
78 LColor::color = LColor::foreground,
79 line_style = line_solid,
80 line_width = line_thin) = 0;
83 * lines - draw a set of lines
84 * @param xp array of points' x co-ords
85 * @param yp array of points' y co-ords
86 * @param np size of the points array
88 virtual Painter & lines(
92 LColor::color = LColor::foreground,
93 line_style = line_solid,
94 line_width = line_thin) = 0;
97 virtual Painter & rectangle(
100 LColor::color = LColor::foreground,
101 line_style = line_solid,
102 line_width = line_thin) = 0;
104 /// draw a filled rectangle
105 virtual Painter & fillRectangle(
110 /// draw a filled (irregular) polygon
111 virtual Painter & fillPolygon(
115 LColor::color = LColor::foreground) = 0;
118 virtual Painter & arc(
120 unsigned int w, unsigned int h,
122 LColor::color = LColor::foreground) = 0;
125 virtual Painter & point(
127 LColor::color = LColor::foreground) = 0;
129 /// draw a filled rectangle with the shape of a 3D button
130 virtual Painter & button(int x, int y,
133 /// draw an image from the image cache
134 virtual Painter & image(int x, int y,
136 grfx::GImage const & image) = 0;
138 /// draw a string at position x, y (y is the baseline)
139 virtual Painter & text(int x, int y,
140 string const & str, LyXFont const & f) = 0;
143 * Draw a string at position x, y (y is the baseline)
144 * This is just for fast drawing
146 virtual Painter & text(int x, int y,
147 char const * str, size_t l,
148 LyXFont const & f) = 0;
150 /// draw a char at position x, y (y is the baseline)
151 virtual Painter & text(int x, int y,
152 char c, LyXFont const & f) = 0;
154 /// draw a string and enclose it inside a rectangle
155 Painter & rectText(int x, int baseline,
156 string const & string,
157 LyXFont const & font,
159 LColor::color frame);
161 /// draw a string and enclose it inside a button frame
162 Painter & buttonText(int x,
163 int baseline, string const & s,
164 LyXFont const & font);
167 /// check the font, and if set, draw an underline
168 void underline(LyXFont const & f,
169 int x, int y, int width);
171 /// draw a bevelled button border
172 Painter & buttonFrame(int x, int y, int w, int h);