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
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() {}
71 /// return the width of the work area in pixels
72 virtual int paperWidth() const = 0;
73 /// return the height of the work area in pixels
74 virtual int paperHeight() const = 0;
76 /// draw a line from point to point
77 virtual Painter & line(
80 LColor::color = LColor::foreground,
81 line_style = line_solid,
82 line_width = line_thin) = 0;
85 * lines - draw a set of lines
86 * @param xp array of points' x co-ords
87 * @param yp array of points' y co-ords
88 * @param np size of the points array
90 virtual Painter & lines(
94 LColor::color = LColor::foreground,
95 line_style = line_solid,
96 line_width = line_thin) = 0;
99 virtual Painter & rectangle(
102 LColor::color = LColor::foreground,
103 line_style = line_solid,
104 line_width = line_thin) = 0;
106 /// draw a filled rectangle
107 virtual Painter & fillRectangle(
112 /// draw a filled (irregular) polygon
113 virtual Painter & fillPolygon(
117 LColor::color = LColor::foreground) = 0;
120 virtual Painter & arc(
122 unsigned int w, unsigned int h,
124 LColor::color = LColor::foreground) = 0;
127 virtual Painter & point(
129 LColor::color = LColor::foreground) = 0;
131 /// draw a filled rectangle with the shape of a 3D button
132 virtual Painter & button(int x, int y,
135 /// draw an image from the image cache
136 virtual Painter & image(int x, int y,
138 grfx::Image const & image) = 0;
140 /// draw a string at position x, y (y is the baseline)
141 virtual Painter & text(int x, int y,
142 string const & str, LyXFont const & f) = 0;
145 * Draw a string at position x, y (y is the baseline)
146 * This is just for fast drawing
148 virtual Painter & text(int x, int y,
149 char const * str, size_t l,
150 LyXFont const & f) = 0;
152 /// draw a char at position x, y (y is the baseline)
153 virtual Painter & text(int x, int y,
154 char c, LyXFont const & f) = 0;
157 * Draw a string and enclose it inside a rectangle. If
158 * back color is specified, the background is cleared with
159 * the given color. If frame is specified, a thin frame is drawn
160 * around the text with the given color.
162 Painter & rectText(int x, int baseline,
163 string const & string,
164 LyXFont const & font,
165 LColor::color back = LColor::none,
166 LColor::color frame = LColor::none);
168 /// draw a string and enclose it inside a button frame
169 Painter & buttonText(int x,
170 int baseline, string const & s,
171 LyXFont const & font);
174 /// check the font, and if set, draw an underline
175 void underline(LyXFont const & f,
176 int x, int y, int width);
178 /// draw a bevelled button border
179 Painter & buttonFrame(int x, int y, int w, int h);