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 /**@Basic drawing routines */
71 /// Draw a line from point to point
72 virtual PainterBase & line(
73 int x1, int y1, int x2, int y2,
74 LColor::color = LColor::foreground,
75 enum line_style = line_solid,
76 enum line_width = line_thin) = 0;
78 /** Draw the lines between the lines in xp and yp.
79 xp and yp are arrays of points, and np is the
81 virtual PainterBase & lines(
82 int const * xp, int const * yp, int np,
83 LColor::color = LColor::foreground,
84 enum line_style = line_solid,
85 enum line_width = line_thin) = 0;
87 /// Here xp and yp are arrays of points
88 virtual PainterBase & fillPolygon(
89 int const * xp, int const * yp,
91 LColor::color =LColor::foreground) = 0;
93 /// Draw lines from x1,y1 to x2,y2. They are arrays
94 virtual PainterBase & segments(
95 int const * x1, int const * y1,
96 int const * x2, int const * y2, int ns,
97 LColor::color = LColor::foreground,
98 enum line_style = line_solid,
99 enum line_width = line_thin) = 0;
102 virtual PainterBase & rectangle(
103 int x, int y, int w, int h,
104 LColor::color = LColor::foreground,
105 enum line_style = line_solid,
106 enum line_width = line_thin) = 0;
108 /// Draw a circle, d is the diameter, not the radious
109 virtual PainterBase & circle(
110 int x, int y, unsigned int d,
111 LColor::color = LColor::foreground);
114 virtual PainterBase & ellipse(
116 unsigned int w, unsigned int h,
117 LColor::color = LColor::foreground);
120 virtual PainterBase & arc(
122 unsigned int w, unsigned int h,
124 LColor::color = LColor::foreground) = 0;
127 virtual PainterBase & point(
129 LColor::color = LColor::foreground) = 0;
132 virtual PainterBase & fillRectangle(
133 int x, int y, int w, int h,
134 LColor::color = LColor::background) = 0;
136 /// A filled rectangle with the shape of a 3D button
137 virtual PainterBase & button(int x, int y, int w, int h);
140 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
144 /// For the figure inset
145 // This can't be part of the base since we don't know what window
146 // system we will be useing, or if are going to use pixmaps at all.
147 //virtual PainterBase & pixmap(int x, int y, Pixmap bitmap)=0;
150 /**@String functions */
152 /// Draw a string at position x, y (y is the baseline)
153 virtual PainterBase & text(int x, int y,
154 string const &str, LyXFont const & f) = 0;
156 /** Draw a string at position x, y (y is the baseline)
157 This is just for fast drawing */
158 virtual PainterBase & text(int x, int y, char const * str, int l,
159 LyXFont const & f) = 0;
161 /// Draw a char at position x, y (y is the baseline)
162 virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
164 /** Draws a string and encloses it inside a rectangle. Returns
165 the size of the rectangle. If draw is false, we only calculate
167 virtual PainterBase & rectText(int x, int baseline,
168 string const & string,
169 LyXFont const & font,
171 LColor::color frame, bool draw = true,
172 int & width = PainterBase::dummy1,
173 int & ascent = PainterBase::dummy2,
174 int & descent = PainterBase::dummy3);
176 /** Draw a string and encloses it inside a button frame. Returns
177 the size of the frame. If draw is false, we only calculate
179 virtual PainterBase & buttonText(int x, int baseline, string const & s,
180 LyXFont const & font, bool draw = true,
181 int & width = PainterBase::dummy1,
182 int & ascent = PainterBase::dummy2,
183 int & descent = PainterBase::dummy3);