]> git.saurik.com Git - wxWidgets.git/commitdiff
reSWIGged
authorRobin Dunn <robin@alldunn.com>
Wed, 30 Aug 2006 19:29:31 +0000 (19:29 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 30 Aug 2006 19:29:31 +0000 (19:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/gtk/_gdi.py
wxPython/src/gtk/_gdi_wrap.cpp
wxPython/src/mac/_gdi.py
wxPython/src/mac/_gdi_wrap.cpp
wxPython/src/msw/_gdi.py
wxPython/src/msw/_gdi_wrap.cpp

index f24c6564f32ee8dfabe33f12ddb8567ebbc54066..95a9c7e8837331499d1205a302faf24b912dda01 100644 (file)
@@ -829,52 +829,39 @@ class NativePixelData(PixelDataBase):
         return _gdi_.NativePixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.NativePixelData_swigregister(NativePixelData)
 
@@ -957,52 +944,39 @@ class AlphaPixelData(PixelDataBase):
         return _gdi_.AlphaPixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.AlphaPixelData_swigregister(AlphaPixelData)
 
index ac6a4fd75c2f6c6c7386c7900deb759cc54c71eb..368e57bc26ef739138c01076098595ae2868464d 100644 (file)
@@ -2961,8 +2961,8 @@ SWIGINTERN bool wxBitmap___ne__(wxBitmap *self,wxBitmap const *other){ return ot
 // appears to me that the other platforms are already doing it, so I'll just
 // automatically do it for wxMSW here.
 #ifdef __WXMSW__
-#define wxPy_premultiply(p, a)   ((p) * (a) / 256)
-#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 256 / (a)) : (p))    
+#define wxPy_premultiply(p, a)   ((p) * (a) / 0xff)
+#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p))    
 #else
 #define wxPy_premultiply(p, a)   (p)
 #define wxPy_unpremultiply(p, a) (p)    
index d54219b4b12a6a9700c6a2515a4ce1e8d8ae78d9..9c29b7011d58311a309785dfe91a3f80b11289d5 100644 (file)
@@ -833,52 +833,39 @@ class NativePixelData(PixelDataBase):
         return _gdi_.NativePixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.NativePixelData_swigregister(NativePixelData)
 
@@ -961,52 +948,39 @@ class AlphaPixelData(PixelDataBase):
         return _gdi_.AlphaPixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.AlphaPixelData_swigregister(AlphaPixelData)
 
index 613156b444927b988a1d2fe33acd02d72767d2c4..f4bb8e70290f51a2950f1d78687ac5e6c7d960b9 100644 (file)
@@ -2984,8 +2984,8 @@ SWIGINTERN bool wxBitmap___ne__(wxBitmap *self,wxBitmap const *other){ return ot
 // appears to me that the other platforms are already doing it, so I'll just
 // automatically do it for wxMSW here.
 #ifdef __WXMSW__
-#define wxPy_premultiply(p, a)   ((p) * (a) / 256)
-#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 256 / (a)) : (p))    
+#define wxPy_premultiply(p, a)   ((p) * (a) / 0xff)
+#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p))    
 #else
 #define wxPy_premultiply(p, a)   (p)
 #define wxPy_unpremultiply(p, a) (p)    
index 22bea127ebb227772b943b1e2d1b202a67337bec..b782a0cfa0fb27c5cec31606140a6b9e5f438a42 100644 (file)
@@ -853,52 +853,39 @@ class NativePixelData(PixelDataBase):
         return _gdi_.NativePixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.NativePixelData_swigregister(NativePixelData)
 
@@ -981,52 +968,39 @@ class AlphaPixelData(PixelDataBase):
         return _gdi_.AlphaPixelData___nonzero__(*args, **kwargs)
 
     def __iter__(self):
-        """Create and return an iterator object for this pixel data object."""
-        return self.PixelIterator(self)
-
-    class PixelIterator(object):
-        """
-        Sequential iterator which returns pixel accessor objects starting at the
-        the top-left corner, and going row-by-row until the bottom-right
-        corner is reached.
-        """
-
-        class PixelAccessor(object):
-            """
-            This class is what is returned by the iterator and allows the pixel
-            to be Get or Set.
-            """
-            def __init__(self, data, pixels, x, y):
-                self.data = data
-                self.pixels = pixels
-                self.x = x
-                self.y = y
-            def Set(self, *args, **kw):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Set(*args, **kw)
+        """
+        Create and return an iterator object for this pixel data
+        object.  (It's really a generator but I won't tell if you
+        don't tell.)
+        """
+        width  = self.GetWidth()
+        height = self.GetHeight()
+        pixels = self.GetPixels()
+        
+
+
+
+        class PixelFacade(object):
             def Get(self):
-                self.pixels.MoveTo(self.data, self.x, self.y)
-                return self.pixels.Get()
-
-        def __init__(self, pixelData):
-            self.x = self.y = 0
-            self.w = pixelData.GetWidth()
-            self.h = pixelData.GetHeight()
-            self.data = pixelData
-            self.pixels = pixelData.GetPixels()
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.y >= self.h:
-                raise StopIteration
-            p = self.PixelAccessor(self.data, self.pixels, self.x, self.y)
-            self.x += 1
-            if self.x >= self.w:
-                self.x = 0
-                self.y += 1
-            return p
+                return pixels.Get()
+            def Set(self, *args, **kw):
+                return pixels.Set(*args, **kw)
+            def __str__(self):
+                return str(self.Get())
+            def __repr__(self):
+                return 'pixel(%d,%d): %s' % (x,y,self.Get())
+            X = property(lambda self: x)
+            Y = property(lambda self: y)
+            
+        pf = PixelFacade()        
+        for y in xrange(height):
+            for x in xrange(width):
+
+
+
+                yield pf    
+                pixels.nextPixel()
+            pixels.MoveTo(self, 0, y)
 
 _gdi_.AlphaPixelData_swigregister(AlphaPixelData)
 
index 44d9bdcc92d835b59f9570decbbe2dfa654a161c..913556f277f9539055241671f648ee44f5658620 100644 (file)
@@ -2962,8 +2962,8 @@ SWIGINTERN bool wxBitmap___ne__(wxBitmap *self,wxBitmap const *other){ return ot
 // appears to me that the other platforms are already doing it, so I'll just
 // automatically do it for wxMSW here.
 #ifdef __WXMSW__
-#define wxPy_premultiply(p, a)   ((p) * (a) / 256)
-#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 256 / (a)) : (p))    
+#define wxPy_premultiply(p, a)   ((p) * (a) / 0xff)
+#define wxPy_unpremultiply(p, a) ((a) ? ((p) * 0xff / (a)) : (p))    
 #else
 #define wxPy_premultiply(p, a)   (p)
 #define wxPy_unpremultiply(p, a) (p)