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"
25 namespace graphics { class Image; }
30 * Painter - A painter class to encapsulate all graphics parameters and operations
32 * Every graphics operation in LyX should be made by this class. The
33 * painter is used for drawing on the WorkArea, and is passed around
34 * during draw operations.
36 * It hides low level windows system parameters so insets and other
37 * clients don't have to worry about them and we can control graphics and
38 * GUI toolkit dependent drawing functions inside this single class.
40 * The intention for a toolkit is that it uses these methods to paint
41 * onto a backing pixmap. Only when expose events arrive via the event
42 * queue (perhaps generated via Screen::expose), does the copy onto
43 * the actual WorkArea widget take place. Paints are wrapped in (possibly
44 * recursive) calls to start() and end() to facilitate the backing pixmap
47 * Note that the methods return *this for convenience.
51 /// possible line widths
53 line_thin, //< thin line
54 line_thick //< thick line
57 /// possible line styles
59 line_solid, //< solid line
60 line_onoffdash //< dashes with spaces
66 //virtual void start() {}
69 ////virtual void end() {}
71 /// draw a line from point to point
76 line_style = line_solid,
77 line_width = line_thin) = 0;
80 * lines - draw a set of lines
81 * @param xp array of points' x co-ords
82 * @param yp array of points' y co-ords
83 * @param np size of the points array
90 line_style = line_solid,
91 line_width = line_thin) = 0;
94 virtual void rectangle(
98 line_style = line_solid,
99 line_width = line_thin) = 0;
101 /// draw a filled rectangle
102 virtual void fillRectangle(
110 unsigned int w, unsigned int h,
119 /// draw a filled rectangle with the shape of a 3D button
120 virtual void button(int x, int y,
123 /// draw an image from the image cache
124 virtual void image(int x, int y,
126 graphics::Image const & image) = 0;
128 /// draw a string at position x, y (y is the baseline)
130 * \return the width of the drawn text.
132 virtual int text(int x, int y,
133 docstring const & str, LyXFont const & f) = 0;
136 * Draw a string at position x, y (y is the baseline)
137 * This is just for fast drawing
138 * \return the width of the drawn text.
140 virtual int text(int x, int y,
141 char_type const * str, size_t l, LyXFont const & f) = 0;
143 /// draw a char at position x, y (y is the baseline)
145 * \return the width of the drawn text.
147 virtual int text(int x, int y, char_type c, LyXFont const & f) = 0;
150 * Draw a string and enclose it inside a rectangle. If
151 * back color is specified, the background is cleared with
152 * the given color. If frame is specified, a thin frame is drawn
153 * around the text with the given color.
155 virtual void rectText(int x, int baseline,
156 docstring const & str,
157 LyXFont const & font,
161 /// draw a string and enclose it inside a button frame
162 virtual void buttonText(int x,
163 int baseline, docstring const & s, LyXFont const & font);
166 /// check the font, and if set, draw an underline
167 virtual void underline(LyXFont const & f,
168 int x, int y, int width);
170 /// draw a bevelled button border
171 virtual void buttonFrame(int x, int y, int w, int h);
174 } // namespace frontend