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.
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(
113 /// draw a filled (irregular) polygon
114 virtual void fillPolygon(
123 unsigned int w, unsigned int h,
132 /// draw a filled rectangle with the shape of a 3D button
133 virtual void button(int x, int y,
136 /// draw an image from the image cache
137 virtual void image(int x, int y,
139 lyx::graphics::Image const & image) = 0;
141 /// draw a string at position x, y (y is the baseline)
142 virtual void text(int x, int y,
143 std::string const & str, LyXFont const & f) = 0;
146 * Draw a string at position x, y (y is the baseline)
147 * This is just for fast drawing
149 virtual void text(int x, int y,
150 char const * str, size_t l,
151 LyXFont const & f) = 0;
153 /// draw a char at position x, y (y is the baseline)
154 virtual void text(int x, int y,
155 char c, LyXFont const & f) = 0;
158 * Draw a string and enclose it inside a rectangle. If
159 * back color is specified, the background is cleared with
160 * the given color. If frame is specified, a thin frame is drawn
161 * around the text with the given color.
163 virtual void rectText(int x, int baseline,
164 std::string const & str,
165 LyXFont const & font,
169 /// draw a string and enclose it inside a button frame
170 virtual void buttonText(int x,
171 int baseline, std::string const & s,
172 LyXFont const & font);
175 /// check the font, and if set, draw an underline
176 virtual void underline(LyXFont const & f,
177 int x, int y, int width);
179 /// draw a bevelled button border
180 virtual void buttonFrame(int x, int y, int w, int h);