]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/panel.py
Respect the REUSEADDR flag to allow rebinding; bind to local port prior to connecting...
[wxWidgets.git] / wxPython / wx / tools / XRCed / panel.py
index 11aac42caced0f67e246621cbdf180bd63191737..785cca2c87e7c2dd1d56342dc78a326624cdbc16 100644 (file)
@@ -37,6 +37,7 @@ class Panel(wxNotebook):
         self.AddPage(self.page1, 'Properties')
         # Second page
         self.page2 = wxScrolledWindow(self, -1)
+        self.page2.Hide()
         sizer = wxBoxSizer()
         sizer.Add(wxBoxSizer())         # dummy sizer
         self.page2.SetAutoLayout(True)
@@ -44,17 +45,16 @@ class Panel(wxNotebook):
         # Cache for already used panels
         self.pageCache = {}             # cached property panels
         self.stylePageCache = {}        # cached style panels
-        # Dummy parent window for cache pages
-        self.cacheParent = wxFrame(None, -1, 'i am invisible')
+
     # Delete child windows and recreate page sizer
     def ResetPage(self, page):
         topSizer = page.GetSizer()
         sizer = topSizer.GetChildren()[0].GetSizer()
         for w in page.GetChildren():
-            sizer.Remove(w)
+            sizer.Detach(w)
             if isinstance(w, ParamPage):
-                # With SetParent, we wouldn't need this
-                w.Reparent(self.cacheParent)
+                if w.IsShown():
+                    w.Hide()
             else:
                 w.Destroy()
         topSizer.Remove(sizer)
@@ -66,13 +66,13 @@ class Panel(wxNotebook):
         else:
             topSizer.Add(sizer, 0, wxALL, 5)
         return sizer
+
     def SetData(self, xxx):
         self.pages = []
         # First page
-        # Set cached or new page
         # Remove current objects and sizer
         sizer = self.ResetPage(self.page1)
-        if not xxx or (not xxx.allParams and not xxx.hasName):
+        if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
             if g.tree.selection:
                 sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
             else:                       # nothing selected
@@ -93,7 +93,7 @@ class Panel(wxNotebook):
             try:
                 page = self.pageCache[cacheID]
                 page.box.SetLabel(xxx.panelName())
-                page.Reparent(self.page1)
+                page.Show()
             except KeyError:
                 page = PropPage(self.page1, xxx.panelName(), xxx)
                 self.pageCache[cacheID] = page
@@ -106,7 +106,7 @@ class Panel(wxNotebook):
                 try:
                     page = self.pageCache[cacheID]
                     page.box.SetLabel(xxx.child.panelName())
-                    page.Reparent(self.page1)
+                    page.Show()
                 except KeyError:
                     page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
                     self.pageCache[cacheID] = page
@@ -125,7 +125,7 @@ class Panel(wxNotebook):
             sizer = self.ResetPage(self.page2)
             try:
                 page = self.stylePageCache[xxx.__class__]
-                page.Reparent(self.page2)
+                page.Show()
             except KeyError:
                 page = StylePage(self.page2, xxx.className + ' style', xxx)
                 self.stylePageCache[xxx.__class__] = page
@@ -136,6 +136,8 @@ class Panel(wxNotebook):
             if not self.GetPageCount() == 2:
                 self.AddPage(self.page2, 'Style')
             self.page2.Layout()
+            if 'wxGTK' in wx.PlatformInfo:
+                self.page2.Show(True)
             size = self.page2.GetSizer().GetMinSize()
             self.page2.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
         else:
@@ -145,17 +147,21 @@ class Panel(wxNotebook):
                 self.page1.Refresh()
                 self.RemovePage(1)
         self.modified = False
+        
     def Clear(self):
         self.SetData(None)
         self.modified = False
+        
     # If some parameter has changed
     def IsModified(self):
         return self.modified
+    
     def SetModified(self, value):
         # Register undo object when modifying first time
         if not self.modified and value:
            g.undoMan.RegisterUndo(UndoEdit())
         self.modified = value
+        
     def Apply(self):
         for p in self.pages: p.Apply()
 
@@ -165,8 +171,6 @@ class Panel(wxNotebook):
 class ParamPage(wxPanel):
     def __init__(self, parent, xxx):
         wxPanel.__init__(self, parent, -1)
-        self.SetBackgroundColour(parent.GetBackgroundColour())
-        self.SetForegroundColour(parent.GetForegroundColour())
         self.xxx = xxx
         # Register event handlers
         for id in paramIDs.values():
@@ -195,7 +199,10 @@ class ParamPage(wxPanel):
                 xxx.params[param] = xxxParam(elem)
             # Find place to put new element: first present element after param
             found = False
-            paramStyles = xxx.allParams + xxx.styles
+            if xxx.hasStyle: 
+                paramStyles = xxx.allParams + xxx.styles
+            else:
+                paramStyles = xxx.allParams 
             for p in paramStyles[paramStyles.index(param) + 1:]:
                 # Content params don't have same type
                 if xxx.params.has_key(p) and p != 'content':
@@ -256,6 +263,8 @@ class ParamPage(wxPanel):
 
 ################################################################################
 
+LABEL_WIDTH = 125
+
 # Panel for displaying properties
 class PropPage(ParamPage):
     def __init__(self, parent, label, xxx):
@@ -263,25 +272,25 @@ class PropPage(ParamPage):
         self.box = wxStaticBox(self, -1, label)
         self.box.SetFont(g.labelFont())
         topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
-        sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
+        sizer = wxFlexGridSizer(len(xxx.allParams), 2, 0, 1)
         sizer.AddGrowableCol(1)
         if xxx.hasName:
-            label = wxStaticText(self, -1, 'XML ID:', size=(100,-1))
+            label = wxStaticText(self, -1, 'XML ID:', size=(LABEL_WIDTH,-1))
             control = ParamText(self, 'XML_name', 200)
             sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
-                            (control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxGROW, 5) ])
+                            (control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxGROW, 10) ])
             self.controlName = control
         for param in xxx.allParams:
             present = xxx.params.has_key(param)
             if param in xxx.required:
                 label = wxStaticText(self, paramIDs[param], param + ':',
-                                     size = (100,-1), name = param)
+                                     size = (LABEL_WIDTH,-1), name = param)
             else:
                 # Notebook has one very loooooong parameter
                 if param == 'usenotebooksizer': sParam = 'usesizer:'
                 else: sParam = param + ':'
                 label = wxCheckBox(self, paramIDs[param], sParam,
-                                   size = (100,-1), name = param)
+                                   size = (LABEL_WIDTH,-1), name = param)
                 self.checks[param] = label
             try:
                 typeClass = xxx.paramDict[param]
@@ -336,12 +345,12 @@ class StylePage(ParamPage):
         box = wxStaticBox(self, -1, label)
         box.SetFont(g.labelFont())
         topSizer = wxStaticBoxSizer(box, wxVERTICAL)
-        sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
+        sizer = wxFlexGridSizer(len(xxx.styles), 2, 0, 1)
         sizer.AddGrowableCol(1)
         for param in xxx.styles:
             present = xxx.params.has_key(param)
             check = wxCheckBox(self, paramIDs[param],
-                               param + ':', size = (100,-1), name = param)
+                               param + ':', size = (LABEL_WIDTH,-1), name = param)
             check.SetValue(present)
             control = paramDict[param](self, name = param)
             control.Enable(present)