]> git.saurik.com Git - wxWidgets.git/commitdiff
Patch #1143556: mods to SashWindow demo: auto-generate IDs
authorRobin Dunn <robin@alldunn.com>
Fri, 18 Feb 2005 20:25:05 +0000 (20:25 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 18 Feb 2005 20:25:05 +0000 (20:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/SashWindow.py

index 7bb72ee785144489f12261d1e6eff364c6d0c23a..72b6357c9cd258a16791bec856e1d2edfd961d6d 100644 (file)
@@ -4,112 +4,115 @@ import  wx
 #---------------------------------------------------------------------------
 
 class TestSashWindow(wx.Panel):
-    ID_WINDOW_TOP    = 5100
-    ID_WINDOW_LEFT1  = 5101
-    ID_WINDOW_LEFT2  = 5102
-    ID_WINDOW_BOTTOM = 5103
-
 
     def __init__(self, parent, log):
         wx.Panel.__init__(self, parent, -1)
 
         self.log = log
-
-        # will occupy the space not used by the Layout Algorithm
-        self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
-
-        self.Bind(
-            wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
-            id=self.ID_WINDOW_TOP, id2=self.ID_WINDOW_BOTTOM, 
-            )
-
-        self.Bind(wx.EVT_SIZE, self.OnSize)
-
+        winids = []
 
         # Create some layout windows
         # A window like a toolbar
-        win = wx.SashLayoutWindow(
-            self, self.ID_WINDOW_TOP, wx.DefaultPosition, (200, 30), 
+        topwin = wx.SashLayoutWindow(
+            self, -1, wx.DefaultPosition, (200, 30), 
             wx.NO_BORDER|wx.SW_3D
             )
 
-        win.SetDefaultSize((1000, 30))
-        win.SetOrientation(wx.LAYOUT_HORIZONTAL)
-        win.SetAlignment(wx.LAYOUT_TOP)
-        win.SetBackgroundColour(wx.Colour(255, 0, 0))
-        win.SetSashVisible(wx.SASH_BOTTOM, True)
-
-        self.topWindow = win
+        topwin.SetDefaultSize((1000, 30))
+        topwin.SetOrientation(wx.LAYOUT_HORIZONTAL)
+        topwin.SetAlignment(wx.LAYOUT_TOP)
+        topwin.SetBackgroundColour(wx.Colour(255, 0, 0))
+        topwin.SetSashVisible(wx.SASH_BOTTOM, True)
 
+        self.topWindow = topwin
+        winids.append(topwin.GetId())
 
         # A window like a statusbar
-        win = wx.SashLayoutWindow(
-                self, self.ID_WINDOW_BOTTOM, wx.DefaultPosition, (200, 30), 
+        bottomwin = wx.SashLayoutWindow(
+                self, -1, wx.DefaultPosition, (200, 30), 
                 wx.NO_BORDER|wx.SW_3D
                 )
 
-        win.SetDefaultSize((1000, 30))
-        win.SetOrientation(wx.LAYOUT_HORIZONTAL)
-        win.SetAlignment(wx.LAYOUT_BOTTOM)
-        win.SetBackgroundColour(wx.Colour(0, 0, 255))
-        win.SetSashVisible(wx.SASH_TOP, True)
+        bottomwin.SetDefaultSize((1000, 30))
+        bottomwin.SetOrientation(wx.LAYOUT_HORIZONTAL)
+        bottomwin.SetAlignment(wx.LAYOUT_BOTTOM)
+        bottomwin.SetBackgroundColour(wx.Colour(0, 0, 255))
+        bottomwin.SetSashVisible(wx.SASH_TOP, True)
 
-        self.bottomWindow = win
+        self.bottomWindow = bottomwin
+        winids.append(bottomwin.GetId())
 
         # A window to the left of the client window
-        win =  wx.SashLayoutWindow(
-                self, self.ID_WINDOW_LEFT1, wx.DefaultPosition, (200, 30), 
+        leftwin1 =  wx.SashLayoutWindow(
+                self, -1, wx.DefaultPosition, (200, 30), 
                 wx.NO_BORDER|wx.SW_3D
                 )
 
-        win.SetDefaultSize((120, 1000))
-        win.SetOrientation(wx.LAYOUT_VERTICAL)
-        win.SetAlignment(wx.LAYOUT_LEFT)
-        win.SetBackgroundColour(wx.Colour(0, 255, 0))
-        win.SetSashVisible(wx.SASH_RIGHT, True)
-        win.SetExtraBorderSize(10)
+        leftwin1.SetDefaultSize((120, 1000))
+        leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
+        leftwin1.SetAlignment(wx.LAYOUT_LEFT)
+        leftwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
+        leftwin1.SetSashVisible(wx.SASH_RIGHT, True)
+        leftwin1.SetExtraBorderSize(10)
         textWindow = wx.TextCtrl(
-                        win, -1, "", wx.DefaultPosition, wx.DefaultSize, 
+                        leftwin1, -1, "", wx.DefaultPosition, wx.DefaultSize, 
                         wx.TE_MULTILINE|wx.SUNKEN_BORDER
                         )
 
         textWindow.SetValue("A sub window")
 
-        self.leftWindow1 = win
+        self.leftWindow1 = leftwin1
+        winids.append(leftwin1.GetId())
 
 
         # Another window to the left of the client window
-        win = wx.SashLayoutWindow(
-                self, self.ID_WINDOW_LEFT2, wx.DefaultPosition, (200, 30), 
+        leftwin2 = wx.SashLayoutWindow(
+                self, -1, wx.DefaultPosition, (200, 30), 
                 wx.NO_BORDER|wx.SW_3D
                 )
 
-        win.SetDefaultSize((120, 1000))
-        win.SetOrientation(wx.LAYOUT_VERTICAL)
-        win.SetAlignment(wx.LAYOUT_LEFT)
-        win.SetBackgroundColour(wx.Colour(0, 255, 255))
-        win.SetSashVisible(wx.SASH_RIGHT, True)
+        leftwin2.SetDefaultSize((120, 1000))
+        leftwin2.SetOrientation(wx.LAYOUT_VERTICAL)
+        leftwin2.SetAlignment(wx.LAYOUT_LEFT)
+        leftwin2.SetBackgroundColour(wx.Colour(0, 255, 255))
+        leftwin2.SetSashVisible(wx.SASH_RIGHT, True)
+
+        self.leftWindow2 = leftwin2
+        winids.append(leftwin2.GetId())
+
+        # will occupy the space not used by the Layout Algorithm
+        self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
+
+        self.Bind(
+            wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
+            id=min(winids), id2=max(winids)
+            )
 
-        self.leftWindow2 = win
+        self.Bind(wx.EVT_SIZE, self.OnSize)
 
 
     def OnSashDrag(self, event):
         if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
+            self.log.write('drag is out of range')
             return
 
-        eID = event.GetId()
+        eobj = event.GetEventObject()
 
-        if eID == self.ID_WINDOW_TOP:
+        if eobj is self.topWindow:
+            self.log.write('topwin received drag event')
             self.topWindow.SetDefaultSize((1000, event.GetDragRect().height))
 
-        elif eID == self.ID_WINDOW_LEFT1:
+        elif eobj is self.leftWindow1:
+            self.log.write('leftwin1 received drag event')
             self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))
 
 
-        elif eID == self.ID_WINDOW_LEFT2:
+        elif eobj is self.leftWindow2:
+            self.log.write('leftwin2 received drag event')
             self.leftWindow2.SetDefaultSize((event.GetDragRect().width, 1000))
 
-        elif eID == self.ID_WINDOW_BOTTOM:
+        elif eobj is self.bottomWindow:
+            self.log.write('bottomwin received drag event')
             self.bottomWindow.SetDefaultSize((1000, event.GetDragRect().height))
 
         wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)