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,
312 wxFONTSTYLE_NORMAL = wxNORMAL,
313 wxFONTSTYLE_ITALIC = wxITALIC,
314 wxFONTSTYLE_SLANT = wxSLANT,
321 wxFONTWEIGHT_NORMAL = wxNORMAL,
322 wxFONTWEIGHT_LIGHT = wxLIGHT,
323 wxFONTWEIGHT_BOLD = wxBOLD,
331 wxFONTENCODING_SYSTEM = -1, // system default
332 wxFONTENCODING_DEFAULT, // current default encoding
334 // ISO8859 standard defines a number of single-byte charsets
335 wxFONTENCODING_ISO8859_1, // West European (Latin1)
336 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
337 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
338 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
339 wxFONTENCODING_ISO8859_5, // Cyrillic
340 wxFONTENCODING_ISO8859_6, // Arabic
341 wxFONTENCODING_ISO8859_7, // Greek
342 wxFONTENCODING_ISO8859_8, // Hebrew
343 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
344 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
345 wxFONTENCODING_ISO8859_11, // Thai
346 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
347 // here anyhow to make all ISO8859
348 // consecutive numbers
349 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
350 wxFONTENCODING_ISO8859_14, // Latin8
351 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
352 wxFONTENCODING_ISO8859_MAX,
354 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
355 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
356 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
357 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
359 // what would we do without Microsoft? They have their own encodings
361 wxFONTENCODING_CP437, // original MS-DOS codepage
362 wxFONTENCODING_CP850, // CP437 merged with Latin1
363 wxFONTENCODING_CP852, // CP437 merged with Latin2
364 wxFONTENCODING_CP855, // another cyrillic encoding
365 wxFONTENCODING_CP866, // and another one
367 wxFONTENCODING_CP874, // WinThai
368 wxFONTENCODING_CP932, // Japanese (shift-JIS)
369 wxFONTENCODING_CP936, // Chiniese simplified (GB)
370 wxFONTENCODING_CP949, // Korean (Hangul charset)
371 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
372 wxFONTENCODING_CP1250, // WinLatin2
373 wxFONTENCODING_CP1251, // WinCyrillic
374 wxFONTENCODING_CP1252, // WinLatin1
375 wxFONTENCODING_CP1253, // WinGreek (8859-7)
376 wxFONTENCODING_CP1254, // WinTurkish
377 wxFONTENCODING_CP1255, // WinHebrew
378 wxFONTENCODING_CP1256, // WinArabic
379 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
380 wxFONTENCODING_CP12_MAX,
382 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
383 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
385 wxFONTENCODING_UNICODE, // Unicode - currently used only by
386 // wxEncodingConverter class
393 // wxNativeFontInfo is platform-specific font representation: this struct
394 // should be considered as opaque font description only used by the native
395 // functions, the user code can only get the objects of this type from
396 // somewhere and pass it somewhere else (possibly save them somewhere using
397 // ToString() and restore them using FromString())
398 struct wxNativeFontInfo
401 // init the elements from an XLFD, return TRUE if ok
402 bool FromXFontName(const wxString& xFontName);
404 // return false if we were never initialized with a valid XLFD
405 bool IsDefault() const;
407 // generate an XLFD using the fontElements
408 wxString GetXFontName() const;
411 void SetXFontName(const wxString& xFontName);
414 wxNativeFontInfo() { Init(); }
416 // reset to the default state
420 // accessors and modifiers for the font elements
421 int GetPointSize() const;
422 wxFontStyle GetStyle() const;
423 wxFontWeight GetWeight() const;
424 bool GetUnderlined() const;
425 wxString GetFaceName() const;
426 wxFontFamily GetFamily() const;
427 wxFontEncoding GetEncoding() const;
429 void SetPointSize(int pointsize);
430 void SetStyle(wxFontStyle style);
431 void SetWeight(wxFontWeight weight);
432 void SetUnderlined(bool underlined);
433 void SetFaceName(wxString facename);
434 void SetFamily(wxFontFamily family);
435 void SetEncoding(wxFontEncoding encoding);
438 // it is important to be able to serialize wxNativeFontInfo objects to be
439 // able to store them (in config file, for example)
440 bool FromString(const wxString& s);
441 wxString ToString() const;
445 return self->ToString();
449 // we also want to present the native font descriptions to the user in some
450 // human-readable form (it is not platform independent neither, but can
451 // hopefully be understood by the user)
452 bool FromUserString(const wxString& s);
453 wxString ToUserString() const;
457 // wxFontMapper manages user-definable correspondence between logical font
458 // names and the fonts present on the machine.
460 // The default implementations of all functions will ask the user if they are
461 // not capable of finding the answer themselves and store the answer in a
462 // config file (configurable via SetConfigXXX functions). This behaviour may
463 // be disabled by giving the value of FALSE to "interactive" parameter.
464 // However, the functions will always consult the config file to allow the
465 // user-defined values override the default logic and there is no way to
466 // disable this - which shouldn't be ever needed because if "interactive" was
467 // never TRUE, the config file is never created anyhow.
475 // find an alternative for the given encoding (which is supposed to not be
476 // available on this system). If successful, return TRUE and rwxFontEcoding
477 // that can be used it wxFont ctor otherwise return FALSE
478 //bool GetAltForEncoding(wxFontEncoding encoding,
479 // wxFontEncoding *alt_encoding,
480 // const wxString& facename = wxEmptyString,
481 // bool interactive = TRUE);
484 // Find an alternative for the given encoding (which is supposed to not be
485 // available on this system). If successful, returns the encoding otherwise
488 PyObject* GetAltForEncoding(wxFontEncoding encoding,
489 const wxString& facename = wxEmptyString,
490 bool interactive = TRUE) {
491 wxFontEncoding alt_enc;
492 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
493 return PyInt_FromLong(alt_enc);
502 // checks whether given encoding is available in given face or not.
503 // If no facename is given,
504 bool IsEncodingAvailable(wxFontEncoding encoding,
505 const wxString& facename = wxEmptyString);
507 // returns the encoding for the given charset (in the form of RFC 2046) or
508 // wxFONTENCODING_SYSTEM if couldn't decode it
509 wxFontEncoding CharsetToEncoding(const wxString& charset,
510 bool interactive = TRUE);
512 // return internal string identifier for the encoding (see also
513 // GetEncodingDescription())
514 static wxString GetEncodingName(wxFontEncoding encoding);
516 // return user-readable string describing the given encoding
518 // NB: hard-coded now, but might change later (read it from config?)
519 static wxString GetEncodingDescription(wxFontEncoding encoding);
521 // the parent window for modal dialogs
522 void SetDialogParent(wxWindow *parent);
524 // the title for the dialogs (note that default is quite reasonable)
525 void SetDialogTitle(const wxString& title);
527 // functions which allow to configure the config object used: by default,
528 // the global one (from wxConfigBase::Get() will be used) and the default
529 // root path for the config settings is the string returned by
530 // GetDefaultConfigPath()
533 // set the config object to use (may be NULL to use default)
534 void SetConfig(wxConfigBase *config);
536 // set the root config path to use (should be an absolute path)
537 void SetConfigPath(const wxString& prefix);
539 // return default config path
540 static const wxChar *GetDefaultConfigPath();
546 class wxFont : public wxGDIObject {
548 wxFont( int pointSize, int family, int style, int weight,
549 int underline=FALSE, char* faceName = "",
550 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
552 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
557 int GetPointSize() const;
558 int GetFamily() const;
559 int GetStyle() const;
560 int GetWeight() const;
561 bool GetUnderlined() const;
562 wxString GetFaceName() const;
563 wxFontEncoding GetEncoding() const;
567 wxNativeFontInfo* GetNativeFontInfo() const;
568 wxString GetNativeFontInfoDesc() const;
569 wxString GetNativeFontInfoUserDesc() const;
571 void SetPointSize(int pointSize);
572 void SetFamily(int family);
573 void SetStyle(int style);
574 void SetWeight(int weight);
575 void SetFaceName(const wxString& faceName);
576 void SetUnderlined(bool underlined);
577 void SetEncoding(wxFontEncoding encoding);
578 void SetNativeFontInfo(const wxNativeFontInfo& info);
579 // void SetNativeFontInfo(const wxString& info);
580 void SetNativeFontInfoUserDesc(const wxString& info);
582 wxString GetFamilyString() const;
583 wxString GetStyleString() const;
584 wxString GetWeightString() const;
586 static wxFontEncoding GetDefaultEncoding();
587 static void SetDefaultEncoding(wxFontEncoding encoding);
592 class wxFontList : public wxObject {
595 void AddFont(wxFont* font);
596 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
597 bool underline = FALSE, const char* facename = NULL,
598 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
599 void RemoveFont(wxFont *font);
605 //----------------------------------------------------------------------
607 class wxColour : public wxObject {
609 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
612 unsigned char Green();
613 unsigned char Blue();
615 void Set(unsigned char red, unsigned char green, unsigned char blue);
618 PyObject* rv = PyTuple_New(3);
619 PyTuple_SetItem(rv, 0, PyInt_FromLong(self->Red()));
620 PyTuple_SetItem(rv, 1, PyInt_FromLong(self->Green()));
621 PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
625 %pragma(python) addtoclass = "asTuple = Get"
626 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
627 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
631 %new wxColour* wxNamedColour(const wxString& colorName);
633 %{ // Alternate 'constructor'
634 wxColour* wxNamedColour(const wxString& colorName) {
635 return new wxColour(colorName);
641 class wxColourDatabase : public wxObject {
644 wxColour *FindColour(const wxString& colour);
645 wxString FindName(const wxColour& colour) const;
648 void Append(const wxString& name, int red, int green, int blue) {
649 self->Append(name.c_str(), new wxColour(red, green, blue));
655 //----------------------------------------------------------------------
657 class wxPen : public wxGDIObject {
659 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
663 wxColour GetColour();
669 void SetCap(int cap_style);
670 void SetColour(wxColour& colour);
671 void SetJoin(int join_style);
672 void SetStyle(int style);
673 void SetWidth(int width);
675 // **** This one needs to return a list of ints (wxDash)
676 //int GetDashes(wxDash **dashes);
677 void SetDashes(int LCOUNT, wxDash* choices);
680 wxBitmap* GetStipple();
681 void SetStipple(wxBitmap& stipple);
688 // The list of ints for the dashes needs to exist for the life of the pen
689 // so we make it part of the class to save it. wxPyPen is aliased to wxPen
693 class wxPyPen : public wxPen {
695 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID)
696 : wxPen(colour, width, style)
703 void SetDashes(int nb_dashes, const wxDash *dash) {
706 m_dash = new wxDash[nb_dashes];
707 for (int i=0; i<nb_dashes; i++) {
710 wxPen::SetDashes(nb_dashes, m_dash);
719 class wxPyPen : public wxPen {
721 wxPyPen(wxColour& colour, int width=1, int style=wxSOLID);
724 void SetDashes(int LCOUNT, wxDash* choices);
730 class wxPenList : public wxObject {
733 void AddPen(wxPen* pen);
734 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
735 void RemovePen(wxPen* pen);
742 //----------------------------------------------------------------------
744 class wxBrush : public wxGDIObject {
746 wxBrush(const wxColour& colour, int style=wxSOLID);
749 wxColour GetColour();
750 wxBitmap * GetStipple();
753 void SetColour(wxColour &colour);
754 void SetStipple(wxBitmap& bitmap);
755 void SetStyle(int style);
759 class wxBrushList : public wxObject {
762 void AddBrush(wxBrush *brush);
763 wxBrush * FindOrCreateBrush(const wxColour& colour, int style);
764 void RemoveBrush(wxBrush *brush);
769 //----------------------------------------------------------------------
773 class wxDC : public wxObject {
775 // wxDC(); **** abstract base class, can't instantiate.
780 bool Blit(long xdest, long ydest,
781 long width, long height,
782 wxDC *source, long xsrc, long ysrc,
783 int logicalFunc = wxCOPY, int useMask = FALSE);
784 // bool Blit(const wxPoint& destPt, const wxSize& sz,
785 // wxDC *source, const wxPoint& srcPt,
786 // int logicalFunc = wxCOPY, int useMask = FALSE);
789 void CrossHair(long x, long y);
790 void DestroyClippingRegion();
791 long DeviceToLogicalX(long x);
792 long DeviceToLogicalXRel(long x);
793 long DeviceToLogicalY(long y);
794 long DeviceToLogicalYRel(long y);
795 void DrawArc(long x1, long y1, long x2, long y2, long xc, long yc);
796 void DrawCircle(long x, long y, long radius);
797 void DrawEllipse(long x, long y, long width, long height);
798 void DrawEllipticArc(long x, long y, long width, long height, long start, long end);
799 void DrawIcon(const wxIcon& icon, long x, long y);
800 void DrawLine(long x1, long y1, long x2, long y2);
801 void DrawLines(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0);
802 void DrawPolygon(int PCOUNT, wxPoint* points, long xoffset=0, long yoffset=0,
803 int fill_style=wxODDEVEN_RULE);
804 void DrawPoint(long x, long y);
805 void DrawRectangle(long x, long y, long width, long height);
806 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
807 void DrawRoundedRectangle(long x, long y, long width, long height, long radius=20);
808 void DrawSpline(int PCOUNT, wxPoint* points);
809 void DrawText(const wxString& text, long x, long y);
813 void FloodFill(long x, long y, const wxColour& colour, int style=wxFLOOD_SURFACE);
814 wxBrush GetBackground();
816 long GetCharHeight();
818 void GetClippingBox(long *OUTPUT, long *OUTPUT,
819 long *OUTPUT, long *OUTPUT);
821 int GetLogicalFunction();
822 void GetLogicalScale(double *OUTPUT, double *OUTPUT);
824 bool GetOptimization();
827 %new wxColour* GetPixel(long x, long y) {
828 wxColour* wc = new wxColour();
829 self->GetPixel(x, y, wc);
833 %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT);
836 wxColour GetTextBackground();
837 void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT);
838 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
839 long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT,
840 const wxFont* font = NULL);
841 wxColour GetTextForeground();
842 void GetUserScale(double *OUTPUT, double *OUTPUT);
843 long LogicalToDeviceX(long x);
844 long LogicalToDeviceXRel(long x);
845 long LogicalToDeviceY(long y);
846 long LogicalToDeviceYRel(long y);
852 void SetDeviceOrigin(long x, long y);
853 void SetBackground(const wxBrush& brush);
854 void SetBackgroundMode(int mode);
855 void SetClippingRegion(long x, long y, long width, long height);
856 %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
857 void SetPalette(const wxPalette& colourMap);
858 void SetBrush(const wxBrush& brush);
859 void SetFont(const wxFont& font);
860 void SetLogicalFunction(int function);
861 void SetLogicalScale(double x, double y);
862 void SetMapMode(int mode);
863 void SetOptimization(bool optimize);
864 void SetPen(const wxPen& pen);
865 void SetTextBackground(const wxColour& colour);
866 void SetTextForeground(const wxColour& colour);
867 void SetUserScale(double x_scale, double y_scale);
868 bool StartDoc(const wxString& message);
873 void DrawBitmap(const wxBitmap& bitmap, long x, long y,
874 int useMask = FALSE);
876 bool CanDrawBitmap();
877 bool CanGetTextExtent();
881 void GetLogicalOrigin(int *OUTPUT, int *OUTPUT);
882 void SetLogicalOrigin(int x, int y);
883 void GetDeviceOrigin(int *OUTPUT, int *OUTPUT);
884 void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
886 void CalcBoundingBox(int x, int y);
887 void ResetBoundingBox();
890 void GetBoundingBox(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
891 // See below for implementation
900 // NOTE: These methods are VERY SIMILAR in implentation. It would be
901 // nice to factor out common code and or turn them into a set of
902 // template-like macros.
904 // Draw a point for every set of coordinants in pyPoints, optionally
905 // setting a new pen for each
906 PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) {
907 bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints);
908 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
916 if (!PySequence_Check(pyPoints)) {
919 if (!PySequence_Check(pyPens)) {
922 numObjs = PySequence_Length(pyPoints);
923 numPens = PySequence_Length(pyPens);
925 for (i = 0; i < numObjs; i++) {
929 obj = PySequence_Fast_GET_ITEM(pyPens, i);
932 obj = PySequence_GetItem(pyPens, i);
934 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
945 // Get the point coordinants
947 obj = PySequence_Fast_GET_ITEM(pyPoints, i);
950 obj = PySequence_GetItem(pyPoints, i);
952 if (! _2int_seq_helper(obj, &x1, &y1)) {
958 // Now draw the point
959 self->DrawPoint(x1, y1);
969 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
972 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences.");
977 // Draw a line for every set of coordinants in pyLines, optionally
978 // setting a new pen for each
979 PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) {
980 bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines);
981 bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens);
989 if (!PySequence_Check(pyLines)) {
992 if (!PySequence_Check(pyPens)) {
995 numObjs = PySequence_Length(pyLines);
996 numPens = PySequence_Length(pyPens);
998 for (i = 0; i < numObjs; i++) {
1002 obj = PySequence_Fast_GET_ITEM(pyPens, i);
1005 obj = PySequence_GetItem(pyPens, i);
1007 if (SWIG_GetPtrObj(obj, (void **) &pen, "_wxPen_p")) {
1018 // Get the line coordinants
1020 obj = PySequence_Fast_GET_ITEM(pyLines, i);
1023 obj = PySequence_GetItem(pyLines, i);
1025 if (! _4int_seq_helper(obj, &x1, &y1, &x2, &y2)) {
1031 // Now draw the line
1032 self->DrawLine(x1, y1, x2, y2);
1042 PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens");
1045 PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences.");
1051 %pragma(python) addtoclass = "
1052 def DrawPointList(self, points, pens=None):
1055 elif isinstance(pens, wxPenPtr):
1057 elif len(pens) != len(points):
1058 raise ValueError('points and pens must have same length')
1059 return self._DrawPointList(points, pens)
1061 def DrawLineList(self, lines, pens=None):
1064 elif isinstance(pens, wxPenPtr):
1066 elif len(pens) != len(lines):
1067 raise ValueError('lines and pens must have same length')
1068 return self._DrawLineList(lines, pens)
1077 static void wxDC_GetBoundingBox(wxDC* dc, int* x1, int* y1, int* x2, int* y2) {
1085 //----------------------------------------------------------------------
1087 class wxMemoryDC : public wxDC {
1091 void SelectObject(const wxBitmap& bitmap);
1094 %new wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC);
1095 %{ // Alternate 'constructor'
1096 wxMemoryDC* wxMemoryDCFromDC(wxDC* oldDC) {
1097 return new wxMemoryDC(oldDC);
1102 //---------------------------------------------------------------------------
1104 class wxScreenDC : public wxDC {
1108 %name(StartDrawingOnTopWin) bool StartDrawingOnTop(wxWindow* window);
1109 bool StartDrawingOnTop(wxRect* rect = NULL);
1110 bool EndDrawingOnTop();
1113 //---------------------------------------------------------------------------
1115 class wxClientDC : public wxDC {
1117 wxClientDC(wxWindow* win);
1120 //---------------------------------------------------------------------------
1122 class wxPaintDC : public wxDC {
1124 wxPaintDC(wxWindow* win);
1127 //---------------------------------------------------------------------------
1129 class wxWindowDC : public wxDC {
1131 wxWindowDC(wxWindow* win);
1134 //---------------------------------------------------------------------------
1140 #include <wx/metafile.h>
1143 class wxMetaFile : public wxObject {
1145 wxMetaFile(const wxString& filename = wxPyEmptyStr);
1149 bool SetClipboard(int width = 0, int height = 0);
1155 const wxString& GetFileName() const { return m_filename; }
1159 // bool wxMakeMetaFilePlaceable(const wxString& filename,
1160 // int minX, int minY, int maxX, int maxY, float scale=1.0);
1163 class wxMetaFileDC : public wxDC {
1165 wxMetaFileDC(const wxString& filename = wxPyEmptyStr,
1166 int width = 0, int height = 0,
1167 const wxString& description = wxPyEmptyStr);
1168 wxMetaFile* Close();
1173 //---------------------------------------------------------------------------
1175 class wxPalette : public wxGDIObject {
1177 wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices);
1180 int GetPixel(byte red, byte green, byte blue);
1181 bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
1185 //---------------------------------------------------------------------------
1188 wxIMAGELIST_DRAW_NORMAL ,
1189 wxIMAGELIST_DRAW_TRANSPARENT,
1190 wxIMAGELIST_DRAW_SELECTED,
1191 wxIMAGELIST_DRAW_FOCUSED,
1192 wxIMAGE_LIST_NORMAL,
1197 class wxImageList : public wxObject {
1199 wxImageList(int width, int height, int mask=TRUE, int initialCount=1);
1202 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1203 %name(AddWithColourMask)int Add(const wxBitmap& bitmap, const wxColour& maskColour);
1204 %name(AddIcon)int Add(const wxIcon& icon);
1206 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
1208 // %name(ReplaceIcon)bool Replace(int index, const wxIcon& icon);
1209 // int Add(const wxBitmap& bitmap);
1210 bool Replace(int index, const wxBitmap& bitmap);
1213 bool Draw(int index, wxDC& dc, int x, int x, int flags = wxIMAGELIST_DRAW_NORMAL,
1214 const bool solidBackground = FALSE);
1216 int GetImageCount();
1217 bool Remove(int index);
1219 void GetSize(int index, int& OUTPUT, int& OUTPUT);
1223 //---------------------------------------------------------------------------
1226 enum wxRegionContain {
1227 wxOutRegion, wxPartRegion, wxInRegion
1231 class wxRegion : public wxGDIObject {
1233 wxRegion(long x=0, long y=0, long width=0, long height=0);
1237 wxRegionContain Contains(long x, long y);
1238 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
1239 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
1240 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
1244 bool Intersect(long x, long y, long width, long height);
1245 %name(IntersectRect)bool Intersect(const wxRect& rect);
1246 %name(IntersectRegion)bool Intersect(const wxRegion& region);
1250 bool Union(long x, long y, long width, long height);
1251 %name(UnionRect)bool Union(const wxRect& rect);
1252 %name(UnionRegion)bool Union(const wxRegion& region);
1254 bool Subtract(long x, long y, long width, long height);
1255 %name(SubtractRect)bool Subtract(const wxRect& rect);
1256 %name(SubtractRegion)bool Subtract(const wxRegion& region);
1258 bool Xor(long x, long y, long width, long height);
1259 %name(XorRect)bool Xor(const wxRect& rect);
1260 %name(XorRegion)bool Xor(const wxRegion& region);
1265 class wxRegionIterator : public wxObject {
1267 wxRegionIterator(const wxRegion& region);
1268 ~wxRegionIterator();
1288 //---------------------------------------------------------------------------
1295 extern wxFont *wxNORMAL_FONT;
1296 extern wxFont *wxSMALL_FONT;
1297 extern wxFont *wxITALIC_FONT;
1298 extern wxFont *wxSWISS_FONT;
1300 extern wxPen *wxRED_PEN;
1301 extern wxPen *wxCYAN_PEN;
1302 extern wxPen *wxGREEN_PEN;
1303 extern wxPen *wxBLACK_PEN;
1304 extern wxPen *wxWHITE_PEN;
1305 extern wxPen *wxTRANSPARENT_PEN;
1306 extern wxPen *wxBLACK_DASHED_PEN;
1307 extern wxPen *wxGREY_PEN;
1308 extern wxPen *wxMEDIUM_GREY_PEN;
1309 extern wxPen *wxLIGHT_GREY_PEN;
1311 extern wxBrush *wxBLUE_BRUSH;
1312 extern wxBrush *wxGREEN_BRUSH;
1313 extern wxBrush *wxWHITE_BRUSH;
1314 extern wxBrush *wxBLACK_BRUSH;
1315 extern wxBrush *wxTRANSPARENT_BRUSH;
1316 extern wxBrush *wxCYAN_BRUSH;
1317 extern wxBrush *wxRED_BRUSH;
1318 extern wxBrush *wxGREY_BRUSH;
1319 extern wxBrush *wxMEDIUM_GREY_BRUSH;
1320 extern wxBrush *wxLIGHT_GREY_BRUSH;
1322 extern wxColour *wxBLACK;
1323 extern wxColour *wxWHITE;
1324 extern wxColour *wxRED;
1325 extern wxColour *wxBLUE;
1326 extern wxColour *wxGREEN;
1327 extern wxColour *wxCYAN;
1328 extern wxColour *wxLIGHT_GREY;
1330 extern wxCursor *wxSTANDARD_CURSOR;
1331 extern wxCursor *wxHOURGLASS_CURSOR;
1332 extern wxCursor *wxCROSS_CURSOR;
1335 extern wxBitmap wxNullBitmap;
1336 extern wxIcon wxNullIcon;
1337 extern wxCursor wxNullCursor;
1338 extern wxPen wxNullPen;
1339 extern wxBrush wxNullBrush;
1340 extern wxPalette wxNullPalette;
1341 extern wxFont wxNullFont;
1342 extern wxColour wxNullColour;
1345 extern wxFontList* wxTheFontList;
1346 extern wxPenList* wxThePenList;
1347 extern wxBrushList* wxTheBrushList;
1348 extern wxColourDatabase* wxTheColourDatabase;
1356 //---------------------------------------------------------------------------
1357 //---------------------------------------------------------------------------