4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
18 #include "support/docstring.h"
31 * Painter - A painter class to encapsulate all graphics parameters and operations
33 * Every graphics operation in LyX should be made by this class. The
34 * painter is used for drawing on the WorkArea, and is passed around
35 * during draw operations.
37 * It hides low level windows system parameters so insets and other
38 * clients don't have to worry about them and we can control graphics and
39 * GUI toolkit dependent drawing functions inside this single class.
41 * The intention for a toolkit is that it uses these methods to paint
42 * onto a backing pixmap. Only when expose events arrive via the event
43 * queue (perhaps generated via Screen::expose), does the copy onto
44 * the actual WorkArea widget take place. Paints are wrapped in (possibly
45 * recursive) calls to start() and end() to facilitate the backing pixmap
48 * Note that the methods return *this for convenience.
52 /// possible line widths
54 line_thin, //< thin line
55 line_thick //< thick line
58 /// possible line styles
60 line_solid, //< solid line
61 line_onoffdash //< dashes with spaces
67 virtual void start() {}
72 /// return the width of the work area in pixels
73 virtual int paperWidth() const = 0;
74 /// return the height of the work area in pixels
75 virtual int paperHeight() const = 0;
77 /// draw a line from point to point
82 line_style = line_solid,
83 line_width = line_thin) = 0;
86 * lines - draw a set of lines
87 * @param xp array of points' x co-ords
88 * @param yp array of points' y co-ords
89 * @param np size of the points array
96 line_style = line_solid,
97 line_width = line_thin) = 0;
100 virtual void rectangle(
104 line_style = line_solid,
105 line_width = line_thin) = 0;
107 /// draw a filled rectangle
108 virtual void fillRectangle(
116 unsigned int w, unsigned int h,
125 /// draw a filled rectangle with the shape of a 3D button
126 virtual void button(int x, int y,
129 /// draw an image from the image cache
130 virtual void image(int x, int y,
132 lyx::graphics::Image const & image) = 0;
134 /// draw a string at position x, y (y is the baseline)
135 virtual void text(int x, int y,
136 lyx::docstring const & str, LyXFont const & f) = 0;
139 * Draw a string at position x, y (y is the baseline)
140 * This is just for fast drawing
142 virtual void text(int x, int y,
143 lyx::char_type const * str, size_t l,
144 LyXFont const & f) = 0;
146 /// draw a char at position x, y (y is the baseline)
147 virtual void text(int x, int y,
148 lyx::char_type c, LyXFont const & f) = 0;
151 * Draw a string and enclose it inside a rectangle. If
152 * back color is specified, the background is cleared with
153 * the given color. If frame is specified, a thin frame is drawn
154 * around the text with the given color.
156 virtual void rectText(int x, int baseline,
157 lyx::docstring const & str,
158 LyXFont const & font,
162 /// draw a string and enclose it inside a button frame
163 virtual void buttonText(int x,
164 int baseline, lyx::docstring const & s,
165 LyXFont const & font);
168 /// check the font, and if set, draw an underline
169 virtual void underline(LyXFont const & f,
170 int x, int y, int width);
172 /// draw a bevelled button border
173 virtual void buttonFrame(int x, int y, int w, int h);
176 } // namespace frontend