daboide Commit
Revision 258
Date: 2005-11-30 06:23:44 -0800 (Wed, 30 Nov 2005)
Author: ed

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

Log:
This corrects the problems noted yesterday with the paged controls in the 
Designer. I've also added a dialog when adding a paged control allowing the 
user to specify the tab position, which cannot be changed after the control is 
created, as well as the number of pages.

There is a minor display problem with the DesignerTreeForm and the 
dPageFrameNoTabs, but that will have to wait for the next release.


Diff:
Modified: trunk/Designer.py
===================================================================
--- trunk/Designer.py   2005-11-30 02:35:25 UTC (rev 257)
+++ trunk/Designer.py   2005-11-30 14:23:44 UTC (rev 258)
@@ -9,7 +9,7 @@
 dui = dabo.ui
 from dabo.ui import dKeys
 from dabo.dLocalize import _
-import dabo.dConstants as k
+import dabo.dConstants as kons
 from DesignerFormMixin import DesignerFormMixin as dfm
 from DesignerTreeForm import DesignerTreeForm
 from DesignerPropSheet import PropSheet
@@ -405,13 +405,54 @@
                                dui.dPageSelect, dui.dPageFrameNoTabs))
                
                if isPageControl:
+                       noTabs = issubclass(cls, dui.dPageFrameNoTabs)
                        props["PageClass"] = self.getControlClass(dui.dPage)
+                       
+                       class PageInfoDialog(dui.dOkCancelDialog):
+                               def __init__(self, *args, **kwargs):
+                                       self.noTabs = self._extractKey(kwargs, 
"NoTabs", False)
+                                       self.pageCount = 3
+                                       self.tabPositions = ("Top", "Bottom", 
"Left", "Right")
+                                       self.tabPosSelection = 0
+                                       super(PageInfoDialog, 
self).__init__(*args, **kwargs)
+                                       
+                               def addControls(self):
+                                       pnl = dui.dPanel(self)
+                                       gsz = pnl.Sizer = 
dui.dGridSizer(maxCols=2, hgap=5, vgap=5)
+                                       lbl = dui.dLabel(pnl, Caption=_("Number 
of pages:"))
+                                       spn = dui.dSpinner(pnl, 
DataSource="form", 
+                                                       DataField="pageCount", 
Min=0, Max=20)
+                                       gsz.append(lbl, halign="right")
+                                       gsz.append(spn)
+                                       
+                                       if not self.noTabs:
+                                               lbl = dui.dLabel(pnl, 
Caption=_("Tab Position:"))
+                                               dd = dui.dDropdownList(pnl, 
Choices=(_("Top"), 
+                                                               _("Bottom"), 
_("Left"), _("Right")), ValueMode="Position",
+                                                               
DataSource="form", DataField="tabPosSelection")
+                                               gsz.append(lbl, halign="right")
+                                               gsz.append(dd)
+                                       gsz.setFullExpand()
+                                       self.Sizer.append1x(pnl, border=10)
+                                       self.refresh()
+                                       self.layout()
+                       
+                       dlg = PageInfoDialog(self.MainForm, NoTabs=noTabs)
+                       dlg.Centered = True
+                       res = dlg.show()
+                       if res == kons.DLG_CANCEL:
+                               # User canceled
+                               return
                        try:
-                               newPgs = int(dabo.ui.getString("How many 
pages?", 
-                                               "New Page Control", "3"))
+                               newPgs = dlg.pageCount
+                               tabPos = dlg.tabPositions[dlg.tabPosSelection]
                        except:
                                newPgs = 3
+                               tabPos = "Top"
+                       dlg.release()
                        props["PageCount"] = newPgs
+                       if not noTabs:
+                               props["TabPosition"] = tabPos
                
                if issubclass(cls, dui.dGrid):
                        # Make sure it adds customized columns.
@@ -596,6 +637,9 @@
                controllingSizer, sizerPos, pnlToKill = None, None, None
                if pnl is None:
                        obj = self._srcObj
+                       if isinstance(obj, dui.dPage):
+                               # Get the layout panel
+                               obj = self.getMainLayoutPanel(obj)
                        while isinstance(obj, LayoutPanel):
                                if controllingSizer is None:
                                        controllingSizer = obj.ControllingSizer
@@ -603,9 +647,6 @@
                                        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
                if slots is None:
@@ -638,7 +679,8 @@
                                for ii in range(slots):
                                        lp = LayoutPanel(obj, AutoSizer=False)
                                        newSizer.append1x(lp)
-               dabo.ui.callAfter(self.MainForm.layout)
+#              dabo.ui.callAfter(self.MainForm.layout)
+               dabo.ui.callAfter(obj.layout)
                dabo.ui.callAfter(self.updateLayout)
                self.uiApp._drawSizerOutlines = drawOutlines
                return obj.Sizer

Modified: trunk/DesignerComponents.py
===================================================================
--- trunk/DesignerComponents.py 2005-11-30 02:35:25 UTC (rev 257)
+++ trunk/DesignerComponents.py 2005-11-30 14:23:44 UTC (rev 258)
@@ -189,17 +189,16 @@
                if isinstance(self.Parent, dabo.ui.dPage):
                        self.Parent.activePanel = self
                pop = self.Form.app.getControlMenu(self)
-               self.showContextMenu(pop)
+               if isinstance(self.Parent, (dabo.ui.dPage, dabo.ui.dPanel)):
+                       pop.prependSeparator()
+                       pop.prepend("Delete", bindfunc=self.onDelete)
+               dabo.ui.callAfter(self.showContextMenu, pop)
                evt.stop()
        
-
-       def onContextMenu(self, evt):
-               return
-               if isinstance(self.Parent, dabo.ui.dPage):
-                       self.Parent.activePanel = self
-               pop = self.Form.app.getControlMenu(self)
-               self.showContextMenu(pop)
-               evt.stop()
+       
+       def onDelete(self, evt):
+               # This happens when the LayoutPanel is inside of a container
+               self.Parent.onDelete(evt)
                
 
        def crawlUp(self, obj, lev=0):

Modified: trunk/DesignerControlMixin.py
===================================================================
--- trunk/DesignerControlMixin.py       2005-11-30 02:35:25 UTC (rev 257)
+++ trunk/DesignerControlMixin.py       2005-11-30 14:23:44 UTC (rev 258)
@@ -81,10 +81,13 @@
        
 
        def onContextMenu(self, evt):
-               # If the control can contain child objects, get that menu
-               if isinstance(self, (dabo.ui.dPage, )):
-                       pop = self.Form.app.getControlMenu(self)
+               # If it is a LayoutPanel or page, return - the event 
+               # is handled elsewhere
+               if isinstance(self, (dabo.ui.dPage, LayoutPanel)):
+                       evt.stop()
+                       return
                elif isinstance(self, (dabo.ui.dPanel,)):
+                       # If the control can contain child objects, get that 
menu
                        pop = self.Form.app.getControlMenu(self)
                else:
                        pop = dabo.ui.dMenu()




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

Reply via email to