]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _dc.i | |
3 | // Purpose: SWIG interface defs for wxDC and releated classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7-July-1997 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
4942342c | 16 | |
d14a1e28 RD |
17 | //--------------------------------------------------------------------------- |
18 | ||
19 | %{ | |
20 | #include "wx/wxPython/pydrawxxx.h" | |
21 | %} | |
22 | ||
23 | // TODO: 1. wrappers for wxDrawObject and wxDC::DrawObject | |
24 | ||
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | ||
28 | %typemap(in) (int points, wxPoint* points_array ) { | |
29 | $2 = wxPoint_LIST_helper($input, &$1); | |
30 | if ($2 == NULL) SWIG_fail; | |
31 | } | |
32 | %typemap(freearg) (int points, wxPoint* points_array ) { | |
33 | if ($2) delete [] $2; | |
34 | } | |
35 | ||
36 | ||
37 | //--------------------------------------------------------------------------- | |
38 | %newgroup; | |
39 | ||
40 | ||
41 | // wxDC is the device context - object on which any drawing is done | |
42 | class wxDC : public wxObject { | |
43 | public: | |
44 | // wxDC(); **** abstract base class, can't instantiate. | |
45 | ~wxDC(); | |
46 | ||
47 | ||
48 | virtual void BeginDrawing(); | |
49 | virtual void EndDrawing(); | |
50 | ||
51 | ||
52 | // virtual void DrawObject(wxDrawObject* drawobject); | |
53 | ||
54 | ||
55 | ||
d7403ad2 | 56 | #if 1 // The < 2.4 and > 2.5.1.5 way |
d14a1e28 RD |
57 | |
58 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); | |
dce2bd22 RD |
59 | %name(FloodFillPoint) bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE); |
60 | ||
d14a1e28 RD |
61 | //bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const; |
62 | %extend { | |
63 | wxColour GetPixel(wxCoord x, wxCoord y) { | |
64 | wxColour col; | |
65 | self->GetPixel(x, y, &col); | |
66 | return col; | |
67 | } | |
dce2bd22 RD |
68 | wxColour GetPixelPoint(const wxPoint& pt) { |
69 | wxColour col; | |
70 | self->GetPixel(pt, &col); | |
71 | return col; | |
72 | } | |
d14a1e28 | 73 | } |
dce2bd22 | 74 | |
d14a1e28 | 75 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); |
dce2bd22 RD |
76 | %name(DrawLinePoint) void DrawLine(const wxPoint& pt1, const wxPoint& pt2); |
77 | ||
d14a1e28 | 78 | void CrossHair(wxCoord x, wxCoord y); |
dce2bd22 RD |
79 | %name(CrossHairPoint) void CrossHair(const wxPoint& pt); |
80 | ||
d14a1e28 | 81 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); |
dce2bd22 RD |
82 | %name(DrawArcPoint) void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre); |
83 | ||
d14a1e28 | 84 | void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
dce2bd22 RD |
85 | %name(DrawCheckMarkRect) void DrawCheckMark(const wxRect& rect); |
86 | ||
d14a1e28 | 87 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea); |
d7403ad2 | 88 | %name(DrawEllipticArcPointSize) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea); |
dce2bd22 | 89 | |
d14a1e28 | 90 | void DrawPoint(wxCoord x, wxCoord y); |
dce2bd22 RD |
91 | %name(DrawPointPoint) void DrawPoint(const wxPoint& pt); |
92 | ||
d14a1e28 RD |
93 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
94 | %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); | |
d7403ad2 | 95 | %name(DrawRectanglePointSize) void DrawRectangle(const wxPoint& pt, const wxSize& sz); |
dce2bd22 | 96 | |
d14a1e28 | 97 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius); |
dce2bd22 | 98 | %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius); |
d7403ad2 | 99 | %name(DrawRoundedRectanglePointSize) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius); |
dce2bd22 | 100 | |
d14a1e28 | 101 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); |
dce2bd22 RD |
102 | %name(DrawCirclePoint) void DrawCircle(const wxPoint& pt, wxCoord radius); |
103 | ||
d14a1e28 | 104 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
dce2bd22 | 105 | %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect); |
d7403ad2 | 106 | %name(DrawEllipsePointSize) void DrawEllipse(const wxPoint& pt, const wxSize& sz); |
dce2bd22 | 107 | |
d14a1e28 | 108 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); |
dce2bd22 RD |
109 | %name(DrawIconPoint) void DrawIcon(const wxIcon& icon, const wxPoint& pt); |
110 | ||
dd9f7fea | 111 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False); |
dce2bd22 RD |
112 | %name(DrawBitmapPoint) void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False); |
113 | ||
d14a1e28 | 114 | void DrawText(const wxString& text, wxCoord x, wxCoord y); |
dce2bd22 RD |
115 | %name(DrawTextPoint) void DrawText(const wxString& text, const wxPoint& pt); |
116 | ||
d14a1e28 | 117 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); |
dce2bd22 RD |
118 | %name(DrawRotatedTextPoint) void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle); |
119 | ||
d14a1e28 RD |
120 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
121 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
dd9f7fea | 122 | int rop = wxCOPY, bool useMask = False, |
d14a1e28 | 123 | wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
d7403ad2 RD |
124 | %name(BlitPointSize) bool Blit(const wxPoint& destPt, const wxSize& sz, |
125 | wxDC *source, const wxPoint& srcPt, | |
126 | int rop = wxCOPY, bool useMask = False, | |
127 | const wxPoint& srcPtMask = wxDefaultPosition); | |
d14a1e28 RD |
128 | |
129 | ||
d7403ad2 RD |
130 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
131 | %name(SetClippingRegionPointSize) void SetClippingRegion(const wxPoint& pt, const wxSize& sz); | |
132 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); | |
133 | %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); | |
d14a1e28 | 134 | |
d7403ad2 | 135 | #else // The doomed 2.5.1.5 |
4942342c | 136 | |
d14a1e28 RD |
137 | %name(FloodFillXY) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); |
138 | bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE); | |
139 | ||
140 | //%name(GetPixelXY) bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
141 | //bool GetPixel(const wxPoint& pt, wxColour *col) const; | |
142 | %extend { | |
143 | wxColour GetPixelXY(wxCoord x, wxCoord y) { | |
144 | wxColour col; | |
145 | self->GetPixel(x, y, &col); | |
146 | return col; | |
147 | } | |
148 | wxColour GetPixel(const wxPoint& pt) { | |
149 | wxColour col; | |
150 | self->GetPixel(pt, &col); | |
151 | return col; | |
152 | } | |
153 | } | |
dce2bd22 | 154 | |
d14a1e28 RD |
155 | %name(DrawLineXY) void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); |
156 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2); | |
157 | ||
158 | %name(CrossHairXY) void CrossHair(wxCoord x, wxCoord y); | |
159 | void CrossHair(const wxPoint& pt); | |
160 | ||
161 | %name(DrawArcXY) void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); | |
162 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre); | |
163 | ||
164 | %name(DrawCheckMarkXY) void DrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
165 | void DrawCheckMark(const wxRect& rect); | |
166 | ||
167 | %name(DrawEllipticArcXY) void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea); | |
168 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea); | |
169 | ||
170 | %name(DrawPointXY) void DrawPoint(wxCoord x, wxCoord y); | |
171 | void DrawPoint(const wxPoint& pt); | |
172 | ||
173 | %name(DrawRectangleXY) void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
174 | void DrawRectangle(const wxPoint& pt, const wxSize& sz); | |
175 | %name(DrawRectangleRect) void DrawRectangle(const wxRect& rect); | |
176 | ||
177 | %name(DrawRoundedRectangleXY) void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius); | |
178 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius); | |
179 | %name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius); | |
180 | ||
181 | %name(DrawCircleXY) void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); | |
182 | void DrawCircle(const wxPoint& pt, wxCoord radius); | |
183 | ||
184 | %name(DrawEllipseXY) void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
185 | void DrawEllipse(const wxPoint& pt, const wxSize& sz); | |
186 | %name(DrawEllipseRect) void DrawEllipse(const wxRect& rect); | |
187 | ||
188 | %name(DrawIconXY) void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
189 | void DrawIcon(const wxIcon& icon, const wxPoint& pt); | |
190 | ||
dd9f7fea RD |
191 | %name(DrawBitmapXY) void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = False); |
192 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, bool useMask = False); | |
d14a1e28 RD |
193 | |
194 | %name(DrawTextXY) void DrawText(const wxString& text, wxCoord x, wxCoord y); | |
195 | void DrawText(const wxString& text, const wxPoint& pt); | |
196 | ||
197 | %name(DrawRotatedTextXY) void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
198 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle); | |
199 | ||
4942342c | 200 | |
d14a1e28 RD |
201 | %name(BlitXY) bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
202 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
dd9f7fea | 203 | int rop = wxCOPY, bool useMask = False, |
d14a1e28 | 204 | wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
4942342c | 205 | bool Blit(const wxPoint& destPt, const wxSize& sz, |
d14a1e28 | 206 | wxDC *source, const wxPoint& srcPt, |
dd9f7fea | 207 | int rop = wxCOPY, bool useMask = False, |
d14a1e28 RD |
208 | const wxPoint& srcPtMask = wxDefaultPosition); |
209 | ||
d7403ad2 RD |
210 | |
211 | %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
212 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz); | |
213 | %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); | |
214 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); | |
215 | ||
d14a1e28 | 216 | #endif |
4942342c | 217 | |
d14a1e28 RD |
218 | void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0); |
219 | ||
220 | void DrawPolygon(int points, wxPoint* points_array, | |
221 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
222 | int fillStyle = wxODDEVEN_RULE); | |
223 | ||
86aafce3 RD |
224 | // TODO: Figure out a good typemap for this... |
225 | // Convert the first 3 args from a sequence of sequences? | |
226 | // void DrawPolyPolygon(int n, int count[], wxPoint points[], | |
227 | // wxCoord xoffset = 0, wxCoord yoffset = 0, | |
228 | // int fillStyle = wxODDEVEN_RULE); | |
d14a1e28 | 229 | |
86aafce3 | 230 | |
d14a1e28 RD |
231 | // this version puts both optional bitmap and the text into the given |
232 | // rectangle and aligns is as specified by alignment parameter; it also | |
233 | // will emphasize the character with the given index if it is != -1 and | |
234 | // return the bounding rectangle if required | |
235 | void DrawLabel(const wxString& text, const wxRect& rect, | |
236 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
237 | int indexAccel = -1); | |
238 | %extend { | |
239 | wxRect DrawImageLabel(const wxString& text, | |
240 | const wxBitmap& image, | |
241 | const wxRect& rect, | |
242 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
243 | int indexAccel = -1) { | |
244 | wxRect rv; | |
245 | self->DrawLabel(text, image, rect, alignment, indexAccel, &rv); | |
246 | return rv; | |
247 | } | |
248 | } | |
249 | ||
250 | ||
251 | ||
252 | void DrawSpline(int points, wxPoint* points_array); | |
253 | ||
254 | ||
4942342c | 255 | |
d14a1e28 RD |
256 | // global DC operations |
257 | // -------------------- | |
258 | ||
259 | virtual void Clear(); | |
260 | ||
261 | virtual bool StartDoc(const wxString& message); | |
262 | virtual void EndDoc(); | |
263 | ||
264 | virtual void StartPage(); | |
265 | virtual void EndPage(); | |
266 | ||
4942342c | 267 | |
d14a1e28 RD |
268 | // set objects to use for drawing |
269 | // ------------------------------ | |
270 | ||
271 | virtual void SetFont(const wxFont& font); | |
272 | virtual void SetPen(const wxPen& pen); | |
273 | virtual void SetBrush(const wxBrush& brush); | |
274 | virtual void SetBackground(const wxBrush& brush); | |
275 | virtual void SetBackgroundMode(int mode); | |
276 | virtual void SetPalette(const wxPalette& palette); | |
277 | ||
4942342c | 278 | |
d14a1e28 RD |
279 | virtual void DestroyClippingRegion(); |
280 | ||
322913ce RD |
281 | DocDeclA( |
282 | void, GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT) const, | |
283 | "GetClippingBox() -> (x, y, width, height)"); | |
4942342c | 284 | |
d14a1e28 RD |
285 | %extend { |
286 | wxRect GetClippingRect() { | |
287 | wxRect rect; | |
288 | self->GetClippingBox(rect); | |
289 | return rect; | |
290 | } | |
291 | } | |
d14a1e28 | 292 | |
4942342c RD |
293 | |
294 | ||
d14a1e28 RD |
295 | // text extent |
296 | // ----------- | |
297 | ||
298 | virtual wxCoord GetCharHeight() const; | |
299 | virtual wxCoord GetCharWidth() const; | |
300 | ||
d14a1e28 | 301 | |
322913ce RD |
302 | DocDeclAStr( |
303 | void, GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT), | |
304 | "GetTextExtent(wxString string) -> (width, height)", | |
305 | "Get the width and height of the text using the current font.\n" | |
306 | "Only works for single line strings."); | |
307 | DocDeclAStrName( | |
308 | void, GetTextExtent(const wxString& string, | |
4942342c | 309 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, |
322913ce RD |
310 | wxFont* font = NULL), |
311 | "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)", | |
312 | "Get the width, height, decent and leading of the text using the current or specified font.\n" | |
313 | "Only works for single line strings.", | |
314 | GetFullTextExtent); | |
315 | ||
4942342c | 316 | |
322913ce RD |
317 | // works for single as well as multi-line strings |
318 | DocDeclAStr( | |
319 | void, GetMultiLineTextExtent(const wxString& text, | |
320 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, | |
321 | wxFont *font = NULL), | |
322 | "GetMultiLineTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)", | |
323 | "Get the width, height, decent and leading of the text using the current or specified font.\n" | |
324 | "Works for single as well as multi-line strings."); | |
325 | ||
746ee6b8 RD |
326 | |
327 | %extend { | |
328 | wxArrayInt GetPartialTextExtents(const wxString& text) { | |
329 | wxArrayInt widths; | |
330 | self->GetPartialTextExtents(text, widths); | |
331 | return widths; | |
332 | } | |
333 | } | |
334 | ||
d14a1e28 RD |
335 | |
336 | // size and resolution | |
337 | // ------------------- | |
338 | ||
322913ce | 339 | DocStr(GetSize, "Get the DC size in device units."); |
d14a1e28 | 340 | wxSize GetSize(); |
322913ce RD |
341 | DocDeclAName( |
342 | void, GetSize( int *OUTPUT, int *OUTPUT ), | |
343 | "GetSizeTuple() -> (width, height)", | |
344 | GetSizeTuple); | |
4942342c | 345 | |
d14a1e28 | 346 | |
322913ce | 347 | DocStr(GetSizeMM, "Get the DC size in milimeters."); |
d14a1e28 | 348 | wxSize GetSizeMM() const; |
322913ce RD |
349 | DocDeclAName( |
350 | void, GetSizeMM( int *OUTPUT, int *OUTPUT ) const, | |
351 | "GetSizeMMTuple() -> (width, height)", | |
352 | GetSizeMMTuple); | |
4942342c RD |
353 | |
354 | ||
d14a1e28 RD |
355 | |
356 | // coordinates conversions | |
357 | // ----------------------- | |
358 | ||
359 | // This group of functions does actual conversion of the input, as you'd | |
360 | // expect. | |
361 | wxCoord DeviceToLogicalX(wxCoord x) const; | |
362 | wxCoord DeviceToLogicalY(wxCoord y) const; | |
363 | wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
364 | wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
365 | wxCoord LogicalToDeviceX(wxCoord x) const; | |
366 | wxCoord LogicalToDeviceY(wxCoord y) const; | |
367 | wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
368 | wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
369 | ||
370 | // query DC capabilities | |
371 | // --------------------- | |
372 | ||
373 | virtual bool CanDrawBitmap() const; | |
374 | virtual bool CanGetTextExtent() const; | |
375 | ||
376 | // colour depth | |
377 | virtual int GetDepth() const; | |
378 | ||
379 | // Resolution in Pixels per inch | |
380 | virtual wxSize GetPPI() const; | |
381 | ||
382 | virtual bool Ok() const; | |
383 | ||
4942342c | 384 | |
d14a1e28 RD |
385 | |
386 | int GetBackgroundMode() const; | |
387 | const wxBrush& GetBackground() const; | |
388 | const wxBrush& GetBrush() const; | |
389 | const wxFont& GetFont() const; | |
390 | const wxPen& GetPen() const; | |
391 | const wxColour& GetTextBackground() const; | |
392 | const wxColour& GetTextForeground() const; | |
393 | ||
394 | virtual void SetTextForeground(const wxColour& colour); | |
395 | virtual void SetTextBackground(const wxColour& colour); | |
396 | ||
397 | int GetMapMode() const; | |
398 | virtual void SetMapMode(int mode); | |
399 | ||
4942342c | 400 | |
322913ce RD |
401 | DocDeclA( |
402 | virtual void, GetUserScale(double *OUTPUT, double *OUTPUT) const, | |
403 | "GetUserScale() -> (xScale, yScale)"); | |
4942342c | 404 | |
d14a1e28 RD |
405 | virtual void SetUserScale(double x, double y); |
406 | ||
4942342c | 407 | |
322913ce RD |
408 | DocDeclA( |
409 | virtual void, GetLogicalScale(double *OUTPUT, double *OUTPUT), | |
410 | "GetLogicalScale() -> (xScale, yScale)"); | |
411 | ||
d14a1e28 RD |
412 | virtual void SetLogicalScale(double x, double y); |
413 | ||
322913ce | 414 | |
d14a1e28 | 415 | wxPoint GetLogicalOrigin() const; |
322913ce RD |
416 | DocDeclAName( |
417 | void, GetLogicalOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, | |
418 | "GetLogicalOriginTuple() -> (x,y)", | |
419 | GetLogicalOriginTuple); | |
4942342c | 420 | |
d14a1e28 | 421 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
d7403ad2 RD |
422 | %extend { |
423 | void SetLogicalOriginPoint(const wxPoint& point) { | |
424 | self->SetLogicalOrigin(point.x, point.y); | |
425 | } | |
426 | } | |
d14a1e28 | 427 | |
d7403ad2 | 428 | |
d14a1e28 | 429 | wxPoint GetDeviceOrigin() const; |
322913ce RD |
430 | DocDeclAName( |
431 | void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const, | |
432 | "GetDeviceOriginTuple() -> (x,y)", | |
433 | GetDeviceOriginTuple); | |
4942342c | 434 | |
d14a1e28 | 435 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); |
d7403ad2 RD |
436 | %extend { |
437 | void SetDeviceOriginPoint(const wxPoint& point) { | |
438 | self->SetDeviceOrigin(point.x, point.y); | |
439 | } | |
440 | } | |
d14a1e28 RD |
441 | |
442 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
443 | ||
444 | int GetLogicalFunction() const; | |
445 | virtual void SetLogicalFunction(int function); | |
446 | ||
447 | virtual void SetOptimization(bool opt); | |
448 | virtual bool GetOptimization(); | |
4942342c | 449 | |
d14a1e28 RD |
450 | |
451 | // bounding box | |
452 | // ------------ | |
453 | ||
454 | virtual void CalcBoundingBox(wxCoord x, wxCoord y); | |
d7403ad2 RD |
455 | %extend { |
456 | void CalcBoundingBoxPoint(const wxPoint& point) { | |
457 | self->CalcBoundingBox(point.x, point.y); | |
458 | } | |
459 | } | |
460 | ||
d14a1e28 RD |
461 | void ResetBoundingBox(); |
462 | ||
463 | // Get the final bounding box of the PostScript or Metafile picture. | |
464 | wxCoord MinX() const; | |
465 | wxCoord MaxX() const; | |
466 | wxCoord MinY() const; | |
467 | wxCoord MaxY() const; | |
468 | ||
469 | ||
322913ce RD |
470 | DocA(GetBoundingBox, |
471 | "GetBoundingBox() -> (x1,y1, x2,y2)"); | |
d14a1e28 RD |
472 | %extend { |
473 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
474 | // See below for implementation | |
4942342c | 475 | } |
d14a1e28 RD |
476 | %pythoncode { def __nonzero__(self): return self.Ok() }; |
477 | ||
478 | ||
479 | ||
480 | %extend { // See drawlist.cpp for impplementaion of these... | |
481 | PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
482 | { | |
483 | return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes); | |
484 | } | |
485 | ||
486 | PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
487 | { | |
488 | return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes); | |
489 | } | |
490 | ||
491 | PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
492 | { | |
493 | return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes); | |
494 | } | |
495 | ||
496 | PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
497 | { | |
498 | return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes); | |
499 | } | |
500 | ||
501 | PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
502 | { | |
503 | return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes); | |
504 | } | |
505 | ||
506 | PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints, | |
507 | PyObject* foregroundList, PyObject* backgroundList) { | |
508 | return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList); | |
509 | } | |
510 | } | |
511 | ||
512 | %pythoncode { | |
513 | def DrawPointList(self, points, pens=None): | |
514 | if pens is None: | |
515 | pens = [] | |
516 | elif isinstance(pens, wx.Pen): | |
517 | pens = [pens] | |
518 | elif len(pens) != len(points): | |
519 | raise ValueError('points and pens must have same length') | |
520 | return self._DrawPointList(points, pens, []) | |
521 | ||
522 | ||
523 | def DrawLineList(self, lines, pens=None): | |
524 | if pens is None: | |
525 | pens = [] | |
526 | elif isinstance(pens, wx.Pen): | |
527 | pens = [pens] | |
528 | elif len(pens) != len(lines): | |
529 | raise ValueError('lines and pens must have same length') | |
530 | return self._DrawLineList(lines, pens, []) | |
531 | ||
532 | ||
533 | def DrawRectangleList(self, rectangles, pens=None, brushes=None): | |
534 | if pens is None: | |
535 | pens = [] | |
536 | elif isinstance(pens, wx.Pen): | |
537 | pens = [pens] | |
538 | elif len(pens) != len(rectangles): | |
539 | raise ValueError('rectangles and pens must have same length') | |
540 | if brushes is None: | |
541 | brushes = [] | |
542 | elif isinstance(brushes, wx.Brush): | |
543 | brushes = [brushes] | |
544 | elif len(brushes) != len(rectangles): | |
545 | raise ValueError('rectangles and brushes must have same length') | |
546 | return self._DrawRectangleList(rectangles, pens, brushes) | |
547 | ||
548 | ||
549 | def DrawEllipseList(self, ellipses, pens=None, brushes=None): | |
550 | if pens is None: | |
551 | pens = [] | |
552 | elif isinstance(pens, wx.Pen): | |
553 | pens = [pens] | |
554 | elif len(pens) != len(ellipses): | |
555 | raise ValueError('ellipses and pens must have same length') | |
556 | if brushes is None: | |
557 | brushes = [] | |
558 | elif isinstance(brushes, wx.Brush): | |
559 | brushes = [brushes] | |
560 | elif len(brushes) != len(ellipses): | |
561 | raise ValueError('ellipses and brushes must have same length') | |
562 | return self._DrawEllipseList(ellipses, pens, brushes) | |
563 | ||
564 | ||
565 | def DrawPolygonList(self, polygons, pens=None, brushes=None): | |
4942342c RD |
566 | %## Note: This does not currently support fill style or offset |
567 | %## you can always use the non-List version if need be. | |
d14a1e28 RD |
568 | if pens is None: |
569 | pens = [] | |
570 | elif isinstance(pens, wx.Pen): | |
571 | pens = [pens] | |
572 | elif len(pens) != len(polygons): | |
573 | raise ValueError('polygons and pens must have same length') | |
574 | if brushes is None: | |
575 | brushes = [] | |
576 | elif isinstance(brushes, wx.Brush): | |
577 | brushes = [brushes] | |
578 | elif len(brushes) != len(polygons): | |
579 | raise ValueError('polygons and brushes must have same length') | |
580 | return self._DrawPolygonList(polygons, pens, brushes) | |
581 | ||
582 | ||
583 | def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None): | |
4942342c RD |
584 | %## NOTE: this does not currently support changing the font |
585 | %## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode) | |
586 | %## If you want backgounds to do anything. | |
d14a1e28 RD |
587 | if type(textList) == type(''): |
588 | textList = [textList] | |
589 | elif len(textList) != len(coords): | |
590 | raise ValueError('textlist and coords must have same length') | |
591 | if foregrounds is None: | |
592 | foregrounds = [] | |
fd3f2efe | 593 | elif isinstance(foregrounds, wx.Colour): |
d14a1e28 RD |
594 | foregrounds = [foregrounds] |
595 | elif len(foregrounds) != len(coords): | |
596 | raise ValueError('foregrounds and coords must have same length') | |
597 | if backgrounds is None: | |
598 | backgrounds = [] | |
fd3f2efe | 599 | elif isinstance(backgrounds, wx.Colour): |
d14a1e28 RD |
600 | backgrounds = [backgrounds] |
601 | elif len(backgrounds) != len(coords): | |
602 | raise ValueError('backgrounds and coords must have same length') | |
603 | return self._DrawTextList(textList, coords, foregrounds, backgrounds) | |
604 | } | |
605 | ||
606 | }; | |
607 | ||
608 | ||
609 | ||
610 | %{ | |
611 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
612 | *x1 = dc->MinX(); | |
613 | *y1 = dc->MinY(); | |
614 | *x2 = dc->MaxX(); | |
615 | *y2 = dc->MaxY(); | |
616 | } | |
617 | %} | |
618 | ||
619 | ||
620 | //--------------------------------------------------------------------------- | |
621 | %newgroup | |
622 | ||
623 | class wxMemoryDC : public wxDC { | |
624 | public: | |
625 | wxMemoryDC(); | |
626 | %name(MemoryDCFromDC) wxMemoryDC(wxDC* oldDC); | |
4942342c | 627 | |
d14a1e28 RD |
628 | void SelectObject(const wxBitmap& bitmap); |
629 | }; | |
630 | ||
631 | //--------------------------------------------------------------------------- | |
632 | %newgroup | |
633 | ||
b159c5c4 | 634 | |
ef22e3d3 | 635 | %{ |
ef22e3d3 | 636 | #include <wx/dcbuffer.h> |
ef22e3d3 RD |
637 | %} |
638 | ||
639 | ||
d14a1e28 RD |
640 | class wxBufferedDC : public wxMemoryDC |
641 | { | |
642 | public: | |
e608d228 | 643 | %pythonAppend wxBufferedDC |
d14a1e28 | 644 | "self._dc = args[0] # save a ref so the other dc will not be deleted before self"; |
d14a1e28 | 645 | |
b159c5c4 RD |
646 | %nokwargs wxBufferedDC; |
647 | ||
d14a1e28 RD |
648 | // Construct a wxBufferedDC using a user supplied buffer. |
649 | wxBufferedDC( wxDC *dc, const wxBitmap &buffer ); | |
650 | ||
b159c5c4 RD |
651 | // Construct a wxBufferedDC with an internal buffer of 'area' |
652 | // (where area is usually something like the size of the window | |
653 | // being buffered) | |
7a0b15e9 | 654 | wxBufferedDC( wxDC *dc, const wxSize &area ); |
b159c5c4 | 655 | |
e608d228 | 656 | |
b159c5c4 | 657 | // TODO: Keep this one too? |
7a0b15e9 | 658 | %pythonAppend wxBufferedDC( wxDC *dc, const wxSize &area ) |
e608d228 | 659 | "val._dc = args[0] # save a ref so the other dc will not be deleted before self"; |
7a0b15e9 RD |
660 | %name(BufferedDCInternalBuffer) wxBufferedDC( wxDC *dc, const wxSize &area ); |
661 | ||
662 | ||
663 | // The buffer is blit to the real DC when the BufferedDC is destroyed. | |
664 | ~wxBufferedDC(); | |
d14a1e28 | 665 | |
e608d228 | 666 | |
b159c5c4 RD |
667 | // Blits the buffer to the dc, and detaches the dc from |
668 | // the buffer. Usually called in the dtor or by the dtor | |
669 | // of derived classes if the BufferedDC must blit before | |
670 | // the derived class (which may own the dc it's blitting | |
671 | // to) is destroyed. | |
d14a1e28 RD |
672 | void UnMask(); |
673 | }; | |
674 | ||
675 | ||
7a0b15e9 RD |
676 | |
677 | ||
678 | // Creates a double buffered wxPaintDC, optionally allowing the | |
679 | // user to specify their own buffer to use. | |
d14a1e28 RD |
680 | class wxBufferedPaintDC : public wxBufferedDC |
681 | { | |
682 | public: | |
b159c5c4 | 683 | |
ef22e3d3 | 684 | // If no bitmap is supplied by the user, a temporary one will be created. |
7a0b15e9 | 685 | wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); |
b159c5c4 | 686 | |
d14a1e28 RD |
687 | }; |
688 | ||
689 | ||
690 | //--------------------------------------------------------------------------- | |
691 | %newgroup | |
692 | ||
693 | class wxScreenDC : public wxDC { | |
694 | public: | |
695 | wxScreenDC(); | |
696 | ||
697 | %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window); | |
698 | bool StartDrawingOnTop(wxRect* rect = NULL); | |
699 | bool EndDrawingOnTop(); | |
700 | }; | |
701 | ||
702 | //--------------------------------------------------------------------------- | |
703 | %newgroup | |
704 | ||
705 | class wxClientDC : public wxDC { | |
706 | public: | |
707 | wxClientDC(wxWindow* win); | |
708 | }; | |
709 | ||
710 | //--------------------------------------------------------------------------- | |
711 | %newgroup | |
712 | ||
713 | class wxPaintDC : public wxDC { | |
714 | public: | |
715 | wxPaintDC(wxWindow* win); | |
716 | }; | |
717 | ||
718 | //--------------------------------------------------------------------------- | |
719 | %newgroup | |
720 | ||
721 | class wxWindowDC : public wxDC { | |
722 | public: | |
723 | wxWindowDC(wxWindow* win); | |
724 | }; | |
725 | ||
726 | //--------------------------------------------------------------------------- | |
727 | %newgroup | |
728 | ||
729 | class wxMirrorDC : public wxDC | |
730 | { | |
731 | public: | |
732 | // constructs a mirror DC associated with the given real DC | |
733 | // | |
dd9f7fea | 734 | // if mirror parameter is True, all vertical and horizontal coordinates are |
d14a1e28 RD |
735 | // exchanged, otherwise this class behaves in exactly the same way as a |
736 | // plain DC | |
737 | // | |
738 | wxMirrorDC(wxDC& dc, bool mirror); | |
739 | }; | |
740 | ||
741 | //--------------------------------------------------------------------------- | |
742 | %newgroup | |
743 | ||
744 | %{ | |
745 | #include <wx/dcps.h> | |
746 | %} | |
747 | ||
748 | class wxPostScriptDC : public wxDC { | |
749 | public: | |
750 | wxPostScriptDC(const wxPrintData& printData); | |
751 | // %name(PostScriptDC2)wxPostScriptDC(const wxString& output, | |
dd9f7fea | 752 | // bool interactive = True, |
d14a1e28 RD |
753 | // wxWindow* parent = NULL); |
754 | ||
755 | wxPrintData& GetPrintData(); | |
756 | void SetPrintData(const wxPrintData& data); | |
757 | ||
758 | static void SetResolution(int ppi); | |
759 | static int GetResolution(); | |
760 | }; | |
761 | ||
762 | //--------------------------------------------------------------------------- | |
763 | %newgroup | |
764 | ||
765 | ||
da457c1b | 766 | #if defined(__WXMSW__) || defined(__WXMAC__) |
d14a1e28 RD |
767 | |
768 | %{ | |
769 | #include <wx/metafile.h> | |
770 | %} | |
771 | ||
772 | class wxMetaFile : public wxObject { | |
773 | public: | |
774 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
775 | ~wxMetaFile(); | |
776 | ||
777 | bool Ok(); | |
778 | bool SetClipboard(int width = 0, int height = 0); | |
779 | ||
780 | wxSize GetSize(); | |
781 | int GetWidth(); | |
782 | int GetHeight(); | |
783 | ||
da457c1b | 784 | #ifdef __WXMSW__ |
d14a1e28 | 785 | const wxString& GetFileName() const; |
da457c1b RD |
786 | #endif |
787 | ||
d14a1e28 RD |
788 | %pythoncode { def __nonzero__(self): return self.Ok() } |
789 | }; | |
790 | ||
791 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
792 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
793 | ||
794 | ||
795 | class wxMetaFileDC : public wxDC { | |
796 | public: | |
797 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
798 | int width = 0, int height = 0, | |
799 | const wxString& description = wxPyEmptyString); | |
800 | wxMetaFile* Close(); | |
801 | }; | |
802 | ||
803 | ||
804 | ||
805 | #else // Make some dummies for the other platforms | |
806 | ||
807 | %{ | |
808 | class wxMetaFile : public wxObject { | |
809 | public: | |
810 | wxMetaFile(const wxString&) | |
81cfe5e1 | 811 | { wxPyRaiseNotImplemented(); } |
d14a1e28 RD |
812 | }; |
813 | ||
814 | class wxMetaFileDC : public wxClientDC { | |
815 | public: | |
816 | wxMetaFileDC(const wxString&, int, int, const wxString&) | |
81cfe5e1 | 817 | { wxPyRaiseNotImplemented(); } |
d14a1e28 RD |
818 | }; |
819 | ||
820 | %} | |
821 | ||
822 | class wxMetaFile : public wxObject { | |
823 | public: | |
824 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
825 | }; | |
826 | ||
827 | class wxMetaFileDC : public wxDC { | |
828 | public: | |
829 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
830 | int width = 0, int height = 0, | |
831 | const wxString& description = wxPyEmptyString); | |
832 | }; | |
833 | ||
834 | ||
835 | #endif | |
836 | ||
837 | ||
838 | //--------------------------------------------------------------------------- | |
839 | ||
840 | #if defined(__WXMSW__) || defined(__WXMAC__) | |
841 | ||
842 | class wxPrinterDC : public wxDC { | |
843 | public: | |
844 | wxPrinterDC(const wxPrintData& printData); | |
845 | // %name(PrinterDC2) wxPrinterDC(const wxString& driver, | |
846 | // const wxString& device, | |
847 | // const wxString& output, | |
dd9f7fea | 848 | // bool interactive = True, |
d14a1e28 RD |
849 | // int orientation = wxPORTRAIT); |
850 | }; | |
851 | ||
852 | #else | |
853 | %{ | |
854 | class wxPrinterDC : public wxClientDC { | |
855 | public: | |
856 | wxPrinterDC(const wxPrintData&) | |
81cfe5e1 | 857 | { wxPyRaiseNotImplemented(); } |
4942342c | 858 | |
d14a1e28 | 859 | // wxPrinterDC(const wxString&, const wxString&, const wxString&, bool, int) |
81cfe5e1 | 860 | // { wxPyRaiseNotImplemented(); } |
d14a1e28 RD |
861 | }; |
862 | %} | |
4942342c | 863 | |
d14a1e28 RD |
864 | class wxPrinterDC : public wxDC { |
865 | public: | |
866 | wxPrinterDC(const wxPrintData& printData); | |
867 | // %name(PrinterDC2) wxPrinterDC(const wxString& driver, | |
868 | // const wxString& device, | |
869 | // const wxString& output, | |
dd9f7fea | 870 | // bool interactive = True, |
d14a1e28 RD |
871 | // int orientation = wxPORTRAIT); |
872 | }; | |
873 | #endif | |
874 | ||
4942342c RD |
875 | //--------------------------------------------------------------------------- |
876 | //--------------------------------------------------------------------------- | |
877 | ||
878 | // Now define some Python classes that rename the Draw methods to be | |
879 | // compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py. | |
880 | ||
881 | ||
d7403ad2 RD |
882 | #if 0 |
883 | ||
4942342c RD |
884 | %define MAKE_OLD_DC_CLASS(classname) |
885 | %pythoncode { | |
886 | class classname##_old(classname): | |
887 | """DC class that has methods with 2.4 compatible parameters.""" | |
888 | FloodFill = classname.FloodFillXY | |
889 | GetPixel = classname.GetPixelXY | |
890 | DrawLine = classname.DrawLineXY | |
891 | CrossHair = classname.CrossHairXY | |
892 | DrawArc = classname.DrawArcXY | |
893 | DrawCheckMark = classname.DrawCheckMarkXY | |
894 | DrawEllipticArc = classname.DrawEllipticArcXY | |
895 | DrawPoint = classname.DrawPointXY | |
896 | DrawRectangle = classname.DrawRectangleXY | |
897 | DrawRoundedRectangle = classname.DrawRoundedRectangleXY | |
898 | DrawCircle = classname.DrawCircleXY | |
899 | DrawEllipse = classname.DrawEllipseXY | |
900 | DrawIcon = classname.DrawIconXY | |
901 | DrawBitmap = classname.DrawBitmapXY | |
902 | DrawText = classname.DrawTextXY | |
903 | DrawRotatedText = classname.DrawRotatedTextXY | |
904 | Blit = classname.BlitXY | |
905 | } | |
906 | %enddef | |
907 | ||
908 | MAKE_OLD_DC_CLASS(DC); | |
909 | MAKE_OLD_DC_CLASS(MemoryDC); | |
910 | MAKE_OLD_DC_CLASS(BufferedDC); | |
911 | MAKE_OLD_DC_CLASS(BufferedPaintDC); | |
912 | MAKE_OLD_DC_CLASS(ScreenDC); | |
913 | MAKE_OLD_DC_CLASS(ClientDC); | |
914 | MAKE_OLD_DC_CLASS(PaintDC); | |
915 | MAKE_OLD_DC_CLASS(WindowDC); | |
916 | MAKE_OLD_DC_CLASS(MirrorDC); | |
917 | MAKE_OLD_DC_CLASS(PostScriptDC); | |
918 | MAKE_OLD_DC_CLASS(MetaFileDC); | |
919 | MAKE_OLD_DC_CLASS(PrinterDC); | |
920 | ||
d7403ad2 | 921 | #endif |
4942342c | 922 | |
d14a1e28 | 923 | //--------------------------------------------------------------------------- |