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(
118 unsigned int w, unsigned int h,
127 /// draw a filled rectangle with the shape of a 3D button
128 virtual void button(int x, int y,
131 /// draw an image from the image cache
132 virtual void image(int x, int y,
134 lyx::graphics::Image const & image) = 0;
136 /// draw a string at position x, y (y is the baseline)
137 virtual void text(int x, int y,
138 lyx::docstring const & str, LyXFont const & f) = 0;
141 * Draw a string at position x, y (y is the baseline)
142 * This is just for fast drawing
144 virtual void text(int x, int y,
145 lyx::char_type const * str, size_t l,
146 LyXFont const & f) = 0;
148 /// draw a char at position x, y (y is the baseline)
149 virtual void text(int x, int y,
150 lyx::char_type c, LyXFont const & f) = 0;
153 * Draw a string and enclose it inside a rectangle. If
154 * back color is specified, the background is cleared with
155 * the given color. If frame is specified, a thin frame is drawn
156 * around the text with the given color.
158 virtual void rectText(int x, int baseline,
159 lyx::docstring const & str,
160 LyXFont const & font,
164 /// draw a string and enclose it inside a button frame
165 virtual void buttonText(int x,
166 int baseline, lyx::docstring const & s,
167 LyXFont const & font);
170 /// check the font, and if set, draw an underline
171 virtual void underline(LyXFont const & f,
172 int x, int y, int width);
174 /// draw a bevelled button border
175 virtual void buttonFrame(int x, int y, int w, int h);
178 } // namespace frontend