1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxDC, wxBrush, wxPen, wxFont, etc.
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
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>
25 //----------------------------------------------------------------------
28 %include my_typemaps.i
30 // Import some definitions of other classes, etc.
35 static wxString wxPyEmptyStr("");
38 //---------------------------------------------------------------------------
40 class wxGDIObject : public wxObject {
46 void SetVisible( bool visible );
52 //---------------------------------------------------------------------------
54 class wxBitmap : public wxGDIObject
57 wxBitmap(const wxString& name, wxBitmapType type=wxBITMAP_TYPE_BMP);
60 wxPalette* GetPalette();
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);
66 void SetPalette(wxPalette& palette);
72 void SetHandle(long handle);
79 void SetHeight(int h);
82 void SetSize(const wxSize& size);
85 wxBitmap GetSubBitmap( const wxRect& rect );
86 bool CopyFromIcon(const wxIcon& icon);
88 bool CopyFromCursor(const wxCursor& cursor);
90 void SetQuality(int q);
93 %pragma(python) addtoclass = "
94 def __del__(self,gdic=gdic):
96 if self.thisown == 1 :
97 gdic.delete_wxBitmap(self)
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 );
111 // %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
112 // int width, int height, int depth = 1);
117 %{ // Implementations of some alternate "constructors"
119 wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
120 return new wxBitmap(width, height, depth);
123 static char** ConvertListOfStrings(PyObject* listOfStrings) {
124 char** cArray = NULL;
127 if (!PyList_Check(listOfStrings)) {
128 PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
131 count = PyList_Size(listOfStrings);
132 cArray = new char*[count];
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));
142 wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
143 char** cArray = NULL;
146 cArray = ConvertListOfStrings(listOfStrings);
149 bmp = new wxBitmap(cArray);
155 wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
156 return new wxBitmap(icon);
160 wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
161 return new wxBitmap(bits, width, height, depth);
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");
172 // return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
177 //---------------------------------------------------------------------------
179 class wxMask : public wxObject {
181 wxMask(const wxBitmap& bitmap);
184 %addmethods { void Destroy() { delete self; } }
187 %new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
189 wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
190 return new wxMask(bitmap, colour);
195 //---------------------------------------------------------------------------
198 class wxIcon : public wxGDIObject
201 wxIcon(const wxString& name, long flags,
202 int desiredWidth = -1, int desiredHeight = -1);
206 bool LoadFile(const wxString& name, long flags);
209 // wxGDIImage methods
212 void SetHandle(long handle);
218 void SetWidth(int w);
219 void SetHeight(int h);
220 void SetDepth(int d);
222 void SetSize(const wxSize& size);
224 void CopyFromBitmap(const wxBitmap& bmp);
226 %pragma(python) addtoclass = "
227 def __del__(self,gdic=gdic):
229 if self.thisown == 1 :
230 gdic.delete_wxIcon(self)
237 // Declarations of some alternate "constructors"
238 %new wxIcon* wxEmptyIcon();
239 %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
241 %{ // Implementations of some alternate "constructors"
242 wxIcon* wxEmptyIcon() {
246 wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
247 char** cArray = NULL;
250 cArray = ConvertListOfStrings(listOfStrings);
253 icon = new wxIcon(cArray);
259 //---------------------------------------------------------------------------
261 class wxCursor : public wxGDIObject
265 wxCursor(const wxString& cursorName, long flags, int hotSpotX=0, int hotSpotY=0);
269 // wxGDIImage methods
272 void SetHandle(long handle);
279 void SetWidth(int w);
280 void SetHeight(int h);
281 void SetDepth(int d);
282 void SetSize(const wxSize& size);
286 %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
287 %{ // Alternate 'constructor'
288 wxCursor* wxPyStockCursor(int id) {
289 return new wxCursor(id);
293 //----------------------------------------------------------------------
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,
311 wxFONTSTYLE_NORMAL = wxNORMAL,
312 wxFONTSTYLE_ITALIC = wxITALIC,
313 wxFONTSTYLE_SLANT = wxSLANT,
320 wxFONTWEIGHT_NORMAL = wxNORMAL,
321 wxFONTWEIGHT_LIGHT = wxLIGHT,
322 wxFONTWEIGHT_BOLD = wxBOLD,
330 wxFONTENCODING_SYSTEM = -1, // system default
331 wxFONTENCODING_DEFAULT, // current default encoding
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,
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
358 // what would we do without Microsoft? They have their own encodings
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
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,
381 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
382 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
384 wxFONTENCODING_UNICODE, // Unicode - currently used only by
385 // wxEncodingConverter class
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
400 // init the elements from an XLFD, return TRUE if ok
401 bool FromXFontName(const wxString& xFontName);
403 // generate an XLFD using the fontElements
404 wxString GetXFontName() const;
407 wxNativeFontInfo() { Init(); }
409 // reset to the default state
412 // accessors and modifiers for the font elements
413 int GetPointSize() const;
414 wxFontStyle GetStyle() const;
415 wxFontWeight GetWeight() const;
416 bool GetUnderlined() const;
417 wxString GetFaceName() const;
418 wxFontFamily GetFamily() const;
419 wxFontEncoding GetEncoding() const;
421 void SetPointSize(int pointsize);
422 void SetStyle(wxFontStyle style);
423 void SetWeight(wxFontWeight weight);
424 void SetUnderlined(bool underlined);
425 void SetFaceName(wxString facename);
426 void SetFamily(wxFontFamily family);
427 void SetEncoding(wxFontEncoding encoding);
429 // it is important to be able to serialize wxNativeFontInfo objects to be
430 // able to store them (in config file, for example)
431 bool FromString(const wxString& s);
432 wxString ToString() const;
436 return self->ToString();
440 // we also want to present the native font descriptions to the user in some
441 // human-readable form (it is not platform independent neither, but can
442 // hopefully be understood by the user)
443 bool FromUserString(const wxString& s);
444 wxString ToUserString() const;
448 // wxFontMapper manages user-definable correspondence between logical font
449 // names and the fonts present on the machine.
451 // The default implementations of all functions will ask the user if they are
452 // not capable of finding the answer themselves and store the answer in a
453 // config file (configurable via SetConfigXXX functions). This behaviour may
454 // be disabled by giving the value of FALSE to "interactive" parameter.
455 // However, the functions will always consult the config file to allow the
456 // user-defined values override the default logic and there is no way to
457 // disable this - which shouldn't be ever needed because if "interactive" was
458 // never TRUE, the config file is never created anyhow.
466 // find an alternative for the given encoding (which is supposed to not be
467 // available on this system). If successful, return TRUE and rwxFontEcoding
468 // that can be used it wxFont ctor otherwise return FALSE
469 //bool GetAltForEncoding(wxFontEncoding encoding,
470 // wxFontEncoding *alt_encoding,
471 // const wxString& facename = wxEmptyString,
472 // bool interactive = TRUE);
475 // Find an alternative for the given encoding (which is supposed to not be
476 // available on this system). If successful, returns the encoding otherwise
479 PyObject* GetAltForEncoding(wxFontEncoding encoding,
480 const wxString& facename = wxEmptyString,
481 bool interactive = TRUE) {
482 wxFontEncoding alt_enc;
483 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
484 return PyInt_FromLong(alt_enc);
493 // checks whether given encoding is available in given face or not.
494 // If no facename is given,
495 bool IsEncodingAvailable(wxFontEncoding encoding,
496 const wxString& facename = wxEmptyString);
498 // returns the encoding for the given charset (in the form of RFC 2046) or
499 // wxFONTENCODING_SYSTEM if couldn't decode it
500 wxFontEncoding CharsetToEncoding(const wxString& charset,
501 bool interactive = TRUE);
503 // return internal string identifier for the encoding (see also
504 // GetEncodingDescription())
505 static wxString GetEncodingName(wxFontEncoding encoding);
507 // return user-readable string describing the given encoding
509 // NB: hard-coded now, but might change later (read it from config?)
510 static wxString GetEncodingDescription(wxFontEncoding encoding);
512 // the parent window for modal dialogs
513 void SetDialogParent(wxWindow *parent);
515 // the title for the dialogs (note that default is quite reasonable)
516 void SetDialogTitle(const wxString& title);
518 // functions which allow to configure the config object used: by default,
519 // the global one (from wxConfigBase::Get() will be used) and the default
520 // root path for the config settings is the string returned by
521 // GetDefaultConfigPath()
524 // set the config object to use (may be NULL to use default)
525 void SetConfig(wxConfigBase *config);
527 // set the root config path to use (should be an absolute path)
528 void SetConfigPath(const wxString& prefix);
530 // return default config path
531 static const wxChar *GetDefaultConfigPath();
537 class wxFont : public wxGDIObject {
539 wxFont( int pointSize, int family, int style, int weight,
540 int underline=FALSE, char* faceName = "",
541 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
543 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
548 int GetPointSize() const;
549 int GetFamily() const;
550 int GetStyle() const;
551 int GetWeight() const;
552 bool GetUnderlined() const;
553 wxString GetFaceName() const;
554 wxFontEncoding GetEncoding() const;
555 wxNativeFontInfo* GetNativeFontInfo() const;
556 wxString GetNativeFontInfoDesc() const;
557 wxString GetNativeFontInfoUserDesc() const;
559 void SetPointSize(int pointSize);
560 void SetFamily(int family);
561 void SetStyle(int style);
562 void SetWeight(int weight);
563 void SetFaceName(const wxString& faceName);
564 void SetUnderlined(bool underlined);
565 void SetEncoding(wxFontEncoding encoding);
566 void SetNativeFontInfo(const wxNativeFontInfo& info);
567 // void SetNativeFontInfo(const wxString& info);
568 void SetNativeFontInfoUserDesc(const wxString& info);
570 wxString GetFamilyString() const;
571 wxString GetStyleString() const;
572 wxString GetWeightString() const;
574 static wxFontEncoding GetDefaultEncoding();
575 static void SetDefaultEncoding(wxFontEncoding encoding);
580 class wxFontList : public wxObject {
583 void AddFont(wxFont* font);
584 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
585 bool underline = FALSE, const char* facename = NULL,
586 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
587 void RemoveFont(wxFont *font);
593 //----------------------------------------------------------------------
595 class wxColour : public wxObject {
597 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
600 unsigned char Green();
601 unsigned char Blue();
603 void Set(unsigned char red, unsigned char green, unsigned char blue);
606 PyObject* rv = PyTuple_New(3);
607 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
608 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
609 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
613 %pragma(python) addtoclass = "asTuple = Get"
614 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
615 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
619 %new wxColour* wxNamedColour(const wxString& colorName);
621 %{ // Alternate 'constructor'
622 wxColour* wxNamedColour(const wxString& colorName) {
623 return new wxColour(colorName);
629 class wxColourDatabase : public wxObject {
632 wxColour *FindColour(const wxString& colour);
633 wxString FindName(const wxColour& colour) const;
636 void Append(const wxString& name, int red, int green, int blue) {
637 self->Append(name.c_str(), new wxColour(red, green, blue));
643 //----------------------------------------------------------------------
645 class wxPen : public wxGDIObject {
647 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
651 wxColour GetColour();
657 void SetCap(int cap_style);
658 void SetColour(wxColour& colour);
659 void SetJoin(int join_style);
660 void SetStyle(int style);
661 void SetWidth(int width);
663 // **** This one needs to return a list of ints (wxDash)
664 //int GetDashes(wxDash **dashes);
665 void SetDashes(int LCOUNT, wxDash* choices);
668 wxBitmap* GetStipple();
669 void SetStipple(wxBitmap& stipple);
676 // The list of ints for the dashes needs to exist for the life of the pen
677 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
681 class wxPyPen : public wxPen {
683 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
684 : wxPen(colour, width, style)
691 void SetDashes(int nb_dashes, const wxDash *dash) {
694 m_dash = new wxDash[nb_dashes];
695 for (int i=0; i<nb_dashes; i++) {
698 wxPen::SetDashes(nb_dashes, m_dash);
707 class wxPyPen : public wxPen {
709 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
712 void SetDashes(int LCOUNT, wxDash* choices);
718 class wxPenList : public wxObject {
721 void AddPen(wxPen* pen);
722 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
723 void RemovePen(wxPen* pen);
730 //----------------------------------------------------------------------
732 class wxBrush : public wxGDIObject {
734 wxBrush(const wxColour& colour, int style=wxSOLID);
737 wxColour GetColour();
738 wxBitmap * GetStipple();
741 void SetColour(wxColour &colour);
742 void SetStipple(wxBitmap& bitmap);
743 void SetStyle(int style);
747 class wxBrushList : public wxObject {
750 void AddBrush(wxBrush *brush);
751 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
752 void RemoveBrush(wxBrush *brush);
757 //----------------------------------------------------------------------
761 class wxDC : public wxObject {
763 // wxDC(); **** abstract base class, can't instantiate.
768 bool Blit(long xdest, long ydest,
769 long width, long height,
770 wxDC *source, long xsrc, long ysrc,
771 int logicalFunc = wxCOPY, int useMask = FALSE);
772 // bool Blit(const wxPoint& destPt, const wxSize& sz,
773 // wxDC *source, const wxPoint& srcPt,
774 // int logicalFunc = wxCOPY, int useMask = FALSE);
777 void CrossHair(long x, long y);
778 void DestroyClippingRegion();
779 long DeviceToLogicalX(long x);
780 long DeviceToLogicalXRel(long x);
781 long DeviceToLogicalY(long y);
782 long DeviceToLogicalYRel(long y);
783 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
784 void DrawCircle(long x, long y, long radius);
785 void DrawEllipse(long x, long y, long width, long height);
786 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
787 void DrawIcon(const wxIcon& icon, long x, long y);
788 void DrawLine(long x1, long y1, long x2, long y2);
789 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
790 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
791 int fill_style=wxODDEVEN_RULE);
792 void DrawPoint(long x, long y);
793 void DrawRectangle(long x, long y, long width, long height);
794 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
795 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
796 void DrawSpline(int PCOUNT, wxPoint* points);
797 void DrawText(const wxString& text, long x, long y);
801 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
802 wxBrush GetBackground();
804 long GetCharHeight();
806 void GetClippingBox(long *OUTPUT, long *OUTPUT,
807 long *OUTPUT, long *OUTPUT);
809 int GetLogicalFunction();
810 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
812 bool GetOptimization();
815 %new wxColour* GetPixel(long x, long y) {
816 wxColour* wc = new wxColour();
817 self->GetPixel(x, y, wc);
821 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
824 wxColour GetTextBackground();
825 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
826 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
827 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
828 const wxFont* font = NULL);
829 wxColour GetTextForeground();
830 void GetUserScale(double *OUTPUT, double *OUTPUT);
831 long LogicalToDeviceX(long x);
832 long LogicalToDeviceXRel(long x);
833 long LogicalToDeviceY(long y);
834 long LogicalToDeviceYRel(long y);
840 void SetDeviceOrigin(long x, long y);
841 void SetBackground(const wxBrush& brush);
842 void SetBackgroundMode(int mode);
843 void SetClippingRegion(long x, long y, long width, long height);
844 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
845 void SetPalette(const wxPalette& colourMap);
846 void SetBrush(const wxBrush& brush);
847 void SetFont(const wxFont& font);
848 void SetLogicalFunction(int function);
849 void SetLogicalScale(double x, double y);
850 void SetMapMode(int mode);
851 void SetOptimization(bool optimize);
852 void SetPen(const wxPen& pen);
853 void SetTextBackground(const wxColour& colour);
854 void SetTextForeground(const wxColour& colour);
855 void SetUserScale(double x_scale, double y_scale);
856 bool StartDoc(const wxString& message);
861 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
862 int useMask = FALSE);
864 bool CanDrawBitmap();
865 bool CanGetTextExtent();
869 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
870 void SetLogicalOrigin(int x, int y);
871 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
872 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
874 void CalcBoundingBox(int x, int y);
875 void ResetBoundingBox();
878 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
879 // See below for implementation
888 // NOTE: These methods are VERY SIMILAR in implentation. It would be
889 // nice to factor out common code and or turn them into a set of
890 // template-like macros.
892 // Draw a point for every set of coordinants in pyPoints, optionally
893 // setting a new pen for each
894 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
895 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
896 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
904 if (!PySequence_Check(pyPoints)) {
907 if (!PySequence_Check(pyPens)) {
910 numObjs = PySequence_Length(pyPoints);
911 numPens = PySequence_Length(pyPens);
913 for (i = 0; i < numObjs; i++) {
917 obj = PySequence_Fast_GET_ITEM(pyPens, i);
920 obj = PySequence_GetItem(pyPens, i);
922 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
933 // Get the point coordinants
935 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
938 obj = PySequence_GetItem(pyPoints, i);
940 if (! _2int_seq_helper(obj, &x1, &y1)) {
946 // Now draw the point
947 self->DrawPoint(x1, y1);
957 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
960 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
965 // Draw a line for every set of coordinants in pyLines, optionally
966 // setting a new pen for each
967 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
968 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
969 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
977 if (!PySequence_Check(pyLines)) {
980 if (!PySequence_Check(pyPens)) {
983 numObjs = PySequence_Length(pyLines);
984 numPens = PySequence_Length(pyPens);
986 for (i = 0; i < numObjs; i++) {
990 obj = PySequence_Fast_GET_ITEM(pyPens, i);
993 obj = PySequence_GetItem(pyPens, i);
995 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1006 // Get the line coordinants
1008 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1011 obj = PySequence_GetItem(pyLines, i);
1013 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1019 // Now draw the line
1020 self->DrawLine(x1, y1, x2, y2);
1030 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1033 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1039 %pragma(python) addtoclass = "
1040 def DrawPointList(self, points, pens=None):
1043 elif isinstance(pens, wxPenPtr):
1045 elif len(pens) != len(points):
1046 raise ValueError('points and pens must have same length')
1047 return self._DrawPointList(points, pens)
1049 def DrawLineList(self, lines, pens=None):
1052 elif isinstance(pens, wxPenPtr):
1054 elif len(pens) != len(lines):
1055 raise ValueError('lines and pens must have same length')
1056 return self._DrawLineList(lines, pens)
1065 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1073 //----------------------------------------------------------------------
1075 class wxMemoryDC : public wxDC {
1079 void SelectObject(const wxBitmap& bitmap);
1082 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1083 %{ // Alternate 'constructor'
1084 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1085 return new wxMemoryDC(oldDC);
1090 //---------------------------------------------------------------------------
1092 class wxScreenDC : public wxDC {
1096 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1097 bool StartDrawingOnTop(wxRect* rect = NULL);
1098 bool EndDrawingOnTop();
1101 //---------------------------------------------------------------------------
1103 class wxClientDC : public wxDC {
1105 wxClientDC(wxWindow* win);
1108 //---------------------------------------------------------------------------
1110 class wxPaintDC : public wxDC {
1112 wxPaintDC(wxWindow* win);
1115 //---------------------------------------------------------------------------
1117 class wxWindowDC : public wxDC {
1119 wxWindowDC(wxWindow* win);
1122 //---------------------------------------------------------------------------
1128 #include <wx/metafile.h>
1131 class wxMetaFile : public wxObject {
1133 wxMetaFile(const wxString& filename = wxPyEmptyStr);
1137 bool SetClipboard(int width = 0, int height = 0);
1143 const wxString& GetFileName() const { return m_filename; }
1147 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1148 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1151 class wxMetaFileDC : public wxDC {
1153 wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
1154 int width = 0, int height = 0,
1155 const wxString& description = wxPyEmptyStr);
1156 wxMetaFile* Close();
1161 //---------------------------------------------------------------------------
1163 class wxPalette : public wxGDIObject {
1165 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1168 int GetPixel(byte red, byte green, byte blue);
1169 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1173 //---------------------------------------------------------------------------
1176 wxIMAGELIST_DRAW_NORMAL ,
1177 wxIMAGELIST_DRAW_TRANSPARENT,
1178 wxIMAGELIST_DRAW_SELECTED,
1179 wxIMAGELIST_DRAW_FOCUSED,
1180 wxIMAGE_LIST_NORMAL,
1185 class wxImageList : public wxObject {
1187 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1190 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1191 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1192 %name(AddIcon)int Add(const wxIcon& icon);
1194 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1196 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1197 // int Add(const wxBitmap& bitmap);
1198 bool Replace(int index, const wxBitmap& bitmap);
1201 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1202 const bool solidBackground = FALSE);
1204 int GetImageCount();
1205 bool Remove(int index);
1207 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1211 //---------------------------------------------------------------------------
1214 enum wxRegionContain {
1215 wxOutRegion, wxPartRegion, wxInRegion
1219 class wxRegion : public wxGDIObject {
1221 wxRegion(long x=0, long y=0, long width=0, long height=0);
1225 wxRegionContain Contains(long x, long y);
1226 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1227 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1228 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1232 bool Intersect(long x, long y, long width, long height);
1233 %name(IntersectRect)bool Intersect(const wxRect& rect);
1234 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1238 bool Union(long x, long y, long width, long height);
1239 %name(UnionRect)bool Union(const wxRect& rect);
1240 %name(UnionRegion)bool Union(const wxRegion& region);
1242 bool Subtract(long x, long y, long width, long height);
1243 %name(SubtractRect)bool Subtract(const wxRect& rect);
1244 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1246 bool Xor(long x, long y, long width, long height);
1247 %name(XorRect)bool Xor(const wxRect& rect);
1248 %name(XorRegion)bool Xor(const wxRegion& region);
1253 class wxRegionIterator : public wxObject {
1255 wxRegionIterator(const wxRegion& region);
1256 ~wxRegionIterator();
1276 //---------------------------------------------------------------------------
1283 extern wxFont *wxNORMAL_FONT;
1284 extern wxFont *wxSMALL_FONT;
1285 extern wxFont *wxITALIC_FONT;
1286 extern wxFont *wxSWISS_FONT;
1288 extern wxPen *wxRED_PEN;
1289 extern wxPen *wxCYAN_PEN;
1290 extern wxPen *wxGREEN_PEN;
1291 extern wxPen *wxBLACK_PEN;
1292 extern wxPen *wxWHITE_PEN;
1293 extern wxPen *wxTRANSPARENT_PEN;
1294 extern wxPen *wxBLACK_DASHED_PEN;
1295 extern wxPen *wxGREY_PEN;
1296 extern wxPen *wxMEDIUM_GREY_PEN;
1297 extern wxPen *wxLIGHT_GREY_PEN;
1299 extern wxBrush *wxBLUE_BRUSH;
1300 extern wxBrush *wxGREEN_BRUSH;
1301 extern wxBrush *wxWHITE_BRUSH;
1302 extern wxBrush *wxBLACK_BRUSH;
1303 extern wxBrush *wxTRANSPARENT_BRUSH;
1304 extern wxBrush *wxCYAN_BRUSH;
1305 extern wxBrush *wxRED_BRUSH;
1306 extern wxBrush *wxGREY_BRUSH;
1307 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1308 extern wxBrush *wxLIGHT_GREY_BRUSH;
1310 extern wxColour *wxBLACK;
1311 extern wxColour *wxWHITE;
1312 extern wxColour *wxRED;
1313 extern wxColour *wxBLUE;
1314 extern wxColour *wxGREEN;
1315 extern wxColour *wxCYAN;
1316 extern wxColour *wxLIGHT_GREY;
1318 extern wxCursor *wxSTANDARD_CURSOR;
1319 extern wxCursor *wxHOURGLASS_CURSOR;
1320 extern wxCursor *wxCROSS_CURSOR;
1323 extern wxBitmap wxNullBitmap;
1324 extern wxIcon wxNullIcon;
1325 extern wxCursor wxNullCursor;
1326 extern wxPen wxNullPen;
1327 extern wxBrush wxNullBrush;
1328 extern wxPalette wxNullPalette;
1329 extern wxFont wxNullFont;
1330 extern wxColour wxNullColour;
1333 extern wxFontList* wxTheFontList;
1334 extern wxPenList* wxThePenList;
1335 extern wxBrushList* wxTheBrushList;
1336 extern wxColourDatabase* wxTheColourDatabase;
1344 //---------------------------------------------------------------------------
1345 //---------------------------------------------------------------------------