X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/59780c72c67a8d880c1ea53d974ce83b03dfa5d2..30e24d9dd5a5abf1c9a375ea259eb239b122b7f7:/wxPython/demo/AlphaDrawing.py diff --git a/wxPython/demo/AlphaDrawing.py b/wxPython/demo/AlphaDrawing.py index 8c3f973d96..7023b7beda 100644 --- a/wxPython/demo/AlphaDrawing.py +++ b/wxPython/demo/AlphaDrawing.py @@ -7,20 +7,26 @@ class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) - - wx.StaticText(self, -1, - "On the Mac these squares should be transparent,\n" - "if the CoreGrahics option is turned on.", - (20, 20)) - self.Bind(wx.EVT_PAINT, self.OnPaint) + txt = """\ +If this build of wxPython includes the new wx.GCDC class (which +provides the wx.DC API on top of the new wx.GraphicsContext class) +then these squares should be transparent. +""" + wx.StaticText(self, -1, txt, (20, 20)) + + def OnPaint(self, evt): - dc = wx.PaintDC(self) + pdc = wx.PaintDC(self) + try: + dc = wx.GCDC(pdc) + except: + dc = pdc rect = wx.Rect(0,0, 100, 100) - for RGB, pos in [((178, 34, 34), ( 50, 70)), - (( 35, 142, 35), (110, 130)), - (( 0, 0, 139), (170, 70)) + for RGB, pos in [((178, 34, 34), ( 50, 90)), + (( 35, 142, 35), (110, 150)), + (( 0, 0, 139), (170, 90)) ]: r, g, b = RGB penclr = wx.Colour(r, g, b, wx.ALPHA_OPAQUE) @@ -28,7 +34,7 @@ class TestPanel(wx.Panel): dc.SetPen(wx.Pen(penclr)) dc.SetBrush(wx.Brush(brushclr)) rect.SetPosition(pos) - dc.DrawRectangleRect(rect) + dc.DrawRoundedRectangleRect(rect, 8) #---------------------------------------------------------------------- @@ -44,10 +50,13 @@ def runTest(frame, nb, log): overview = """

Alpha Drawing

-The wx.DC on Mac now supports alpha transparent drawing using pens and -brushes. This is accomplished by enabling the wx.Colour class to have -a fourth component for the alpha value, where 0 is fully transparent, -and 255 is fully opaque. +The wx.GCDC class is a class that implemented the wx.DC API using the +new wx.GraphicsContext class, and so it supports anti-aliased drawing +using pens and brushes, that can optionally also be drawn using an +alpha transparency. (On the Mac all the DC classes are using this new +implementation.) This is accomplished by enabling the wx.Colour class +to have a fourth component for the alpha value, where 0 is fully +transparent, and 255 is fully opaque. """