]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/tests/test_bufDcBlit.py
   3 print "PID:", os
.getpid() 
   7 class ResultsFrame(wx
.Frame
): 
   8     def __init__(self
, parent
, bmp
): 
  11         wx
.Frame
.__init
__(self
, parent
, title
=str(count
), size
=(100,100)) 
  13         sb 
= wx
.StaticBitmap(p
, -1, bmp
, (20,20)) 
  18 class TestPanel(wx
.Panel
): 
  19     def __init__(self
, parent
): 
  20         wx
.Panel
.__init
__(self
, parent
) 
  21         b 
= wx
.Button(self
, -1, "Test", (50,50)) 
  22         self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
) 
  24     def RunTest(self
, bdc
, bg
, fg
): 
  25         # draw to the buffered dc 
  26         bdc
.SetBackground(wx
.Brush(bg
)) 
  28         bdc
.SetPen(wx
.Pen(fg
, 2)) 
  29         bdc
.DrawLine(0,0, 30,30) 
  30         bdc
.DrawLine(0,30, 30,0) 
  32         # now bilt it to a bitmap 
  33         bmp 
= wx
.EmptyBitmap(30,30) 
  36         mdc
.Blit(0,0, 30,30, bdc
, 0,0) 
  40         ResultsFrame(self
, bmp
) 
  44     def OnButton(self
, evt
): 
  46         # 1. test a buffered dc not using a buffer bitmap 
  47         bdc 
= wx
.BufferedDC(wx
.ClientDC(self
), self
.GetSize()) 
  48         self
.RunTest(bdc
, "yellow", "red") 
  51         # 2. now do one that does have a buffer bitmap 
  52         buf 
= wx
.EmptyBitmap(100,100) 
  53         bdc 
= wx
.BufferedDC(wx
.ClientDC(self
), buf
) 
  54         self
.RunTest(bdc
, "red", "blue") 
  57         # 3. now one without a real DC 
  58         buf 
= wx
.EmptyBitmap(100,100) 
  59         bdc 
= wx
.BufferedDC(None, buf
) 
  60         self
.RunTest(bdc
, "purple", "yellow") 
  63         # 4. finally test a real unbuffered DC 
  64         dc 
= wx
.ClientDC(self
) 
  65         self
.RunTest(dc
, "red", "white") 
  68         # blit from the last buffer back to the main window 
  69         buf
.SetMaskColour("yellow") 
  72         dc
.Blit(100,100,30,30, mdc
, 0,0, useMask
=True)