]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/gtk/gdi.py
SWIGged updates for wxGTK
[wxWidgets.git] / wxPython / src / gtk / gdi.py
index 364bb91b86eff82165fe4cf8da3788c7c0fc39d8..a5a770e9aad93021b55e4ab49cc8812bb42bee49 100644 (file)
@@ -4,13 +4,17 @@ import gdic
 from misc import *
 
 from fonts import *
 from misc import *
 
 from fonts import *
+import wx
 class wxGDIObjectPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
 class wxGDIObjectPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxGDIObject(self)
+    def __del__(self, delfunc=gdic.delete_wxGDIObject):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetVisible(self, *_args, **_kwargs):
         val = apply(gdic.wxGDIObject_GetVisible,(self,) + _args, _kwargs)
         return val
     def GetVisible(self, *_args, **_kwargs):
         val = apply(gdic.wxGDIObject_GetVisible,(self,) + _args, _kwargs)
         return val
@@ -34,9 +38,12 @@ class wxBitmapPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxBitmap(self)
+    def __del__(self, delfunc=gdic.delete_wxBitmap):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetPalette(self, *_args, **_kwargs):
         val = apply(gdic.wxBitmap_GetPalette,(self,) + _args, _kwargs)
         if val: val = wxPalettePtr(val) 
     def GetPalette(self, *_args, **_kwargs):
         val = apply(gdic.wxBitmap_GetPalette,(self,) + _args, _kwargs)
         if val: val = wxPalettePtr(val) 
@@ -85,13 +92,10 @@ class wxBitmapPtr(wxGDIObjectPtr):
     def __repr__(self):
         return "<C wxBitmap instance at %s>" % (self.this,)
     
     def __repr__(self):
         return "<C wxBitmap instance at %s>" % (self.this,)
     
-    def __del__(self,gdic=gdic):
-        try:
-            if self.thisown == 1 :
-                gdic.delete_wxBitmap(self)
-        except:
-            pass
-
+    def SetMaskColour(self, colour):
+        mask = wxMaskColour(self, colour)
+        self.SetMask(mask)
+    
 class wxBitmap(wxBitmapPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxBitmap,_args,_kwargs)
 class wxBitmap(wxBitmapPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxBitmap,_args,_kwargs)
@@ -121,9 +125,12 @@ class wxIconPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxIcon(self)
+    def __del__(self, delfunc=gdic.delete_wxIcon):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def LoadFile(self, *_args, **_kwargs):
         val = apply(gdic.wxIcon_LoadFile,(self,) + _args, _kwargs)
         return val
     def LoadFile(self, *_args, **_kwargs):
         val = apply(gdic.wxIcon_LoadFile,(self,) + _args, _kwargs)
         return val
@@ -153,14 +160,6 @@ class wxIconPtr(wxGDIObjectPtr):
         return val
     def __repr__(self):
         return "<C wxIcon instance at %s>" % (self.this,)
         return val
     def __repr__(self):
         return "<C wxIcon instance at %s>" % (self.this,)
-    
-    def __del__(self,gdic=gdic):
-        try:
-            if self.thisown == 1 :
-                gdic.delete_wxIcon(self)
-        except:
-            pass
-
 class wxIcon(wxIconPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxIcon,_args,_kwargs)
 class wxIcon(wxIconPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxIcon,_args,_kwargs)
@@ -173,9 +172,12 @@ class wxIconBundlePtr :
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxIconBundle(self)
+    def __del__(self, delfunc=gdic.delete_wxIconBundle):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def AddIcon(self, *_args, **_kwargs):
         val = apply(gdic.wxIconBundle_AddIcon,(self,) + _args, _kwargs)
         return val
     def AddIcon(self, *_args, **_kwargs):
         val = apply(gdic.wxIconBundle_AddIcon,(self,) + _args, _kwargs)
         return val
@@ -210,9 +212,12 @@ class wxCursorPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxCursor(self)
+    def __del__(self, delfunc=gdic.delete_wxCursor):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def Ok(self, *_args, **_kwargs):
         val = apply(gdic.wxCursor_Ok,(self,) + _args, _kwargs)
         return val
     def Ok(self, *_args, **_kwargs):
         val = apply(gdic.wxCursor_Ok,(self,) + _args, _kwargs)
         return val
@@ -229,9 +234,12 @@ class wxColourPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxColour(self)
+    def __del__(self, delfunc=gdic.delete_wxColour):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def Red(self, *_args, **_kwargs):
         val = apply(gdic.wxColour_Red,(self,) + _args, _kwargs)
         return val
     def Red(self, *_args, **_kwargs):
         val = apply(gdic.wxColour_Red,(self,) + _args, _kwargs)
         return val
@@ -250,11 +258,22 @@ class wxColourPtr(wxObjectPtr):
     def Get(self, *_args, **_kwargs):
         val = apply(gdic.wxColour_Get,(self,) + _args, _kwargs)
         return val
     def Get(self, *_args, **_kwargs):
         val = apply(gdic.wxColour_Get,(self,) + _args, _kwargs)
         return val
+    def __eq__(self, *_args, **_kwargs):
+        val = apply(gdic.wxColour___eq__,(self,) + _args, _kwargs)
+        return val
+    def __ne__(self, *_args, **_kwargs):
+        val = apply(gdic.wxColour___ne__,(self,) + _args, _kwargs)
+        return val
     def __repr__(self):
         return "<C wxColour instance at %s>" % (self.this,)
     asTuple = Get
     def __repr__(self):
         return "<C wxColour instance at %s>" % (self.this,)
     asTuple = Get
-    def __str__(self): return str(self.asTuple())
-    def __repr__(self): return str(self.asTuple())
+    def __str__(self):                  return str(self.asTuple())
+    def __repr__(self):                 return 'wxColour:' + str(self.asTuple())
+    def __nonzero__(self):              return self.Ok()
+    def __getinitargs__(self):          return ()
+    def __getstate__(self):             return self.asTuple()
+    def __setstate__(self, state):      self.Set(*state)
+
 class wxColour(wxColourPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxColour,_args,_kwargs)
 class wxColour(wxColourPtr):
     def __init__(self,*_args,**_kwargs):
         self.this = apply(gdic.new_wxColour,_args,_kwargs)
@@ -290,9 +309,12 @@ class wxPenPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxPen(self)
+    def __del__(self, delfunc=gdic.delete_wxPen):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetCap(self, *_args, **_kwargs):
         val = apply(gdic.wxPen_GetCap,(self,) + _args, _kwargs)
         return val
     def GetCap(self, *_args, **_kwargs):
         val = apply(gdic.wxPen_GetCap,(self,) + _args, _kwargs)
         return val
@@ -347,9 +369,12 @@ class wxPyPenPtr(wxPenPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxPyPen(self)
+    def __del__(self, delfunc=gdic.delete_wxPyPen):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def SetDashes(self, *_args, **_kwargs):
         val = apply(gdic.wxPyPen_SetDashes,(self,) + _args, _kwargs)
         return val
     def SetDashes(self, *_args, **_kwargs):
         val = apply(gdic.wxPyPen_SetDashes,(self,) + _args, _kwargs)
         return val
@@ -393,9 +418,12 @@ class wxBrushPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxBrush(self)
+    def __del__(self, delfunc=gdic.delete_wxBrush):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetColour(self, *_args, **_kwargs):
         val = apply(gdic.wxBrush_GetColour,(self,) + _args, _kwargs)
         if val: val = wxColourPtr(val) ; val.thisown = 1
     def GetColour(self, *_args, **_kwargs):
         val = apply(gdic.wxBrush_GetColour,(self,) + _args, _kwargs)
         if val: val = wxColourPtr(val) ; val.thisown = 1
@@ -459,9 +487,12 @@ class wxDCPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxDC(self)
+    def __del__(self, delfunc=gdic.delete_wxDC):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def BeginDrawing(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_BeginDrawing,(self,) + _args, _kwargs)
         return val
     def BeginDrawing(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_BeginDrawing,(self,) + _args, _kwargs)
         return val
@@ -615,6 +646,9 @@ class wxDCPtr(wxObjectPtr):
     def GetFullTextExtent(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_GetFullTextExtent,(self,) + _args, _kwargs)
         return val
     def GetFullTextExtent(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_GetFullTextExtent,(self,) + _args, _kwargs)
         return val
+    def GetMultiLineTextExtent(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC_GetMultiLineTextExtent,(self,) + _args, _kwargs)
+        return val
     def GetTextForeground(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_GetTextForeground,(self,) + _args, _kwargs)
         if val: val = wxColourPtr(val) ; val.thisown = 1
     def GetTextForeground(self, *_args, **_kwargs):
         val = apply(gdic.wxDC_GetTextForeground,(self,) + _args, _kwargs)
         if val: val = wxColourPtr(val) ; val.thisown = 1
@@ -749,6 +783,18 @@ class wxDCPtr(wxObjectPtr):
     def _DrawLineList(self, *_args, **_kwargs):
         val = apply(gdic.wxDC__DrawLineList,(self,) + _args, _kwargs)
         return val
     def _DrawLineList(self, *_args, **_kwargs):
         val = apply(gdic.wxDC__DrawLineList,(self,) + _args, _kwargs)
         return val
+    def _DrawRectangleList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawRectangleList,(self,) + _args, _kwargs)
+        return val
+    def _DrawEllipseList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawEllipseList,(self,) + _args, _kwargs)
+        return val
+    def _DrawPolygonList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawPolygonList,(self,) + _args, _kwargs)
+        return val
+    def _DrawTextList(self, *_args, **_kwargs):
+        val = apply(gdic.wxDC__DrawTextList,(self,) + _args, _kwargs)
+        return val
     def __repr__(self):
         return "<C wxDC instance at %s>" % (self.this,)
     
     def __repr__(self):
         return "<C wxDC instance at %s>" % (self.this,)
     
@@ -759,7 +805,8 @@ class wxDCPtr(wxObjectPtr):
            pens = [pens]
         elif len(pens) != len(points):
            raise ValueError('points and pens must have same length')
            pens = [pens]
         elif len(pens) != len(points):
            raise ValueError('points and pens must have same length')
-        return self._DrawPointList(points, pens)
+        return self._DrawPointList(points, pens, [])
+
 
     def DrawLineList(self, lines, pens=None):
         if pens is None:
 
     def DrawLineList(self, lines, pens=None):
         if pens is None:
@@ -768,7 +815,83 @@ class wxDCPtr(wxObjectPtr):
            pens = [pens]
         elif len(pens) != len(lines):
            raise ValueError('lines and pens must have same length')
            pens = [pens]
         elif len(pens) != len(lines):
            raise ValueError('lines and pens must have same length')
-        return self._DrawLineList(lines, pens)
+        return self._DrawLineList(lines, pens, [])
+
+
+    def DrawRectangleList(self, rectangles, pens=None, brushes=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(rectangles):
+           raise ValueError('rectangles and pens must have same length')
+        if brushes is None:
+           brushes = []
+        elif isinstance(brushes, wxBrushPtr):
+           brushes = [brushes]
+        elif len(brushes) != len(rectangles):
+           raise ValueError('rectangles and brushes must have same length')
+        return self._DrawRectangleList(rectangles, pens, brushes)
+
+
+    def DrawEllipseList(self, ellipses, pens=None, brushes=None):
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(ellipses):
+           raise ValueError('ellipses and pens must have same length')
+        if brushes is None:
+           brushes = []
+        elif isinstance(brushes, wxBrushPtr):
+           brushes = [brushes]
+        elif len(brushes) != len(ellipses):
+           raise ValueError('ellipses and brushes must have same length')
+        return self._DrawEllipseList(ellipses, pens, brushes)
+
+
+    def DrawPolygonList(self, polygons, pens=None, brushes=None):
+        ## Note: This does not currently support fill style or offset
+        ## you can always use the non-List version if need be.
+        ## I really would like to support fill-style, however,
+        ## but wxODDEVEN_RULE does not appear to be defined at the Python level
+        ## [It's in wx.py... --Robin]
+        if pens is None:
+           pens = []
+        elif isinstance(pens, wxPenPtr):
+           pens = [pens]
+        elif len(pens) != len(polygons):
+           raise ValueError('polygons and pens must have same length')
+        if brushes is None:
+           brushes = []
+        elif isinstance(brushes, wxBrushPtr):
+           brushes = [brushes]
+        elif len(brushes) != len(polygons):
+           raise ValueError('polygons and brushes must have same length')
+        return self._DrawPolygonList(polygons, pens, brushes)
+
+
+    def DrawTextList(self, textList, coords, foregrounds = None, backgrounds = None, fonts = None):
+        ## NOTE: this does not currently support changing the font
+        ##       Make sure you set Background mode to wxSolid (DC.SetBackgroundMode)
+        ##       If you want backgounds to do anything.
+        if type(textList) == type(''):
+           textList = [textList]
+        elif len(textList) != len(coords):
+           raise ValueError('textlist and coords must have same length')
+        if foregrounds is None:
+           foregrounds = []
+        elif isinstance(foregrounds, wxColourPtr):
+           foregrounds = [foregrounds]
+        elif len(foregrounds) != len(coords):
+           raise ValueError('foregrounds and coords must have same length')
+        if backgrounds is None:
+           backgrounds = []
+        elif isinstance(backgrounds, wxColourPtr):
+           backgrounds = [backgrounds]
+        elif len(backgrounds) != len(coords):
+           raise ValueError('backgrounds and coords must have same length')
+        return  self._DrawTextList(textList, coords, foregrounds, backgrounds)
 
 class wxDC(wxDCPtr):
     def __init__(self,this):
 
 class wxDC(wxDCPtr):
     def __init__(self,this):
@@ -901,9 +1024,12 @@ class wxPalettePtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxPalette(self)
+    def __del__(self, delfunc=gdic.delete_wxPalette):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetPixel(self, *_args, **_kwargs):
         val = apply(gdic.wxPalette_GetPixel,(self,) + _args, _kwargs)
         return val
     def GetPixel(self, *_args, **_kwargs):
         val = apply(gdic.wxPalette_GetPixel,(self,) + _args, _kwargs)
         return val
@@ -927,9 +1053,12 @@ class wxImageListPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxImageList(self)
+    def __del__(self, delfunc=gdic.delete_wxImageList):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def Add(self, *_args, **_kwargs):
         val = apply(gdic.wxImageList_Add,(self,) + _args, _kwargs)
         return val
     def Add(self, *_args, **_kwargs):
         val = apply(gdic.wxImageList_Add,(self,) + _args, _kwargs)
         return val
@@ -971,9 +1100,12 @@ class wxRegionPtr(wxGDIObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxRegion(self)
+    def __del__(self, delfunc=gdic.delete_wxRegion):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def Clear(self, *_args, **_kwargs):
         val = apply(gdic.wxRegion_Clear,(self,) + _args, _kwargs)
         return val
     def Clear(self, *_args, **_kwargs):
         val = apply(gdic.wxRegion_Clear,(self,) + _args, _kwargs)
         return val
@@ -1054,9 +1186,12 @@ class wxRegionIteratorPtr(wxObjectPtr):
     def __init__(self,this):
         self.this = this
         self.thisown = 0
     def __init__(self,this):
         self.this = this
         self.thisown = 0
-    def __del__(self,gdic=gdic):
-        if self.thisown == 1 :
-            gdic.delete_wxRegionIterator(self)
+    def __del__(self, delfunc=gdic.delete_wxRegionIterator):
+        if self.thisown == 1:
+            try:
+                delfunc(self)
+            except:
+                pass
     def GetX(self, *_args, **_kwargs):
         val = apply(gdic.wxRegionIterator_GetX,(self,) + _args, _kwargs)
         return val
     def GetX(self, *_args, **_kwargs):
         val = apply(gdic.wxRegionIterator_GetX,(self,) + _args, _kwargs)
         return val
@@ -1147,6 +1282,11 @@ def wxStockCursor(*_args, **_kwargs):
     if val: val = wxCursorPtr(val); val.thisown = 1
     return val
 
     if val: val = wxCursorPtr(val); val.thisown = 1
     return val
 
+def wxCursorFromImage(*_args, **_kwargs):
+    val = apply(gdic.wxCursorFromImage,_args,_kwargs)
+    if val: val = wxCursorPtr(val); val.thisown = 1
+    return val
+
 def wxNamedColour(*_args, **_kwargs):
     val = apply(gdic.wxNamedColour,_args,_kwargs)
     if val: val = wxColourPtr(val); val.thisown = 1
 def wxNamedColour(*_args, **_kwargs):
     val = apply(gdic.wxNamedColour,_args,_kwargs)
     if val: val = wxColourPtr(val); val.thisown = 1