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