New toolbar wrappers
wxMask demos GenericButton now derives from wxControl Lots of small changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
103
utils/wxPython/demo/wxMask.py
Normal file
103
utils/wxPython/demo/wxMask.py
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
logic = ['']*16
|
||||
def rlf(x):
|
||||
logic[eval(x)]=x
|
||||
|
||||
|
||||
rlf('wxAND')
|
||||
rlf('wxAND_INVERT')
|
||||
rlf('wxAND_REVERSE')
|
||||
rlf('wxCLEAR')
|
||||
rlf('wxCOPY')
|
||||
rlf('wxEQUIV')
|
||||
rlf('wxINVERT')
|
||||
rlf('wxNAND')
|
||||
rlf('wxNOR')
|
||||
rlf('wxNO_OP')
|
||||
rlf('wxOR')
|
||||
rlf('wxOR_INVERT')
|
||||
rlf('wxOR_REVERSE')
|
||||
rlf('wxSET')
|
||||
rlf('wxSRC_INVERT')
|
||||
rlf('wxXOR')
|
||||
|
||||
class TestMaskWindow(wxScrolledWindow):
|
||||
def __init__(self, parent):
|
||||
wxScrolledWindow.__init__(self, parent, -1)
|
||||
self.SetBackgroundColour(wxColour(0,128,0))
|
||||
|
||||
# A reference bitmap that we won't mask
|
||||
self.bmp_nomask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
|
||||
# One that we will
|
||||
self.bmp_withmask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
|
||||
# this mask comes from a monochrome bitmap
|
||||
self.bmp_themask = wxBitmap('bitmaps/test_mask.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.bmp_themask.SetDepth(1)
|
||||
mask = wxMask(self.bmp_themask)
|
||||
|
||||
# set the mask on our bitmap
|
||||
self.bmp_withmask.SetMask(mask)
|
||||
|
||||
# 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 = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
mask = wxMaskColour(self.bmp_withcolourmask, wxWHITE)
|
||||
self.bmp_withcolourmask.SetMask(mask)
|
||||
|
||||
self.SetScrollbars(20, 20, 600/20, 460/20)
|
||||
|
||||
|
||||
|
||||
def OnPaint (self, e):
|
||||
dc = wxPaintDC(self)
|
||||
self.PrepareDC(dc)
|
||||
dc.SetTextForeground(wxWHITE)
|
||||
|
||||
# make an interesting background...
|
||||
dc.SetPen(wxMEDIUM_GREY_PEN)
|
||||
for i in range(100):
|
||||
dc.DrawLine(0,i*10,i*10,0)
|
||||
|
||||
# draw raw image, mask, and masked images
|
||||
dc.DrawText('original image', 0,0)
|
||||
dc.DrawBitmap(self.bmp_nomask, 0,20, 0)
|
||||
dc.DrawText('with colour mask', 0,100)
|
||||
dc.DrawBitmap(self.bmp_withcolourmask, 0,120, 1)
|
||||
dc.DrawText('the mask image', 0,200)
|
||||
dc.DrawBitmap(self.bmp_themask, 0,220, 0)
|
||||
dc.DrawText('masked image', 0,300)
|
||||
dc.DrawBitmap(self.bmp_withmask, 0,320, 1)
|
||||
|
||||
cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight()
|
||||
|
||||
# draw array of assorted blit operations
|
||||
mdc = wxMemoryDC()
|
||||
for i in range(16):
|
||||
text = logic[i]
|
||||
x,y = 120+100*(i%4), 20+100*(i/4)
|
||||
dc.DrawText(text, x,y-20)
|
||||
mdc.SelectObject(self.bmp_withcolourmask)
|
||||
dc.Blit(x,y, cx,cy, mdc, 0,0, i,1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestMaskWindow(nb)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
Reference in New Issue
Block a user