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