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/types.h"
33 * Painter - A painter class to encapsulate all graphics parameters and operations
35 * Every graphics operation in LyX should be made by this class. The
36 * painter is used for drawing on the WorkArea, and is passed around
37 * during draw operations.
39 * It hides low level windows system parameters so insets and other
40 * clients don't have to worry about them and we can control graphics and
41 * GUI toolkit dependent drawing functions inside this single class.
43 * The intention for a toolkit is that it uses these methods to paint
44 * onto a backing pixmap. Only when expose events arrive via the event
45 * queue (perhaps generated via Screen::expose), does the copy onto
46 * the actual WorkArea widget take place. Paints are wrapped in (possibly
47 * recursive) calls to start() and end() to facilitate the backing pixmap
50 * Note that the methods return *this for convenience.
54 /// possible line widths
56 line_thin, //< thin line
57 line_thick //< thick line
60 /// possible line styles
62 line_solid, //< solid line
63 line_onoffdash //< dashes with spaces
69 virtual void start() {}
74 /// return the width of the work area in pixels
75 virtual int paperWidth() const = 0;
76 /// return the height of the work area in pixels
77 virtual int paperHeight() const = 0;
79 /// draw a line from point to point
84 line_style = line_solid,
85 line_width = line_thin) = 0;
88 * lines - draw a set of lines
89 * @param xp array of points' x co-ords
90 * @param yp array of points' y co-ords
91 * @param np size of the points array
98 line_style = line_solid,
99 line_width = line_thin) = 0;
102 virtual void rectangle(
106 line_style = line_solid,
107 line_width = line_thin) = 0;
109 /// draw a filled rectangle
110 virtual void fillRectangle(
115 /// draw a filled (irregular) polygon (UNUSED, could be removed)
116 virtual void fillPolygon(
125 unsigned int w, unsigned int h,
134 /// draw a filled rectangle with the shape of a 3D button
135 virtual void button(int x, int y,
138 /// draw an image from the image cache
139 virtual void image(int x, int y,
141 lyx::graphics::Image const & image) = 0;
143 /// draw a string at position x, y (y is the baseline)
144 virtual void text(int x, int y,
145 std::string const & str, LyXFont const & f) = 0;
148 * Draw a string at position x, y (y is the baseline)
149 * This is just for fast drawing
151 virtual void text(int x, int y,
152 char const * str, size_t l,
153 LyXFont const & f) = 0;
155 /// draw a char at position x, y (y is the baseline)
156 virtual void text(int x, int y,
157 lyx::char_type c, LyXFont const & f) = 0;
160 * Draw a string and enclose it inside a rectangle. If
161 * back color is specified, the background is cleared with
162 * the given color. If frame is specified, a thin frame is drawn
163 * around the text with the given color.
165 virtual void rectText(int x, int baseline,
166 std::string const & str,
167 LyXFont const & font,
171 /// draw a string and enclose it inside a button frame
172 virtual void buttonText(int x,
173 int baseline, std::string const & s,
174 LyXFont const & font);
177 /// check the font, and if set, draw an underline
178 virtual void underline(LyXFont const & f,
179 int x, int y, int width);
181 /// draw a bevelled button border
182 virtual void buttonFrame(int x, int y, int w, int h);