]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: gdi.i | |
3 | // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, etc. | |
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 | ||
14 | %module gdi | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/imaglist.h> | |
19 | #include <wx/fontmap.h> | |
20 | #include <wx/fontenc.h> | |
21 | #include <wx/fontmap.h> | |
22 | #include <wx/fontutil.h> | |
23 | #include <wx/dcbuffer.h> | |
24 | #include <wx/dcmirror.h> | |
25 | #include <wx/iconbndl.h> | |
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 | |
36 | %import fonts.i | |
37 | ||
38 | %pragma(python) code = "import wx" | |
39 | ||
40 | //--------------------------------------------------------------------------- | |
41 | %{ | |
42 | // Put some wx default wxChar* values into wxStrings. | |
43 | static const wxString wxPyEmptyString(wxT("")); | |
44 | %} | |
45 | //--------------------------------------------------------------------------- | |
46 | ||
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 | }; | |
58 | ||
59 | //--------------------------------------------------------------------------- | |
60 | ||
61 | ||
62 | // TODO: When the API stabalizes and is available on other platforms, add | |
63 | // wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff... | |
64 | ||
65 | class wxBitmap : public wxGDIObject | |
66 | { | |
67 | public: | |
68 | wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); | |
69 | ~wxBitmap(); | |
70 | ||
71 | wxPalette* GetPalette(); | |
72 | wxMask* GetMask(); | |
73 | bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_ANY); | |
74 | bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL); | |
75 | void SetMask(wxMask* mask); | |
76 | %pragma(python) addtoclass = " | |
77 | def SetMaskColour(self, colour): | |
78 | mask = wxMaskColour(self, colour) | |
79 | self.SetMask(mask) | |
80 | " | |
81 | #ifdef __WXMSW__ | |
82 | void SetPalette(wxPalette& palette); | |
83 | #endif | |
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 | |
100 | ||
101 | wxBitmap GetSubBitmap( const wxRect& rect ); | |
102 | bool CopyFromIcon(const wxIcon& icon); | |
103 | #ifdef __WXMSW__ | |
104 | bool CopyFromCursor(const wxCursor& cursor); | |
105 | int GetQuality(); | |
106 | void SetQuality(int q); | |
107 | #endif | |
108 | ||
109 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
110 | }; | |
111 | ||
112 | ||
113 | // Declarations of some alternate "constructors" | |
114 | %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); | |
115 | %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); | |
116 | %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); | |
117 | %new wxBitmap* wxBitmapFromBits(PyObject* bits, int width, int height, int depth = 1 ); | |
118 | ||
119 | // #ifdef __WXMSW__ | |
120 | // %new wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
121 | // int width, int height, int depth = 1); | |
122 | // #endif | |
123 | ||
124 | ||
125 | ||
126 | %{ // Implementations of some alternate "constructors" | |
127 | ||
128 | wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) { | |
129 | return new wxBitmap(width, height, depth); | |
130 | } | |
131 | ||
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 | ||
150 | ||
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 | ||
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); | |
174 | } | |
175 | ||
176 | ||
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 | |
187 | %} | |
188 | ||
189 | //--------------------------------------------------------------------------- | |
190 | ||
191 | class wxMask : public wxObject { | |
192 | public: | |
193 | wxMask(const wxBitmap& bitmap); | |
194 | //~wxMask(); | |
195 | ||
196 | %addmethods { void Destroy() { delete self; } } | |
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 | ||
210 | class wxIcon : public wxGDIObject | |
211 | { | |
212 | public: | |
213 | wxIcon(const wxString& name, long flags, | |
214 | int desiredWidth = -1, int desiredHeight = -1); | |
215 | ~wxIcon(); | |
216 | ||
217 | #ifndef __WXMAC__ | |
218 | bool LoadFile(const wxString& name, long flags); | |
219 | #endif | |
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 | |
236 | void CopyFromBitmap(const wxBitmap& bmp); | |
237 | ||
238 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
239 | }; | |
240 | ||
241 | ||
242 | // Declarations of some alternate "constructors" | |
243 | %new wxIcon* wxEmptyIcon(); | |
244 | %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); | |
245 | %new wxIcon* wxIconFromBitmap(const wxBitmap& bmp); | |
246 | %new wxIcon* wxIconFromLocation(const wxIconLocation& loc); | |
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 | } | |
264 | ||
265 | wxIcon* wxIconFromBitmap(const wxBitmap& bmp) { | |
266 | wxIcon* icon = new wxIcon(); | |
267 | icon->CopyFromBitmap(bmp); | |
268 | return icon; | |
269 | } | |
270 | ||
271 | wxIcon* wxIconFromLocation(const wxIconLocation& loc) { | |
272 | wxIcon* icon = new wxIcon(loc); | |
273 | return icon; | |
274 | } | |
275 | %} | |
276 | ||
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 | ||
325 | //--------------------------------------------------------------------------- | |
326 | ||
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 | ||
359 | class wxCursor : public wxGDIObject | |
360 | { | |
361 | public: | |
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); | |
369 | #endif | |
370 | } | |
371 | } | |
372 | ||
373 | ~wxCursor(); | |
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 | |
390 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
391 | }; | |
392 | ||
393 | %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); | |
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 | %{ | |
400 | wxCursor* wxPyStockCursor(int id) { | |
401 | return new wxCursor(id); | |
402 | } | |
403 | ||
404 | wxCursor* wxCursorFromImage(const wxImage& image) { | |
405 | return new wxCursor(image); | |
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); | |
418 | } | |
419 | %} | |
420 | ||
421 | //---------------------------------------------------------------------- | |
422 | ||
423 | class wxColour : public wxObject { | |
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); | |
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)); | |
446 | return rv; | |
447 | } | |
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 | } | |
464 | } | |
465 | ||
466 | %pragma(python) addtoclass = "asTuple = Get | |
467 | def __str__(self): return str(self.asTuple()) | |
468 | def __repr__(self): return 'wxColour' + str(self.asTuple()) | |
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 | " | |
474 | ||
475 | }; | |
476 | ||
477 | %new wxColour* wxNamedColour(const wxString& colorName); | |
478 | ||
479 | %{ // Alternate 'constructor' | |
480 | wxColour* wxNamedColour(const wxString& colorName) { | |
481 | return new wxColour(colorName); | |
482 | } | |
483 | %} | |
484 | ||
485 | ||
486 | ||
487 | class wxColourDatabase : public wxObject { | |
488 | public: | |
489 | ||
490 | wxColourDatabase(); | |
491 | ~wxColourDatabase(); | |
492 | ||
493 | // find colour by name or name for the given colour | |
494 | wxColour Find(const wxString& name) const; | |
495 | wxString FindName(const wxColour& colour) const; | |
496 | ||
497 | // add a new colour to the database | |
498 | void AddColour(const wxString& name, const wxColour& colour); | |
499 | ||
500 | %addmethods { | |
501 | void Append(const wxString& name, int red, int green, int blue) { | |
502 | self->AddColour(name, wxColour(red, green, blue)); | |
503 | } | |
504 | } | |
505 | }; | |
506 | ||
507 | ||
508 | //---------------------------------------------------------------------- | |
509 | ||
510 | class wxPen : public wxGDIObject { | |
511 | public: | |
512 | wxPen(wxColour& colour, int width=1, int style=wxSOLID); | |
513 | ~wxPen(); | |
514 | ||
515 | int GetCap(); | |
516 | wxColour GetColour(); | |
517 | ||
518 | int GetJoin(); | |
519 | int GetStyle(); | |
520 | int GetWidth(); | |
521 | bool Ok(); | |
522 | void SetCap(int cap_style); | |
523 | void SetColour(wxColour& colour); | |
524 | void SetJoin(int join_style); | |
525 | void SetStyle(int style); | |
526 | void SetWidth(int width); | |
527 | ||
528 | ||
529 | void SetDashes(int LCOUNT, wxDash* choices); | |
530 | //int GetDashes(wxDash **dashes); | |
531 | %addmethods { | |
532 | PyObject* GetDashes() { | |
533 | wxDash* dashes; | |
534 | int count = self->GetDashes(&dashes); | |
535 | wxPyBeginBlockThreads(); | |
536 | PyObject* retval = PyList_New(0); | |
537 | for (int x=0; x<count; x++) | |
538 | PyList_Append(retval, PyInt_FromLong(dashes[x])); | |
539 | wxPyEndBlockThreads(); | |
540 | return retval; | |
541 | } | |
542 | } | |
543 | ||
544 | #ifdef __WXMSW__ | |
545 | wxBitmap* GetStipple(); | |
546 | void SetStipple(wxBitmap& stipple); | |
547 | #endif | |
548 | ||
549 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
550 | }; | |
551 | ||
552 | ||
553 | ||
554 | ||
555 | // The list of ints for the dashes needs to exist for the life of the pen | |
556 | // so we make it part of the class to save it. wxPyPen is aliased to wxPen | |
557 | // in _extras.py | |
558 | ||
559 | %{ | |
560 | class wxPyPen : public wxPen { | |
561 | public: | |
562 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID) | |
563 | : wxPen(colour, width, style) | |
564 | { m_dash = NULL; } | |
565 | ~wxPyPen() { | |
566 | if (m_dash) | |
567 | delete [] m_dash; | |
568 | } | |
569 | ||
570 | void SetDashes(int nb_dashes, const wxDash *dash) { | |
571 | if (m_dash) | |
572 | delete [] m_dash; | |
573 | m_dash = new wxDash[nb_dashes]; | |
574 | for (int i=0; i<nb_dashes; i++) { | |
575 | m_dash[i] = dash[i]; | |
576 | } | |
577 | wxPen::SetDashes(nb_dashes, m_dash); | |
578 | } | |
579 | ||
580 | private: | |
581 | wxDash* m_dash; | |
582 | }; | |
583 | %} | |
584 | ||
585 | ||
586 | class wxPyPen : public wxPen { | |
587 | public: | |
588 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID); | |
589 | ~wxPyPen(); | |
590 | ||
591 | void SetDashes(int LCOUNT, wxDash* choices); | |
592 | }; | |
593 | ||
594 | ||
595 | ||
596 | ||
597 | class wxPenList : public wxObject { | |
598 | public: | |
599 | ||
600 | void AddPen(wxPen* pen); | |
601 | wxPen* FindOrCreatePen(const wxColour& colour, int width, int style); | |
602 | void RemovePen(wxPen* pen); | |
603 | ||
604 | int GetCount(); | |
605 | }; | |
606 | ||
607 | ||
608 | ||
609 | //---------------------------------------------------------------------- | |
610 | ||
611 | class wxBrush : public wxGDIObject { | |
612 | public: | |
613 | wxBrush(const wxColour& colour, int style=wxSOLID); | |
614 | ~wxBrush(); | |
615 | ||
616 | wxColour GetColour(); | |
617 | wxBitmap * GetStipple(); | |
618 | int GetStyle(); | |
619 | bool Ok(); | |
620 | void SetColour(wxColour &colour); | |
621 | void SetStipple(wxBitmap& bitmap); | |
622 | void SetStyle(int style); | |
623 | ||
624 | #ifdef __WXMAC__ | |
625 | short GetMacTheme(); | |
626 | void SetMacTheme(short macThemeBrush); | |
627 | #endif | |
628 | ||
629 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
630 | }; | |
631 | ||
632 | ||
633 | class wxBrushList : public wxObject { | |
634 | public: | |
635 | ||
636 | void AddBrush(wxBrush *brush); | |
637 | wxBrush * FindOrCreateBrush(const wxColour& colour, int style); | |
638 | void RemoveBrush(wxBrush *brush); | |
639 | ||
640 | int GetCount(); | |
641 | }; | |
642 | ||
643 | //---------------------------------------------------------------------- | |
644 | ||
645 | ||
646 | class wxDC : public wxObject { | |
647 | public: | |
648 | // wxDC(); **** abstract base class, can't instantiate. | |
649 | ~wxDC(); | |
650 | ||
651 | void BeginDrawing(); | |
652 | ||
653 | // %name(BlitXY) | |
654 | bool Blit(wxCoord xdest, wxCoord ydest, | |
655 | wxCoord width, wxCoord height, | |
656 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
657 | int logicalFunc = wxCOPY, int useMask = FALSE); | |
658 | // bool Blit(const wxPoint& destPt, const wxSize& sz, | |
659 | // wxDC *source, const wxPoint& srcPt, | |
660 | // int logicalFunc = wxCOPY, int useMask = FALSE); | |
661 | ||
662 | void Clear(); | |
663 | void CrossHair(wxCoord x, wxCoord y); | |
664 | void DestroyClippingRegion(); | |
665 | wxCoord DeviceToLogicalX(wxCoord x); | |
666 | wxCoord DeviceToLogicalXRel(wxCoord x); | |
667 | wxCoord DeviceToLogicalY(wxCoord y); | |
668 | wxCoord DeviceToLogicalYRel(wxCoord y); | |
669 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc); | |
670 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); | |
671 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
672 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord start, wxCoord end); | |
673 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
674 | ||
675 | void DrawLabel(const wxString& text, const wxRect& rect, | |
676 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
677 | int indexAccel = -1); | |
678 | ||
679 | %addmethods { | |
680 | wxRect DrawImageLabel(const wxString& text, | |
681 | const wxBitmap& image, | |
682 | const wxRect& rect, | |
683 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
684 | int indexAccel = -1) { | |
685 | wxRect rv; | |
686 | self->DrawLabel(text, image, rect, alignment, indexAccel, &rv); | |
687 | return rv; | |
688 | } | |
689 | } | |
690 | ||
691 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
692 | void DrawLines(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0); | |
693 | void DrawPolygon(int PCOUNT, wxPoint* points, wxCoord xoffset=0, wxCoord yoffset=0, | |
694 | int fill_style=wxODDEVEN_RULE); | |
695 | void DrawPoint(wxCoord x, wxCoord y); | |
696 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
697 | %name(DrawRectangleRect)void DrawRectangle(const wxRect& rect); | |
698 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
699 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxCoord radius=20); | |
700 | void DrawSpline(int PCOUNT, wxPoint* points); | |
701 | void DrawText(const wxString& text, wxCoord x, wxCoord y); | |
702 | void EndDoc(); | |
703 | void EndDrawing(); | |
704 | void EndPage(); | |
705 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour, int style=wxFLOOD_SURFACE); | |
706 | wxBrush GetBackground(); | |
707 | wxBrush GetBrush(); | |
708 | wxCoord GetCharHeight(); | |
709 | wxCoord GetCharWidth(); | |
710 | void GetClippingBox(wxCoord *OUTPUT, wxCoord *OUTPUT, | |
711 | wxCoord *OUTPUT, wxCoord *OUTPUT); | |
712 | wxFont GetFont(); | |
713 | int GetLogicalFunction(); | |
714 | void GetLogicalScale(double *OUTPUT, double *OUTPUT); | |
715 | int GetMapMode(); | |
716 | bool GetOptimization(); | |
717 | wxPen GetPen(); | |
718 | %addmethods { | |
719 | %new wxColour* GetPixel(wxCoord x, wxCoord y) { | |
720 | wxColour* wc = new wxColour(); | |
721 | self->GetPixel(x, y, wc); | |
722 | return wc; | |
723 | } | |
724 | } | |
725 | %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); | |
726 | wxSize GetSize(); | |
727 | wxSize GetSizeMM(); | |
728 | wxColour GetTextBackground(); | |
729 | void GetTextExtent(const wxString& string, wxCoord *OUTPUT, wxCoord *OUTPUT); | |
730 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, | |
731 | wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord* OUTPUT, | |
732 | const wxFont* font = NULL); | |
733 | void GetMultiLineTextExtent(const wxString& text, wxCoord *OUTPUT, wxCoord *OUTPUT, wxCoord *OUTPUT, | |
734 | wxFont *font = NULL); | |
735 | wxColour GetTextForeground(); | |
736 | void GetUserScale(double *OUTPUT, double *OUTPUT); | |
737 | wxCoord LogicalToDeviceX(wxCoord x); | |
738 | wxCoord LogicalToDeviceXRel(wxCoord x); | |
739 | wxCoord LogicalToDeviceY(wxCoord y); | |
740 | wxCoord LogicalToDeviceYRel(wxCoord y); | |
741 | wxCoord MaxX(); | |
742 | wxCoord MaxY(); | |
743 | wxCoord MinX(); | |
744 | wxCoord MinY(); | |
745 | bool Ok(); | |
746 | void SetDeviceOrigin(wxCoord x, wxCoord y); | |
747 | void SetBackground(const wxBrush& brush); | |
748 | void SetBackgroundMode(int mode); | |
749 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
750 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); | |
751 | %name(SetClippingRect) void SetClippingRegion(const wxRect& rect); | |
752 | void SetPalette(const wxPalette& colourMap); | |
753 | void SetBrush(const wxBrush& brush); | |
754 | void SetFont(const wxFont& font); | |
755 | void SetLogicalFunction(int function); | |
756 | void SetLogicalScale(double x, double y); | |
757 | void SetMapMode(int mode); | |
758 | void SetOptimization(bool optimize); | |
759 | void SetPen(const wxPen& pen); | |
760 | void SetTextBackground(const wxColour& colour); | |
761 | void SetTextForeground(const wxColour& colour); | |
762 | void SetUserScale(double x_scale, double y_scale); | |
763 | bool StartDoc(const wxString& message); | |
764 | void StartPage(); | |
765 | ||
766 | ||
767 | ||
768 | void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, | |
769 | int useMask = FALSE); | |
770 | ||
771 | bool CanDrawBitmap(); | |
772 | bool CanGetTextExtent(); | |
773 | int GetDepth(); | |
774 | wxSize GetPPI(); | |
775 | ||
776 | void GetLogicalOrigin(int *OUTPUT, int *OUTPUT); | |
777 | void SetLogicalOrigin(int x, int y); | |
778 | void GetDeviceOrigin(int *OUTPUT, int *OUTPUT); | |
779 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
780 | ||
781 | void CalcBoundingBox(int x, int y); | |
782 | void ResetBoundingBox(); | |
783 | ||
784 | %addmethods { | |
785 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
786 | // See below for implementation | |
787 | } | |
788 | ||
789 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
790 | ||
791 | #ifdef __WXMSW__ | |
792 | long GetHDC(); | |
793 | #endif | |
794 | ||
795 | ||
796 | %addmethods { // See drawlist.cpp for impplementaion of these... | |
797 | ||
798 | PyObject* _DrawPointList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
799 | { | |
800 | return wxPyDrawXXXList(*self, wxPyDrawXXXPoint, pyCoords, pyPens, pyBrushes); | |
801 | } | |
802 | ||
803 | PyObject* _DrawLineList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
804 | { | |
805 | return wxPyDrawXXXList(*self, wxPyDrawXXXLine, pyCoords, pyPens, pyBrushes); | |
806 | } | |
807 | ||
808 | PyObject* _DrawRectangleList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
809 | { | |
810 | return wxPyDrawXXXList(*self, wxPyDrawXXXRectangle, pyCoords, pyPens, pyBrushes); | |
811 | } | |
812 | ||
813 | PyObject* _DrawEllipseList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
814 | { | |
815 | return wxPyDrawXXXList(*self, wxPyDrawXXXEllipse, pyCoords, pyPens, pyBrushes); | |
816 | } | |
817 | ||
818 | PyObject* _DrawPolygonList(PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes) | |
819 | { | |
820 | return wxPyDrawXXXList(*self, wxPyDrawXXXPolygon, pyCoords, pyPens, pyBrushes); | |
821 | } | |
822 | ||
823 | PyObject* _DrawTextList(PyObject* textList, PyObject* pyPoints, | |
824 | PyObject* foregroundList, PyObject* backgroundList) { | |
825 | return wxPyDrawTextList(*self, textList, pyPoints, foregroundList, backgroundList); | |
826 | } | |
827 | } | |
828 | ||
829 | %pragma(python) addtoclass = " | |
830 | def DrawPointList(self, points, pens=None): | |
831 | if pens is None: | |
832 | pens = [] | |
833 | elif isinstance(pens, wxPenPtr): | |
834 | pens = [pens] | |
835 | elif len(pens) != len(points): | |
836 | raise ValueError('points and pens must have same length') | |
837 | return self._DrawPointList(points, pens, []) | |
838 | ||
839 | ||
840 | def DrawLineList(self, lines, pens=None): | |
841 | if pens is None: | |
842 | pens = [] | |
843 | elif isinstance(pens, wxPenPtr): | |
844 | pens = [pens] | |
845 | elif len(pens) != len(lines): | |
846 | raise ValueError('lines and pens must have same length') | |
847 | return self._DrawLineList(lines, pens, []) | |
848 | ||
849 | ||
850 | def DrawRectangleList(self, rectangles, pens=None, brushes=None): | |
851 | if pens is None: | |
852 | pens = [] | |
853 | elif isinstance(pens, wxPenPtr): | |
854 | pens = [pens] | |
855 | elif len(pens) != len(rectangles): | |
856 | raise ValueError('rectangles and pens must have same length') | |
857 | if brushes is None: | |
858 | brushes = [] | |
859 | elif isinstance(brushes, wxBrushPtr): | |
860 | brushes = [brushes] | |
861 | elif len(brushes) != len(rectangles): | |
862 | raise ValueError('rectangles and brushes must have same length') | |
863 | return self._DrawRectangleList(rectangles, pens, brushes) | |
864 | ||
865 | ||
866 | def DrawEllipseList(self, ellipses, pens=None, brushes=None): | |
867 | if pens is None: | |
868 | pens = [] | |
869 | elif isinstance(pens, wxPenPtr): | |
870 | pens = [pens] | |
871 | elif len(pens) != len(ellipses): | |
872 | raise ValueError('ellipses and pens must have same length') | |
873 | if brushes is None: | |
874 | brushes = [] | |
875 | elif isinstance(brushes, wxBrushPtr): | |
876 | brushes = [brushes] | |
877 | elif len(brushes) != len(ellipses): | |
878 | raise ValueError('ellipses and brushes must have same length') | |
879 | return self._DrawEllipseList(ellipses, pens, brushes) | |
880 | ||
881 | ||
882 | def DrawPolygonList(self, polygons, pens=None, brushes=None): | |
883 | ## Note: This does not currently support fill style or offset | |
884 | ## you can always use the non-List version if need be. | |
885 | ## I really would like to support fill-style, however, | |
886 | ## but wxODDEVEN_RULE does not appear to be defined at the Python level | |
887 | ## [It's in wx.py... --Robin] | |
888 | if pens is None: | |
889 | pens = [] | |
890 | elif isinstance(pens, wxPenPtr): | |
891 | pens = [pens] | |
892 | elif len(pens) != len(polygons): | |
893 | raise ValueError('polygons and pens must have same length') | |
894 | if brushes is None: | |
895 | brushes = [] | |
896 | elif isinstance(brushes, wxBrushPtr): | |
897 | brushes = [brushes] | |
898 | elif len(brushes) != len(polygons): | |
899 | raise ValueError('polygons and brushes must have same length') | |
900 | return self._DrawPolygonList(polygons, pens, brushes) | |
901 | ||
902 | ||
903 | def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None): | |
904 | ## NOTE: this does not currently support changing the font | |
905 | ## Make sure you set Background mode to wxSolid (DC.SetBackgroundMode) | |
906 | ## If you want backgounds to do anything. | |
907 | if type(textList) == type(''): | |
908 | textList = [textList] | |
909 | elif len(textList) != len(coords): | |
910 | raise ValueError('textlist and coords must have same length') | |
911 | if foregrounds is None: | |
912 | foregrounds = [] | |
913 | elif isinstance(foregrounds, wxColourPtr): | |
914 | foregrounds = [foregrounds] | |
915 | elif len(foregrounds) != len(coords): | |
916 | raise ValueError('foregrounds and coords must have same length') | |
917 | if backgrounds is None: | |
918 | backgrounds = [] | |
919 | elif isinstance(backgrounds, wxColourPtr): | |
920 | backgrounds = [backgrounds] | |
921 | elif len(backgrounds) != len(coords): | |
922 | raise ValueError('backgrounds and coords must have same length') | |
923 | return self._DrawTextList(textList, coords, foregrounds, backgrounds) | |
924 | " | |
925 | ||
926 | ||
927 | }; | |
928 | ||
929 | ||
930 | ||
931 | %{ | |
932 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
933 | *x1 = dc->MinX(); | |
934 | *y1 = dc->MinY(); | |
935 | *x2 = dc->MaxX(); | |
936 | *y2 = dc->MaxY(); | |
937 | } | |
938 | %} | |
939 | ||
940 | //---------------------------------------------------------------------- | |
941 | ||
942 | class wxMemoryDC : public wxDC { | |
943 | public: | |
944 | wxMemoryDC(); | |
945 | ||
946 | void SelectObject(const wxBitmap& bitmap); | |
947 | } | |
948 | ||
949 | %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC); | |
950 | %{ // Alternate 'constructor' | |
951 | wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) { | |
952 | return new wxMemoryDC(oldDC); | |
953 | } | |
954 | %} | |
955 | ||
956 | ||
957 | //--------------------------------------------------------------------------- | |
958 | ||
959 | class wxBufferedDC : public wxMemoryDC { | |
960 | public: | |
961 | // Construct a wxBufferedDC using a user supplied buffer. | |
962 | wxBufferedDC( wxDC *dc, const wxBitmap &buffer ); | |
963 | ||
964 | // Construct a wxBufferedDC with an internal buffer of 'area' | |
965 | // (where area is usually something like the size of the window | |
966 | // being buffered) | |
967 | %name(wxBufferedDCInternalBuffer)wxBufferedDC( wxDC *dc, const wxSize &area ); | |
968 | ||
969 | // Blits the buffer to the dc, and detaches the dc from | |
970 | // the buffer. Usually called in the dtor or by the dtor | |
971 | // of derived classes if the BufferedDC must blit before | |
972 | // the derived class (which may own the dc it's blitting | |
973 | // to) is destroyed. | |
974 | void UnMask(); | |
975 | ||
976 | ||
977 | %pragma(python) addtomethod = | |
978 | "__init__:self._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
979 | %pragma(python) addtomethod = | |
980 | "wxBufferedDCInternalBuffer:val._dc = _args[0] # save a ref so the other dc won't be deleted before self" | |
981 | }; | |
982 | ||
983 | ||
984 | class wxBufferedPaintDC : public wxBufferedDC | |
985 | { | |
986 | public: | |
987 | wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap ); | |
988 | }; | |
989 | ||
990 | //--------------------------------------------------------------------------- | |
991 | ||
992 | class wxScreenDC : public wxDC { | |
993 | public: | |
994 | wxScreenDC(); | |
995 | ||
996 | %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window); | |
997 | bool StartDrawingOnTop(wxRect* rect = NULL); | |
998 | bool EndDrawingOnTop(); | |
999 | }; | |
1000 | ||
1001 | //--------------------------------------------------------------------------- | |
1002 | ||
1003 | class wxClientDC : public wxDC { | |
1004 | public: | |
1005 | wxClientDC(wxWindow* win); | |
1006 | }; | |
1007 | ||
1008 | //--------------------------------------------------------------------------- | |
1009 | ||
1010 | class wxPaintDC : public wxDC { | |
1011 | public: | |
1012 | wxPaintDC(wxWindow* win); | |
1013 | }; | |
1014 | ||
1015 | //--------------------------------------------------------------------------- | |
1016 | ||
1017 | class wxWindowDC : public wxDC { | |
1018 | public: | |
1019 | wxWindowDC(wxWindow* win); | |
1020 | }; | |
1021 | ||
1022 | //--------------------------------------------------------------------------- | |
1023 | ||
1024 | class wxMirrorDC : public wxDC | |
1025 | { | |
1026 | public: | |
1027 | // constructs a mirror DC associated with the given real DC | |
1028 | // | |
1029 | // if mirror parameter is true, all vertical and horizontal coordinates are | |
1030 | // exchanged, otherwise this class behaves in exactly the same way as a | |
1031 | // plain DC | |
1032 | // | |
1033 | wxMirrorDC(wxDC& dc, bool mirror); | |
1034 | }; | |
1035 | ||
1036 | //--------------------------------------------------------------------------- | |
1037 | ||
1038 | ||
1039 | #ifdef __WXMSW__ | |
1040 | ||
1041 | %{ | |
1042 | #include <wx/metafile.h> | |
1043 | %} | |
1044 | ||
1045 | class wxMetaFile : public wxObject { | |
1046 | public: | |
1047 | wxMetaFile(const wxString& filename = wxPyEmptyString); | |
1048 | ~wxMetaFile(); | |
1049 | ||
1050 | bool Ok(); | |
1051 | bool SetClipboard(int width = 0, int height = 0); | |
1052 | ||
1053 | wxSize GetSize(); | |
1054 | int GetWidth(); | |
1055 | int GetHeight(); | |
1056 | ||
1057 | const wxString& GetFileName() const { return m_filename; } | |
1058 | ||
1059 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
1060 | }; | |
1061 | ||
1062 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
1063 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
1064 | ||
1065 | ||
1066 | class wxMetaFileDC : public wxDC { | |
1067 | public: | |
1068 | wxMetaFileDC(const wxString& filename = wxPyEmptyString, | |
1069 | int width = 0, int height = 0, | |
1070 | const wxString& description = wxPyEmptyString); | |
1071 | wxMetaFile* Close(); | |
1072 | }; | |
1073 | ||
1074 | #endif | |
1075 | ||
1076 | //--------------------------------------------------------------------------- | |
1077 | ||
1078 | class wxPalette : public wxGDIObject { | |
1079 | public: | |
1080 | wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); | |
1081 | ~wxPalette(); | |
1082 | ||
1083 | int GetPixel(byte red, byte green, byte blue); | |
1084 | bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); | |
1085 | bool Ok(); | |
1086 | ||
1087 | %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()" | |
1088 | }; | |
1089 | ||
1090 | //--------------------------------------------------------------------------- | |
1091 | ||
1092 | enum { | |
1093 | wxIMAGELIST_DRAW_NORMAL , | |
1094 | wxIMAGELIST_DRAW_TRANSPARENT, | |
1095 | wxIMAGELIST_DRAW_SELECTED, | |
1096 | wxIMAGELIST_DRAW_FOCUSED, | |
1097 | wxIMAGE_LIST_NORMAL, | |
1098 | wxIMAGE_LIST_SMALL, | |
1099 | wxIMAGE_LIST_STATE | |
1100 | }; | |
1101 | ||
1102 | class wxImageList : public wxObject { | |
1103 | public: | |
1104 | wxImageList(int width, int height, int mask=TRUE, int initialCount=1); | |
1105 | ~wxImageList(); | |
1106 | ||
1107 | int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1108 | %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
1109 | %name(AddIcon)int Add(const wxIcon& icon); | |
1110 | #ifdef __WXMSW__ | |
1111 | bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1112 | #else | |
1113 | // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon); | |
1114 | // int Add(const wxBitmap& bitmap); | |
1115 | bool Replace(int index, const wxBitmap& bitmap); | |
1116 | #endif | |
1117 | ||
1118 | bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL, | |
1119 | const bool solidBackground = FALSE); | |
1120 | ||
1121 | int GetImageCount(); | |
1122 | bool Remove(int index); | |
1123 | bool RemoveAll(); | |
1124 | void GetSize(int index, int& OUTPUT, int& OUTPUT); | |
1125 | }; | |
1126 | ||
1127 | ||
1128 | //--------------------------------------------------------------------------- | |
1129 | // Regions, etc. | |
1130 | ||
1131 | enum wxRegionContain { | |
1132 | wxOutRegion, wxPartRegion, wxInRegion | |
1133 | }; | |
1134 | ||
1135 | ||
1136 | class wxRegion : public wxGDIObject { | |
1137 | public: | |
1138 | wxRegion(wxCoord x=0, wxCoord y=0, wxCoord width=0, wxCoord height=0); | |
1139 | #ifndef __WXMAC__ | |
1140 | %name(wxRegionFromPoints)wxRegion(int PCOUNT, wxPoint* points, int fillStyle = wxWINDING_RULE); | |
1141 | #endif | |
1142 | %name(wxRegionFromBitmap)wxRegion(const wxBitmap& bmp, | |
1143 | const wxColour& transColour = wxNullColour, | |
1144 | int tolerance = 0); | |
1145 | ~wxRegion(); | |
1146 | ||
1147 | ||
1148 | void Clear(); | |
1149 | #ifndef __WXMAC__ | |
1150 | bool Offset(wxCoord x, wxCoord y); | |
1151 | #endif | |
1152 | ||
1153 | wxRegionContain Contains(wxCoord x, wxCoord y); | |
1154 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); | |
1155 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
1156 | %name(ContainsRectDim)wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h); | |
1157 | ||
1158 | wxRect GetBox(); | |
1159 | ||
1160 | bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
1161 | %name(IntersectRect)bool Intersect(const wxRect& rect); | |
1162 | %name(IntersectRegion)bool Intersect(const wxRegion& region); | |
1163 | ||
1164 | bool IsEmpty(); | |
1165 | ||
1166 | bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
1167 | %name(UnionRect)bool Union(const wxRect& rect); | |
1168 | %name(UnionRegion)bool Union(const wxRegion& region); | |
1169 | ||
1170 | bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
1171 | %name(SubtractRect)bool Subtract(const wxRect& rect); | |
1172 | %name(SubtractRegion)bool Subtract(const wxRegion& region); | |
1173 | ||
1174 | bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
1175 | %name(XorRect)bool Xor(const wxRect& rect); | |
1176 | %name(XorRegion)bool Xor(const wxRegion& region); | |
1177 | ||
1178 | // Convert the region to a B&W bitmap with the white pixels being inside | |
1179 | // the region. | |
1180 | wxBitmap ConvertToBitmap(); | |
1181 | ||
1182 | // Use the non-transparent pixels of a wxBitmap for the region to combine | |
1183 | // with this region. If the bitmap has a mask then it will be used, | |
1184 | // otherwise the colour to be treated as transparent may be specified, | |
1185 | // along with an optional tolerance value. | |
1186 | %name(UnionBitmap)bool Union(const wxBitmap& bmp, | |
1187 | const wxColour& transColour = wxNullColour, | |
1188 | int tolerance = 0); | |
1189 | }; | |
1190 | ||
1191 | ||
1192 | ||
1193 | class wxRegionIterator : public wxObject { | |
1194 | public: | |
1195 | wxRegionIterator(const wxRegion& region); | |
1196 | ~wxRegionIterator(); | |
1197 | ||
1198 | wxCoord GetX(); | |
1199 | wxCoord GetY(); | |
1200 | wxCoord GetW(); | |
1201 | wxCoord GetWidth(); | |
1202 | wxCoord GetH(); | |
1203 | wxCoord GetHeight(); | |
1204 | wxRect GetRect(); | |
1205 | bool HaveRects(); | |
1206 | void Reset(); | |
1207 | ||
1208 | %addmethods { | |
1209 | void Next() { | |
1210 | (*self) ++; | |
1211 | } | |
1212 | ||
1213 | bool __nonzero__() { | |
1214 | return self->operator bool(); | |
1215 | } | |
1216 | }; | |
1217 | }; | |
1218 | ||
1219 | ||
1220 | //--------------------------------------------------------------------------- | |
1221 | ||
1222 | ||
1223 | %readonly | |
1224 | %{ | |
1225 | #if 0 | |
1226 | %} | |
1227 | ||
1228 | // See also wxPy_ReinitStockObjects in helpers.cpp | |
1229 | ||
1230 | extern wxFont *wxNORMAL_FONT; | |
1231 | extern wxFont *wxSMALL_FONT; | |
1232 | extern wxFont *wxITALIC_FONT; | |
1233 | extern wxFont *wxSWISS_FONT; | |
1234 | ||
1235 | extern wxPen *wxRED_PEN; | |
1236 | extern wxPen *wxCYAN_PEN; | |
1237 | extern wxPen *wxGREEN_PEN; | |
1238 | extern wxPen *wxBLACK_PEN; | |
1239 | extern wxPen *wxWHITE_PEN; | |
1240 | extern wxPen *wxTRANSPARENT_PEN; | |
1241 | extern wxPen *wxBLACK_DASHED_PEN; | |
1242 | extern wxPen *wxGREY_PEN; | |
1243 | extern wxPen *wxMEDIUM_GREY_PEN; | |
1244 | extern wxPen *wxLIGHT_GREY_PEN; | |
1245 | ||
1246 | extern wxBrush *wxBLUE_BRUSH; | |
1247 | extern wxBrush *wxGREEN_BRUSH; | |
1248 | extern wxBrush *wxWHITE_BRUSH; | |
1249 | extern wxBrush *wxBLACK_BRUSH; | |
1250 | extern wxBrush *wxTRANSPARENT_BRUSH; | |
1251 | extern wxBrush *wxCYAN_BRUSH; | |
1252 | extern wxBrush *wxRED_BRUSH; | |
1253 | extern wxBrush *wxGREY_BRUSH; | |
1254 | extern wxBrush *wxMEDIUM_GREY_BRUSH; | |
1255 | extern wxBrush *wxLIGHT_GREY_BRUSH; | |
1256 | ||
1257 | extern wxColour *wxBLACK; | |
1258 | extern wxColour *wxWHITE; | |
1259 | extern wxColour *wxRED; | |
1260 | extern wxColour *wxBLUE; | |
1261 | extern wxColour *wxGREEN; | |
1262 | extern wxColour *wxCYAN; | |
1263 | extern wxColour *wxLIGHT_GREY; | |
1264 | ||
1265 | extern wxCursor *wxSTANDARD_CURSOR; | |
1266 | extern wxCursor *wxHOURGLASS_CURSOR; | |
1267 | extern wxCursor *wxCROSS_CURSOR; | |
1268 | ||
1269 | ||
1270 | extern wxBitmap wxNullBitmap; | |
1271 | extern wxIcon wxNullIcon; | |
1272 | extern wxCursor wxNullCursor; | |
1273 | extern wxPen wxNullPen; | |
1274 | extern wxBrush wxNullBrush; | |
1275 | extern wxPalette wxNullPalette; | |
1276 | extern wxFont wxNullFont; | |
1277 | extern wxColour wxNullColour; | |
1278 | ||
1279 | ||
1280 | extern wxFontList* wxTheFontList; | |
1281 | extern wxPenList* wxThePenList; | |
1282 | extern wxBrushList* wxTheBrushList; | |
1283 | extern wxColourDatabase* wxTheColourDatabase; | |
1284 | ||
1285 | ||
1286 | %readwrite | |
1287 | %{ | |
1288 | #endif | |
1289 | %} | |
1290 | ||
1291 | //--------------------------------------------------------------------------- | |
1292 | //--------------------------------------------------------------------------- | |
1293 |