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
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;
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);
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;
438 return self->ToString();
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;
450 // wxFontMapper manages user-definable correspondence between logical font
451 // names and the fonts present on the machine.
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.
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);
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
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);
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);
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);
505 // return internal string identifier for the encoding (see also
506 // GetEncodingDescription())
507 static wxString GetEncodingName(wxFontEncoding encoding);
509 // return user-readable string describing the given encoding
511 // NB: hard-coded now, but might change later (read it from config?)
512 static wxString GetEncodingDescription(wxFontEncoding encoding);
514 // the parent window for modal dialogs
515 void SetDialogParent(wxWindow *parent);
517 // the title for the dialogs (note that default is quite reasonable)
518 void SetDialogTitle(const wxString& title);
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()
526 // set the config object to use (may be NULL to use default)
527 void SetConfig(wxConfigBase *config);
529 // set the root config path to use (should be an absolute path)
530 void SetConfigPath(const wxString& prefix);
532 // return default config path
533 static const wxChar *GetDefaultConfigPath();
539 class wxFont : public wxGDIObject {
541 wxFont( int pointSize, int family, int style, int weight,
542 int underline=FALSE, char* faceName = "",
543 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
545 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
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;
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);
572 wxString GetFamilyString() const;
573 wxString GetStyleString() const;
574 wxString GetWeightString() const;
576 static wxFontEncoding GetDefaultEncoding();
577 static void SetDefaultEncoding(wxFontEncoding encoding);
582 class wxFontList : public wxObject {
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);
595 //----------------------------------------------------------------------
597 class wxColour : public wxObject {
599 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
602 unsigned char Green();
603 unsigned char Blue();
605 void Set(unsigned char red, unsigned char green, unsigned char blue);
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()));
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())"
621 %new wxColour* wxNamedColour(const wxString& colorName);
623 %{ // Alternate 'constructor'
624 wxColour* wxNamedColour(const wxString& colorName) {
625 return new wxColour(colorName);
631 class wxColourDatabase : public wxObject {
634 wxColour *FindColour(const wxString& colour);
635 wxString FindName(const wxColour& colour) const;
638 void Append(const wxString& name, int red, int green, int blue) {
639 self->Append(name.c_str(), new wxColour(red, green, blue));
645 //----------------------------------------------------------------------
647 class wxPen : public wxGDIObject {
649 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
653 wxColour GetColour();
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);
665 // **** This one needs to return a list of ints (wxDash)
666 //int GetDashes(wxDash **dashes);
667 void SetDashes(int LCOUNT, wxDash* choices);
670 wxBitmap* GetStipple();
671 void SetStipple(wxBitmap& stipple);
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
683 class wxPyPen : public wxPen {
685 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
686 : wxPen(colour, width, style)
693 void SetDashes(int nb_dashes, const wxDash *dash) {
696 m_dash = new wxDash[nb_dashes];
697 for (int i=0; i<nb_dashes; i++) {
700 wxPen::SetDashes(nb_dashes, m_dash);
709 class wxPyPen : public wxPen {
711 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
714 void SetDashes(int LCOUNT, wxDash* choices);
720 class wxPenList : public wxObject {
723 void AddPen(wxPen* pen);
724 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
725 void RemovePen(wxPen* pen);
732 //----------------------------------------------------------------------
734 class wxBrush : public wxGDIObject {
736 wxBrush(const wxColour& colour, int style=wxSOLID);
739 wxColour GetColour();
740 wxBitmap * GetStipple();
743 void SetColour(wxColour &colour);
744 void SetStipple(wxBitmap& bitmap);
745 void SetStyle(int style);
749 class wxBrushList : public wxObject {
752 void AddBrush(wxBrush *brush);
753 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
754 void RemoveBrush(wxBrush *brush);
759 //----------------------------------------------------------------------
763 class wxDC : public wxObject {
765 // wxDC(); **** abstract base class, can't instantiate.
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);
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);
803 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
804 wxBrush GetBackground();
806 long GetCharHeight();
808 void GetClippingBox(long *OUTPUT, long *OUTPUT,
809 long *OUTPUT, long *OUTPUT);
811 int GetLogicalFunction();
812 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
814 bool GetOptimization();
817 %new wxColour* GetPixel(long x, long y) {
818 wxColour* wc = new wxColour();
819 self->GetPixel(x, y, wc);
823 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
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);
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);
863 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
864 int useMask = FALSE);
866 bool CanDrawBitmap();
867 bool CanGetTextExtent();
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);
876 void CalcBoundingBox(int x, int y);
877 void ResetBoundingBox();
880 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
881 // See below for implementation
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.
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);
906 if (!PySequence_Check(pyPoints)) {
909 if (!PySequence_Check(pyPens)) {
912 numObjs = PySequence_Length(pyPoints);
913 numPens = PySequence_Length(pyPens);
915 for (i = 0; i < numObjs; i++) {
919 obj = PySequence_Fast_GET_ITEM(pyPens, i);
922 obj = PySequence_GetItem(pyPens, i);
924 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
935 // Get the point coordinants
937 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
940 obj = PySequence_GetItem(pyPoints, i);
942 if (! _2int_seq_helper(obj, &x1, &y1)) {
948 // Now draw the point
949 self->DrawPoint(x1, y1);
959 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
962 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
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);
979 if (!PySequence_Check(pyLines)) {
982 if (!PySequence_Check(pyPens)) {
985 numObjs = PySequence_Length(pyLines);
986 numPens = PySequence_Length(pyPens);
988 for (i = 0; i < numObjs; i++) {
992 obj = PySequence_Fast_GET_ITEM(pyPens, i);
995 obj = PySequence_GetItem(pyPens, i);
997 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1008 // Get the line coordinants
1010 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1013 obj = PySequence_GetItem(pyLines, i);
1015 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1021 // Now draw the line
1022 self->DrawLine(x1, y1, x2, y2);
1032 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1035 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1041 %pragma(python) addtoclass = "
1042 def DrawPointList(self, points, pens=None):
1045 elif isinstance(pens, wxPenPtr):
1047 elif len(pens) != len(points):
1048 raise ValueError('points and pens must have same length')
1049 return self._DrawPointList(points, pens)
1051 def DrawLineList(self, lines, pens=None):
1054 elif isinstance(pens, wxPenPtr):
1056 elif len(pens) != len(lines):
1057 raise ValueError('lines and pens must have same length')
1058 return self._DrawLineList(lines, pens)
1067 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1075 //----------------------------------------------------------------------
1077 class wxMemoryDC : public wxDC {
1081 void SelectObject(const wxBitmap& bitmap);
1084 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1085 %{ // Alternate 'constructor'
1086 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1087 return new wxMemoryDC(oldDC);
1092 //---------------------------------------------------------------------------
1094 class wxScreenDC : public wxDC {
1098 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1099 bool StartDrawingOnTop(wxRect* rect = NULL);
1100 bool EndDrawingOnTop();
1103 //---------------------------------------------------------------------------
1105 class wxClientDC : public wxDC {
1107 wxClientDC(wxWindow* win);
1110 //---------------------------------------------------------------------------
1112 class wxPaintDC : public wxDC {
1114 wxPaintDC(wxWindow* win);
1117 //---------------------------------------------------------------------------
1119 class wxWindowDC : public wxDC {
1121 wxWindowDC(wxWindow* win);
1124 //---------------------------------------------------------------------------
1130 #include <wx/metafile.h>
1133 class wxMetaFile : public wxObject {
1135 wxMetaFile(const wxString& filename = wxPyEmptyStr);
1139 bool SetClipboard(int width = 0, int height = 0);
1145 const wxString& GetFileName() const { return m_filename; }
1149 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1150 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1153 class wxMetaFileDC : public wxDC {
1155 wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
1156 int width = 0, int height = 0,
1157 const wxString& description = wxPyEmptyStr);
1158 wxMetaFile* Close();
1163 //---------------------------------------------------------------------------
1165 class wxPalette : public wxGDIObject {
1167 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1170 int GetPixel(byte red, byte green, byte blue);
1171 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1175 //---------------------------------------------------------------------------
1178 wxIMAGELIST_DRAW_NORMAL ,
1179 wxIMAGELIST_DRAW_TRANSPARENT,
1180 wxIMAGELIST_DRAW_SELECTED,
1181 wxIMAGELIST_DRAW_FOCUSED,
1182 wxIMAGE_LIST_NORMAL,
1187 class wxImageList : public wxObject {
1189 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
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);
1196 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1198 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1199 // int Add(const wxBitmap& bitmap);
1200 bool Replace(int index, const wxBitmap& bitmap);
1203 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1204 const bool solidBackground = FALSE);
1206 int GetImageCount();
1207 bool Remove(int index);
1209 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1213 //---------------------------------------------------------------------------
1216 enum wxRegionContain {
1217 wxOutRegion, wxPartRegion, wxInRegion
1221 class wxRegion : public wxGDIObject {
1223 wxRegion(long x=0, long y=0, long width=0, long height=0);
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);
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);
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);
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);
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);
1255 class wxRegionIterator : public wxObject {
1257 wxRegionIterator(const wxRegion& region);
1258 ~wxRegionIterator();
1278 //---------------------------------------------------------------------------
1285 extern wxFont *wxNORMAL_FONT;
1286 extern wxFont *wxSMALL_FONT;
1287 extern wxFont *wxITALIC_FONT;
1288 extern wxFont *wxSWISS_FONT;
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;
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;
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;
1320 extern wxCursor *wxSTANDARD_CURSOR;
1321 extern wxCursor *wxHOURGLASS_CURSOR;
1322 extern wxCursor *wxCROSS_CURSOR;
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;
1335 extern wxFontList* wxTheFontList;
1336 extern wxPenList* wxThePenList;
1337 extern wxBrushList* wxTheBrushList;
1338 extern wxColourDatabase* wxTheColourDatabase;
1346 //---------------------------------------------------------------------------
1347 //---------------------------------------------------------------------------