2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2001 The LyX Team
9 *======================================================*/
25 /** A painter class to encapsulate all graphics parameters and operations
27 Every graphics operation in LyX should be made by this class. It will
28 be initialized and managed by the Screen class, and will be passed
29 as a parameter to inset.
31 It hides low level windows system parameters so insets and other
32 clients don't have to worry about them and we can control graphics and
33 GUI toolkit dependent drawing functions inside this single class.
64 explicit PainterBase(WorkArea & wa) : owner(wa) {}
67 virtual ~PainterBase() {}
71 int paperMargin() const;
73 int paperWidth() const;
75 int paperHeight() const;
77 /// Draw a line from point to point
78 virtual PainterBase & line(
79 int x1, int y1, int x2, int y2,
80 LColor::color = LColor::foreground,
81 enum line_style = line_solid,
82 enum line_width = line_thin) = 0;
84 /** Draw the lines between the lines in xp and yp.
85 xp and yp are arrays of points, and np is the
87 virtual PainterBase & lines(
88 int const * xp, int const * yp, int np,
89 LColor::color = LColor::foreground,
90 enum line_style = line_solid,
91 enum line_width = line_thin) = 0;
93 /// Here xp and yp are arrays of points
94 virtual PainterBase & fillPolygon(
95 int const * xp, int const * yp,
97 LColor::color = LColor::foreground) = 0;
99 /// Draw lines from x1,y1 to x2,y2. They are arrays
100 virtual PainterBase & segments(
101 int const * x1, int const * y1,
102 int const * x2, int const * y2, int ns,
103 LColor::color = LColor::foreground,
104 enum line_style = line_solid,
105 enum line_width = line_thin) = 0;
108 virtual PainterBase & rectangle(
109 int x, int y, int w, int h,
110 LColor::color = LColor::foreground,
111 enum line_style = line_solid,
112 enum line_width = line_thin) = 0;
114 /// Draw a circle, d is the diameter, not the radious
115 virtual PainterBase & circle(
116 int x, int y, unsigned int d,
117 LColor::color = LColor::foreground);
120 virtual PainterBase & ellipse(
122 unsigned int w, unsigned int h,
123 LColor::color = LColor::foreground);
126 virtual PainterBase & arc(
128 unsigned int w, unsigned int h,
130 LColor::color = LColor::foreground) = 0;
133 virtual PainterBase & point(
135 LColor::color = LColor::foreground) = 0;
138 virtual PainterBase & fillRectangle(
139 int x, int y, int w, int h,
142 /// A filled rectangle with the shape of a 3D button
143 virtual PainterBase & button(int x, int y, int w, int h);
146 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
149 // For the figure inset
150 virtual PainterBase & image(int x, int y, int w, int h, LyXImage const * image) = 0;
153 /// Draw a string at position x, y (y is the baseline)
154 virtual PainterBase & text(int x, int y,
155 string const & str, LyXFont const & f) = 0;
157 /** Draw a string at position x, y (y is the baseline)
158 This is just for fast drawing */
159 virtual PainterBase & text(int x, int y, char const * str, size_t l,
160 LyXFont const & f) = 0;
162 /// Draw a char at position x, y (y is the baseline)
163 virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
165 /** Draws a string and encloses it inside a rectangle. */
166 PainterBase & rectText(int x, int baseline,
167 string const & string,
168 LyXFont const & font,
170 LColor::color frame);
172 /** Draw a string and encloses it inside a button frame. */
173 PainterBase & buttonText(int x, int baseline, string const & s,
174 LyXFont const & font);