2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2001 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.
66 explicit PainterBase(WorkArea & wa) : owner(wa) {}
69 virtual ~PainterBase() {}
73 int paperMargin() const;
75 int paperWidth() const;
77 int paperHeight() const;
79 /// Draw a line from point to point
80 virtual PainterBase & line(
81 int x1, int y1, int x2, int y2,
82 LColor::color = LColor::foreground,
83 enum line_style = line_solid,
84 enum line_width = line_thin) = 0;
86 /** Draw the lines between the lines in xp and yp.
87 xp and yp are arrays of points, and np is the
89 virtual PainterBase & lines(
90 int const * xp, int const * yp, int np,
91 LColor::color = LColor::foreground,
92 enum line_style = line_solid,
93 enum line_width = line_thin) = 0;
95 /// Here xp and yp are arrays of points
96 virtual PainterBase & fillPolygon(
97 int const * xp, int const * yp,
99 LColor::color = LColor::foreground) = 0;
101 /// Draw lines from x1,y1 to x2,y2. They are arrays
102 virtual PainterBase & segments(
103 int const * x1, int const * y1,
104 int const * x2, int const * y2, int ns,
105 LColor::color = LColor::foreground,
106 enum line_style = line_solid,
107 enum line_width = line_thin) = 0;
110 virtual PainterBase & rectangle(
111 int x, int y, int w, int h,
112 LColor::color = LColor::foreground,
113 enum line_style = line_solid,
114 enum line_width = line_thin) = 0;
116 /// Draw a circle, d is the diameter, not the radious
117 virtual PainterBase & circle(
118 int x, int y, unsigned int d,
119 LColor::color = LColor::foreground);
122 virtual PainterBase & ellipse(
124 unsigned int w, unsigned int h,
125 LColor::color = LColor::foreground);
128 virtual PainterBase & arc(
130 unsigned int w, unsigned int h,
132 LColor::color = LColor::foreground) = 0;
135 virtual PainterBase & point(
137 LColor::color = LColor::foreground) = 0;
140 virtual PainterBase & fillRectangle(
141 int x, int y, int w, int h,
144 /// A filled rectangle with the shape of a 3D button
145 virtual PainterBase & button(int x, int y, int w, int h);
148 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
151 // For the figure inset
152 virtual PainterBase & image(int x, int y, int w, int h,
153 grfx::GImage const & image) = 0;
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, size_t 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 /** Draws a string and encloses it inside a rectangle. */
168 PainterBase & rectText(int x, int baseline,
169 string const & string,
170 LyXFont const & font,
172 LColor::color frame);
174 /** Draw a string and encloses it inside a button frame. */
175 PainterBase & buttonText(int x, int baseline, string const & s,
176 LyXFont const & font);