]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/tree.py
moved custom menu up
[wxWidgets.git] / wxPython / wx / tools / XRCed / tree.py
index ad64a5a709dcb40701e224652b5b8e7d2a9e6290..10169a9a6070ebe8dd12c5ec4ef8f837fc458079 100644 (file)
@@ -128,6 +128,9 @@ class ID_NEW:
     REF = wx.NewId()
     COMMENT = wx.NewId()
 
+    CUSTOM = wx.NewId()
+    for i in range(99): wx.NewId()   # reserve IDs for custom controls
+
     LAST = wx.NewId()
 
     
@@ -377,7 +380,17 @@ class PullDownMenu:
             ID_NEW.HELP_BUTTON: ('wxID_HELP', '&Help'),
             ID_NEW.CONTEXT_HELP_BUTTON: ('wxID_CONTEXT_HELP', '&Help'),
             }
-            
+        self.clearCustom()
+
+    def clearCustom(self):
+        # Custom controls
+        self.custom = [['custom', 'User-defined controls']]
+        self.customMap = {}        
+        
+    def addCustom(self, klass):
+        n = len(self.custom[0])-2
+        self.custom[0].append((ID_NEW.CUSTOM + n, klass))
+        self.customMap[ID_NEW.CUSTOM + n] = klass
 
 
 ################################################################################
@@ -835,19 +848,6 @@ class XML_Tree(wx.TreeCtrl):
         testWin = g.testWin
         # Create a window with this resource
         xxx = self.GetPyData(item).treeObject()
-
-        # If frame
-#        if xxx.__class__ == xxxFrame:
-            # Frame can't have many children,
-            # but it's first child possibly can...
-#            child = self.GetFirstChild(item)[0]
-#            if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
-#                # Clean-up before recursive call or error
-#                wx.MemoryFSHandler.RemoveFile('xxx.xrc')
-#                wx.EndBusyCursor()
-#                self.CreateTestWin(child)
-#                return
-
         # Close old window, remember where it was
         highLight = None
         if testWin:
@@ -904,16 +904,8 @@ class XML_Tree(wx.TreeCtrl):
         res = xrc.XmlResource('', xmlFlags)
         xrc.XmlResource.Set(res)        # set as global
         # Register handlers
-        addHandlers(res)
-        # Test Test.py
-        #import Test
-        #res.InsertHandler(Test.TestXmlHandler())
-        # Test test.so
-        import ctypes
-        test = ctypes.CDLL('test.so')
-        addr = int(str(res.this).split('_')[1], 16)
-        #test._Z17AddTestXmlHandlerP13wxXmlResource(ctypes.c_void_p(addr))
-        #test.AddTestXmlHandler(ctypes.c_void_p(addr))
+        addHandlers()
+        # Same module list
         res.Load('memory:xxx.xrc')
         try:
             if xxx.__class__ == xxxFrame:
@@ -1013,6 +1005,9 @@ class XML_Tree(wx.TreeCtrl):
             inf = sys.exc_info()
             wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
             wx.LogError('Error loading resource')
+        # Cleanup
+        res.Unload('xxx.xrc')
+        xrc.XmlResource.Set(None)
         wx.MemoryFSHandler.RemoveFile('xxx.xrc')
 
     def CloseTestWindow(self):
@@ -1134,6 +1129,9 @@ class XML_Tree(wx.TreeCtrl):
                         m.Enable(ID_NEW.SPACER, False)
                     if xxx.__class__ is not xxxFrame:
                         m.Enable(ID_NEW.MENU_BAR, False)
+                # Add custom controls menu
+                if pullDownMenu.customMap:
+                    SetMenu(m, pullDownMenu.custom)
                 m.AppendSeparator()
                 m.Append(ID_NEW.REF, 'reference...', 'Create object_ref node')
                 m.Append(ID_NEW.COMMENT, 'comment', 'Create comment node')