X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b68dc582b8c6dd32ef9f0a4ec91573bd5cc0296a..b8fbf1a035db2af6d3aba89203263a4711cb7c53:/wxPython/src/gdi.i?ds=sidebyside diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 8d6dbfe7a5..21f67f0232 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -31,34 +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(); @@ -105,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__ @@ -317,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(); @@ -352,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(); @@ -389,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(); @@ -413,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(); @@ -480,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); @@ -531,6 +623,10 @@ public: void CalcBoundingBox(int x, int y); void ResetBoundingBox(); + +#ifdef __WXMSW__ + long GetHDC(); +#endif }; @@ -594,15 +690,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 { @@ -668,6 +755,13 @@ extern wxPalette wxNullPalette; extern wxFont wxNullFont; extern wxColour wxNullColour; + +extern wxFontList* wxTheFontList; +extern wxPenList* wxThePenList; +extern wxBrushlist* wxTheBrushList; +extern wxColourDatabase* wxTheColourDatabase; + + %readwrite %{ #endif @@ -675,7 +769,7 @@ extern wxColour wxNullColour; //--------------------------------------------------------------------------- -class wxPalette { +class wxPalette : public wxGDIObject { public: wxPalette(int LCOUNT, byte* choices, byte* choices, byte* choices); ~wxPalette(); @@ -697,7 +791,7 @@ enum { wxIMAGE_LIST_STATE }; -class wxImageList { +class wxImageList : public wxObject { public: wxImageList(int width, int height, int mask=TRUE, int initialCount=1); ~wxImageList(); @@ -723,5 +817,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) ++; + } + }; +}; + + //---------------------------------------------------------------------------