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.
59 explicit PainterBase(WorkArea & wa) : owner(wa) {}
62 virtual ~PainterBase() {}
66 int paperMargin() const;
68 int paperWidth() const;
70 int paperHeight() const;
72 /// Draw a line from point to point
73 virtual PainterBase & line(
74 int x1, int y1, int x2, int y2,
75 LColor::color = LColor::foreground,
76 enum line_style = line_solid,
77 enum line_width = line_thin) = 0;
79 /** Draw the lines between the lines in xp and yp.
80 xp and yp are arrays of points, and np is the
82 virtual PainterBase & lines(
83 int const * xp, int const * yp, int np,
84 LColor::color = LColor::foreground,
85 enum line_style = line_solid,
86 enum line_width = line_thin) = 0;
88 /// Here xp and yp are arrays of points
89 virtual PainterBase & fillPolygon(
90 int const * xp, int const * yp,
92 LColor::color = LColor::foreground) = 0;
94 /// Draw lines from x1,y1 to x2,y2. They are arrays
95 virtual PainterBase & segments(
96 int const * x1, int const * y1,
97 int const * x2, int const * y2, int ns,
98 LColor::color = LColor::foreground,
99 enum line_style = line_solid,
100 enum line_width = line_thin) = 0;
103 virtual PainterBase & rectangle(
104 int x, int y, int w, int h,
105 LColor::color = LColor::foreground,
106 enum line_style = line_solid,
107 enum line_width = line_thin) = 0;
109 /// Draw a circle, d is the diameter, not the radious
110 virtual PainterBase & circle(
111 int x, int y, unsigned int d,
112 LColor::color = LColor::foreground);
115 virtual PainterBase & ellipse(
117 unsigned int w, unsigned int h,
118 LColor::color = LColor::foreground);
121 virtual PainterBase & arc(
123 unsigned int w, unsigned int h,
125 LColor::color = LColor::foreground) = 0;
128 virtual PainterBase & point(
130 LColor::color = LColor::foreground) = 0;
133 virtual PainterBase & fillRectangle(
134 int x, int y, int w, int h,
137 /// A filled rectangle with the shape of a 3D button
138 virtual PainterBase & button(int x, int y, int w, int h);
141 virtual PainterBase & buttonFrame(int x, int y, int w, int h);
144 // For the figure inset
145 virtual PainterBase & image(int x, int y, int w, int h,
146 grfx::GImage const & image) = 0;
148 /// Draw a string at position x, y (y is the baseline)
149 virtual PainterBase & text(int x, int y,
150 string const & str, LyXFont const & f) = 0;
152 /** Draw a string at position x, y (y is the baseline)
153 This is just for fast drawing */
154 virtual PainterBase & text(int x, int y, char const * str, size_t l,
155 LyXFont const & f) = 0;
157 /// Draw a char at position x, y (y is the baseline)
158 virtual PainterBase & text(int x, int y, char c, LyXFont const & f)=0;
160 /** Draws a string and encloses it inside a rectangle. */
161 PainterBase & rectText(int x, int baseline,
162 string const & string,
163 LyXFont const & font,
165 LColor::color frame);
167 /** Draw a string and encloses it inside a button frame. */
168 PainterBase & buttonText(int x, int baseline, string const & s,
169 LyXFont const & font);