X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de20db997ddf7ee903076e72e9918caa2e269c19..0e980f91092ded629a7b014ff0d2238b1c8940c5:/wxPython/src/gdi.i diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 63e628e81e..192668dbab 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -31,29 +31,30 @@ %import _defs.i %import misc.i +%{ + static wxString wxPyEmptyStr(""); +%} + //--------------------------------------------------------------------------- -// class wxGDIImage { -// public: -// long GetHandle(); -// void SetHandle(long handle); -// bool Ok(); -// int GetWidth(); -// int GetHeight(); -// int GetDepth(); -// void SetWidth(int w); -// void SetHeight(int h); -// void SetDepth(int d); -// void SetSize(const wxSize& size); -// }; +class wxGDIObject : public wxObject { +public: + wxGDIObject(); + ~wxGDIObject(); + + bool GetVisible(); + void SetVisible( bool visible ); + + bool IsNull(); + +}; //--------------------------------------------------------------------------- -class wxBitmap -//: public wxGDIImage +class wxBitmap : public wxGDIObject { public: - wxBitmap(const wxString& name, long type); + wxBitmap(const wxString& name, wxBitmapType type); ~wxBitmap(); wxPalette* GetPalette(); @@ -100,37 +101,87 @@ public: }; +// Declarations of some alternate "constructors" %new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1); +%new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings); +%new wxBitmap* wxBitmapFromIcon(const wxIcon& icon); +%new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ); -#ifdef __WXMSW__ -%new wxBitmap* wxBitmapFromData(PyObject* data, long type, - int width, int height, int depth = 1); -#endif +// #ifdef __WXMSW__ +// %new wxBitmap* wxBitmapFromData(PyObject* data, long type, +// int width, int height, int depth = 1); +// #endif + + + +%{ // Implementations of some alternate "constructors" -%{ // Alternate 'constructor' wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) { return new wxBitmap(width, height, depth); } -#ifdef __WXMSW__ - wxBitmap* wxBitmapFromData(PyObject* data, long type, - int width, int height, int depth = 1) { - if (! PyString_Check(data)) { - PyErr_SetString(PyExc_TypeError, "Expected string object"); + static char** ConvertListOfStrings(PyObject* listOfStrings) { + char** cArray = NULL; + int count; + + if (!PyList_Check(listOfStrings)) { + PyErr_SetString(PyExc_TypeError, "Expected a list of strings."); return NULL; } + count = PyList_Size(listOfStrings); + cArray = new char*[count]; - return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth); + for(int x=0; xFindOrCreateFont(pointSize, family, style, weight, - underline, faceName, encoding); - } - // NO Destructor. - } +class wxFont : public wxGDIObject { +public: + wxFont( int pointSize, int family, int style, int weight, + int underline=FALSE, char* faceName = "", + wxFontEncoding encoding=wxFONTENCODING_DEFAULT); + ~wxFont(); bool Ok(); - wxString GetFaceName(); int GetFamily(); #ifdef __WXMSW__ @@ -312,9 +376,21 @@ public: } %} + +class wxFontList : public wxObject { +public: + + void AddFont(wxFont* font); + wxFont * FindOrCreateFont(int point_size, int family, int style, int weight, + bool underline = FALSE, const char* facename = NULL, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + void RemoveFont(wxFont *font); +}; + + //---------------------------------------------------------------------- -class wxColour { +class wxColour : public wxObject { public: wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0); ~wxColour(); @@ -347,22 +423,31 @@ public: %} -//---------------------------------------------------------------------- - -class wxPen { +class wxColourDatabase : public wxObject { public: - // I'll do it this way to use long-lived objects and not have to - // worry about when python may delete the object. + + wxColour *FindColour(const wxString& colour); + wxString FindName(const wxColour& colour) const; + %addmethods { - wxPen(wxColour* colour, int width=1, int style=wxSOLID) { - return wxThePenList->FindOrCreatePen(*colour, width, style); + void Append(const wxString& name, int red, int green, int blue) { + self->Append(name.c_str(), new wxColour(red, green, blue)); } - // NO Destructor. } +}; + + +//---------------------------------------------------------------------- + + +class wxPen : public wxGDIObject { +public: + wxPen(wxColour& colour, int width=1, int style=wxSOLID); + ~wxPen(); int GetCap(); - wxColour& GetColour(); + wxColour GetColour(); int GetJoin(); int GetStyle(); @@ -384,22 +469,25 @@ public: #endif }; -//---------------------------------------------------------------------- -class wxBrush { +class wxPenList : public wxObject { public: - // I'll do it this way to use long-lived objects and not have to - // worry about when python may delete the object. - %addmethods { - wxBrush(const wxColour* colour, int style=wxSOLID) { - return wxTheBrushList->FindOrCreateBrush(*colour, style); - } - // NO Destructor. - } -// wxBrush(const wxColour& colour, int style=wxSOLID); + void AddPen(wxPen* pen); + wxPen* FindOrCreatePen(const wxColour& colour, int width, int style); + void RemovePen(wxPen* pen); +}; - wxColour& GetColour(); + + +//---------------------------------------------------------------------- + +class wxBrush : public wxGDIObject { +public: + wxBrush(const wxColour& colour, int style=wxSOLID); + ~wxBrush(); + + wxColour GetColour(); wxBitmap * GetStipple(); int GetStyle(); bool Ok(); @@ -408,11 +496,20 @@ public: void SetStyle(int style); }; + +class wxBrushList { +public: + + void AddBrush(wxBrush *brush); + wxBrush * FindOrCreateBrush(const wxColour& colour, int style); + void RemoveBrush(wxBrush *brush); +}; + //---------------------------------------------------------------------- -class wxDC { +class wxDC : public wxObject { public: // wxDC(); **** abstract base class, can't instantiate. ~wxDC(); @@ -475,12 +572,12 @@ public: %name(GetSizeTuple)void GetSize(int* OUTPUT, int* OUTPUT); wxSize GetSize(); wxSize GetSizeMM(); - wxColour& GetTextBackground(); + wxColour GetTextBackground(); void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT); %name(GetFullTextExtent)void GetTextExtent(const wxString& string, long *OUTPUT, long *OUTPUT, long *OUTPUT, long* OUTPUT, const wxFont* font = NULL); - wxColour& GetTextForeground(); + wxColour GetTextForeground(); void GetUserScale(double *OUTPUT, double *OUTPUT); long LogicalToDeviceX(long x); long LogicalToDeviceXRel(long x); @@ -589,15 +686,6 @@ public: //--------------------------------------------------------------------------- -#ifdef __WXMSW__ -class wxPrinterDC : public wxDC { -public: - wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, - bool interactive = TRUE, int orientation = wxPORTRAIT); -}; -#endif - -//--------------------------------------------------------------------------- #ifdef __WXMSW__ class wxMetaFileDC : public wxDC { @@ -663,6 +751,13 @@ extern wxPalette wxNullPalette; extern wxFont wxNullFont; extern wxColour wxNullColour; + +extern wxFontList* wxTheFontList; +extern wxPenList* wxThePenList; +extern wxBrushlist* wxTheBrushList; +extern wxColourDatabase* wxTheColourDatabase; + + %readwrite %{ #endif @@ -670,7 +765,7 @@ extern wxColour wxNullColour; //--------------------------------------------------------------------------- -class wxPalette { +class wxPalette : public wxGDIObject { public: wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); ~wxPalette(); @@ -692,7 +787,7 @@ enum { wxIMAGE_LIST_STATE }; -class wxImageList { +class wxImageList : public wxObject { public: wxImageList(int width, int height, int mask=TRUE, int initialCount=1); ~wxImageList(); @@ -718,5 +813,70 @@ public: }; +//--------------------------------------------------------------------------- +// Regions, etc. + +enum wxRegionContain { + wxOutRegion, wxPartRegion, wxInRegion +}; + + +class wxRegion : public wxGDIObject { +public: + wxRegion(long x=0, long y=0, long width=0, long height=0); + ~wxRegion(); + + void Clear(); + wxRegionContain Contains(long x, long y); + %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); + %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); + %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h); + + wxRect GetBox(); + + bool Intersect(long x, long y, long width, long height); + %name(IntersectRect)bool Intersect(const wxRect& rect); + %name(IntersectRegion)bool Intersect(const wxRegion& region); + + bool IsEmpty(); + + bool Union(long x, long y, long width, long height); + %name(UnionRect)bool Union(const wxRect& rect); + %name(UnionRegion)bool Union(const wxRegion& region); + + bool Subtract(long x, long y, long width, long height); + %name(SubtractRect)bool Subtract(const wxRect& rect); + %name(SubtractRegion)bool Subtract(const wxRegion& region); + + bool Xor(long x, long y, long width, long height); + %name(XorRect)bool Xor(const wxRect& rect); + %name(XorRegion)bool Xor(const wxRegion& region); +}; + + + +class wxRegionIterator : public wxObject { +public: + wxRegionIterator(const wxRegion& region); + ~wxRegionIterator(); + + long GetX(); + long GetY(); + long GetW(); + long GetWidth(); + long GetH(); + long GetHeight(); + wxRect GetRect(); + bool HaveRects(); + void Reset(); + + %addmethods { + void Next() { + (*self) ++; + } + }; +}; + + //---------------------------------------------------------------------------