X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd3f2efe791cf99c2e4944cd615f02a5502ed93e..d2638b42a831a5eaebb25f4cdde220ae668df80f:/wxPython/demo/wxMask.py diff --git a/wxPython/demo/wxMask.py b/wxPython/demo/wxMask.py index fb4f453497..ad35dfd9b5 100644 --- a/wxPython/demo/wxMask.py +++ b/wxPython/demo/wxMask.py @@ -1,37 +1,41 @@ +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# -from wxPython.wx import * +import wx #---------------------------------------------------------------------- logicList = [ - ('wxAND', wxAND), - ('wxAND_INVERT', wxAND_INVERT), - ('wxAND_REVERSE', wxAND_REVERSE), - ('wxCLEAR', wxCLEAR), - ('wxCOPY', wxCOPY), - ('wxEQUIV', wxEQUIV), - ('wxINVERT', wxINVERT), - ('wxNAND', wxNAND), + ('wx.AND', wx.AND), + ('wx.AND_INVERT', wx.AND_INVERT), + ('wx.AND_REVERSE', wx.AND_REVERSE), + ('wx.CLEAR', wx.CLEAR), + ('wx.COPY', wx.COPY), + ('wx.EQUIV', wx.EQUIV), + ('wx.INVERT', wx.INVERT), + ('wx.NAND', wx.NAND), # this one causes an assert on wxGTK, and doesn't seem to # do much on MSW anyway, so I'll just take it out.... #('wxNOR', wxNOR), - ('wxNO_OP', wxNO_OP), - ('wxOR', wxOR), - ('wxOR_INVERT', wxOR_INVERT), - ('wxOR_REVERSE', wxOR_REVERSE), - ('wxSET', wxSET), - ('wxSRC_INVERT', wxSRC_INVERT), - ('wxXOR', wxXOR), + ('wx.NO_OP', wx.NO_OP), + ('wx.OR', wx.OR), + ('wx.OR_INVERT', wx.OR_INVERT), + ('wx.OR_REVERSE', wx.OR_REVERSE), + ('wx.SET', wx.SET), + ('wx.SRC_INVERT', wx.SRC_INVERT), + ('wx.XOR', wx.XOR), ] import images -class TestMaskWindow(wxScrolledWindow): +class TestMaskWindow(wx.ScrolledWindow): def __init__(self, parent): - wxScrolledWindow.__init__(self, parent, -1) - self.SetBackgroundColour(wxColour(0,128,0)) + wx.ScrolledWindow.__init__(self, parent, -1) + self.SetBackgroundColour(wx.Colour(0,128,0)) # A reference bitmap that we won't mask self.bmp_nomask = images.getTestStar2Bitmap() @@ -40,8 +44,8 @@ class TestMaskWindow(wxScrolledWindow): self.bmp_withmask = images.getTestStar2Bitmap() # this mask comes from a monochrome bitmap - self.bmp_themask = wxBitmapFromImage(images.getTestMaskImage(), 1) - mask = wxMask(self.bmp_themask) + self.bmp_themask = wx.BitmapFromImage(images.getTestMaskImage(), 1) + mask = wx.Mask(self.bmp_themask) # set the mask on our bitmap self.bmp_withmask.SetMask(mask) @@ -49,21 +53,21 @@ class TestMaskWindow(wxScrolledWindow): # Now we'll create a mask in a bit of an easier way, by picking a # colour in the image that is to be the transparent colour. self.bmp_withcolourmask = images.getTestStar2Bitmap() - mask = wxMaskColour(self.bmp_withcolourmask, wxWHITE) + mask = wx.MaskColour(self.bmp_withcolourmask, wx.WHITE) self.bmp_withcolourmask.SetMask(mask) self.SetScrollbars(20, 20, 700/20, 460/20) - EVT_PAINT(self, self.OnPaint) + self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint (self, e): - dc = wxPaintDC(self) + dc = wx.PaintDC(self) self.PrepareDC(dc) - dc.SetTextForeground(wxWHITE) + dc.SetTextForeground(wx.WHITE) # make an interesting background... - dc.SetPen(wxMEDIUM_GREY_PEN) + dc.SetPen(wx.MEDIUM_GREY_PEN) for i in range(100): dc.DrawLine((0,i*10), (i*10,0)) @@ -80,8 +84,9 @@ class TestMaskWindow(wxScrolledWindow): cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight() # draw array of assorted blit operations - mdc = wxMemoryDC() + mdc = wx.MemoryDC() i = 0 + for text, code in logicList: x,y = 120+150*(i%4), 20+100*(i/4) dc.DrawText(text, (x, y-20)) @@ -92,11 +97,11 @@ class TestMaskWindow(wxScrolledWindow): # On wxGTK there needs to be a panel under wxScrolledWindows if they are # going to be in a wxNotebook... -class TestPanel(wxPanel): +class TestPanel(wx.Panel): def __init__(self, parent, ID): - wxPanel.__init__(self, parent, ID) + wx.Panel.__init__(self, parent, ID) self.win = TestMaskWindow(self) - EVT_SIZE(self, self.OnSize) + self.Bind(wx.EVT_SIZE, self.OnSize) def OnSize(self, evt): self.win.SetSize(evt.GetSize()) @@ -111,8 +116,14 @@ def runTest(frame, nb, log): #---------------------------------------------------------------------- - overview = """\ +This class encapsulates a monochrome mask bitmap, where the masked area is black +and the unmasked area is white. When associated with a bitmap and drawn in a device +context, the unmasked area of the bitmap will be drawn, and the masked area will +not be drawn. + +This example shows not only how to create a Mask, but the effects of the Device +Context (dc) Blit() method's logic codes. """