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