]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gdi.i | |
3 | // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, 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 | ||
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> | |
7bf85405 RD |
23 | %} |
24 | ||
25 | //---------------------------------------------------------------------- | |
26 | ||
27 | %include typemaps.i | |
28 | %include my_typemaps.i | |
29 | ||
30 | // Import some definitions of other classes, etc. | |
31 | %import _defs.i | |
32 | %import misc.i | |
33 | ||
b68dc582 RD |
34 | %{ |
35 | static wxString wxPyEmptyStr(""); | |
36 | %} | |
37 | ||
7bf85405 RD |
38 | //--------------------------------------------------------------------------- |
39 | ||
9416aa89 RD |
40 | class wxGDIObject : public wxObject { |
41 | public: | |
42 | wxGDIObject(); | |
43 | ~wxGDIObject(); | |
44 | ||
45 | bool GetVisible(); | |
46 | void SetVisible( bool visible ); | |
47 | ||
48 | bool IsNull(); | |
49 | ||
50 | }; | |
6999b0d8 RD |
51 | |
52 | //--------------------------------------------------------------------------- | |
53 | ||
9416aa89 | 54 | class wxBitmap : public wxGDIObject |
5bff6bb8 | 55 | { |
7bf85405 | 56 | public: |
e6056257 | 57 | wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP); |
7bf85405 RD |
58 | ~wxBitmap(); |
59 | ||
7bf85405 RD |
60 | wxPalette* GetPalette(); |
61 | wxMask* GetMask(); | |
e6056257 RD |
62 | bool LoadFile(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP); |
63 | bool SaveFile(const wxString& name, wxBitmapType type, wxPalette* palette = NULL); | |
7bf85405 | 64 | void SetMask(wxMask* mask); |
fb5e0af0 | 65 | #ifdef __WXMSW__ |
b8b8dda7 | 66 | void SetPalette(wxPalette& palette); |
fb5e0af0 | 67 | #endif |
5bff6bb8 RD |
68 | |
69 | // wxGDIImage methods | |
70 | #ifdef __WXMSW__ | |
71 | long GetHandle(); | |
72 | void SetHandle(long handle); | |
73 | #endif | |
74 | bool Ok(); | |
75 | int GetWidth(); | |
76 | int GetHeight(); | |
77 | int GetDepth(); | |
78 | void SetWidth(int w); | |
79 | void SetHeight(int h); | |
80 | void SetDepth(int d); | |
81 | #ifdef __WXMSW__ | |
82 | void SetSize(const wxSize& size); | |
83 | #endif | |
f6bcfd97 BP |
84 | |
85 | wxBitmap GetSubBitmap( const wxRect& rect ); | |
f6bcfd97 | 86 | bool CopyFromIcon(const wxIcon& icon); |
ecc08ead | 87 | #ifdef __WXMSW__ |
f6bcfd97 BP |
88 | bool CopyFromCursor(const wxCursor& cursor); |
89 | int GetQuality(); | |
90 | void SetQuality(int q); | |
91 | #endif | |
92 | ||
93 | %pragma(python) addtoclass = " | |
94 | def __del__(self,gdic=gdic): | |
95 | try: | |
96 | if self.thisown == 1 : | |
97 | gdic.delete_wxBitmap(self) | |
98 | except: | |
99 | pass | |
100 | " | |
7bf85405 RD |
101 | }; |
102 | ||
5bff6bb8 | 103 | |
96bfd053 | 104 | // Declarations of some alternate "constructors" |
7bf85405 | 105 | %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); |
96bfd053 RD |
106 | %new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); |
107 | %new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); | |
d56cebe7 | 108 | %new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ); |
9c039d08 | 109 | |
d56cebe7 RD |
110 | // #ifdef __WXMSW__ |
111 | // %new wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
112 | // int width, int height, int depth = 1); | |
113 | // #endif | |
8bf5d46e | 114 | |
96bfd053 RD |
115 | |
116 | ||
117 | %{ // Implementations of some alternate "constructors" | |
118 | ||
7bf85405 RD |
119 | wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) { |
120 | return new wxBitmap(width, height, depth); | |
121 | } | |
122 | ||
96bfd053 RD |
123 | static char** ConvertListOfStrings(PyObject* listOfStrings) { |
124 | char** cArray = NULL; | |
125 | int count; | |
126 | ||
127 | if (!PyList_Check(listOfStrings)) { | |
128 | PyErr_SetString(PyExc_TypeError, "Expected a list of strings."); | |
129 | return NULL; | |
130 | } | |
131 | count = PyList_Size(listOfStrings); | |
132 | cArray = new char*[count]; | |
133 | ||
134 | for(int x=0; x<count; x++) { | |
135 | // TODO: Need some validation and error checking here | |
136 | cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x)); | |
137 | } | |
138 | return cArray; | |
139 | } | |
140 | ||
d56cebe7 | 141 | |
96bfd053 RD |
142 | wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) { |
143 | char** cArray = NULL; | |
144 | wxBitmap* bmp; | |
145 | ||
146 | cArray = ConvertListOfStrings(listOfStrings); | |
147 | if (! cArray) | |
148 | return NULL; | |
149 | bmp = new wxBitmap(cArray); | |
150 | delete [] cArray; | |
151 | return bmp; | |
152 | } | |
153 | ||
154 | ||
155 | wxBitmap* wxBitmapFromIcon(const wxIcon& icon) { | |
156 | return new wxBitmap(icon); | |
157 | } | |
158 | ||
159 | ||
d56cebe7 RD |
160 | wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) { |
161 | return new wxBitmap(bits, width, height, depth); | |
162 | } | |
926bb76c | 163 | |
4c9993c3 | 164 | |
d56cebe7 RD |
165 | // #ifdef __WXMSW__ |
166 | // wxBitmap* wxBitmapFromData(PyObject* data, long type, | |
167 | // int width, int height, int depth = 1) { | |
168 | // if (! PyString_Check(data)) { | |
169 | // PyErr_SetString(PyExc_TypeError, "Expected string object"); | |
170 | // return NULL; | |
171 | // } | |
172 | // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth); | |
173 | // } | |
174 | // #endif | |
7bf85405 RD |
175 | %} |
176 | ||
177 | //--------------------------------------------------------------------------- | |
178 | ||
9416aa89 | 179 | class wxMask : public wxObject { |
7bf85405 RD |
180 | public: |
181 | wxMask(const wxBitmap& bitmap); | |
eb715945 | 182 | //~wxMask(); |
96bfd053 RD |
183 | |
184 | %addmethods { void Destroy() { delete self; } } | |
7bf85405 RD |
185 | }; |
186 | ||
187 | %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour); | |
188 | %{ | |
189 | wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) { | |
190 | return new wxMask(bitmap, colour); | |
191 | } | |
192 | %} | |
193 | ||
194 | ||
195 | //--------------------------------------------------------------------------- | |
196 | ||
197 | ||
9416aa89 | 198 | class wxIcon : public wxGDIObject |
5bff6bb8 | 199 | { |
7bf85405 | 200 | public: |
fb5e0af0 RD |
201 | wxIcon(const wxString& name, long flags, |
202 | int desiredWidth = -1, int desiredHeight = -1); | |
7bf85405 RD |
203 | ~wxIcon(); |
204 | ||
6abe8375 | 205 | #ifndef __WXMAC__ |
7bf85405 | 206 | bool LoadFile(const wxString& name, long flags); |
6abe8375 | 207 | #endif |
5bff6bb8 RD |
208 | |
209 | // wxGDIImage methods | |
210 | #ifdef __WXMSW__ | |
211 | long GetHandle(); | |
212 | void SetHandle(long handle); | |
213 | #endif | |
214 | bool Ok(); | |
215 | int GetWidth(); | |
216 | int GetHeight(); | |
217 | int GetDepth(); | |
218 | void SetWidth(int w); | |
219 | void SetHeight(int h); | |
220 | void SetDepth(int d); | |
221 | #ifdef __WXMSW__ | |
222 | void SetSize(const wxSize& size); | |
223 | #endif | |
96bfd053 RD |
224 | void CopyFromBitmap(const wxBitmap& bmp); |
225 | ||
f6bcfd97 BP |
226 | %pragma(python) addtoclass = " |
227 | def __del__(self,gdic=gdic): | |
228 | try: | |
229 | if self.thisown == 1 : | |
230 | gdic.delete_wxIcon(self) | |
231 | except: | |
232 | pass | |
233 | " | |
7bf85405 RD |
234 | }; |
235 | ||
8bf5d46e | 236 | |
96bfd053 RD |
237 | // Declarations of some alternate "constructors" |
238 | %new wxIcon* wxEmptyIcon(); | |
239 | %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); | |
240 | ||
241 | %{ // Implementations of some alternate "constructors" | |
242 | wxIcon* wxEmptyIcon() { | |
243 | return new wxIcon(); | |
244 | } | |
245 | ||
246 | wxIcon* wxIconFromXPMData(PyObject* listOfStrings) { | |
247 | char** cArray = NULL; | |
248 | wxIcon* icon; | |
249 | ||
250 | cArray = ConvertListOfStrings(listOfStrings); | |
251 | if (! cArray) | |
252 | return NULL; | |
253 | icon = new wxIcon(cArray); | |
254 | delete [] cArray; | |
255 | return icon; | |
256 | } | |
257 | %} | |
258 | ||
7bf85405 RD |
259 | //--------------------------------------------------------------------------- |
260 | ||
9416aa89 | 261 | class wxCursor : public wxGDIObject |
5bff6bb8 | 262 | { |
7bf85405 | 263 | public: |
fb5e0af0 | 264 | #ifdef __WXMSW__ |
7bf85405 | 265 | wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0); |
fb5e0af0 | 266 | #endif |
7bf85405 | 267 | ~wxCursor(); |
5bff6bb8 RD |
268 | |
269 | // wxGDIImage methods | |
270 | #ifdef __WXMSW__ | |
271 | long GetHandle(); | |
272 | void SetHandle(long handle); | |
273 | #endif | |
274 | bool Ok(); | |
275 | #ifdef __WXMSW__ | |
276 | int GetWidth(); | |
277 | int GetHeight(); | |
278 | int GetDepth(); | |
279 | void SetWidth(int w); | |
280 | void SetHeight(int h); | |
281 | void SetDepth(int d); | |
282 | void SetSize(const wxSize& size); | |
283 | #endif | |
7bf85405 RD |
284 | }; |
285 | ||
9c039d08 | 286 | %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); |
7bf85405 | 287 | %{ // Alternate 'constructor' |
9c039d08 | 288 | wxCursor* wxPyStockCursor(int id) { |
7bf85405 RD |
289 | return new wxCursor(id); |
290 | } | |
291 | %} | |
292 | ||
293 | //---------------------------------------------------------------------- | |
294 | ||
f0261a72 | 295 | |
6d8b4f8d RD |
296 | enum wxFontFamily |
297 | { | |
298 | wxFONTFAMILY_DEFAULT = wxDEFAULT, | |
299 | wxFONTFAMILY_DECORATIVE = wxDECORATIVE, | |
300 | wxFONTFAMILY_ROMAN = wxROMAN, | |
301 | wxFONTFAMILY_SCRIPT = wxSCRIPT, | |
302 | wxFONTFAMILY_SWISS = wxSWISS, | |
303 | wxFONTFAMILY_MODERN = wxMODERN, | |
304 | wxFONTFAMILY_TELETYPE = wxTELETYPE, | |
ce914f73 RD |
305 | wxFONTFAMILY_MAX, |
306 | wxFONTFAMILY_UNKNOWN | |
6d8b4f8d RD |
307 | }; |
308 | ||
309 | // font styles | |
310 | enum wxFontStyle | |
311 | { | |
312 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
313 | wxFONTSTYLE_ITALIC = wxITALIC, | |
314 | wxFONTSTYLE_SLANT = wxSLANT, | |
315 | wxFONTSTYLE_MAX | |
316 | }; | |
317 | ||
318 | // font weights | |
319 | enum wxFontWeight | |
320 | { | |
321 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
322 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
323 | wxFONTWEIGHT_BOLD = wxBOLD, | |
324 | wxFONTWEIGHT_MAX | |
325 | }; | |
326 | ||
327 | ||
328 | // font encodings | |
f0261a72 RD |
329 | enum wxFontEncoding |
330 | { | |
331 | wxFONTENCODING_SYSTEM = -1, // system default | |
332 | wxFONTENCODING_DEFAULT, // current default encoding | |
333 | ||
334 | // ISO8859 standard defines a number of single-byte charsets | |
335 | wxFONTENCODING_ISO8859_1, // West European (Latin1) | |
336 | wxFONTENCODING_ISO8859_2, // Central and East European (Latin2) | |
337 | wxFONTENCODING_ISO8859_3, // Esperanto (Latin3) | |
6d8b4f8d | 338 | wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4) |
f0261a72 RD |
339 | wxFONTENCODING_ISO8859_5, // Cyrillic |
340 | wxFONTENCODING_ISO8859_6, // Arabic | |
341 | wxFONTENCODING_ISO8859_7, // Greek | |
342 | wxFONTENCODING_ISO8859_8, // Hebrew | |
343 | wxFONTENCODING_ISO8859_9, // Turkish (Latin5) | |
344 | wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6) | |
345 | wxFONTENCODING_ISO8859_11, // Thai | |
346 | wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it | |
347 | // here anyhow to make all ISO8859 | |
348 | // consecutive numbers | |
6d8b4f8d | 349 | wxFONTENCODING_ISO8859_13, // Baltic (Latin7) |
f0261a72 RD |
350 | wxFONTENCODING_ISO8859_14, // Latin8 |
351 | wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) | |
6d8b4f8d | 352 | wxFONTENCODING_ISO8859_MAX, |
f0261a72 RD |
353 | |
354 | // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html) | |
355 | wxFONTENCODING_KOI8, // we don't support any of KOI8 variants | |
356 | wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866 | |
357 | wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria | |
358 | ||
359 | // what would we do without Microsoft? They have their own encodings | |
360 | // for DOS | |
361 | wxFONTENCODING_CP437, // original MS-DOS codepage | |
362 | wxFONTENCODING_CP850, // CP437 merged with Latin1 | |
363 | wxFONTENCODING_CP852, // CP437 merged with Latin2 | |
364 | wxFONTENCODING_CP855, // another cyrillic encoding | |
365 | wxFONTENCODING_CP866, // and another one | |
366 | // and for Windows | |
6d8b4f8d | 367 | wxFONTENCODING_CP874, // WinThai |
98624b49 RD |
368 | wxFONTENCODING_CP932, // Japanese (shift-JIS) |
369 | wxFONTENCODING_CP936, // Chiniese simplified (GB) | |
370 | wxFONTENCODING_CP949, // Korean (Hangul charset) | |
371 | wxFONTENCODING_CP950, // Chinese (traditional - Big5) | |
f0261a72 RD |
372 | wxFONTENCODING_CP1250, // WinLatin2 |
373 | wxFONTENCODING_CP1251, // WinCyrillic | |
374 | wxFONTENCODING_CP1252, // WinLatin1 | |
6d8b4f8d RD |
375 | wxFONTENCODING_CP1253, // WinGreek (8859-7) |
376 | wxFONTENCODING_CP1254, // WinTurkish | |
377 | wxFONTENCODING_CP1255, // WinHebrew | |
378 | wxFONTENCODING_CP1256, // WinArabic | |
379 | wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) | |
380 | wxFONTENCODING_CP12_MAX, | |
381 | ||
382 | wxFONTENCODING_UTF7, // UTF-7 Unicode encoding | |
383 | wxFONTENCODING_UTF8, // UTF-8 Unicode encoding | |
384 | ||
385 | wxFONTENCODING_UNICODE, // Unicode - currently used only by | |
386 | // wxEncodingConverter class | |
f0261a72 RD |
387 | |
388 | wxFONTENCODING_MAX | |
389 | }; | |
390 | ||
0569df0f | 391 | |
6d8b4f8d RD |
392 | |
393 | // wxNativeFontInfo is platform-specific font representation: this struct | |
394 | // should be considered as opaque font description only used by the native | |
395 | // functions, the user code can only get the objects of this type from | |
396 | // somewhere and pass it somewhere else (possibly save them somewhere using | |
397 | // ToString() and restore them using FromString()) | |
398 | struct wxNativeFontInfo | |
399 | { | |
b5a5d647 RD |
400 | #ifdef __WXGTK__ |
401 | // init the elements from an XLFD, return TRUE if ok | |
402 | bool FromXFontName(const wxString& xFontName); | |
403 | ||
ce914f73 RD |
404 | // return false if we were never initialized with a valid XLFD |
405 | bool IsDefault() const; | |
406 | ||
b5a5d647 RD |
407 | // generate an XLFD using the fontElements |
408 | wxString GetXFontName() const; | |
ce914f73 RD |
409 | |
410 | // set the XFLD | |
411 | void SetXFontName(const wxString& xFontName); | |
b5a5d647 RD |
412 | #endif |
413 | ||
414 | wxNativeFontInfo() { Init(); } | |
415 | ||
416 | // reset to the default state | |
417 | void Init(); | |
418 | ||
1893b029 | 419 | #ifndef __WXGTK__ |
b5a5d647 RD |
420 | // accessors and modifiers for the font elements |
421 | int GetPointSize() const; | |
422 | wxFontStyle GetStyle() const; | |
423 | wxFontWeight GetWeight() const; | |
424 | bool GetUnderlined() const; | |
425 | wxString GetFaceName() const; | |
426 | wxFontFamily GetFamily() const; | |
427 | wxFontEncoding GetEncoding() const; | |
428 | ||
429 | void SetPointSize(int pointsize); | |
430 | void SetStyle(wxFontStyle style); | |
431 | void SetWeight(wxFontWeight weight); | |
432 | void SetUnderlined(bool underlined); | |
433 | void SetFaceName(wxString facename); | |
434 | void SetFamily(wxFontFamily family); | |
435 | void SetEncoding(wxFontEncoding encoding); | |
1893b029 | 436 | #endif |
b5a5d647 | 437 | |
6d8b4f8d RD |
438 | // it is important to be able to serialize wxNativeFontInfo objects to be |
439 | // able to store them (in config file, for example) | |
440 | bool FromString(const wxString& s); | |
441 | wxString ToString() const; | |
442 | ||
443 | %addmethods { | |
444 | wxString __str__() { | |
445 | return self->ToString(); | |
446 | } | |
447 | } | |
b5a5d647 RD |
448 | |
449 | // we also want to present the native font descriptions to the user in some | |
450 | // human-readable form (it is not platform independent neither, but can | |
451 | // hopefully be understood by the user) | |
452 | bool FromUserString(const wxString& s); | |
453 | wxString ToUserString() const; | |
6d8b4f8d RD |
454 | }; |
455 | ||
456 | ||
457 | // wxFontMapper manages user-definable correspondence between logical font | |
458 | // names and the fonts present on the machine. | |
459 | // | |
460 | // The default implementations of all functions will ask the user if they are | |
461 | // not capable of finding the answer themselves and store the answer in a | |
462 | // config file (configurable via SetConfigXXX functions). This behaviour may | |
463 | // be disabled by giving the value of FALSE to "interactive" parameter. | |
464 | // However, the functions will always consult the config file to allow the | |
465 | // user-defined values override the default logic and there is no way to | |
466 | // disable this - which shouldn't be ever needed because if "interactive" was | |
467 | // never TRUE, the config file is never created anyhow. | |
468 | class wxFontMapper | |
469 | { | |
470 | public: | |
471 | wxFontMapper(); | |
472 | ~wxFontMapper(); | |
473 | ||
474 | ||
475 | // find an alternative for the given encoding (which is supposed to not be | |
476 | // available on this system). If successful, return TRUE and rwxFontEcoding | |
477 | // that can be used it wxFont ctor otherwise return FALSE | |
478 | //bool GetAltForEncoding(wxFontEncoding encoding, | |
479 | // wxFontEncoding *alt_encoding, | |
480 | // const wxString& facename = wxEmptyString, | |
481 | // bool interactive = TRUE); | |
482 | ||
483 | ||
484 | // Find an alternative for the given encoding (which is supposed to not be | |
485 | // available on this system). If successful, returns the encoding otherwise | |
486 | // returns None. | |
487 | %addmethods { | |
488 | PyObject* GetAltForEncoding(wxFontEncoding encoding, | |
489 | const wxString& facename = wxEmptyString, | |
490 | bool interactive = TRUE) { | |
491 | wxFontEncoding alt_enc; | |
492 | if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive)) | |
493 | return PyInt_FromLong(alt_enc); | |
494 | else { | |
495 | Py_INCREF(Py_None); | |
496 | return Py_None; | |
497 | } | |
498 | } | |
499 | } | |
500 | ||
501 | ||
502 | // checks whether given encoding is available in given face or not. | |
503 | // If no facename is given, | |
504 | bool IsEncodingAvailable(wxFontEncoding encoding, | |
505 | const wxString& facename = wxEmptyString); | |
506 | ||
507 | // returns the encoding for the given charset (in the form of RFC 2046) or | |
508 | // wxFONTENCODING_SYSTEM if couldn't decode it | |
509 | wxFontEncoding CharsetToEncoding(const wxString& charset, | |
510 | bool interactive = TRUE); | |
511 | ||
512 | // return internal string identifier for the encoding (see also | |
513 | // GetEncodingDescription()) | |
514 | static wxString GetEncodingName(wxFontEncoding encoding); | |
515 | ||
516 | // return user-readable string describing the given encoding | |
517 | // | |
518 | // NB: hard-coded now, but might change later (read it from config?) | |
519 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
520 | ||
521 | // the parent window for modal dialogs | |
522 | void SetDialogParent(wxWindow *parent); | |
523 | ||
524 | // the title for the dialogs (note that default is quite reasonable) | |
525 | void SetDialogTitle(const wxString& title); | |
526 | ||
527 | // functions which allow to configure the config object used: by default, | |
528 | // the global one (from wxConfigBase::Get() will be used) and the default | |
529 | // root path for the config settings is the string returned by | |
530 | // GetDefaultConfigPath() | |
531 | ||
532 | ||
533 | // set the config object to use (may be NULL to use default) | |
534 | void SetConfig(wxConfigBase *config); | |
535 | ||
536 | // set the root config path to use (should be an absolute path) | |
537 | void SetConfigPath(const wxString& prefix); | |
538 | ||
539 | // return default config path | |
540 | static const wxChar *GetDefaultConfigPath(); | |
541 | }; | |
542 | ||
543 | ||
544 | ||
545 | ||
9416aa89 | 546 | class wxFont : public wxGDIObject { |
7bf85405 | 547 | public: |
0569df0f RD |
548 | wxFont( int pointSize, int family, int style, int weight, |
549 | int underline=FALSE, char* faceName = "", | |
550 | wxFontEncoding encoding=wxFONTENCODING_DEFAULT); | |
6d8b4f8d RD |
551 | |
552 | %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info); | |
553 | ||
0569df0f | 554 | ~wxFont(); |
7bf85405 | 555 | |
6d8b4f8d RD |
556 | bool Ok() const; |
557 | int GetPointSize() const; | |
558 | int GetFamily() const; | |
559 | int GetStyle() const; | |
560 | int GetWeight() const; | |
561 | bool GetUnderlined() const; | |
562 | wxString GetFaceName() const; | |
563 | wxFontEncoding GetEncoding() const; | |
68320e40 RD |
564 | |
565 | bool IsFixedWidth(); | |
566 | ||
6d8b4f8d | 567 | wxNativeFontInfo* GetNativeFontInfo() const; |
b5a5d647 RD |
568 | wxString GetNativeFontInfoDesc() const; |
569 | wxString GetNativeFontInfoUserDesc() const; | |
6d8b4f8d | 570 | |
7bf85405 | 571 | void SetPointSize(int pointSize); |
6d8b4f8d | 572 | void SetFamily(int family); |
7bf85405 | 573 | void SetStyle(int style); |
7bf85405 | 574 | void SetWeight(int weight); |
6d8b4f8d RD |
575 | void SetFaceName(const wxString& faceName); |
576 | void SetUnderlined(bool underlined); | |
f0261a72 | 577 | void SetEncoding(wxFontEncoding encoding); |
6d8b4f8d | 578 | void SetNativeFontInfo(const wxNativeFontInfo& info); |
b5a5d647 RD |
579 | // void SetNativeFontInfo(const wxString& info); |
580 | void SetNativeFontInfoUserDesc(const wxString& info); | |
7bf85405 | 581 | |
6d8b4f8d RD |
582 | wxString GetFamilyString() const; |
583 | wxString GetStyleString() const; | |
584 | wxString GetWeightString() const; | |
f0261a72 | 585 | |
6d8b4f8d RD |
586 | static wxFontEncoding GetDefaultEncoding(); |
587 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
588 | ||
589 | }; | |
f0261a72 | 590 | |
0569df0f | 591 | |
9416aa89 | 592 | class wxFontList : public wxObject { |
0569df0f RD |
593 | public: |
594 | ||
595 | void AddFont(wxFont* font); | |
596 | wxFont * FindOrCreateFont(int point_size, int family, int style, int weight, | |
597 | bool underline = FALSE, const char* facename = NULL, | |
598 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
599 | void RemoveFont(wxFont *font); | |
2f4e9287 RD |
600 | |
601 | int GetCount(); | |
0569df0f RD |
602 | }; |
603 | ||
604 | ||
7bf85405 RD |
605 | //---------------------------------------------------------------------- |
606 | ||
9416aa89 | 607 | class wxColour : public wxObject { |
7bf85405 RD |
608 | public: |
609 | wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0); | |
610 | ~wxColour(); | |
611 | unsigned char Red(); | |
612 | unsigned char Green(); | |
613 | unsigned char Blue(); | |
614 | bool Ok(); | |
615 | void Set(unsigned char red, unsigned char green, unsigned char blue); | |
616 | %addmethods { | |
617 | PyObject* Get() { | |
618 | PyObject* rv = PyTuple_New(3); | |
619 | PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red())); | |
620 | PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green())); | |
621 | PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue())); | |
622 | return rv; | |
623 | } | |
624 | } | |
9b3d3bc4 RD |
625 | %pragma(python) addtoclass = "asTuple = Get" |
626 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
627 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
628 | ||
7bf85405 RD |
629 | }; |
630 | ||
631 | %new wxColour* wxNamedColour(const wxString& colorName); | |
de20db99 | 632 | |
7bf85405 RD |
633 | %{ // Alternate 'constructor' |
634 | wxColour* wxNamedColour(const wxString& colorName) { | |
635 | return new wxColour(colorName); | |
636 | } | |
637 | %} | |
638 | ||
639 | ||
7bf85405 | 640 | |
9416aa89 | 641 | class wxColourDatabase : public wxObject { |
7bf85405 | 642 | public: |
0569df0f RD |
643 | |
644 | wxColour *FindColour(const wxString& colour); | |
645 | wxString FindName(const wxColour& colour) const; | |
646 | ||
7bf85405 | 647 | %addmethods { |
0569df0f RD |
648 | void Append(const wxString& name, int red, int green, int blue) { |
649 | self->Append(name.c_str(), new wxColour(red, green, blue)); | |
7bf85405 | 650 | } |
7bf85405 | 651 | } |
0569df0f RD |
652 | }; |
653 | ||
654 | ||
655 | //---------------------------------------------------------------------- | |
656 | ||
9416aa89 | 657 | class wxPen : public wxGDIObject { |
0569df0f RD |
658 | public: |
659 | wxPen(wxColour& colour, int width=1, int style=wxSOLID); | |
660 | ~wxPen(); | |
7bf85405 RD |
661 | |
662 | int GetCap(); | |
25832b3f | 663 | wxColour GetColour(); |
7bf85405 | 664 | |
fb5e0af0 | 665 | int GetJoin(); |
7bf85405 RD |
666 | int GetStyle(); |
667 | int GetWidth(); | |
668 | bool Ok(); | |
669 | void SetCap(int cap_style); | |
670 | void SetColour(wxColour& colour); | |
aeeb6a44 RR |
671 | void SetJoin(int join_style); |
672 | void SetStyle(int style); | |
673 | void SetWidth(int width); | |
08127323 | 674 | |
aeeb6a44 | 675 | // **** This one needs to return a list of ints (wxDash) |
ecc08ead | 676 | //int GetDashes(wxDash **dashes); |
eec92d76 | 677 | void SetDashes(int LCOUNT, wxDash* choices); |
6999b0d8 RD |
678 | |
679 | #ifdef __WXMSW__ | |
680 | wxBitmap* GetStipple(); | |
b8b8dda7 | 681 | void SetStipple(wxBitmap& stipple); |
fb5e0af0 | 682 | #endif |
7bf85405 RD |
683 | }; |
684 | ||
0569df0f | 685 | |
ecc08ead | 686 | |
05f30eec RD |
687 | |
688 | // The list of ints for the dashes needs to exist for the life of the pen | |
689 | // so we make it part of the class to save it. wxPyPen is aliased to wxPen | |
690 | // in _extras.py | |
691 | ||
ecc08ead RD |
692 | %{ |
693 | class wxPyPen : public wxPen { | |
694 | public: | |
695 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID) | |
696 | : wxPen(colour, width, style) | |
697 | { m_dash = NULL; } | |
698 | ~wxPyPen() { | |
699 | if (m_dash) | |
05f30eec | 700 | delete [] m_dash; |
ecc08ead RD |
701 | } |
702 | ||
703 | void SetDashes(int nb_dashes, const wxDash *dash) { | |
05f30eec RD |
704 | if (m_dash) |
705 | delete [] m_dash; | |
ecc08ead | 706 | m_dash = new wxDash[nb_dashes]; |
05f30eec | 707 | for (int i=0; i<nb_dashes; i++) { |
ecc08ead | 708 | m_dash[i] = dash[i]; |
05f30eec | 709 | } |
ecc08ead RD |
710 | wxPen::SetDashes(nb_dashes, m_dash); |
711 | } | |
712 | ||
713 | private: | |
714 | wxDash* m_dash; | |
715 | }; | |
716 | %} | |
717 | ||
718 | ||
ecc08ead RD |
719 | class wxPyPen : public wxPen { |
720 | public: | |
721 | wxPyPen(wxColour& colour, int width=1, int style=wxSOLID); | |
722 | ~wxPyPen(); | |
723 | ||
724 | void SetDashes(int LCOUNT, wxDash* choices); | |
725 | }; | |
726 | ||
727 | ||
728 | ||
05f30eec | 729 | |
9416aa89 | 730 | class wxPenList : public wxObject { |
0569df0f RD |
731 | public: |
732 | ||
733 | void AddPen(wxPen* pen); | |
734 | wxPen* FindOrCreatePen(const wxColour& colour, int width, int style); | |
735 | void RemovePen(wxPen* pen); | |
2f4e9287 RD |
736 | |
737 | int GetCount(); | |
0569df0f RD |
738 | }; |
739 | ||
740 | ||
741 | ||
7bf85405 RD |
742 | //---------------------------------------------------------------------- |
743 | ||
9416aa89 | 744 | class wxBrush : public wxGDIObject { |
7bf85405 | 745 | public: |
0569df0f RD |
746 | wxBrush(const wxColour& colour, int style=wxSOLID); |
747 | ~wxBrush(); | |
26b9cf27 | 748 | |
25832b3f | 749 | wxColour GetColour(); |
7bf85405 RD |
750 | wxBitmap * GetStipple(); |
751 | int GetStyle(); | |
752 | bool Ok(); | |
753 | void SetColour(wxColour &colour); | |
b8b8dda7 | 754 | void SetStipple(wxBitmap& bitmap); |
7bf85405 RD |
755 | void SetStyle(int style); |
756 | }; | |
757 | ||
0569df0f | 758 | |
6ee2116b | 759 | class wxBrushList : public wxObject { |
0569df0f RD |
760 | public: |
761 | ||
762 | void AddBrush(wxBrush *brush); | |
763 | wxBrush * FindOrCreateBrush(const wxColour& colour, int style); | |
764 | void RemoveBrush(wxBrush *brush); | |
2f4e9287 RD |
765 | |
766 | int GetCount(); | |
0569df0f RD |
767 | }; |
768 | ||
7bf85405 RD |
769 | //---------------------------------------------------------------------- |
770 | ||
771 | ||
772 | ||
9416aa89 | 773 | class wxDC : public wxObject { |
7bf85405 | 774 | public: |
fb5e0af0 | 775 | // wxDC(); **** abstract base class, can't instantiate. |
7bf85405 RD |
776 | ~wxDC(); |
777 | ||
778 | void BeginDrawing(); | |
efc5f224 RD |
779 | // %name(BlitXY) |
780 | bool Blit(long xdest, long ydest, | |
781 | long width, long height, | |
782 | wxDC *source, long xsrc, long ysrc, | |
783 | int logicalFunc = wxCOPY, int useMask = FALSE); | |
784 | // bool Blit(const wxPoint& destPt, const wxSize& sz, | |
785 | // wxDC *source, const wxPoint& srcPt, | |
786 | // int logicalFunc = wxCOPY, int useMask = FALSE); | |
787 | ||
7bf85405 RD |
788 | void Clear(); |
789 | void CrossHair(long x, long y); | |
790 | void DestroyClippingRegion(); | |
791 | long DeviceToLogicalX(long x); | |
792 | long DeviceToLogicalXRel(long x); | |
793 | long DeviceToLogicalY(long y); | |
794 | long DeviceToLogicalYRel(long y); | |
795 | void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc); | |
bb0054cd | 796 | void DrawCircle(long x, long y, long radius); |
7bf85405 RD |
797 | void DrawEllipse(long x, long y, long width, long height); |
798 | void DrawEllipticArc(long x, long y, long width, long height, long start, long end); | |
799 | void DrawIcon(const wxIcon& icon, long x, long y); | |
800 | void DrawLine(long x1, long y1, long x2, long y2); | |
eec92d76 RD |
801 | void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0); |
802 | void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0, | |
7bf85405 RD |
803 | int fill_style=wxODDEVEN_RULE); |
804 | void DrawPoint(long x, long y); | |
805 | void DrawRectangle(long x, long y, long width, long height); | |
6999b0d8 | 806 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); |
7bf85405 | 807 | void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20); |
eec92d76 | 808 | void DrawSpline(int PCOUNT, wxPoint* points); |
7bf85405 RD |
809 | void DrawText(const wxString& text, long x, long y); |
810 | void EndDoc(); | |
811 | void EndDrawing(); | |
812 | void EndPage(); | |
813 | void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE); | |
c5943253 RD |
814 | wxBrush GetBackground(); |
815 | wxBrush GetBrush(); | |
7bf85405 RD |
816 | long GetCharHeight(); |
817 | long GetCharWidth(); | |
818 | void GetClippingBox(long *OUTPUT, long *OUTPUT, | |
819 | long *OUTPUT, long *OUTPUT); | |
c5943253 | 820 | wxFont GetFont(); |
7bf85405 | 821 | int GetLogicalFunction(); |
eec92d76 | 822 | void GetLogicalScale(double *OUTPUT, double *OUTPUT); |
7bf85405 RD |
823 | int GetMapMode(); |
824 | bool GetOptimization(); | |
c5943253 | 825 | wxPen GetPen(); |
fb5e0af0 RD |
826 | %addmethods { |
827 | %new wxColour* GetPixel(long x, long y) { | |
828 | wxColour* wc = new wxColour(); | |
829 | self->GetPixel(x, y, wc); | |
830 | return wc; | |
831 | } | |
832 | } | |
bb0054cd RD |
833 | %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); |
834 | wxSize GetSize(); | |
eec92d76 | 835 | wxSize GetSizeMM(); |
25832b3f | 836 | wxColour GetTextBackground(); |
af309447 RD |
837 | void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT); |
838 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, | |
839 | long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT, | |
840 | const wxFont* font = NULL); | |
25832b3f | 841 | wxColour GetTextForeground(); |
eec92d76 | 842 | void GetUserScale(double *OUTPUT, double *OUTPUT); |
7bf85405 RD |
843 | long LogicalToDeviceX(long x); |
844 | long LogicalToDeviceXRel(long x); | |
845 | long LogicalToDeviceY(long y); | |
846 | long LogicalToDeviceYRel(long y); | |
847 | long MaxX(); | |
848 | long MaxY(); | |
849 | long MinX(); | |
850 | long MinY(); | |
851 | bool Ok(); | |
852 | void SetDeviceOrigin(long x, long y); | |
853 | void SetBackground(const wxBrush& brush); | |
854 | void SetBackgroundMode(int mode); | |
855 | void SetClippingRegion(long x, long y, long width, long height); | |
19a97bd6 | 856 | %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region); |
7bf85405 RD |
857 | void SetPalette(const wxPalette& colourMap); |
858 | void SetBrush(const wxBrush& brush); | |
859 | void SetFont(const wxFont& font); | |
860 | void SetLogicalFunction(int function); | |
eec92d76 | 861 | void SetLogicalScale(double x, double y); |
7bf85405 RD |
862 | void SetMapMode(int mode); |
863 | void SetOptimization(bool optimize); | |
864 | void SetPen(const wxPen& pen); | |
865 | void SetTextBackground(const wxColour& colour); | |
866 | void SetTextForeground(const wxColour& colour); | |
867 | void SetUserScale(double x_scale, double y_scale); | |
868 | bool StartDoc(const wxString& message); | |
869 | void StartPage(); | |
870 | ||
871 | ||
efc5f224 RD |
872 | |
873 | void DrawBitmap(const wxBitmap& bitmap, long x, long y, | |
874 | int useMask = FALSE); | |
875 | ||
eec92d76 RD |
876 | bool CanDrawBitmap(); |
877 | bool CanGetTextExtent(); | |
878 | int GetDepth(); | |
879 | wxSize GetPPI(); | |
880 | ||
881 | void GetLogicalOrigin(int *OUTPUT, int *OUTPUT); | |
882 | void SetLogicalOrigin(int x, int y); | |
883 | void GetDeviceOrigin(int *OUTPUT, int *OUTPUT); | |
eec92d76 RD |
884 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp); |
885 | ||
f6bcfd97 BP |
886 | void CalcBoundingBox(int x, int y); |
887 | void ResetBoundingBox(); | |
c7e7022c | 888 | |
9d37f964 RD |
889 | %addmethods { |
890 | void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT); | |
891 | // See below for implementation | |
892 | } | |
893 | ||
c7e7022c RD |
894 | #ifdef __WXMSW__ |
895 | long GetHDC(); | |
896 | #endif | |
9d37f964 RD |
897 | |
898 | ||
899 | %addmethods { | |
76e280e7 | 900 | // NOTE: These methods are VERY SIMILAR in implentation. It would be |
17c0e08c | 901 | // nice to factor out common code and or turn them into a set of |
76e280e7 RD |
902 | // template-like macros. |
903 | ||
9d37f964 RD |
904 | // Draw a point for every set of coordinants in pyPoints, optionally |
905 | // setting a new pen for each | |
906 | PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) { | |
907 | bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints); | |
908 | bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); | |
909 | int numObjs = 0; | |
910 | int numPens = 0; | |
911 | wxPen* pen; | |
912 | PyObject* obj; | |
913 | int x1, y1; | |
914 | int i = 0; | |
915 | ||
916 | if (!PySequence_Check(pyPoints)) { | |
917 | goto err0; | |
918 | } | |
919 | if (!PySequence_Check(pyPens)) { | |
920 | goto err1; | |
921 | } | |
922 | numObjs = PySequence_Length(pyPoints); | |
923 | numPens = PySequence_Length(pyPens); | |
924 | ||
925 | for (i = 0; i < numObjs; i++) { | |
926 | // Use a new pen? | |
927 | if (i < numPens) { | |
928 | if (isFastPens) { | |
929 | obj = PySequence_Fast_GET_ITEM(pyPens, i); | |
930 | } | |
931 | else { | |
932 | obj = PySequence_GetItem(pyPens, i); | |
933 | } | |
934 | if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) { | |
76e280e7 RD |
935 | if (!isFastPens) |
936 | Py_DECREF(obj); | |
9d37f964 RD |
937 | goto err1; |
938 | } | |
939 | ||
940 | self->SetPen(*pen); | |
941 | if (!isFastPens) | |
942 | Py_DECREF(obj); | |
943 | } | |
944 | ||
945 | // Get the point coordinants | |
946 | if (isFastSeq) { | |
947 | obj = PySequence_Fast_GET_ITEM(pyPoints, i); | |
948 | } | |
949 | else { | |
950 | obj = PySequence_GetItem(pyPoints, i); | |
951 | } | |
952 | if (! _2int_seq_helper(obj, &x1, &y1)) { | |
76e280e7 RD |
953 | if (!isFastPens) |
954 | Py_DECREF(obj); | |
9d37f964 RD |
955 | goto err0; |
956 | } | |
957 | ||
958 | // Now draw the point | |
959 | self->DrawPoint(x1, y1); | |
960 | ||
961 | if (!isFastSeq) | |
962 | Py_DECREF(obj); | |
963 | } | |
964 | ||
965 | Py_INCREF(Py_None); | |
966 | return Py_None; | |
967 | ||
968 | err1: | |
969 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); | |
970 | return NULL; | |
971 | err0: | |
972 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences."); | |
973 | return NULL; | |
974 | } | |
975 | ||
976 | ||
977 | // Draw a line for every set of coordinants in pyLines, optionally | |
978 | // setting a new pen for each | |
979 | PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) { | |
980 | bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines); | |
981 | bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); | |
982 | int numObjs = 0; | |
983 | int numPens = 0; | |
984 | wxPen* pen; | |
985 | PyObject* obj; | |
986 | int x1, y1, x2, y2; | |
987 | int i = 0; | |
988 | ||
989 | if (!PySequence_Check(pyLines)) { | |
990 | goto err0; | |
991 | } | |
992 | if (!PySequence_Check(pyPens)) { | |
993 | goto err1; | |
994 | } | |
995 | numObjs = PySequence_Length(pyLines); | |
996 | numPens = PySequence_Length(pyPens); | |
997 | ||
998 | for (i = 0; i < numObjs; i++) { | |
999 | // Use a new pen? | |
1000 | if (i < numPens) { | |
1001 | if (isFastPens) { | |
1002 | obj = PySequence_Fast_GET_ITEM(pyPens, i); | |
1003 | } | |
1004 | else { | |
1005 | obj = PySequence_GetItem(pyPens, i); | |
1006 | } | |
1007 | if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) { | |
76e280e7 RD |
1008 | if (!isFastPens) |
1009 | Py_DECREF(obj); | |
9d37f964 RD |
1010 | goto err1; |
1011 | } | |
1012 | ||
1013 | self->SetPen(*pen); | |
1014 | if (!isFastPens) | |
1015 | Py_DECREF(obj); | |
1016 | } | |
1017 | ||
1018 | // Get the line coordinants | |
1019 | if (isFastSeq) { | |
1020 | obj = PySequence_Fast_GET_ITEM(pyLines, i); | |
1021 | } | |
1022 | else { | |
1023 | obj = PySequence_GetItem(pyLines, i); | |
1024 | } | |
1025 | if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) { | |
76e280e7 RD |
1026 | if (!isFastPens) |
1027 | Py_DECREF(obj); | |
9d37f964 RD |
1028 | goto err0; |
1029 | } | |
1030 | ||
1031 | // Now draw the line | |
1032 | self->DrawLine(x1, y1, x2, y2); | |
1033 | ||
1034 | if (!isFastSeq) | |
1035 | Py_DECREF(obj); | |
1036 | } | |
1037 | ||
1038 | Py_INCREF(Py_None); | |
1039 | return Py_None; | |
1040 | ||
1041 | err1: | |
1042 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); | |
1043 | return NULL; | |
1044 | err0: | |
1045 | PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences."); | |
1046 | return NULL; | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | ||
1051 | %pragma(python) addtoclass = " | |
1052 | def DrawPointList(self, points, pens=None): | |
1053 | if pens is None: | |
1054 | pens = [] | |
1055 | elif isinstance(pens, wxPenPtr): | |
1056 | pens = [pens] | |
1057 | elif len(pens) != len(points): | |
1058 | raise ValueError('points and pens must have same length') | |
1059 | return self._DrawPointList(points, pens) | |
1060 | ||
1061 | def DrawLineList(self, lines, pens=None): | |
1062 | if pens is None: | |
1063 | pens = [] | |
1064 | elif isinstance(pens, wxPenPtr): | |
1065 | pens = [pens] | |
1066 | elif len(pens) != len(lines): | |
1067 | raise ValueError('lines and pens must have same length') | |
1068 | return self._DrawLineList(lines, pens) | |
1069 | " | |
1070 | ||
1071 | ||
7bf85405 RD |
1072 | }; |
1073 | ||
1074 | ||
9d37f964 RD |
1075 | |
1076 | %{ | |
1077 | static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) { | |
1078 | *x1 = dc->MinX(); | |
1079 | *y1 = dc->MinY(); | |
1080 | *x2 = dc->MaxX(); | |
1081 | *y2 = dc->MaxY(); | |
1082 | } | |
1083 | %} | |
1084 | ||
7bf85405 RD |
1085 | //---------------------------------------------------------------------- |
1086 | ||
1087 | class wxMemoryDC : public wxDC { | |
1088 | public: | |
1089 | wxMemoryDC(); | |
1090 | ||
1091 | void SelectObject(const wxBitmap& bitmap); | |
1092 | } | |
1093 | ||
1094 | %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC); | |
1095 | %{ // Alternate 'constructor' | |
1096 | wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) { | |
1097 | return new wxMemoryDC(oldDC); | |
1098 | } | |
1099 | %} | |
1100 | ||
1101 | ||
1102 | //--------------------------------------------------------------------------- | |
1103 | ||
1104 | class wxScreenDC : public wxDC { | |
1105 | public: | |
1106 | wxScreenDC(); | |
1107 | ||
26b9cf27 RD |
1108 | %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window); |
1109 | bool StartDrawingOnTop(wxRect* rect = NULL); | |
7bf85405 RD |
1110 | bool EndDrawingOnTop(); |
1111 | }; | |
1112 | ||
1113 | //--------------------------------------------------------------------------- | |
1114 | ||
1115 | class wxClientDC : public wxDC { | |
1116 | public: | |
1117 | wxClientDC(wxWindow* win); | |
1118 | }; | |
1119 | ||
1120 | //--------------------------------------------------------------------------- | |
1121 | ||
1122 | class wxPaintDC : public wxDC { | |
1123 | public: | |
1124 | wxPaintDC(wxWindow* win); | |
1125 | }; | |
1126 | ||
1127 | //--------------------------------------------------------------------------- | |
1128 | ||
b639c3c5 RD |
1129 | class wxWindowDC : public wxDC { |
1130 | public: | |
1131 | wxWindowDC(wxWindow* win); | |
1132 | }; | |
b639c3c5 RD |
1133 | |
1134 | //--------------------------------------------------------------------------- | |
1135 | ||
7bf85405 | 1136 | |
fb5e0af0 | 1137 | #ifdef __WXMSW__ |
17c0e08c RD |
1138 | |
1139 | %{ | |
1140 | #include <wx/metafile.h> | |
1141 | %} | |
1142 | ||
1143 | class wxMetaFile : public wxObject { | |
1144 | public: | |
1145 | wxMetaFile(const wxString& filename = wxPyEmptyStr); | |
1146 | ~wxMetaFile(); | |
1147 | ||
1148 | bool Ok(); | |
1149 | bool SetClipboard(int width = 0, int height = 0); | |
1150 | ||
1151 | wxSize GetSize(); | |
1152 | int GetWidth(); | |
1153 | int GetHeight(); | |
1154 | ||
1155 | const wxString& GetFileName() const { return m_filename; } | |
1156 | ||
1157 | }; | |
1158 | ||
1159 | // bool wxMakeMetaFilePlaceable(const wxString& filename, | |
1160 | // int minX, int minY, int maxX, int maxY, float scale=1.0); | |
1161 | ||
1162 | ||
7bf85405 RD |
1163 | class wxMetaFileDC : public wxDC { |
1164 | public: | |
17c0e08c RD |
1165 | wxMetaFileDC(const wxString& filename = wxPyEmptyStr, |
1166 | int width = 0, int height = 0, | |
1167 | const wxString& description = wxPyEmptyStr); | |
7bf85405 RD |
1168 | wxMetaFile* Close(); |
1169 | }; | |
17c0e08c | 1170 | |
fb5e0af0 | 1171 | #endif |
7bf85405 | 1172 | |
b639c3c5 RD |
1173 | //--------------------------------------------------------------------------- |
1174 | ||
9416aa89 | 1175 | class wxPalette : public wxGDIObject { |
b639c3c5 | 1176 | public: |
eec92d76 | 1177 | wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); |
b639c3c5 RD |
1178 | ~wxPalette(); |
1179 | ||
1180 | int GetPixel(byte red, byte green, byte blue); | |
1181 | bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); | |
1182 | bool Ok(); | |
1183 | }; | |
1184 | ||
1185 | //--------------------------------------------------------------------------- | |
1186 | ||
af309447 RD |
1187 | enum { |
1188 | wxIMAGELIST_DRAW_NORMAL , | |
1189 | wxIMAGELIST_DRAW_TRANSPARENT, | |
1190 | wxIMAGELIST_DRAW_SELECTED, | |
1191 | wxIMAGELIST_DRAW_FOCUSED, | |
1192 | wxIMAGE_LIST_NORMAL, | |
1193 | wxIMAGE_LIST_SMALL, | |
1194 | wxIMAGE_LIST_STATE | |
1195 | }; | |
1196 | ||
9416aa89 | 1197 | class wxImageList : public wxObject { |
af309447 | 1198 | public: |
dcd38683 | 1199 | wxImageList(int width, int height, int mask=TRUE, int initialCount=1); |
af309447 RD |
1200 | ~wxImageList(); |
1201 | ||
1202 | int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
1203 | %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
1204 | %name(AddIcon)int Add(const wxIcon& icon); | |
f6bcfd97 | 1205 | #ifdef __WXMSW__ |
b57bdb5a | 1206 | bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); |
b57bdb5a | 1207 | #else |
f6bcfd97 BP |
1208 | // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon); |
1209 | // int Add(const wxBitmap& bitmap); | |
b57bdb5a RD |
1210 | bool Replace(int index, const wxBitmap& bitmap); |
1211 | #endif | |
af309447 RD |
1212 | |
1213 | bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL, | |
1214 | const bool solidBackground = FALSE); | |
1215 | ||
1216 | int GetImageCount(); | |
1217 | bool Remove(int index); | |
1218 | bool RemoveAll(); | |
f6bcfd97 | 1219 | void GetSize(int index, int& OUTPUT, int& OUTPUT); |
af309447 RD |
1220 | }; |
1221 | ||
b639c3c5 | 1222 | |
9416aa89 RD |
1223 | //--------------------------------------------------------------------------- |
1224 | // Regions, etc. | |
1225 | ||
1226 | enum wxRegionContain { | |
1227 | wxOutRegion, wxPartRegion, wxInRegion | |
1228 | }; | |
1229 | ||
1230 | ||
1231 | class wxRegion : public wxGDIObject { | |
1232 | public: | |
1233 | wxRegion(long x=0, long y=0, long width=0, long height=0); | |
1234 | ~wxRegion(); | |
1235 | ||
1236 | void Clear(); | |
1237 | wxRegionContain Contains(long x, long y); | |
1238 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); | |
1239 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
1240 | %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h); | |
1241 | ||
1242 | wxRect GetBox(); | |
1243 | ||
1244 | bool Intersect(long x, long y, long width, long height); | |
1245 | %name(IntersectRect)bool Intersect(const wxRect& rect); | |
1246 | %name(IntersectRegion)bool Intersect(const wxRegion& region); | |
1247 | ||
1248 | bool IsEmpty(); | |
1249 | ||
1250 | bool Union(long x, long y, long width, long height); | |
1251 | %name(UnionRect)bool Union(const wxRect& rect); | |
1252 | %name(UnionRegion)bool Union(const wxRegion& region); | |
1253 | ||
1254 | bool Subtract(long x, long y, long width, long height); | |
1255 | %name(SubtractRect)bool Subtract(const wxRect& rect); | |
1256 | %name(SubtractRegion)bool Subtract(const wxRegion& region); | |
1257 | ||
1258 | bool Xor(long x, long y, long width, long height); | |
1259 | %name(XorRect)bool Xor(const wxRect& rect); | |
1260 | %name(XorRegion)bool Xor(const wxRegion& region); | |
1261 | }; | |
1262 | ||
1263 | ||
1264 | ||
1265 | class wxRegionIterator : public wxObject { | |
1266 | public: | |
1267 | wxRegionIterator(const wxRegion& region); | |
1268 | ~wxRegionIterator(); | |
1269 | ||
1270 | long GetX(); | |
1271 | long GetY(); | |
1272 | long GetW(); | |
1273 | long GetWidth(); | |
1274 | long GetH(); | |
1275 | long GetHeight(); | |
1276 | wxRect GetRect(); | |
1277 | bool HaveRects(); | |
1278 | void Reset(); | |
1279 | ||
1280 | %addmethods { | |
1281 | void Next() { | |
1282 | (*self) ++; | |
1283 | } | |
1284 | }; | |
1285 | }; | |
1286 | ||
1287 | ||
7bf85405 RD |
1288 | //--------------------------------------------------------------------------- |
1289 | ||
c5943253 RD |
1290 | %readonly |
1291 | %{ | |
1292 | #if 0 | |
1293 | %} | |
1294 | ||
1295 | extern wxFont *wxNORMAL_FONT; | |
1296 | extern wxFont *wxSMALL_FONT; | |
1297 | extern wxFont *wxITALIC_FONT; | |
1298 | extern wxFont *wxSWISS_FONT; | |
1299 | ||
1300 | extern wxPen *wxRED_PEN; | |
1301 | extern wxPen *wxCYAN_PEN; | |
1302 | extern wxPen *wxGREEN_PEN; | |
1303 | extern wxPen *wxBLACK_PEN; | |
1304 | extern wxPen *wxWHITE_PEN; | |
1305 | extern wxPen *wxTRANSPARENT_PEN; | |
1306 | extern wxPen *wxBLACK_DASHED_PEN; | |
1307 | extern wxPen *wxGREY_PEN; | |
1308 | extern wxPen *wxMEDIUM_GREY_PEN; | |
1309 | extern wxPen *wxLIGHT_GREY_PEN; | |
1310 | ||
1311 | extern wxBrush *wxBLUE_BRUSH; | |
1312 | extern wxBrush *wxGREEN_BRUSH; | |
1313 | extern wxBrush *wxWHITE_BRUSH; | |
1314 | extern wxBrush *wxBLACK_BRUSH; | |
1315 | extern wxBrush *wxTRANSPARENT_BRUSH; | |
1316 | extern wxBrush *wxCYAN_BRUSH; | |
1317 | extern wxBrush *wxRED_BRUSH; | |
1318 | extern wxBrush *wxGREY_BRUSH; | |
1319 | extern wxBrush *wxMEDIUM_GREY_BRUSH; | |
1320 | extern wxBrush *wxLIGHT_GREY_BRUSH; | |
1321 | ||
1322 | extern wxColour *wxBLACK; | |
1323 | extern wxColour *wxWHITE; | |
1324 | extern wxColour *wxRED; | |
1325 | extern wxColour *wxBLUE; | |
1326 | extern wxColour *wxGREEN; | |
1327 | extern wxColour *wxCYAN; | |
1328 | extern wxColour *wxLIGHT_GREY; | |
1329 | ||
1330 | extern wxCursor *wxSTANDARD_CURSOR; | |
1331 | extern wxCursor *wxHOURGLASS_CURSOR; | |
1332 | extern wxCursor *wxCROSS_CURSOR; | |
1333 | ||
1334 | ||
1335 | extern wxBitmap wxNullBitmap; | |
1336 | extern wxIcon wxNullIcon; | |
1337 | extern wxCursor wxNullCursor; | |
1338 | extern wxPen wxNullPen; | |
1339 | extern wxBrush wxNullBrush; | |
1340 | extern wxPalette wxNullPalette; | |
1341 | extern wxFont wxNullFont; | |
1342 | extern wxColour wxNullColour; | |
1343 | ||
1344 | ||
1345 | extern wxFontList* wxTheFontList; | |
1346 | extern wxPenList* wxThePenList; | |
1347 | extern wxBrushList* wxTheBrushList; | |
1348 | extern wxColourDatabase* wxTheColourDatabase; | |
1349 | ||
1350 | ||
1351 | %readwrite | |
1352 | %{ | |
1353 | #endif | |
1354 | %} | |
1355 | ||
1356 | //--------------------------------------------------------------------------- | |
1357 | //--------------------------------------------------------------------------- | |
1358 |