4 * Read the file COPYING
9 * Full author contact details are available in file CREDITS
29 * Painter - A painter class to encapsulate all graphics parameters and operations
31 * Every graphics operation in LyX should be made by this class. The
32 * painter is used for drawing on the WorkArea, and is passed around
33 * during draw operations.
35 * It hides low level windows system parameters so insets and other
36 * clients don't have to worry about them and we can control graphics and
37 * GUI toolkit dependent drawing functions inside this single class.
39 * The intention for a toolkit is that it uses these methods to paint
40 * onto a backing pixmap. Only when expose events arrive via the event
41 * queue (perhaps generated via Screen::expose), does the copy onto
42 * the actual WorkArea widget take place. Paints are wrapped in (possibly
43 * recursive) calls to start() and end() to facilitate the backing pixmap
46 * Note that the methods return *this for convenience.
50 /// possible line widths
52 line_thin, //< thin line
53 line_thick //< thick line
56 /// possible line styles
58 line_solid, //< solid line
59 line_onoffdash //< dashes with spaces
65 virtual void start() {}
70 /// return the width of the work area in pixels
71 virtual int paperWidth() const = 0;
72 /// return the height of the work area in pixels
73 virtual int paperHeight() const = 0;
75 /// draw a line from point to point
76 virtual Painter & line(
79 LColor::color = LColor::foreground,
80 line_style = line_solid,
81 line_width = line_thin) = 0;
84 * lines - draw a set of lines
85 * @param xp array of points' x co-ords
86 * @param yp array of points' y co-ords
87 * @param np size of the points array
89 virtual Painter & lines(
93 LColor::color = LColor::foreground,
94 line_style = line_solid,
95 line_width = line_thin) = 0;
98 virtual Painter & rectangle(
101 LColor::color = LColor::foreground,
102 line_style = line_solid,
103 line_width = line_thin) = 0;
105 /// draw a filled rectangle
106 virtual Painter & fillRectangle(
111 /// draw a filled (irregular) polygon
112 virtual Painter & fillPolygon(
116 LColor::color = LColor::foreground) = 0;
119 virtual Painter & arc(
121 unsigned int w, unsigned int h,
123 LColor::color = LColor::foreground) = 0;
126 virtual Painter & point(
128 LColor::color = LColor::foreground) = 0;
130 /// draw a filled rectangle with the shape of a 3D button
131 virtual Painter & button(int x, int y,
134 /// draw an image from the image cache
135 virtual Painter & image(int x, int y,
137 grfx::Image const & image) = 0;
139 /// draw a string at position x, y (y is the baseline)
140 virtual Painter & text(int x, int y,
141 string const & str, LyXFont const & f) = 0;
144 * Draw a string at position x, y (y is the baseline)
145 * This is just for fast drawing
147 virtual Painter & text(int x, int y,
148 char const * str, size_t l,
149 LyXFont const & f) = 0;
151 /// draw a char at position x, y (y is the baseline)
152 virtual Painter & text(int x, int y,
153 char c, LyXFont const & f) = 0;
156 * Draw a string and enclose it inside a rectangle. If
157 * back color is specified, the background is cleared with
158 * the given color. If frame is specified, a thin frame is drawn
159 * around the text with the given color.
161 Painter & rectText(int x, int baseline,
162 string const & string,
163 LyXFont const & font,
164 LColor::color back = LColor::none,
165 LColor::color frame = LColor::none);
167 /// draw a string and enclose it inside a button frame
168 Painter & buttonText(int x,
169 int baseline, string const & s,
170 LyXFont const & font);
173 /// check the font, and if set, draw an underline
174 void underline(LyXFont const & f,
175 int x, int y, int width);
177 /// draw a bevelled button border
178 Painter & buttonFrame(int x, int y, int w, int h);