1 """GNUmed widget shadowing.
2
3 A module to add shadowing to an arbitrary widget.
4 """
5
6
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
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
35 w, h = self.GetClientSizeTuple ()
36 self.contents.SetClientSizeWH (w-self.sh_width, h-self.sh_width)
37
39 dc = wxPaintDC (self)
40 w, h = self.GetClientSizeTuple ()
41 dc.SetPen (wx.TRANSPARENT_PEN)
42
43 dc.SetBrush (wx.Brush (wx.Colour (240, 240, 240), wx.SOLID))
44
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
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