]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-08/shaped_frame_mobile.py
   4 class ShapedFrame(wx
.Frame
): 
   6         wx
.Frame
.__init
__(self
, None, -1, "Shaped Window", 
   7                 style 
= wx
.FRAME_SHAPED | wx
.SIMPLE_BORDER 
) 
   9         self
.delta 
= wx
.Point(0,0) 
  10         self
.bmp 
= images
.getVippiBitmap() 
  11         self
.SetClientSize((self
.bmp
.GetWidth(), self
.bmp
.GetHeight())) 
  12         dc 
= wx
.ClientDC(self
) 
  13         dc
.DrawBitmap(self
.bmp
, 0,0, True) 
  15         self
.Bind(wx
.EVT_LEFT_DCLICK
, self
.OnDoubleClick
) 
  16         self
.Bind(wx
.EVT_LEFT_DOWN
, self
.OnLeftDown
) 
  17         self
.Bind(wx
.EVT_LEFT_UP
, self
.OnLeftUp
) 
  18         self
.Bind(wx
.EVT_MOTION
, self
.OnMouseMove
) 
  19         self
.Bind(wx
.EVT_RIGHT_UP
, self
.OnExit
) 
  20         self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
) 
  21         self
.Bind(wx
.EVT_WINDOW_CREATE
, self
.SetWindowShape
) 
  23     def SetWindowShape(self
, evt
=None): 
  24         r 
= wx
.RegionFromBitmap(self
.bmp
) 
  25         self
.hasShape 
= self
.SetShape(r
) 
  27     def OnDoubleClick(self
, evt
): 
  29             self
.SetShape(wx
.Region()) 
  34     def OnPaint(self
, evt
): 
  36         dc
.DrawBitmap(self
.bmp
, 0,0, True) 
  38     def OnExit(self
, evt
): 
  41     def OnLeftDown(self
, evt
): 
  43         pos 
= self
.ClientToScreen(evt
.GetPosition()) 
  44         origin 
= self
.GetPosition() 
  45         self
.delta 
= wx
.Point(pos
.x 
- origin
.x
, pos
.y 
- origin
.y
) 
  47     def OnMouseMove(self
, evt
): 
  48         if evt
.Dragging() and evt
.LeftIsDown(): 
  49             pos 
= self
.ClientToScreen(evt
.GetPosition()) 
  50             newPos 
= (pos
.x 
- self
.delta
.x
, pos
.y 
- self
.delta
.y
) 
  53     def OnLeftUp(self
, evt
): 
  59 if __name__ 
== '__main__': 
  60     app 
= wx
.PySimpleApp()