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.
38 static int dummy1, dummy2, dummy3;
59 explicit PainterBase(WorkArea & wa) : owner(wa) {}
62 virtual ~PainterBase() {}
64 /** Screen geometry */
66 int paperMargin() const;
68 int paperWidth() const;
70 int paperHeight() const;
72 /**@Basic drawing routines */
73 /// Draw a line from point to point
74 virtual PainterBase & line(
75 int x1, int y1, int x2, int y2,
76 LColor::color = LColor::foreground,
77 enum line_style = line_solid,
78 enum line_width = line_thin) = 0;
80 /** Draw the lines between the lines in xp and yp.
81 xp and yp are arrays of points, and np is the
83 virtual PainterBase & lines(
84 int const * xp, int const * yp, int np,
85 LColor::color = LColor::foreground,
86 enum line_style = line_solid,
87 enum line_width = line_thin) = 0;
89 /// Here xp and yp are arrays of points
90 virtual PainterBase & fillPolygon(
91 int const * xp, int const * yp,
93 LColor::color =LColor::foreground) = 0;
95 /// Draw lines from x1,y1 to x2,y2. They are arrays
96 virtual PainterBase & segments(
97 int const * x1, int const * y1,
98 int const * x2, int const * y2, int ns,
99 LColor::color = LColor::foreground,
100 enum line_style = line_solid,
101 enum line_width = line_thin) = 0;
104 virtual PainterBase & rectangle(
105 int x, int y, int w, int h,
106 LColor::color = LColor::foreground,
107 enum line_style = line_solid,
108 enum line_width = line_thin) = 0;
110 /// Draw a circle, d is the diameter, not the radious
111 virtual PainterBase & circle(
112 int x, int y, unsigned int d,
113 LColor::color = LColor::foreground);
116 virtual PainterBase & ellipse(
118 unsigned int w, unsigned int h,
119 LColor::color = LColor::foreground);
122 virtual PainterBase & arc(
124 unsigned int w, unsigned int h,
126 LColor::color = LColor::foreground) = 0;
129 virtual PainterBase & point(
131 LColor::color = LColor::foreground) = 0;
134 virtual PainterBase & fillRectangle(
135 int x, int y, int w, int h,
136 LColor::color = LColor::background) = 0;
138 /// A filled rectangle with the shape of a 3D button
139 virtual PainterBase & button(int x, int y, int w, int h);
142 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
146 /// For the figure inset
147 // This can't be part of the base since we don't know what window
148 // system we will be useing, or if are going to use pixmaps at all.
149 //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
152 /**@String functions */
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, int 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);