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
27 * Painter - A painter class to encapsulate all graphics parameters and operations
29 * Every graphics operation in LyX should be made by this class. The
30 * painter is used for drawing on the WorkArea, and is passed around
31 * during draw operations.
33 * It hides low level windows system parameters so insets and other
34 * clients don't have to worry about them and we can control graphics and
35 * GUI toolkit dependent drawing functions inside this single class.
37 * The intention for a toolkit is that it uses these methods to paint
38 * onto a backing pixmap. Only when expose events arrive via the event
39 * queue (perhaps generated via Screen::expose), does the copy onto
40 * the actual WorkArea widget take place. Paints are wrapped in (possibly
41 * recursive) calls to start() and end() to facilitate the backing pixmap
44 * Note that the methods return *this for convenience.
48 /// possible line widths
50 line_thin, //< thin line
51 line_thick //< thick line
54 /// possible line styles
56 line_solid, //< solid line
57 line_onoffdash //< dashes with spaces
63 virtual void start() {}
68 /// return the width of the work area in pixels
69 virtual int paperWidth() const = 0;
70 /// return the height of the work area in pixels
71 virtual int paperHeight() const = 0;
73 /// draw a line from point to point
74 virtual Painter & line(
77 LColor::color = LColor::foreground,
78 line_style = line_solid,
79 line_width = line_thin) = 0;
82 * lines - draw a set of lines
83 * @param xp array of points' x co-ords
84 * @param yp array of points' y co-ords
85 * @param np size of the points array
87 virtual Painter & lines(
91 LColor::color = LColor::foreground,
92 line_style = line_solid,
93 line_width = line_thin) = 0;
96 virtual Painter & rectangle(
99 LColor::color = LColor::foreground,
100 line_style = line_solid,
101 line_width = line_thin) = 0;
103 /// draw a filled rectangle
104 virtual Painter & fillRectangle(
109 /// draw a filled (irregular) polygon
110 virtual Painter & fillPolygon(
114 LColor::color = LColor::foreground) = 0;
117 virtual Painter & arc(
119 unsigned int w, unsigned int h,
121 LColor::color = LColor::foreground) = 0;
124 virtual Painter & point(
126 LColor::color = LColor::foreground) = 0;
128 /// draw a filled rectangle with the shape of a 3D button
129 virtual Painter & button(int x, int y,
132 /// draw an image from the image cache
133 virtual Painter & image(int x, int y,
135 grfx::Image const & image) = 0;
137 /// draw a string at position x, y (y is the baseline)
138 virtual Painter & text(int x, int y,
139 string const & str, LyXFont const & f) = 0;
142 * Draw a string at position x, y (y is the baseline)
143 * This is just for fast drawing
145 virtual Painter & text(int x, int y,
146 char const * str, size_t l,
147 LyXFont const & f) = 0;
149 /// draw a char at position x, y (y is the baseline)
150 virtual Painter & text(int x, int y,
151 char c, LyXFont const & f) = 0;
154 * Draw a string and enclose it inside a rectangle. If
155 * back color is specified, the background is cleared with
156 * the given color. If frame is specified, a thin frame is drawn
157 * around the text with the given color.
159 Painter & rectText(int x, int baseline,
160 string const & string,
161 LyXFont const & font,
162 LColor::color back = LColor::none,
163 LColor::color frame = LColor::none);
165 /// draw a string and enclose it inside a button frame
166 Painter & buttonText(int x,
167 int baseline, string const & s,
168 LyXFont const & font);
171 /// check the font, and if set, draw an underline
172 void underline(LyXFont const & f,
173 int x, int y, int width);
175 /// draw a bevelled button border
176 Painter & buttonFrame(int x, int y, int w, int h);