2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2000 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.
39 static int dummy1, dummy2, dummy3;
60 PainterBase(WorkArea & wa) : owner(wa) {}
63 virtual ~PainterBase() {}
65 /** Screen geometry */
67 int paperMargin() const;
69 int paperWidth() const;
71 /**@Basic drawing routines */
72 /// Draw a line from point to point
73 virtual PainterBase & line(
74 int x1, int y1, int x2, int y2,
75 LColor::color = LColor::foreground,
76 enum line_style = line_solid,
77 enum line_width = line_thin) = 0;
79 /** Draw the lines between the lines in xp and yp.
80 xp and yp are arrays of points, and np is the
82 virtual PainterBase & lines(
83 int const * xp, int const * yp, int np,
84 LColor::color = LColor::foreground,
85 enum line_style = line_solid,
86 enum line_width = line_thin) = 0;
88 /// Here xp and yp are arrays of points
89 virtual PainterBase & fillPolygon(
90 int const * xp, int const * yp,
92 LColor::color =LColor::foreground) = 0;
94 /// Draw lines from x1,y1 to x2,y2. They are arrays
95 virtual PainterBase & segments(
96 int const * x1, int const * y1,
97 int const * x2, int const * y2, int ns,
98 LColor::color = LColor::foreground,
99 enum line_style = line_solid,
100 enum line_width = line_thin) = 0;
103 virtual PainterBase & rectangle(
104 int x, int y, int w, int h,
105 LColor::color = LColor::foreground,
106 enum line_style = line_solid,
107 enum line_width = line_thin) = 0;
109 /// Draw a circle, d is the diameter, not the radious
110 virtual PainterBase & circle(
111 int x, int y, unsigned int d,
112 LColor::color = LColor::foreground);
115 virtual PainterBase & ellipse(
117 unsigned int w, unsigned int h,
118 LColor::color = LColor::foreground);
121 virtual PainterBase & arc(
123 unsigned int w, unsigned int h,
125 LColor::color = LColor::foreground) = 0;
128 virtual PainterBase & point(
130 LColor::color = LColor::foreground) = 0;
133 virtual PainterBase & fillRectangle(
134 int x, int y, int w, int h,
135 LColor::color = LColor::background) = 0;
137 /// A filled rectangle with the shape of a 3D button
138 virtual PainterBase & button(int x, int y, int w, int h);
141 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
145 /// For the figure inset
146 // This can't be part of the base since we don't know what window
147 // system we will be useing, or if are going to use pixmaps at all.
148 //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
151 /**@String functions */
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, int 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 /// Get the width of text
166 int width(string const & s, LyXFont const & f) const;
168 /** Get the width of text
169 This is just for fast width */
170 int width(char const * s, int l, LyXFont const & f) const;
172 /// Get the width of text
173 int width(char c, LyXFont const & f) const;
175 /** Draws a string and encloses it inside a rectangle. Returns
176 the size of the rectangle. If draw is false, we only calculate
178 virtual PainterBase & rectText(int x, int baseline,
179 string const & string,
180 LyXFont const & font,
182 LColor::color frame, bool draw = true,
183 int & width = PainterBase::dummy1,
184 int & ascent = PainterBase::dummy2,
185 int & descent = PainterBase::dummy3);
187 /** Draw a string and encloses it inside a button frame. Returns
188 the size of the frame. If draw is false, we only calculate
190 virtual PainterBase & buttonText(int x, int baseline, string const & s,
191 LyXFont const & font, bool draw = true,
192 int & width = PainterBase::dummy1,
193 int & ascent = PainterBase::dummy2,
194 int & descent = PainterBase::dummy3);