2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2000 The LyX Team
9 *======================================================*/
27 /** A painter class to encapsulate all graphics parameters and operations
29 Every graphics operation in LyX should be made by this class. It will
30 be initialized and managed by the Screen class, and will be passed
31 as a parameter to inset.
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.
41 static int dummy1, dummy2, dummy3;
62 PainterBase(WorkArea & wa) : owner(wa) {}
65 virtual ~PainterBase() {}
67 /** Screen geometry */
73 /**@Basic drawing routines */
74 /// Draw a line from point to point
75 virtual PainterBase & line(
76 int x1, int y1, int x2, int y2,
77 LColor::color = LColor::foreground,
78 enum line_style = line_solid,
79 enum line_width = line_thin) = 0;
81 /** Draw the lines between the lines in xp and yp.
82 xp and yp are arrays of points, and np is the
84 virtual PainterBase & lines(
85 int const * xp, int const * yp, int np,
86 LColor::color = LColor::foreground,
87 enum line_style = line_solid,
88 enum line_width = line_thin) = 0;
90 /// Here xp and yp are arrays of points
91 virtual PainterBase & fillPolygon(
92 int const * xp, int const * yp,
94 LColor::color =LColor::foreground) = 0;
96 /// Draw lines from x1,y1 to x2,y2. They are arrays
97 virtual PainterBase & segments(
98 int const * x1, int const * y1,
99 int const * x2, int const * y2, int ns,
100 LColor::color = LColor::foreground,
101 enum line_style = line_solid,
102 enum line_width = line_thin) = 0;
105 virtual PainterBase & rectangle(
106 int x, int y, int w, int h,
107 LColor::color = LColor::foreground,
108 enum line_style = line_solid,
109 enum line_width = line_thin) = 0;
111 /// Draw a circle, d is the diameter, not the radious
112 virtual PainterBase & circle(
113 int x, int y, unsigned int d,
114 LColor::color = LColor::foreground);
117 virtual PainterBase & ellipse(
119 unsigned int w, unsigned int h,
120 LColor::color = LColor::foreground);
123 virtual PainterBase & arc(
125 unsigned int w, unsigned int h,
127 LColor::color = LColor::foreground) = 0;
130 virtual PainterBase & point(
132 LColor::color = LColor::foreground) = 0;
135 virtual PainterBase & fillRectangle(
136 int x, int y, int w, int h,
137 LColor::color = LColor::background) = 0;
139 /// A filled rectangle with the shape of a 3D button
140 virtual PainterBase & button(int x, int y, int w, int h);
143 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
147 /// For the figure inset
148 // This can't be part of the base since we don't know what window
149 // system we will be useing, or if are going to use pixmaps at all.
150 //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
153 /**@String functions */
155 /// Draw a string at position x, y (y is the baseline)
156 virtual PainterBase & text(int x, int y,
157 string const &str, LyXFont const & f) = 0;
159 /** Draw a string at position x, y (y is the baseline)
160 This is just for fast drawing */
161 virtual PainterBase & text(int x, int y, char const * str, int l,
162 LyXFont const & f) = 0;
164 /// Draw a char at position x, y (y is the baseline)
165 virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
167 /// Get the width of text
168 int width(string const & s, LyXFont const & f);
170 /** Get the width of text
171 This is just for fast width */
172 int width(char const * s, int l, LyXFont const & f);
174 /// Get the width of text
175 int width(char c, LyXFont const & f);
177 /** Draws a string and encloses it inside a rectangle. Returns
178 the size of the rectangle. If draw is false, we only calculate
180 virtual PainterBase & rectText(int x, int baseline,
181 string const & string,
182 LyXFont const & font,
184 LColor::color frame, bool draw = true,
185 int & width = PainterBase::dummy1,
186 int & ascent = PainterBase::dummy2,
187 int & descent = PainterBase::dummy3);
189 /** Draw a string and encloses it inside a button frame. Returns
190 the size of the frame. If draw is false, we only calculate
192 virtual PainterBase & buttonText(int x, int baseline, string const & s,
193 LyXFont const & font, bool draw = true,
194 int & width = PainterBase::dummy1,
195 int & ascent = PainterBase::dummy2,
196 int & descent = PainterBase::dummy3);
197 /// This is preliminary
198 //BufferView const * getOwner() const { return &owner; }