]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/multisash.py
compilation fix after removing wxImage(wxImage *) ctor
[wxWidgets.git] / wxPython / wx / lib / multisash.py
index 7d364910e751f61a0dcd5c72e943200632df6e10..6be5e730aaba69358ca4a0477e8b2940167e2eea 100644 (file)
@@ -7,12 +7,18 @@
 # Created:      2002/11/20
 # Version:      0.1
 # RCS-ID:       $Id$
-# License:      wxWindows licensie
+# License:      wxWindows license
 #----------------------------------------------------------------------
 # 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
 #
 # o 2.5 compatability update.
 #
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMultiSash -> MultiSash
+# o wxMultiSplit -> MultiSplit 
+# o wxMultiViewLeaf -> MultiViewLeaf
+#
 
 import wx
 
@@ -24,11 +30,11 @@ CR_SIZE = SH_SIZE * 3
 
 #----------------------------------------------------------------------
 
-class wxMultiSash(wx.Window):
+class MultiSash(wx.Window):
     def __init__(self, *_args,**_kwargs):
         apply(wx.Window.__init__,(self,) + _args,_kwargs)
         self._defChild = EmptyChild
-        self.child = wxMultiSplit(self,self,(0,0),self.GetSize())
+        self.child = MultiSplit(self,self,(0,0),self.GetSize())
         self.Bind(wx.EVT_SIZE,self.OnMultiSize)
 
     def SetDefaultChildClass(self,childCls):
@@ -43,23 +49,24 @@ class wxMultiSash(wx.Window):
 
     def Clear(self):
         old = self.child
-        self.child = wxMultiSplit(self,self,(0,0),self.GetSize())
+        self.child = MultiSplit(self,self,(0,0),self.GetSize())
         old.Destroy()
         self.child.OnSize(None)
 
     def GetSaveData(self):
         saveData = {}
-        saveData['_defChild'] = str(self._defChild)
+        saveData['_defChild_class'] = self._defChild.__name__
+        saveData['_defChild_mod']   = self._defChild.__module__
         saveData['child'] = self.child.GetSaveData()
         return saveData
 
     def SetSaveData(self,data):
-        dChild = data['_defChild']
-        mod = dChild.split('.')[0]
+        mod = data['_defChild_mod']
+        dChild = mod + '.' + data['_defChild_class']
         exec 'import %s' % mod
         self._defChild = eval(dChild)
         old = self.child
-        self.child = wxMultiSplit(self,self,wxPoint(0,0),self.GetSize())
+        self.child = MultiSplit(self,self,wx.Point(0,0),self.GetSize())
         self.child.SetSaveData(data['child'])
         old.Destroy()
         self.OnMultiSize(None)
@@ -69,7 +76,7 @@ class wxMultiSash(wx.Window):
 #----------------------------------------------------------------------
 
 
-class wxMultiSplit(wx.Window):
+class MultiSplit(wx.Window):
     def __init__(self,multiView,parent,pos,size,view1 = None):
         wx.Window.__init__(self,id = -1,parent = parent,pos = pos,size = size,
                           style = wx.CLIP_CHILDREN)
@@ -80,7 +87,7 @@ class wxMultiSplit(wx.Window):
             self.view1.Reparent(self)
             self.view1.MoveXY(0,0)
         else:
-            self.view1 = wxMultiViewLeaf(self.multiView,self,
+            self.view1 = MultiViewLeaf(self.multiView,self,
                                          (0,0),self.GetSize())
         self.direction = None
 
@@ -90,11 +97,11 @@ class wxMultiSplit(wx.Window):
         saveData = {}
         if self.view1:
             saveData['view1'] = self.view1.GetSaveData()
-            if isinstance(self.view1,wxMultiSplit):
+            if isinstance(self.view1,MultiSplit):
                 saveData['view1IsSplit'] = 1
         if self.view2:
             saveData['view2'] = self.view2.GetSaveData()
-            if isinstance(self.view2,wxMultiSplit):
+            if isinstance(self.view2,MultiSplit):
                 saveData['view2IsSplit'] = 1
         saveData['direction'] = self.direction
         v1,v2 = self.GetPosition()
@@ -107,16 +114,16 @@ class wxMultiSplit(wx.Window):
 
     def SetSaveData(self,data):
         self.direction = data['direction']
-        self.SetDimensions(data['x'],data['y'],data['w'],data['h'])
+        self.SetDimensions(int(data['x']), int(data['y']), int(data['w']), int(data['h']))
         v1Data = data.get('view1',None)
         if v1Data:
             isSplit = data.get('view1IsSplit',None)
             old = self.view1
             if isSplit:
-                self.view1 = wxMultiSplit(self.multiView,self,
+                self.view1 = MultiSplit(self.multiView,self,
                                           (0,0),self.GetSize())
             else:
-                self.view1 = wxMultiViewLeaf(self.multiView,self,
+                self.view1 = MultiViewLeaf(self.multiView,self,
                                              (0,0),self.GetSize())
             self.view1.SetSaveData(v1Data)
             if old:
@@ -126,10 +133,10 @@ class wxMultiSplit(wx.Window):
             isSplit = data.get('view2IsSplit',None)
             old = self.view2
             if isSplit:
-                self.view2 = wxMultiSplit(self.multiView,self,
+                self.view2 = MultiSplit(self.multiView,self,
                                           (0,0),self.GetSize())
             else:
-                self.view2 = wxMultiViewLeaf(self.multiView,self,
+                self.view2 = MultiViewLeaf(self.multiView,self,
                                              (0,0),self.GetSize())
             self.view2.SetSaveData(v2Data)
             if old:
@@ -152,13 +159,13 @@ class wxMultiSplit(wx.Window):
     def AddLeaf(self,direction,caller,pos):
         if self.view2:
             if caller == self.view1:
-                self.view1 = wxMultiSplit(self.multiView,self,
+                self.view1 = MultiSplit(self.multiView,self,
                                           caller.GetPosition(),
                                           caller.GetSize(),
                                           caller)
                 self.view1.AddLeaf(direction,caller,pos)
             else:
-                self.view2 = wxMultiSplit(self.multiView,self,
+                self.view2 = MultiSplit(self.multiView,self,
                                           caller.GetPosition(),
                                           caller.GetSize(),
                                           caller)
@@ -174,7 +181,7 @@ class wxMultiSplit(wx.Window):
                 x,y = (0,pos)
                 w1,h1 = (w,h-pos)
                 w2,h2 = (w,pos)
-            self.view2 = wxMultiViewLeaf(self.multiView, self, (x,y), (w1,h1))
+            self.view2 = MultiViewLeaf(self.multiView, self, (x,y), (w1,h1))
             self.view1.SetSize((w2,h2))
             self.view2.OnSize(None)
 
@@ -272,8 +279,8 @@ class wxMultiSplit(wx.Window):
         else:
             v1h = v2h = h
 
-        self.view1.SetDimensions(v1x,v1y,v1w,v1h)
-        self.view2.SetDimensions(v2x,v2y,v2w,v2h)
+        self.view1.SetDimensions(int(v1x), int(v1y), int(v1w), int(v1h))
+        self.view2.SetDimensions(int(v2x), int(v2y), int(v2w), int(v2h))
         self.view1.OnSize(None)
         self.view2.OnSize(None)
 
@@ -281,7 +288,7 @@ class wxMultiSplit(wx.Window):
 #----------------------------------------------------------------------
 
 
-class wxMultiViewLeaf(wx.Window):
+class MultiViewLeaf(wx.Window):
     def __init__(self,multiView,parent,pos,size):
         wx.Window.__init__(self,id = -1,parent = parent,pos = pos,size = size,
                           style = wx.CLIP_CHILDREN)
@@ -296,9 +303,13 @@ class wxMultiViewLeaf(wx.Window):
 
         self.Bind(wx.EVT_SIZE,self.OnSize)
 
+        self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
+
+
     def GetSaveData(self):
         saveData = {}
-        saveData['detailClass'] = str(self.detail.child.__class__)
+        saveData['detailClass_class'] = self.detail.child.__class__.__name__
+        saveData['detailClass_mod'] = self.detail.child.__module__
         if hasattr(self.detail.child,'GetSaveData'):
             attr = getattr(self.detail.child,'GetSaveData')
             if callable(attr):
@@ -314,8 +325,8 @@ class wxMultiViewLeaf(wx.Window):
         return saveData
 
     def SetSaveData(self,data):
-        dChild = data['detailClass']
-        mod = dChild.split('.')[0]
+        mod = data['detailClass_mod']
+        dChild = mod + '.' + data['detailClass_class']
         exec 'import %s' % mod
         detClass = eval(dChild)
         self.SetDimensions(data['x'],data['y'],data['w'],data['h'])
@@ -355,12 +366,17 @@ class wxMultiViewLeaf(wx.Window):
         return self.GetParent().CanSize(side,self)
 
     def OnSize(self,evt):
-        self.sizerHor.OnSize(evt)
-        self.sizerVer.OnSize(evt)
-        self.creatorHor.OnSize(evt)
-        self.creatorVer.OnSize(evt)
-        self.detail.OnSize(evt)
-        self.closer.OnSize(evt)
+        def doresize():
+            try:
+                self.sizerHor.OnSize(evt)
+                self.sizerVer.OnSize(evt)
+                self.creatorHor.OnSize(evt)
+                self.creatorVer.OnSize(evt)
+                self.detail.OnSize(evt)
+                self.closer.OnSize(evt)
+            except:
+                pass
+        wx.CallAfter(doresize)
 
 #----------------------------------------------------------------------
 
@@ -444,6 +460,9 @@ class MultiSizer(wx.Window):
         self.Bind(wx.EVT_LEFT_DOWN,self.OnPress)
         self.Bind(wx.EVT_LEFT_UP,self.OnRelease)
 
+        self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
+
+
     def CalcSizePos(self,parent):
         pw,ph = parent.GetSize()
         if self.side == MV_HOR:
@@ -604,13 +623,13 @@ class MultiCreator(wx.Window):
 
         # Draw outline
         dc.SetPen(highlight)
-        dc.DrawLine((0,0), (0,h))
-        dc.DrawLine((0,0), (w,0))
+        dc.DrawLine(0,0, 0,h)
+        dc.DrawLine(0,0, w,0)
         dc.SetPen(black)
-        dc.DrawLine((0,h), (w+1,h))
-        dc.DrawLine((w,0), (w,h))
+        dc.DrawLine(0,h, w+1,h)
+        dc.DrawLine(w,0, w,h)
         dc.SetPen(shadow)
-        dc.DrawLine((w-1,2), (w-1,h))
+        dc.DrawLine(w-1,2, w-1,h)
 
 #----------------------------------------------------------------------
 
@@ -686,11 +705,11 @@ def DrawSash(win,x,y,direction):
     bmp = wx.EmptyBitmap(8,8)
     bdc = wx.MemoryDC()
     bdc.SelectObject(bmp)
-    bdc.DrawRectangle((-1,-1), (10,10))
+    bdc.DrawRectangle(-1,-1, 10,10)
     for i in range(8):
         for j in range(8):
             if ((i + j) & 1):
-                bdc.DrawPoint((i,j))
+                bdc.DrawPoint(i,j)
 
     brush = wx.Brush(wx.Colour(0,0,0))
     brush.SetStipple(bmp)
@@ -720,8 +739,8 @@ def DrawSash(win,x,y,direction):
     h = body_h
 
     if direction == MV_HOR:
-        dc.DrawRectangle((x,y-2), (w,4))
+        dc.DrawRectangle(x,y-2, w,4)
     else:
-        dc.DrawRectangle((x-2,y), (4,h))
+        dc.DrawRectangle(x-2,y, 4,h)
 
     dc.EndDrawingOnTop()