]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gdi.i | |
68bc8549 | 3 | // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, etc. |
7bf85405 RD |
4 | // |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/7/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
03e9bead RD |
14 | %module gdi |
15 | ||
16 | %{ | |
7bf85405 | 17 | #include "helpers.h" |
af309447 | 18 | #include <wx/imaglist.h> |
6d8b4f8d RD |
19 | #include <wx/fontmap.h> |
20 | #include <wx/fontenc.h> | |
21 | #include <wx/fontmap.h> | |
22 | #include <wx/fontutil.h> | |
e9159fe8 | 23 | #include <wx/dcbuffer.h> |
3ef86e32 | 24 | #include <wx/dcmirror.h> |
0e9b78ce | 25 | #include <wx/iconbndl.h> |
7bf85405 RD |
26 | %} |
27 | ||
28 | //---------------------------------------------------------------------- | |
29 | ||
30 | %include typemaps.i | |
31 | %include my_typemaps.i | |
32 | ||
33 | // Import some definitions of other classes, etc. | |
34 | %import _defs.i | |
35 | %import misc.i | |
68bc8549 | 36 | %import fonts.i |
7bf85405 | 37 | |
1e4a197e | 38 | %pragma(python) code = "import wx" |
b68dc582 | 39 | |
137b5242 RD |
40 | //--------------------------------------------------------------------------- |
41 | %{ | |
42 | // Put some wx default wxChar* values into wxStrings. | |
43 | static const wxString wxPyEmptyString(wxT("")); | |
44 | %} | |
7bf85405 RD |
45 | //--------------------------------------------------------------------------- |
46 | ||
9416aa89 RD |
47 | class wxGDIObject : public wxObject { |
48 | public: | |
49 | wxGDIObject(); | |
50 | ~wxGDIObject(); | |
51 | ||
52 | bool GetVisible(); | |
53 | void SetVisible( bool visible ); | |
54 | ||
55 | bool IsNull(); | |
56 | ||
57 | }; | |
6999b0d8 RD |
58 | |
59 | //--------------------------------------------------------------------------- | |
60 | ||
9cbf6f6e RD |
61 | |
62 | // TODO: When the API stabalizes and is available on other platforms, add | |
63 | // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff... | |
64 | ||
9416aa89 | 65 | class wxBitmap : public wxGDIObject |
5bff6bb8 | 66 | { |
7bf85405 | 67 | public: |
96de41c2 | 68 | wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); |
7bf85405 RD |
69 | ~wxBitmap(); |
70 | ||
7bf85405 RD |
71 | wxPalette* GetPalette(); |
72 | wxMask* GetMask(); | |
96de41c2 | 73 | bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); |
e6056257 | 74 | bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL); |
7bf85405 | 75 | void SetMask(wxMask* mask); |
1e4a197e RD |
76 | %pragma(python) addtoclass = " |
77 | def SetMaskColour(self, colour): | |
78 | mask = wxMaskColour(self, colour) | |
79 | self.SetMask(mask) | |
80 | " | |
fb5e0af0 | 81 | #ifdef __WXMSW__ |
b8b8dda7 | 82 | void SetPalette(wxPalette& palette); |
fb5e0af0 | 83 | #endif |
5bff6bb8 RD |
84 | |
85 | // wxGDIImage methods | |
86 | #ifdef __WXMSW__ | |
87 | long GetHandle(); | |
88 | void SetHandle(long handle); | |
89 | #endif | |
90 | bool Ok(); | |
91 | int GetWidth(); | |
92 | int GetHeight(); | |
93 | int GetDepth(); | |
94 | void SetWidth(int w); | |
95 | void SetHeight(int h); | |
96 | void SetDepth(int d); | |
97 | #ifdef __WXMSW__ | |
98 | void SetSize(const wxSize& size); | |
99 | #endif | |
f6bcfd97 BP |
100 | |
101 | wxBitmap GetSubBitmap( const wxRect& rect ); | |
f6bcfd97 | 102 | bool CopyFromIcon(const wxIcon& icon); |
ecc08ead | 103 | #ifdef __WXMSW__ |
f6bcfd97 BP |
104 | bool CopyFromCursor(const wxCursor& cursor); |
105 | int GetQuality(); | |
106 | void SetQuality(int q); | |
107 | #endif | |
108 | ||
1fded56b | 109 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
7bf85405 RD |
110 | }; |
111 | ||
5bff6bb8 | 112 | |
96bfd053 | 113 | // Declarations of some alternate "constructors" |
7bf85405 | 114 | %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); |
96bfd053 RD |
115 | %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); |
116 | %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); | |
3eb221f6 | 117 | %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ); |
9c039d08 | 118 | |
d56cebe7 RD |
119 | // #ifdef __WXMSW__ |
120 | // %new wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
121 | // int width, int height, int depth = 1); | |
122 | // #endif | |
8bf5d46e | 123 | |
96bfd053 RD |
124 | |
125 | ||
126 | %{ // Implementations of some alternate "constructors" | |
127 | ||
7bf85405 RD |
128 | wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) { |
129 | return new wxBitmap(width, height, depth); | |
130 | } | |
131 | ||
96bfd053 RD |
132 | static char** ConvertListOfStrings(PyObject* listOfStrings) { |
133 | char** cArray = NULL; | |
134 | int count; | |
135 | ||
136 | if (!PyList_Check(listOfStrings)) { | |
137 | PyErr_SetString(PyExc_TypeError, "Expected a list of strings."); | |
138 | return NULL; | |
139 | } | |
140 | count = PyList_Size(listOfStrings); | |
141 | cArray = new char*[count]; | |
142 | ||
143 | for(int x=0; x<count; x++) { | |
144 | // TODO: Need some validation and error checking here | |
145 | cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x)); | |
146 | } | |
147 | return cArray; | |
148 | } | |
149 | ||
d56cebe7 | 150 | |
96bfd053 RD |
151 | wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) { |
152 | char** cArray = NULL; | |
153 | wxBitmap* bmp; | |
154 | ||
155 | cArray = ConvertListOfStrings(listOfStrings); | |
156 | if (! cArray) | |
157 | return NULL; | |
158 | bmp = new wxBitmap(cArray); | |
159 | delete [] cArray; | |
160 | return bmp; | |
161 | } | |
162 | ||
163 | ||
164 | wxBitmap* wxBitmapFromIcon(const wxIcon& icon) { | |
165 | return new wxBitmap(icon); | |
166 | } | |
167 | ||
168 | ||
3eb221f6 RD |
169 | wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ) { |
170 | char* buf; | |
171 | int length; | |
172 | PyString_AsStringAndSize(bits, &buf, &length); | |
173 | return new wxBitmap(buf, width, height, depth); | |
d56cebe7 | 174 | } |
926bb76c | 175 | |
4c9993c3 | 176 | |
d56cebe7 RD |
177 | // #ifdef __WXMSW__ |
178 | // wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
179 | // int width, int height, int depth = 1) { | |
180 | // if (! PyString_Check(data)) { | |
181 | // PyErr_SetString(PyExc_TypeError, "Expected string object"); | |
182 | // return NULL; | |
183 | // } | |
184 | // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth); | |
185 | // } | |
186 | // #endif | |
7bf85405 RD |
187 | %} |
188 | ||
189 | //--------------------------------------------------------------------------- | |
190 | ||
9416aa89 | 191 | class wxMask : public wxObject { |
7bf85405 RD |
192 | public: |
193 | wxMask(const wxBitmap& bitmap); | |
eb715945 | 194 | //~wxMask(); |
96bfd053 RD |
195 | |
196 | %addmethods { void Destroy() { delete self; } } | |
7bf85405 RD |
197 | }; |
198 | ||
199 | %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour); | |
200 | %{ | |
201 | wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) { | |
202 | return new wxMask(bitmap, colour); | |
203 | } | |
204 | %} | |
205 | ||
206 | ||
207 | //--------------------------------------------------------------------------- | |
208 | ||
209 | ||
9416aa89 | 210 | class wxIcon : public wxGDIObject |
5bff6bb8 | 211 | { |
7bf85405 | 212 | public: |
fb5e0af0 RD |
213 | wxIcon(const wxString& name, long flags, |
214 | int desiredWidth = -1, int desiredHeight = -1); | |
7bf85405 RD |
215 | ~wxIcon(); |
216 | ||
6abe8375 | 217 | #ifndef __WXMAC__ |
7bf85405 | 218 | bool LoadFile(const wxString& name, long flags); |
6abe8375 | 219 | #endif |
5bff6bb8 RD |
220 | |
221 | // wxGDIImage methods | |
222 | #ifdef __WXMSW__ | |
223 | long GetHandle(); | |
224 | void SetHandle(long handle); | |
225 | #endif | |
226 | bool Ok(); | |
227 | int GetWidth(); | |
228 | int GetHeight(); | |
229 | int GetDepth(); | |
230 | void SetWidth(int w); | |
231 | void SetHeight(int h); | |
232 | void SetDepth(int d); | |
233 | #ifdef __WXMSW__ | |
234 | void SetSize(const wxSize& size); | |
235 | #endif | |
96bfd053 RD |
236 | void CopyFromBitmap(const wxBitmap& bmp); |
237 | ||
1fded56b | 238 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
7bf85405 RD |
239 | }; |
240 | ||
8bf5d46e | 241 | |
96bfd053 RD |
242 | // Declarations of some alternate "constructors" |
243 | %new wxIcon* wxEmptyIcon(); | |
244 | %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); | |
7248a051 | 245 | %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp); |
3ef86e32 | 246 | %new wxIcon* wxIconFromLocation(const wxIconLocation& loc); |
96bfd053 RD |
247 | |
248 | %{ // Implementations of some alternate "constructors" | |
249 | wxIcon* wxEmptyIcon() { | |
250 | return new wxIcon(); | |
251 | } | |
252 | ||
253 | wxIcon* wxIconFromXPMData(PyObject* listOfStrings) { | |
254 | char** cArray = NULL; | |
255 | wxIcon* icon; | |
256 | ||
257 | cArray = ConvertListOfStrings(listOfStrings); | |
258 | if (! cArray) | |
259 | return NULL; | |
260 | icon = new wxIcon(cArray); | |
261 | delete [] cArray; | |
262 | return icon; | |
263 | } | |
7248a051 RD |
264 | |
265 | wxIcon* wxIconFromBitmap(const wxBitmap& bmp) { | |
266 | wxIcon* icon = new wxIcon(); | |
267 | icon->CopyFromBitmap(bmp); | |
268 | return icon; | |
269 | } | |
3ef86e32 RD |
270 | |
271 | wxIcon* wxIconFromLocation(const wxIconLocation& loc) { | |
272 | wxIcon* icon = new wxIcon(loc); | |
273 | return icon; | |
274 | } | |
96bfd053 RD |
275 | %} |
276 | ||
3ef86e32 RD |
277 | |
278 | //--------------------------------------------------------------------------- | |
279 | ||
280 | class wxIconLocation | |
281 | { | |
282 | public: | |
283 | // ctor takes the name of the file where the icon is | |
284 | %addmethods { | |
285 | wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) { | |
286 | #ifdef __WXMSW__ | |
287 | return new wxIconLocation(*filename, num); | |
288 | #else | |
289 | return new wxIconLocation(*filename); | |
290 | #endif | |
291 | } | |
292 | } | |
293 | ||
294 | ~wxIconLocation(); | |
295 | ||
296 | ||
297 | // returns true if this object is valid/initialized | |
298 | bool IsOk() const; | |
299 | ||
300 | // set/get the icon file name | |
301 | void SetFileName(const wxString& filename); | |
302 | const wxString& GetFileName() const; | |
303 | ||
304 | %addmethods { | |
305 | void SetIndex(int num) { | |
306 | #ifdef __WXMSW__ | |
307 | self->SetIndex(num); | |
308 | #else | |
309 | // do nothing | |
310 | #endif | |
311 | } | |
312 | ||
313 | int GetIndex() { | |
314 | #ifdef __WXMSW__ | |
315 | return self->GetIndex(); | |
316 | #else | |
317 | return -1; | |
318 | #endif | |
319 | } | |
320 | } | |
321 | }; | |
322 | ||
323 | ||
324 | ||
7bf85405 RD |
325 | //--------------------------------------------------------------------------- |
326 | ||
0e9b78ce RD |
327 | class wxIconBundle |
328 | { | |
329 | public: | |
330 | // default constructor | |
331 | wxIconBundle(); | |
332 | ||
333 | // initializes the bundle with the icon(s) found in the file | |
334 | %name(wxIconBundleFromFile) wxIconBundle( const wxString& file, long type ); | |
335 | ||
336 | // initializes the bundle with a single icon | |
337 | %name(wxIconBundleFromIcon)wxIconBundle( const wxIcon& icon ); | |
338 | ||
339 | ~wxIconBundle(); | |
340 | ||
341 | // adds the icon to the collection, if the collection already | |
342 | // contains an icon with the same width and height, it is | |
343 | // replaced | |
344 | void AddIcon( const wxIcon& icon ); | |
345 | ||
346 | // adds all the icons contained in the file to the collection, | |
347 | // if the collection already contains icons with the same | |
348 | // width and height, they are replaced | |
349 | %name(AddIconFromFile)void AddIcon( const wxString& file, long type ); | |
350 | ||
351 | // returns the icon with the given size; if no such icon exists, | |
352 | // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists, | |
353 | // returns the first icon in the bundle | |
354 | const wxIcon& GetIcon( const wxSize& size ) const; | |
355 | }; | |
356 | ||
357 | //--------------------------------------------------------------------------- | |
358 | ||
9416aa89 | 359 | class wxCursor : public wxGDIObject |
5bff6bb8 | 360 | { |
7bf85405 | 361 | public: |
1fded56b RD |
362 | %addmethods { |
363 | wxCursor(const wxString* cursorName, long flags, int hotSpotX=0, int hotSpotY=0) { | |
364 | #ifdef __WXGTK__ | |
365 | wxCHECK_MSG(FALSE, NULL, | |
366 | wxT("wxCursor constructor not implemented for wxGTK, use wxStockCursor, wxCursorFromImage, or wxCursorFromBits instead.")); | |
367 | #else | |
368 | return new wxCursor(*cursorName, flags, hotSpotX, hotSpotY); | |
fb5e0af0 | 369 | #endif |
1fded56b RD |
370 | } |
371 | } | |
372 | ||
7bf85405 | 373 | ~wxCursor(); |
5bff6bb8 RD |
374 | |
375 | // wxGDIImage methods | |
376 | #ifdef __WXMSW__ | |
377 | long GetHandle(); | |
378 | void SetHandle(long handle); | |
379 | #endif | |
380 | bool Ok(); | |
381 | #ifdef __WXMSW__ | |
382 | int GetWidth(); | |
383 | int GetHeight(); | |
384 | int GetDepth(); | |
385 | void SetWidth(int w); | |
386 | void SetHeight(int h); | |
387 | void SetDepth(int d); | |
388 | void SetSize(const wxSize& size); | |
389 | #endif | |
1fded56b | 390 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
7bf85405 RD |
391 | }; |
392 | ||
9c039d08 | 393 | %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); |
1fded56b RD |
394 | %new wxCursor* wxCursorFromImage(const wxImage& image); |
395 | %new wxCursor* wxCursorFromBits(PyObject* bits, int width, int height, | |
396 | int hotSpotX=-1, int hotSpotY=-1, | |
397 | PyObject* maskBits=0); | |
398 | ||
399 | %{ | |
9c039d08 | 400 | wxCursor* wxPyStockCursor(int id) { |
7bf85405 RD |
401 | return new wxCursor(id); |
402 | } | |
7bf85405 | 403 | |
1e4a197e | 404 | wxCursor* wxCursorFromImage(const wxImage& image) { |
1e4a197e | 405 | return new wxCursor(image); |
1fded56b RD |
406 | } |
407 | ||
408 | wxCursor* wxCursorFromBits(PyObject* bits, int width, int height, | |
409 | int hotSpotX=-1, int hotSpotY=-1, | |
410 | PyObject* maskBits=0) { | |
411 | char* bitsbuf; | |
412 | char* maskbuf = NULL; | |
413 | int length; | |
414 | PyString_AsStringAndSize(bits, &bitsbuf, &length); | |
415 | if (maskBits) | |
416 | PyString_AsStringAndSize(maskBits, &maskbuf, &length); | |
417 | return new wxCursor(bitsbuf, width, height, hotSpotX, hotSpotY, maskbuf); | |
1e4a197e RD |
418 | } |
419 | %} | |
420 | ||
7bf85405 RD |
421 | //---------------------------------------------------------------------- |
422 | ||
9416aa89 | 423 | class wxColour : public wxObject { |
7bf85405 RD |
424 | public: |
425 | wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0); | |
426 | ~wxColour(); | |
427 | unsigned char Red(); | |
428 | unsigned char Green(); | |
429 | unsigned char Blue(); | |
430 | bool Ok(); | |
431 | void Set(unsigned char red, unsigned char green, unsigned char blue); | |
432 | %addmethods { | |
433 | PyObject* Get() { | |
434 | PyObject* rv = PyTuple_New(3); | |
1e4a197e RD |
435 | int red = -1; |
436 | int green = -1; | |
437 | int blue = -1; | |
438 | if (self->Ok()) { | |
439 | red = self->Red(); | |
440 | green = self->Green(); | |
441 | blue = self->Blue(); | |
442 | } | |
443 | PyTuple_SetItem(rv, 0, PyInt_FromLong(red)); | |
444 | PyTuple_SetItem(rv, 1, PyInt_FromLong(green)); | |
445 | PyTuple_SetItem(rv, 2, PyInt_FromLong(blue)); | |
7bf85405 RD |
446 | return rv; |
447 | } | |
1e4a197e RD |
448 | bool __eq__(PyObject* obj) { |
449 | wxColour tmp; | |
450 | wxColour* ptr = &tmp; | |
451 | if (obj == Py_None) return FALSE; | |
452 | wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear()); | |
453 | if (! success) return FALSE; | |
454 | return *self == *ptr; | |
455 | } | |
456 | bool __ne__(PyObject* obj) { | |
457 | wxColour tmp; | |
458 | wxColour* ptr = &tmp; | |
459 | if (obj == Py_None) return TRUE; | |
460 | wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear()); | |
461 | if (! success) return TRUE; | |
462 | return *self != *ptr; | |
463 | } | |
7bf85405 | 464 | } |
1e4a197e RD |
465 | |
466 | %pragma(python) addtoclass = "asTuple = Get | |
467 | def __str__(self): return str(self.asTuple()) | |
1a10a058 | 468 | def __repr__(self): return 'wxColour' + str(self.asTuple()) |
1e4a197e RD |
469 | def __nonzero__(self): return self.Ok() |
470 | def __getinitargs__(self): return () | |
471 | def __getstate__(self): return self.asTuple() | |
472 | def __setstate__(self, state): self.Set(*state) | |
473 | " | |
9b3d3bc4 | 474 | |
7bf85405 RD |
475 | }; |
476 | ||
477 | %new wxColour* wxNamedColour(const wxString& colorName); | |
de20db99 | 478 | |
7bf85405 RD |
479 | %{ // Alternate 'constructor' |
480 | wxColour* wxNamedColour(const wxString& colorName) { | |
481 | return new wxColour(colorName); | |
482 | } | |
483 | %} | |
484 | ||
485 | ||
7bf85405 | 486 | |
9416aa89 | 487 | class wxColourDatabase : public wxObject { |
7bf85405 | 488 | public: |
0569df0f | 489 | |
dd116e73 RD |
490 | wxColour *FindColour(const wxString& colour) ; |
491 | wxColour *FindColourNoAdd(const wxString& colour) const; | |
0569df0f RD |
492 | wxString FindName(const wxColour& colour) const; |
493 | ||
7bf85405 | 494 | %addmethods { |
dd116e73 RD |
495 | void AddColour(const wxString& name, wxColour* colour) { |
496 | // make a copy since the python one will be GC'd | |
497 | wxColour* c = new wxColour(*colour); | |
498 | self->AddColour(name, c); | |
499 | } | |
fe40185d | 500 | |
dd116e73 RD |
501 | void Append(const wxString& name, int red, int green, int blue) { |
502 | wxColour* c = new wxColour(red, green, blue); | |
503 | self->AddColour(name, c); | |
7bf85405 | 504 | } |
7bf85405 | 505 | } |
0569df0f RD |
506 | }; |
507 | ||
508 | ||
509 | //---------------------------------------------------------------------- | |
510 | ||
9416aa89 | 511 | class wxPen : public wxGDIObject { |
0569df0f RD |
512 | public: |
513 | wxPen(wxColour& colour, int width=1, int style=wxSOLID); | |
514 | ~wxPen(); | |
7bf85405 RD |
515 | |
516 | int GetCap(); | |
25832b3f | 517 | wxColour GetColour(); |
7bf85405 | 518 | |
fb5e0af0 | 519 | int GetJoin(); |
7bf85405 RD |
520 | int GetStyle(); |
521 | int GetWidth(); | |
522 | bool Ok(); | |
523 | void SetCap(int cap_style); | |
524 | void SetColour(wxColour& colour); | |
aeeb6a44 RR |
525 | void SetJoin(int join_style); |
526 | void SetStyle(int style); | |
527 | void SetWidth(int width); | |
08127323 | 528 | |
756ed80c | 529 | |
eec92d76 | 530 | void SetDashes(int LCOUNT, wxDash* choices); |
756ed80c RD |
531 | //int GetDashes(wxDash **dashes); |
532 | %addmethods { | |
533 | PyObject* GetDashes() { | |
534 | wxDash* dashes; | |
535 | int count = self->GetDashes(&dashes); | |
536 | wxPyBeginBlockThreads(); | |
537 | PyObject* retval = PyList_New(0); | |
538 | for (int x=0; x<count; x++) | |
539 | PyList_Append(retval, PyInt_FromLong(dashes[x])); | |
540 | wxPyEndBlockThreads(); | |
541 | return retval; | |
542 | } | |
543 | } | |
6999b0d8 RD |
544 | |
545 | #ifdef __WXMSW__ | |
546 | wxBitmap* GetStipple(); | |
b8b8dda7 | 547 | void SetStipple(wxBitmap& stipple); |
fb5e0af0 | 548 | #endif |
1fded56b RD |
549 | |
550 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
7bf85405 RD |
551 | }; |
552 | ||
0569df0f | 553 | |
ecc08ead | 554 | |
05f30eec RD |
555 | |
556 | // The list of ints for the dashes needs to exist for the life of the pen | |
557 | // so we make it part of the class to save it. wxPyPen is aliased to wxPen | |
558 | // in _extras.py | |
559 | ||
ecc08ead RD |
560 | %{ |
561 | class wxPyPen : public wxPen { | |
562 | public: | |
563 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID) | |
564 | : wxPen(colour, width, style) | |
565 | { m_dash = NULL; } | |
566 | ~wxPyPen() { | |
567 | if (m_dash) | |
05f30eec | 568 | delete [] m_dash; |
ecc08ead RD |
569 | } |
570 | ||
571 | void SetDashes(int nb_dashes, const wxDash *dash) { | |
05f30eec RD |
572 | if (m_dash) |
573 | delete [] m_dash; | |
ecc08ead | 574 | m_dash = new wxDash[nb_dashes]; |
05f30eec | 575 | for (int i=0; i<nb_dashes; i++) { |
ecc08ead | 576 | m_dash[i] = dash[i]; |
05f30eec | 577 | } |
ecc08ead RD |
578 | wxPen::SetDashes(nb_dashes, m_dash); |
579 | } | |
580 | ||
581 | private: | |
582 | wxDash* m_dash; | |
583 | }; | |
584 | %} | |
585 | ||
586 | ||
ecc08ead RD |
587 | class wxPyPen : public wxPen { |
588 | public: | |
589 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID); | |
590 | ~wxPyPen(); | |
591 | ||
592 | void SetDashes(int LCOUNT, wxDash* choices); | |
593 | }; | |
594 | ||
595 | ||
596 | ||
05f30eec | 597 | |
9416aa89 | 598 | class wxPenList : public wxObject { |
0569df0f RD |
599 | public: |
600 | ||
601 | void AddPen(wxPen* pen); | |
602 | wxPen* FindOrCreatePen(const wxColour& colour, int width, int style); | |
603 | void RemovePen(wxPen* pen); | |
2f4e9287 RD |
604 | |
605 | int GetCount(); | |
0569df0f RD |
606 | }; |
607 | ||
608 | ||
609 | ||
7bf85405 RD |
610 | //---------------------------------------------------------------------- |
611 | ||
9416aa89 | 612 | class wxBrush : public wxGDIObject { |
7bf85405 | 613 | public: |
0569df0f RD |
614 | wxBrush(const wxColour& colour, int style=wxSOLID); |
615 | ~wxBrush(); | |
26b9cf27 | 616 | |
25832b3f | 617 | wxColour GetColour(); |
7bf85405 RD |
618 | wxBitmap * GetStipple(); |
619 | int GetStyle(); | |
620 | bool Ok(); | |
621 | void SetColour(wxColour &colour); | |
b8b8dda7 | 622 | void SetStipple(wxBitmap& bitmap); |
7bf85405 | 623 | void SetStyle(int style); |
1fded56b RD |
624 | |
625 | #ifdef __WXMAC__ | |
626 | short GetMacTheme(); | |
627 | void SetMacTheme(short macThemeBrush); | |
628 | #endif | |
629 | ||
630 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
7bf85405 RD |
631 | }; |
632 | ||
0569df0f | 633 | |
6ee2116b | 634 | class wxBrushList : public wxObject { |
0569df0f RD |
635 | public: |
636 | ||
637 | void AddBrush(wxBrush *brush); | |
638 | wxBrush * FindOrCreateBrush(const wxColour& colour, int style); | |
639 | void RemoveBrush(wxBrush *brush); | |
2f4e9287 RD |
640 | |
641 | int GetCount(); | |
0569df0f RD |
642 | }; |
643 | ||
7bf85405 RD |
644 | //---------------------------------------------------------------------- |
645 | ||
646 | ||
9416aa89 | 647 | class wxDC : public wxObject { |
7bf85405 | 648 | public: |
fb5e0af0 | 649 | // wxDC(); **** abstract base class, can't instantiate. |
7bf85405 RD |
650 | ~wxDC(); |
651 | ||
652 | void BeginDrawing(); | |
1e4a197e | 653 | |
efc5f224 | 654 | // %name(BlitXY) |
1e4a197e RD |
655 | bool Blit(wxCoord xdest, wxCoord ydest, |
656 | wxCoord width, wxCoord height, | |
657 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
efc5f224 RD |
658 | int logicalFunc = wxCOPY, int useMask = FALSE); |
659 | // bool Blit(const wxPoint& destPt, const wxSize& sz, | |
660 | // wxDC *source, const wxPoint& srcPt, | |
661 | // int logicalFunc = wxCOPY, int useMask = FALSE); | |
662 | ||
7bf85405 | 663 | void Clear(); |
1e4a197e | 664 | void CrossHair(wxCoord x, wxCoord y); |
7bf85405 | 665 | void DestroyClippingRegion(); |
1e4a197e RD |
666 | wxCoord DeviceToLogicalX(wxCoord x); |
667 | wxCoord DeviceToLogicalXRel(wxCoord x); | |
668 | wxCoord DeviceToLogicalY(wxCoord y); | |
669 | wxCoord DeviceToLogicalYRel(wxCoord y); | |
670 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); | |
671 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); | |
672 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
673 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end); | |
674 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
23bed520 RD |
675 | |
676 | void DrawLabel(const wxString& text, const wxRect& rect, | |
677 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
678 | int indexAccel = -1); | |
679 | ||
680 | %addmethods { | |
681 | wxRect DrawImageLabel(const wxString& text, | |
682 | const wxBitmap& image, | |
683 | const wxRect& rect, | |
684 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
685 | int indexAccel = -1) { | |
686 | wxRect rv; | |
687 | self->DrawLabel(text, image, rect, alignment, indexAccel, &rv); | |
688 | return rv; | |
689 | } | |
690 | } | |
691 | ||
1e4a197e RD |
692 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); |
693 | void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0); | |
694 | void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0, | |
7bf85405 | 695 | int fill_style=wxODDEVEN_RULE); |
1e4a197e RD |
696 | void DrawPoint(wxCoord x, wxCoord y); |
697 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
33ffdd72 | 698 | %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); |
6999b0d8 | 699 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); |
1e4a197e | 700 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20); |
eec92d76 | 701 | void DrawSpline(int PCOUNT, wxPoint* points); |
1e4a197e | 702 | void DrawText(const wxString& text, wxCoord x, wxCoord y); |
7bf85405 RD |
703 | void EndDoc(); |
704 | void EndDrawing(); | |
705 | void EndPage(); | |
1e4a197e | 706 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE); |
c5943253 RD |
707 | wxBrush GetBackground(); |
708 | wxBrush GetBrush(); | |
1e4a197e RD |
709 | wxCoord GetCharHeight(); |
710 | wxCoord GetCharWidth(); | |
711 | void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, | |
712 | wxCoord *OUTPUT, wxCoord *OUTPUT); | |
c5943253 | 713 | wxFont GetFont(); |
7bf85405 | 714 | int GetLogicalFunction(); |
eec92d76 | 715 | void GetLogicalScale(double *OUTPUT, double *OUTPUT); |
7bf85405 RD |
716 | int GetMapMode(); |
717 | bool GetOptimization(); | |
c5943253 | 718 | wxPen GetPen(); |
fb5e0af0 | 719 | %addmethods { |
1e4a197e | 720 | %new wxColour* GetPixel(wxCoord x, wxCoord y) { |
fb5e0af0 RD |
721 | wxColour* wc = new wxColour(); |
722 | self->GetPixel(x, y, wc); | |
723 | return wc; | |
724 | } | |
725 | } | |
bb0054cd RD |
726 | %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); |
727 | wxSize GetSize(); | |
eec92d76 | 728 | wxSize GetSizeMM(); |
25832b3f | 729 | wxColour GetTextBackground(); |
1e4a197e | 730 | void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT); |
af309447 | 731 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, |
1e4a197e | 732 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, |
af309447 | 733 | const wxFont* font = NULL); |
1e4a197e RD |
734 | void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, |
735 | wxFont *font = NULL); | |
25832b3f | 736 | wxColour GetTextForeground(); |
eec92d76 | 737 | void GetUserScale(double *OUTPUT, double *OUTPUT); |
1e4a197e RD |
738 | wxCoord LogicalToDeviceX(wxCoord x); |
739 | wxCoord LogicalToDeviceXRel(wxCoord x); | |
740 | wxCoord LogicalToDeviceY(wxCoord y); | |
741 | wxCoord LogicalToDeviceYRel(wxCoord y); | |
742 | wxCoord MaxX(); | |
743 | wxCoord MaxY(); | |
744 | wxCoord MinX(); | |
745 | wxCoord MinY(); | |
7bf85405 | 746 | bool Ok(); |
1e4a197e | 747 | void SetDeviceOrigin(wxCoord x, wxCoord y); |
7bf85405 RD |
748 | void SetBackground(const wxBrush& brush); |
749 | void SetBackgroundMode(int mode); | |
1e4a197e | 750 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
19a97bd6 | 751 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); |
33ffdd72 | 752 | %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); |
7bf85405 RD |
753 | void SetPalette(const wxPalette& colourMap); |
754 | void SetBrush(const wxBrush& brush); | |
755 | void SetFont(const wxFont& font); | |
756 | void SetLogicalFunction(int function); | |
eec92d76 | 757 | void SetLogicalScale(double x, double y); |
7bf85405 RD |
758 | void SetMapMode(int mode); |
759 | void SetOptimization(bool optimize); | |
760 | void SetPen(const wxPen& pen); | |
761 | void SetTextBackground(const wxColour& colour); | |
762 | void SetTextForeground(const wxColour& colour); | |
763 | void SetUserScale(double x_scale, double y_scale); | |
764 | bool StartDoc(const wxString& message); | |
765 | void StartPage(); | |
766 | ||
767 | ||
efc5f224 | 768 | |
1e4a197e | 769 | void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, |
efc5f224 RD |
770 | int useMask = FALSE); |
771 | ||
eec92d76 RD |
772 | bool CanDrawBitmap(); |
773 | bool CanGetTextExtent(); | |
774 | int GetDepth(); | |
775 | wxSize GetPPI(); | |
776 | ||
777 | void GetLogicalOrigin(int *OUTPUT, int *OUTPUT); | |
778 | void SetLogicalOrigin(int x, int y); | |
779 | void GetDeviceOrigin(int *OUTPUT, int *OUTPUT); | |
eec92d76 RD |
780 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); |
781 | ||
f6bcfd97 BP |
782 | void CalcBoundingBox(int x, int y); |
783 | void ResetBoundingBox(); | |
c7e7022c | 784 | |
9d37f964 RD |
785 | %addmethods { |
786 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
787 | // See below for implementation | |
788 | } | |
789 | ||
1fded56b RD |
790 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
791 | ||
c7e7022c RD |
792 | #ifdef __WXMSW__ |
793 | long GetHDC(); | |
794 | #endif | |
9d37f964 RD |
795 | |
796 | ||
1e4a197e | 797 | %addmethods { // See drawlist.cpp for impplementaion of these... |
9d37f964 | 798 | |
1e4a197e RD |
799 | PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) |
800 | { | |
801 | return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes); | |
9d37f964 RD |
802 | } |
803 | ||
1e4a197e RD |
804 | PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) |
805 | { | |
806 | return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes); | |
807 | } | |
9d37f964 | 808 | |
1e4a197e RD |
809 | PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) |
810 | { | |
811 | return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes); | |
812 | } | |
9d37f964 | 813 | |
1e4a197e RD |
814 | PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) |
815 | { | |
816 | return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes); | |
817 | } | |
fd512ba2 | 818 | |
1e4a197e RD |
819 | PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) |
820 | { | |
821 | return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes); | |
822 | } | |
fd512ba2 | 823 | |
1e4a197e RD |
824 | PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints, |
825 | PyObject* foregroundList, PyObject* backgroundList) { | |
826 | return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList); | |
9d37f964 RD |
827 | } |
828 | } | |
829 | ||
9d37f964 RD |
830 | %pragma(python) addtoclass = " |
831 | def DrawPointList(self, points, pens=None): | |
832 | if pens is None: | |
833 | pens = [] | |
834 | elif isinstance(pens, wxPenPtr): | |
835 | pens = [pens] | |
836 | elif len(pens) != len(points): | |
837 | raise ValueError('points and pens must have same length') | |
1e4a197e RD |
838 | return self._DrawPointList(points, pens, []) |
839 | ||
9d37f964 RD |
840 | |
841 | def DrawLineList(self, lines, pens=None): | |
842 | if pens is None: | |
843 | pens = [] | |
844 | elif isinstance(pens, wxPenPtr): | |
845 | pens = [pens] | |
846 | elif len(pens) != len(lines): | |
847 | raise ValueError('lines and pens must have same length') | |
1e4a197e RD |
848 | return self._DrawLineList(lines, pens, []) |
849 | ||
850 | ||
851 | def DrawRectangleList(self, rectangles, pens=None, brushes=None): | |
852 | if pens is None: | |
853 | pens = [] | |
854 | elif isinstance(pens, wxPenPtr): | |
855 | pens = [pens] | |
856 | elif len(pens) != len(rectangles): | |
857 | raise ValueError('rectangles and pens must have same length') | |
858 | if brushes is None: | |
859 | brushes = [] | |
860 | elif isinstance(brushes, wxBrushPtr): | |
861 | brushes = [brushes] | |
862 | elif len(brushes) != len(rectangles): | |
863 | raise ValueError('rectangles and brushes must have same length') | |
864 | return self._DrawRectangleList(rectangles, pens, brushes) | |
865 | ||
866 | ||
867 | def DrawEllipseList(self, ellipses, pens=None, brushes=None): | |
868 | if pens is None: | |
869 | pens = [] | |
870 | elif isinstance(pens, wxPenPtr): | |
871 | pens = [pens] | |
872 | elif len(pens) != len(ellipses): | |
873 | raise ValueError('ellipses and pens must have same length') | |
874 | if brushes is None: | |
875 | brushes = [] | |
876 | elif isinstance(brushes, wxBrushPtr): | |
877 | brushes = [brushes] | |
878 | elif len(brushes) != len(ellipses): | |
879 | raise ValueError('ellipses and brushes must have same length') | |
880 | return self._DrawEllipseList(ellipses, pens, brushes) | |
881 | ||
882 | ||
883 | def DrawPolygonList(self, polygons, pens=None, brushes=None): | |
884 | ## Note: This does not currently support fill style or offset | |
885 | ## you can always use the non-List version if need be. | |
886 | ## I really would like to support fill-style, however, | |
887 | ## but wxODDEVEN_RULE does not appear to be defined at the Python level | |
888 | ## [It's in wx.py... --Robin] | |
889 | if pens is None: | |
890 | pens = [] | |
891 | elif isinstance(pens, wxPenPtr): | |
892 | pens = [pens] | |
893 | elif len(pens) != len(polygons): | |
894 | raise ValueError('polygons and pens must have same length') | |
895 | if brushes is None: | |
896 | brushes = [] | |
897 | elif isinstance(brushes, wxBrushPtr): | |
898 | brushes = [brushes] | |
899 | elif len(brushes) != len(polygons): | |
900 | raise ValueError('polygons and brushes must have same length') | |
901 | return self._DrawPolygonList(polygons, pens, brushes) | |
902 | ||
903 | ||
904 | def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None): | |
905 | ## NOTE: this does not currently support changing the font | |
906 | ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode) | |
907 | ## If you want backgounds to do anything. | |
908 | if type(textList) == type(''): | |
909 | textList = [textList] | |
910 | elif len(textList) != len(coords): | |
911 | raise ValueError('textlist and coords must have same length') | |
912 | if foregrounds is None: | |
913 | foregrounds = [] | |
914 | elif isinstance(foregrounds, wxColourPtr): | |
915 | foregrounds = [foregrounds] | |
916 | elif len(foregrounds) != len(coords): | |
917 | raise ValueError('foregrounds and coords must have same length') | |
918 | if backgrounds is None: | |
919 | backgrounds = [] | |
920 | elif isinstance(backgrounds, wxColourPtr): | |
921 | backgrounds = [backgrounds] | |
922 | elif len(backgrounds) != len(coords): | |
923 | raise ValueError('backgrounds and coords must have same length') | |
924 | return self._DrawTextList(textList, coords, foregrounds, backgrounds) | |
9d37f964 RD |
925 | " |
926 | ||
927 | ||
7bf85405 RD |
928 | }; |
929 | ||
930 | ||
9d37f964 RD |
931 | |
932 | %{ | |
933 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
934 | *x1 = dc->MinX(); | |
935 | *y1 = dc->MinY(); | |
936 | *x2 = dc->MaxX(); | |
937 | *y2 = dc->MaxY(); | |
938 | } | |
939 | %} | |
940 | ||
7bf85405 RD |
941 | //---------------------------------------------------------------------- |
942 | ||
943 | class wxMemoryDC : public wxDC { | |
944 | public: | |
945 | wxMemoryDC(); | |
946 | ||
947 | void SelectObject(const wxBitmap& bitmap); | |
948 | } | |
949 | ||
950 | %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC); | |
951 | %{ // Alternate 'constructor' | |
952 | wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) { | |
953 | return new wxMemoryDC(oldDC); | |
954 | } | |
955 | %} | |
956 | ||
957 | ||
e9159fe8 RD |
958 | //--------------------------------------------------------------------------- |
959 | ||
960 | class wxBufferedDC : public wxMemoryDC { | |
961 | public: | |
962 | // Construct a wxBufferedDC using a user supplied buffer. | |
963 | wxBufferedDC( wxDC *dc, const wxBitmap &buffer ); | |
964 | ||
965 | // Construct a wxBufferedDC with an internal buffer of 'area' | |
966 | // (where area is usually something like the size of the window | |
967 | // being buffered) | |
968 | %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area ); | |
d3bfec74 RD |
969 | |
970 | // Blits the buffer to the dc, and detaches the dc from | |
971 | // the buffer. Usually called in the dtor or by the dtor | |
972 | // of derived classes if the BufferedDC must blit before | |
973 | // the derived class (which may own the dc it's blitting | |
974 | // to) is destroyed. | |
975 | void UnMask(); | |
976 | ||
977 | ||
978 | %pragma(python) addtomethod = | |
979 | "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
980 | %pragma(python) addtomethod = | |
981 | "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
e9159fe8 RD |
982 | }; |
983 | ||
984 | ||
985 | class wxBufferedPaintDC : public wxBufferedDC | |
986 | { | |
987 | public: | |
988 | wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); | |
989 | }; | |
990 | ||
7bf85405 RD |
991 | //--------------------------------------------------------------------------- |
992 | ||
993 | class wxScreenDC : public wxDC { | |
994 | public: | |
995 | wxScreenDC(); | |
996 | ||
26b9cf27 RD |
997 | %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window); |
998 | bool StartDrawingOnTop(wxRect* rect = NULL); | |
7bf85405 RD |
999 | bool EndDrawingOnTop(); |
1000 | }; | |
1001 | ||
1002 | //--------------------------------------------------------------------------- | |
1003 | ||
1004 | class wxClientDC : public wxDC { | |
1005 | public: | |
1006 | wxClientDC(wxWindow* win); | |
1007 | }; | |
1008 | ||
1009 | //--------------------------------------------------------------------------- | |
1010 | ||
1011 | class wxPaintDC : public wxDC { | |
1012 | public: | |
1013 | wxPaintDC(wxWindow* win); | |
1014 | }; | |
1015 | ||
1016 | //--------------------------------------------------------------------------- | |
1017 | ||
b639c3c5 RD |
1018 | class wxWindowDC : public wxDC { |
1019 | public: | |
1020 | wxWindowDC(wxWindow* win); | |
1021 | }; | |
b639c3c5 RD |
1022 | |
1023 | //--------------------------------------------------------------------------- | |
1024 | ||
3ef86e32 RD |
1025 | class wxMirrorDC : public wxDC |
1026 | { | |
1027 | public: | |
1028 | // constructs a mirror DC associated with the given real DC | |
1029 | // | |
1030 | // if mirror parameter is true, all vertical and horizontal coordinates are | |
1031 | // exchanged, otherwise this class behaves in exactly the same way as a | |
1032 | // plain DC | |
1033 | // | |
1034 | wxMirrorDC(wxDC& dc, bool mirror); | |
1035 | }; | |
1036 | ||
1037 | //--------------------------------------------------------------------------- | |
1038 | ||
7bf85405 | 1039 | |
d063802f | 1040 | #ifdef __WXMSW__ |
17c0e08c RD |
1041 | |
1042 | %{ | |
1043 | #include <wx/metafile.h> | |
1044 | %} | |
1045 | ||
1046 | class wxMetaFile : public wxObject { | |
1047 | public: | |
137b5242 | 1048 | wxMetaFile(const wxString& filename = wxPyEmptyString); |
17c0e08c RD |
1049 | ~wxMetaFile(); |
1050 | ||
1051 | bool Ok(); | |
1052 | bool SetClipboard(int width = 0, int height = 0); | |
1053 | ||
1054 | wxSize GetSize(); | |
1055 | int GetWidth(); | |
1056 | int GetHeight(); | |
1057 | ||
1058 | const wxString& GetFileName() const { return m_filename; } | |
1059 | ||
1fded56b | 1060 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" |
17c0e08c RD |
1061 | }; |
1062 | ||
1063 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
1064 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
1065 | ||
1066 | ||
7bf85405 RD |
1067 | class wxMetaFileDC : public wxDC { |
1068 | public: | |
137b5242 | 1069 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, |
17c0e08c | 1070 | int width = 0, int height = 0, |
137b5242 | 1071 | const wxString& description = wxPyEmptyString); |
7bf85405 RD |
1072 | wxMetaFile* Close(); |
1073 | }; | |
17c0e08c | 1074 | |
fb5e0af0 | 1075 | #endif |
7bf85405 | 1076 | |
b639c3c5 RD |
1077 | //--------------------------------------------------------------------------- |
1078 | ||
9416aa89 | 1079 | class wxPalette : public wxGDIObject { |
b639c3c5 | 1080 | public: |
eec92d76 | 1081 | wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); |
b639c3c5 RD |
1082 | ~wxPalette(); |
1083 | ||
1084 | int GetPixel(byte red, byte green, byte blue); | |
1085 | bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); | |
1086 | bool Ok(); | |
1fded56b RD |
1087 | |
1088 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
b639c3c5 RD |
1089 | }; |
1090 | ||
1091 | //--------------------------------------------------------------------------- | |
1092 | ||
af309447 RD |
1093 | enum { |
1094 | wxIMAGELIST_DRAW_NORMAL , | |
1095 | wxIMAGELIST_DRAW_TRANSPARENT, | |
1096 | wxIMAGELIST_DRAW_SELECTED, | |
1097 | wxIMAGELIST_DRAW_FOCUSED, | |
1098 | wxIMAGE_LIST_NORMAL, | |
1099 | wxIMAGE_LIST_SMALL, | |
1100 | wxIMAGE_LIST_STATE | |
1101 | }; | |
1102 | ||
9416aa89 | 1103 | class wxImageList : public wxObject { |
af309447 | 1104 | public: |
dcd38683 | 1105 | wxImageList(int width, int height, int mask=TRUE, int initialCount=1); |
af309447 RD |
1106 | ~wxImageList(); |
1107 | ||
1108 | int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1109 | %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
1110 | %name(AddIcon)int Add(const wxIcon& icon); | |
f6bcfd97 | 1111 | #ifdef __WXMSW__ |
b57bdb5a | 1112 | bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); |
b57bdb5a | 1113 | #else |
f6bcfd97 BP |
1114 | // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon); |
1115 | // int Add(const wxBitmap& bitmap); | |
b57bdb5a RD |
1116 | bool Replace(int index, const wxBitmap& bitmap); |
1117 | #endif | |
af309447 RD |
1118 | |
1119 | bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL, | |
1120 | const bool solidBackground = FALSE); | |
1121 | ||
1122 | int GetImageCount(); | |
1123 | bool Remove(int index); | |
1124 | bool RemoveAll(); | |
f6bcfd97 | 1125 | void GetSize(int index, int& OUTPUT, int& OUTPUT); |
af309447 RD |
1126 | }; |
1127 | ||
b639c3c5 | 1128 | |
9416aa89 RD |
1129 | //--------------------------------------------------------------------------- |
1130 | // Regions, etc. | |
1131 | ||
1132 | enum wxRegionContain { | |
1133 | wxOutRegion, wxPartRegion, wxInRegion | |
1134 | }; | |
1135 | ||
1136 | ||
1137 | class wxRegion : public wxGDIObject { | |
1138 | public: | |
1e4a197e | 1139 | wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0); |
8038a802 | 1140 | #ifndef __WXMAC__ |
3de0866e | 1141 | %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE); |
8038a802 | 1142 | #endif |
1542ea39 RD |
1143 | %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp, |
1144 | const wxColour& transColour = wxNullColour, | |
1145 | int tolerance = 0); | |
9416aa89 RD |
1146 | ~wxRegion(); |
1147 | ||
1542ea39 | 1148 | |
9416aa89 | 1149 | void Clear(); |
d063802f | 1150 | #ifndef __WXMAC__ |
23bed520 | 1151 | bool Offset(wxCoord x, wxCoord y); |
d063802f | 1152 | #endif |
23bed520 | 1153 | |
1e4a197e | 1154 | wxRegionContain Contains(wxCoord x, wxCoord y); |
9416aa89 RD |
1155 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); |
1156 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
1e4a197e | 1157 | %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h); |
9416aa89 RD |
1158 | |
1159 | wxRect GetBox(); | |
1160 | ||
1e4a197e | 1161 | bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
9416aa89 RD |
1162 | %name(IntersectRect)bool Intersect(const wxRect& rect); |
1163 | %name(IntersectRegion)bool Intersect(const wxRegion& region); | |
1164 | ||
1165 | bool IsEmpty(); | |
1166 | ||
1e4a197e | 1167 | bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
9416aa89 RD |
1168 | %name(UnionRect)bool Union(const wxRect& rect); |
1169 | %name(UnionRegion)bool Union(const wxRegion& region); | |
1170 | ||
1e4a197e | 1171 | bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
9416aa89 RD |
1172 | %name(SubtractRect)bool Subtract(const wxRect& rect); |
1173 | %name(SubtractRegion)bool Subtract(const wxRegion& region); | |
1174 | ||
1e4a197e | 1175 | bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
9416aa89 RD |
1176 | %name(XorRect)bool Xor(const wxRect& rect); |
1177 | %name(XorRegion)bool Xor(const wxRegion& region); | |
1542ea39 | 1178 | |
1fded56b | 1179 | // Convert the region to a B&W bitmap with the white pixels being inside |
1542ea39 RD |
1180 | // the region. |
1181 | wxBitmap ConvertToBitmap(); | |
1182 | ||
1183 | // Use the non-transparent pixels of a wxBitmap for the region to combine | |
1184 | // with this region. If the bitmap has a mask then it will be used, | |
1185 | // otherwise the colour to be treated as transparent may be specified, | |
1186 | // along with an optional tolerance value. | |
1187 | %name(UnionBitmap)bool Union(const wxBitmap& bmp, | |
1188 | const wxColour& transColour = wxNullColour, | |
1189 | int tolerance = 0); | |
9416aa89 RD |
1190 | }; |
1191 | ||
1192 | ||
1193 | ||
1194 | class wxRegionIterator : public wxObject { | |
1195 | public: | |
1196 | wxRegionIterator(const wxRegion& region); | |
1197 | ~wxRegionIterator(); | |
1198 | ||
1e4a197e RD |
1199 | wxCoord GetX(); |
1200 | wxCoord GetY(); | |
1201 | wxCoord GetW(); | |
1202 | wxCoord GetWidth(); | |
1203 | wxCoord GetH(); | |
1204 | wxCoord GetHeight(); | |
9416aa89 RD |
1205 | wxRect GetRect(); |
1206 | bool HaveRects(); | |
1207 | void Reset(); | |
1208 | ||
1209 | %addmethods { | |
1210 | void Next() { | |
1211 | (*self) ++; | |
1212 | } | |
1a10a058 RD |
1213 | |
1214 | bool __nonzero__() { | |
1215 | return self->operator bool(); | |
1216 | } | |
9416aa89 RD |
1217 | }; |
1218 | }; | |
1219 | ||
1220 | ||
7bf85405 RD |
1221 | //--------------------------------------------------------------------------- |
1222 | ||
1542ea39 | 1223 | |
c5943253 RD |
1224 | %readonly |
1225 | %{ | |
1226 | #if 0 | |
1227 | %} | |
1228 | ||
dd116e73 RD |
1229 | // See also wxPy_ReinitStockObjects in helpers.cpp |
1230 | ||
c5943253 RD |
1231 | extern wxFont *wxNORMAL_FONT; |
1232 | extern wxFont *wxSMALL_FONT; | |
1233 | extern wxFont *wxITALIC_FONT; | |
1234 | extern wxFont *wxSWISS_FONT; | |
1235 | ||
1236 | extern wxPen *wxRED_PEN; | |
1237 | extern wxPen *wxCYAN_PEN; | |
1238 | extern wxPen *wxGREEN_PEN; | |
1239 | extern wxPen *wxBLACK_PEN; | |
1240 | extern wxPen *wxWHITE_PEN; | |
1241 | extern wxPen *wxTRANSPARENT_PEN; | |
1242 | extern wxPen *wxBLACK_DASHED_PEN; | |
1243 | extern wxPen *wxGREY_PEN; | |
1244 | extern wxPen *wxMEDIUM_GREY_PEN; | |
1245 | extern wxPen *wxLIGHT_GREY_PEN; | |
1246 | ||
1247 | extern wxBrush *wxBLUE_BRUSH; | |
1248 | extern wxBrush *wxGREEN_BRUSH; | |
1249 | extern wxBrush *wxWHITE_BRUSH; | |
1250 | extern wxBrush *wxBLACK_BRUSH; | |
1251 | extern wxBrush *wxTRANSPARENT_BRUSH; | |
1252 | extern wxBrush *wxCYAN_BRUSH; | |
1253 | extern wxBrush *wxRED_BRUSH; | |
1254 | extern wxBrush *wxGREY_BRUSH; | |
1255 | extern wxBrush *wxMEDIUM_GREY_BRUSH; | |
1256 | extern wxBrush *wxLIGHT_GREY_BRUSH; | |
1257 | ||
1258 | extern wxColour *wxBLACK; | |
1259 | extern wxColour *wxWHITE; | |
1260 | extern wxColour *wxRED; | |
1261 | extern wxColour *wxBLUE; | |
1262 | extern wxColour *wxGREEN; | |
1263 | extern wxColour *wxCYAN; | |
1264 | extern wxColour *wxLIGHT_GREY; | |
1265 | ||
1266 | extern wxCursor *wxSTANDARD_CURSOR; | |
1267 | extern wxCursor *wxHOURGLASS_CURSOR; | |
1268 | extern wxCursor *wxCROSS_CURSOR; | |
1269 | ||
1270 | ||
1271 | extern wxBitmap wxNullBitmap; | |
1272 | extern wxIcon wxNullIcon; | |
1273 | extern wxCursor wxNullCursor; | |
1274 | extern wxPen wxNullPen; | |
1275 | extern wxBrush wxNullBrush; | |
1276 | extern wxPalette wxNullPalette; | |
1277 | extern wxFont wxNullFont; | |
1278 | extern wxColour wxNullColour; | |
1279 | ||
1280 | ||
1281 | extern wxFontList* wxTheFontList; | |
1282 | extern wxPenList* wxThePenList; | |
1283 | extern wxBrushList* wxTheBrushList; | |
1284 | extern wxColourDatabase* wxTheColourDatabase; | |
1285 | ||
1286 | ||
1287 | %readwrite | |
1288 | %{ | |
1289 | #endif | |
1290 | %} | |
1291 | ||
1292 | //--------------------------------------------------------------------------- | |
1293 | //--------------------------------------------------------------------------- | |
1294 |