daboide Commit
Revision 254
Date: 2005-11-29 17:47:02 -0800 (Tue, 29 Nov 2005)
Author: ed

Changed:
U   trunk/Designer.py
U   trunk/DesignerComponents.py
U   trunk/DesignerControlMixin.py
U   trunk/DesignerTreeForm.py

Log:
OK, this is really close to stable. I've noticed an intermittant problem with 
sizers embedded in pageframes, but I'll look into this more. If I don't get to 
it tonight, we can still release this as-is, and I'll include the fix in the 
0.3.1 release

These changes clean up a lot of the clutter inherent in the use of LayoutPanels 
to visually display an unfilled sizer area. Nested sizers had unecessary panels 
that complicated not only the cdxml file, but also the creation of the form 
from the cdxml file.

There were lots of segfaults when releasing the LayoutPanels, and I solved it 
by our old friend callAfter(). It now works great on OS X; I will test these 
changes on Win/Lin next.


Diff:
Modified: trunk/Designer.py
===================================================================
--- trunk/Designer.py   2005-11-30 01:16:44 UTC (rev 253)
+++ trunk/Designer.py   2005-11-30 01:47:02 UTC (rev 254)
@@ -593,21 +593,54 @@
        
        
        def addSizer(self, orient, pnl=None, slots=None):
+               controllingSizer, sizerPos, pnlToKill = None, None, None
                if pnl is None:
                        obj = self._srcObj
+                       while isinstance(obj, LayoutPanel):
+                               if controllingSizer is None:
+                                       controllingSizer = obj.ControllingSizer
+                                       sizerPos = obj.getPositionInSizer()
+                                       pnlToKill = obj
+                               # Set the controlling sizer info
+                               obj = obj.Parent
                        if isinstance(obj, dui.dPage):
                                # Get the layout panel
                                obj = self.getMainLayoutPanel(obj)
                else:
                        obj = pnl
-               obj.Sizer.Orientation = orient
                if slots is None:
                        slots = self.getNumSlots("Add how many slots?")
-               if slots:
-                       for ii in range(slots):
-                               pp = LayoutPanel(obj)
-                       obj.layout()
-               self.updateLayout()
+               if not slots:
+                       # User canceled
+                       return
+               
+               drawOutlines = self.uiApp._drawSizerOutlines
+               self.uiApp._drawSizerOutlines = False
+               sizerKids = 0
+               if controllingSizer:
+                       sizerKids = len(controllingSizer.Children)
+               
+               if sizerKids == 1:
+                       # Basic sizer with nothing added yet.
+                       controllingSizer.Orientation = orient
+                       for ii in range(slots-1):
+                               lp = LayoutPanel(obj, AutoSizer=False)
+                               controllingSizer.append1x(lp)
+               else:
+                       newSizer = LayoutSizer(orient)
+                       if controllingSizer is not None:
+                               dabo.ui.callAfter(controllingSizer.remove, 
pnlToKill, True)
+                               controllingSizer.insert(sizerPos, newSizer, 1, 
"x")
+                       else:
+                               obj.Sizer = newSizer
+
+                       if slots:
+                               for ii in range(slots):
+                                       lp = LayoutPanel(obj, AutoSizer=False)
+                                       newSizer.append1x(lp)
+               dabo.ui.callAfter(self.MainForm.layout)
+               dabo.ui.callAfter(self.updateLayout)
+               self.uiApp._drawSizerOutlines = drawOutlines
                return obj.Sizer
                        
                                

Modified: trunk/DesignerComponents.py
===================================================================
--- trunk/DesignerComponents.py 2005-11-30 01:16:44 UTC (rev 253)
+++ trunk/DesignerComponents.py 2005-11-30 01:47:02 UTC (rev 254)
@@ -125,11 +125,8 @@
 class LayoutPanel(dabo.ui.dPanel, LayoutSaverMixin):
        """Panel used to display empty sizer slots."""
        def __init__(self, parent, properties=None, *args, **kwargs):
-               self._autoSizer  = True
                self._baseClass = LayoutPanel
-               auto = self._extractKey(kwargs, "AutoSizer")
-               if auto is not None:
-                       self._autoSizer = auto
+               self._autoSizer = self._extractKey(kwargs, "AutoSizer", True)
                super(LayoutPanel, self).__init__(parent, properties, *args, 
**kwargs)
                # Store the defaults for the various props
                self._propDefaults = {}
@@ -141,10 +138,12 @@
                self.BorderWidth = 0
                self.depth = self.crawlUp(self)
                self.colors = ("lightblue", "tan", "lightgreen", "pink", 
"purple", "gold")
-               self.normalBorderColor = self.normalColor = self.BackColor = 
self.BorderColor = self.colors[self.depth]
+               self.normalColor = self.BackColor = self.colors[self.depth]
+               self.normalBorderColor = self.BorderColor = "black"
                self.hiliteColor = "white"
                self.hiliteBorder = "gold"
-               self.BorderWidth = 3
+               self.BorderWidth = 1
+               self.BorderLineStyle = "dot"
                self.__selected = False
                self.Selected = False
                
@@ -159,18 +158,12 @@
                                        ornt = "h"
                else:
                        ornt = "v"
-               self.Sizer = LayoutSizer(ornt)
-               self.Sizer.Border = self.BorderWidth/2
-               self.Sizer.BorderAll = True
+#              self.Sizer = LayoutSizer(ornt)
+#              self.Sizer.Border = self.BorderWidth/2
+#              self.Sizer.BorderAll = True
                self.layout()
-               self.autoBindEvents()
        
-       
-#      def initEvents(self):
-#              self.bindEvent(dEvents.MouseLeftClick, self.onClick)
-#              self.bindEvent(dEvents.MouseRightClick, self.onRightClick)
 
-
        def getDesignerDict(self, itemNum=0):
                # Augment the default to add non-Property values
                ret = super(LayoutPanel, self).getDesignerDict(itemNum)
@@ -237,6 +230,7 @@
                        self._needRedraw = True
                self.__selected = val
 
+
        DesignerProps = property(_getDesProps, None, None,
                _("""Returns a dict of editable properties for the sizer, with 
the 
                prop names as the keys, and the value for each another dict, 

Modified: trunk/DesignerControlMixin.py
===================================================================
--- trunk/DesignerControlMixin.py       2005-11-30 01:16:44 UTC (rev 253)
+++ trunk/DesignerControlMixin.py       2005-11-30 01:47:02 UTC (rev 254)
@@ -378,15 +378,15 @@
                                "Right": {"type" : int, "readonly" : True},
                                "Top": {"type" : int, "readonly" : True},
                                "Bottom": {"type" : int, "readonly" : True}}
-               sizerProps = {"Sizer_Border": {"type" : int, "readonly" : 
False},
+               sizerProps = {"Sizer_Border": {"type" : int, "readonly" : 
False}, 
+                               "Sizer_Expand" : {"type" : bool, "readonly" : 
False},
                                "Sizer_Proportion": {"type" : int, "readonly" : 
False},
                                "Sizer_HAlign": {"type" : list, "readonly" : 
False,
                                        "values" : ["Left", "Right", "Center"]},
                                "Sizer_VAlign": {"type" : list, "readonly" : 
False,
                                        "values" : ["Top", "Bottom", "Middle"]}}
                gridSizerProps = {"Sizer_RowExpand" : {"type" : bool, 
"readonly" : False},
-                               "Sizer_ColExpand" : {"type" : bool, "readonly" 
: False}, 
-                               "Sizer_Expand" : {"type" : bool, "readonly" : 
False}}
+                               "Sizer_ColExpand" : {"type" : bool, "readonly" 
: False}}
                pageFrameProps = {"PageCount" : {"type" : int, "readonly" : 
False},
                                "TabPosition" : {"type" : list, "readonly" : 
False, 
                                "values" : ["Top", "Bottom", "Left", "Right"] }}
@@ -398,8 +398,6 @@
                                ret.update(sizerProps)
                        if isinstance(csz, LayoutGridSizer):
                                ret.update(gridSizerProps)
-#                      elif isinstance(csz, LayoutSizer):
-#                              ret.update(boxSizerProps)
                if isinstance(self, dabo.ui.dDataControlMixin):
                        ret.update(dataProps)
                        

Modified: trunk/DesignerTreeForm.py
===================================================================
--- trunk/DesignerTreeForm.py   2005-11-30 01:16:44 UTC (rev 253)
+++ trunk/DesignerTreeForm.py   2005-11-30 01:47:02 UTC (rev 254)
@@ -76,6 +76,7 @@
                sel = self.tree.Selection
                if sel:
                        selObjs = [nn._obj for nn in sel]
+               
                self.tree.clear()
                self.recurseLayout(frm, None)
                self.tree.expandAll()
@@ -94,6 +95,7 @@
                                        cap = _("Grid Sizer")
                                else:
                                        cap = _("Sizer: %s") % ornt
+                               
                                childNode = node.appendChild(cap)
                                childNode._obj = itm
                        for chil in itm.Children:
@@ -102,6 +104,7 @@
                elif isinstance(itm, (wx.SizerItem, wx.GBSizerItem)):
                        cap = self._slotCaption
                        if itm.IsWindow():
+                               recurse = True
                                nodisp = False
                                win = itm.GetWindow()
                                if isinstance(win, LayoutPanel):
@@ -110,6 +113,11 @@
                                                r, c = 
win.ControllingSizer.getGridPos(win)
                                                cap = "%s r:%s, c:%s" % (cap, 
r, c)
                                        sz = win.Sizer
+                                       if sz is None:
+                                               # Empty slot; display it in the 
tree.
+                                               childNode = 
node.appendChild(cap)                               
+                                               childNode._obj = win
+                                               recurse = False
                                        if isinstance(sz, LayoutSizer) and 
sz.SlotCount == 0:
                                                # Empty slot; display it in the 
tree.
                                                childNode = 
node.appendChild(cap)                               
@@ -121,7 +129,8 @@
                                else:
                                        # A non-Designer control
                                        childNode = node
-                               self.recurseLayout(win, childNode, 
noDisplay=nodisp)
+                               if recurse:
+                                       self.recurseLayout(win, childNode, 
noDisplay=nodisp)
                                        
                        elif itm.IsSizer():
                                sz = itm.GetSizer()
@@ -168,10 +177,9 @@
                                else:
                                        childNode = node.appendChild("%s (%s)" 
% dsp)
                                childNode._obj = itm
-                       chilWin = []
+
                        if hasattr(itm, "Sizer") and itm.Sizer:
                                self.recurseLayout(itm.Sizer, childNode, 
noDisplay=noDisplay)
-                               chilWin = itm.Sizer.ChildWindows
                        if isinstance(itm, dabo.ui.dGrid):
                                children = itm.Columns
                        else:
@@ -183,7 +191,9 @@
                                for chil in children:
                                        if chil is self:
                                                continue
-                                       if chil not in chilWin:
+                                       # See if it has already been added via 
recursive calls
+                                       chilNode = self.getNodeFor(chil)
+                                       if chilNode is None:
                                                # Child item wasn't already 
listed by the sizer
                                                nodisp = False
                                                self.recurseLayout(chil, 
childNode, noDisplay=nodisp)




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to