Gnumed.wxpython.gmShadow

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  try:
    11          import wxversion
    12          import wx
    13  except ImportError:
    14          from wxPython import wx
    15
    16  from Gnumed.pycommon import gmGuiBroker
    17  #=========================================================
    18 -class Shadow (wx.Panel):
    19 -        def __init__(self, parent, id):
    20                  """Create a new shadow.
    21                  """
    22                  wx.Panel.__init__ (self, parent, id)
    23                  self.sh_width = gmGuiBroker.config['main.shadow.width']
    24                  wx.EVT_SIZE (self, self.OnSize)
    25                  wx.EVT_PAINT (self, self.OnPaint)
    26          #-----------------------------------------------------
    27 -        def SetContents (self, widget):
    28                  """Marry a widget and a shadow.
    29
    30                  Widget MUST have parent=Shadow widget, and pos=(0,0)
    31                  """
    32                  self.contents = widget
    33          #-----------------------------------------------------
    34 -        def OnSize (self, event):
    35                  w, h = self.GetClientSizeTuple ()
    36                  self.contents.SetClientSizeWH (w-self.sh_width, h-self.sh_width)
    37          #-----------------------------------------------------
    38 -        def OnPaint (self, event):
    39                  dc = wxPaintDC (self)
    40                  w, h = self.GetClientSizeTuple ()
    41                  dc.SetPen (wx.TRANSPARENT_PEN)
    42                  #dc.SetBrush (wxWHITE_BRUSH)
    43                  dc.SetBrush (wx.Brush (wx.Colour (240, 240, 240), wx.SOLID))
    44                  # draw white bars
    45                  dc.DrawRectangle (0, h-self.sh_width, w, self.sh_width)
    46                  dc.DrawRectangle (w-self.sh_width, 0, self.sh_width, h)
    47                  r, g, b = gmGuiBroker.config['main.shadow.colour']
    48                  dc.SetBrush (wx.Brush (wx.Colour (r, g, b), wx.SOLID))
    49                  # draw grey bars half as thick
    50                  dc.DrawRectangle (
    51                          self.sh_width/2,
    52                          h-self.sh_width,
    53                          w-self.sh_width,
    54                          self.sh_width/2
    55                  )
    56                  dc.DrawRectangle (
    57                          w-self.sh_width,
    58                          self.sh_width/2,
    59                          self.sh_width/2,
    60                          h-self.sh_width-self.sh_width/2
    61                  )
    62  #=======================================================================
    63