2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2000 The LyX Team
9 *======================================================*/
24 /** A painter class to encapsulate all graphics parameters and operations
26 Every graphics operation in LyX should be made by this class. It will
27 be initialized and managed by the Screen class, and will be passed
28 as a parameter to inset.
30 It hides low level windows system parameters so insets and other
31 clients don't have to worry about them and we can control graphics and
32 GUI toolkit dependent drawing functions inside this single class.
63 explicit PainterBase(WorkArea & wa) : owner(wa) {}
66 virtual ~PainterBase() {}
70 int paperMargin() const;
72 int paperWidth() const;
74 int paperHeight() const;
76 /// Draw a line from point to point
77 virtual PainterBase & line(
78 int x1, int y1, int x2, int y2,
79 LColor::color = LColor::foreground,
80 enum line_style = line_solid,
81 enum line_width = line_thin) = 0;
83 /** Draw the lines between the lines in xp and yp.
84 xp and yp are arrays of points, and np is the
86 virtual PainterBase & lines(
87 int const * xp, int const * yp, int np,
88 LColor::color = LColor::foreground,
89 enum line_style = line_solid,
90 enum line_width = line_thin) = 0;
92 /// Here xp and yp are arrays of points
93 virtual PainterBase & fillPolygon(
94 int const * xp, int const * yp,
96 LColor::color =LColor::foreground) = 0;
98 /// Draw lines from x1,y1 to x2,y2. They are arrays
99 virtual PainterBase & segments(
100 int const * x1, int const * y1,
101 int const * x2, int const * y2, int ns,
102 LColor::color = LColor::foreground,
103 enum line_style = line_solid,
104 enum line_width = line_thin) = 0;
107 virtual PainterBase & rectangle(
108 int x, int y, int w, int h,
109 LColor::color = LColor::foreground,
110 enum line_style = line_solid,
111 enum line_width = line_thin) = 0;
113 /// Draw a circle, d is the diameter, not the radious
114 virtual PainterBase & circle(
115 int x, int y, unsigned int d,
116 LColor::color = LColor::foreground);
119 virtual PainterBase & ellipse(
121 unsigned int w, unsigned int h,
122 LColor::color = LColor::foreground);
125 virtual PainterBase & arc(
127 unsigned int w, unsigned int h,
129 LColor::color = LColor::foreground) = 0;
132 virtual PainterBase & point(
134 LColor::color = LColor::foreground) = 0;
137 virtual PainterBase & fillRectangle(
138 int x, int y, int w, int h,
139 LColor::color = LColor::background) = 0;
141 /// A filled rectangle with the shape of a 3D button
142 virtual PainterBase & button(int x, int y, int w, int h);
145 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
148 // For the figure inset
149 // This can't be part of the base since we don't know what window
150 // system we will be useing, or if are going to use pixmaps at all.
151 //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
154 /// Draw a string at position x, y (y is the baseline)
155 virtual PainterBase & text(int x, int y,
156 string const & str, LyXFont const & f) = 0;
158 /** Draw a string at position x, y (y is the baseline)
159 This is just for fast drawing */
160 virtual PainterBase & text(int x, int y, char const * str, size_t l,
161 LyXFont const & f) = 0;
163 /// Draw a char at position x, y (y is the baseline)
164 virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
166 /** Draws a string and encloses it inside a rectangle. Returns
167 the size of the rectangle. If draw is false, we only calculate
169 virtual PainterBase & rectText(int x, int baseline,
170 string const & string,
171 LyXFont const & font,
173 LColor::color frame, bool draw = true,
174 int & width = PainterBase::dummy1,
175 int & ascent = PainterBase::dummy2,
176 int & descent = PainterBase::dummy3);
178 /** Draw a string and encloses it inside a button frame. Returns
179 the size of the frame. If draw is false, we only calculate
181 virtual PainterBase & buttonText(int x, int baseline, string const & s,
182 LyXFont const & font, bool draw = true,
183 int & width = PainterBase::dummy1,
184 int & ascent = PainterBase::dummy2,
185 int & descent = PainterBase::dummy3);