Package Gnumed :: Package wxpython :: Module gmShadow
[frames] | no frames]

Source Code for Module Gnumed.wxpython.gmShadow

 1  """GNUmed widget shadowing. 
 2   
 3  A module to add shadowing to an arbitrary widget. 
 4  """ 
 5  ############################################################################## 
 6  # $Source: /home/ncq/Projekte/cvs2git/vcs-mirror/gnumed/gnumed/client/wxpython/gmShadow.py,v $ 
 7  __version__ = "$Revision: 1.13 $" 
 8  __author__  = "H.Berger <Hilmar.Berger@gmx.de>, I. Haywood <i.haywood@ugrad.unimelb.edu.au>, R.Terry <rterry@gnumed.net>" 
 9   
10  import wx 
11   
12  from Gnumed.pycommon import gmGuiBroker 
13  #========================================================= 
14 -class Shadow (wx.Panel):
15 - def __init__(self, parent, id):
16 """Create a new shadow. 17 """ 18 wx.Panel.__init__ (self, parent, id) 19 self.sh_width = gmGuiBroker.config['main.shadow.width'] 20 wx.EVT_SIZE (self, self.OnSize) 21 wx.EVT_PAINT (self, self.OnPaint)
22 #-----------------------------------------------------
23 - def SetContents (self, widget):
24 """Marry a widget and a shadow. 25 26 Widget MUST have parent=Shadow widget, and pos=(0,0) 27 """ 28 self.contents = widget
29 #-----------------------------------------------------
30 - def OnSize (self, event):
31 w, h = self.GetClientSize () 32 self.contents.SetClientSizeWH (w-self.sh_width, h-self.sh_width)
33 #-----------------------------------------------------
34 - def OnPaint (self, event):
35 dc = wxPaintDC (self) 36 w, h = self.GetClientSize () 37 dc.SetPen (wx.TRANSPARENT_PEN) 38 #dc.SetBrush (wxWHITE_BRUSH) 39 dc.SetBrush (wx.Brush (wx.Colour (240, 240, 240), wx.SOLID)) 40 # draw white bars 41 dc.DrawRectangle (0, h-self.sh_width, w, self.sh_width) 42 dc.DrawRectangle (w-self.sh_width, 0, self.sh_width, h) 43 r, g, b = gmGuiBroker.config['main.shadow.colour'] 44 dc.SetBrush (wx.Brush (wx.Colour (r, g, b), wx.SOLID)) 45 # draw grey bars half as thick 46 dc.DrawRectangle ( 47 self.sh_width/2, 48 h-self.sh_width, 49 w-self.sh_width, 50 self.sh_width/2 51 ) 52 dc.DrawRectangle ( 53 w-self.sh_width, 54 self.sh_width/2, 55 self.sh_width/2, 56 h-self.sh_width-self.sh_width/2 57 )
58 #======================================================================= 59