daboide Commit
Revision 599
Date: 2006-07-16 09:23:01 -0700 (Sun, 16 Jul 2006)
Author: ed
Changed:
U trunk/ClassDesigner.py
U trunk/ClassDesignerComponents.py
U trunk/ClassDesignerControlMixin.py
U trunk/ClassDesignerFormMixin.py
U trunk/ClassDesignerPemForm.py
U trunk/ClassDesignerTreeSheet.py
Log:
This represents several lines of improvement over the past week or two. First,
the object tree dropdown is now working much better, allowing you to interact
with it as before.
Second, the Class Designer supports trees and splitters now. There were several
major issues that prevented these classes from working correctly; these have
all been addressed, and seem to be working fine now. However, there still may
be some loose ends that are not working; if you find any unusual or unexpected
behaviors, please report them.
Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesigner.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -602,6 +602,7 @@
props = {}
newClass = dui.__dict__[cls]
isGrid = issubclass(newClass, dui.dGrid)
+ isSplitter = issubclass(newClass, dui.dSplitter)
isPageControl = issubclass(newClass,
(dui.dPageFrame,
dui.dPageList, dui.dPageSelect,
dui.dPageFrameNoTabs))
noTabs = issubclass(newClass,
dui.dPageFrameNoTabs)
@@ -624,7 +625,11 @@
except: pass
if noTabs:
del props["TabPosition"]
-
+ elif isSplitter:
+ ornt = self._extractKey(atts,
"Orientation", "Vertical")
+ splt = self._extractKey(atts, "Split",
"False")
+ props["createPanes"] = False
+ atts["Split"] = False
# If we are pasting, we can get two objects
with the same
# Name value, so change it to NameBase.
nm = self._extractKey(atts, "Name", clsname)
@@ -632,6 +637,10 @@
obj = self.addNewControl(None, newClass,
props=props,
skipUpdate=True,
attProperties=atts)
ret = obj
+ if isSplitter:
+
obj.setPropertiesFromAtts({"Orientation": ornt})
+ if splt:
+ dabo.ui.setAfter(obj, "Split",
True)
sz = obj.ControllingSizer
itm = obj.ControllingSizerItem
if sz is not None and itm is not None:
@@ -670,7 +679,30 @@
grandkids =
kid.get("children", [])
if grandkids:
self._srcObj =
pg
-
self.recreateChildren(pg, grandkids, None, False)
+
self.recreateChildren(pg, grandkids, None, False)
+
+ elif isSplitter:
+ for pos, kid in enumerate(kids):
+ pnlClass =
dui.__dict__[kid["name"]]
+
obj.createPanes(pnlClass, pane=pos+1, force=True)
+ if pos == 0:
+ pnl = obj.Panel1
+ else:
+ pnl = obj.Panel2
+ if pnl is None:
+ continue
+ kidatts =
kid.get("attributes", {})
+
pnl.setPropertiesFromAtts(kidatts)
+ kidcode =
kid.get("code", {})
+ if kidcode:
+
self._codeDict[pnl] = kidcode
+ grandkids =
kid.get("children", [])
+ if grandkids:
+ curr =
self._srcObj
+ self._srcObj =
pnl
+
self.recreateChildren(pnl, grandkids, None, False)
+ self._srcObj =
curr
+
else:
currPnl = self._srcObj
if isinstance(obj, (dui.dPanel,
)):
@@ -1585,7 +1617,6 @@
# that that page is active
self.currentForm.ensureVisible(selObj)
self.Tree._inAppSelection = False
- self.PemForm.hideTree()
def getMainLayoutPanel(self, obj):
@@ -1856,6 +1887,12 @@
nd = self.Tree.getNodeFor(pnl)
sz.remove(pnl)
dui.callAfter(pnl.release)
+
+ if issubclass(cls, dui.dSplitter):
+ # We need to disable the initial splitting. This will
be done
+ # after the control is created.
+ soi = self._extractKey((props, attProperties),
"splitOnInit")
+ props["splitOnInit"] = False
isSavedClass = (self._extractKey(attProperties, "savedClass")
== "True")
classID = self._extractKey(attProperties, "classID")
@@ -1866,6 +1903,9 @@
propNmBase = props.get("NameBase", "")
mixedClass = self.getControlClass(cls)
obj = mixedClass(parent, properties=props,
attProperties=attProperties)
+
+ print "ADDING OBJ %s to PARENT %s" % (obj.Name, parent.Name)
+
if attNmBase and attNmBase != "controlMix":
obj.NameBase = attNmBase
elif propNmBase and propNmBase != "controlMix":
@@ -1879,12 +1919,18 @@
if issubclass(cls, dui.dSplitter):
# Add the panels
pnlClass = self.getControlClass(obj.PanelClass)
- obj.PanelClass = pnlClass
- obj.createPanes()
- if attProperties is not None:
- if not attProperties.has_key("Split"):
- obj.Split = True
-
+ obj.createPanes(cls=pnlClass)
+ if attProperties is None or (not
attProperties.has_key("Split")):
+ obj.Split = True
+ try:
+ obj.Panel1.Sizer = LayoutSizer("v")
+ LayoutPanel(obj.Panel1)
+ except AttributeError: pass
+ try:
+ obj.Panel2.Sizer = LayoutSizer("v")
+ LayoutPanel(obj.Panel2)
+ except AttributeError: pass
+
if isPageControl:
pg0panel = None
for pg in obj.Pages[::-1]:
Modified: trunk/ClassDesignerComponents.py
===================================================================
--- trunk/ClassDesignerComponents.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesignerComponents.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -90,16 +90,20 @@
propsToInclude = ("classID")
else:
propsToInclude = ("Caption", "Choices", "ColumnCount",
- "Orientation", "PageCount",
"ScaleMode", "SlotCount")
+ "Orientation", "PageCount",
"SashPosition", "ScaleMode",
+ "SlotCount", "Split")
# We want to exclude some props, since they are derived from
# other props or are settable via other props (fonts).
propsToExclude = ("Right", "Bottom", "Font", "HeaderFont")
+ isSplitPanel = (isinstance(self, dabo.ui.dPanel)
+ and isinstance(self.Parent, dabo.ui.dSplitter))
for prop in self.DesignerProps:
if prop.startswith("Sizer_"):
continue
if prop in propsToExclude:
continue
- if (hasSizer or isinstance(self, dabo.ui.dPage)) and
prop in ("Left", "Right", "Top", "Bottom", "Width", "Height"):
+ if (hasSizer or isinstance(self, dabo.ui.dPage) or
isSplitPanel) and prop in ("Left",
+ "Right", "Top", "Bottom", "Width",
"Height"):
continue
if prop == "BackColor" and isinstance(self,
(LayoutPanel, LayoutSpacerPanel)):
continue
@@ -251,6 +255,8 @@
elif isinstance(self, dabo.ui.dGrid):
# Grid children are Columns
nonSizerKids = self.Columns
+ elif isinstance(self, dabo.ui.dSplitter):
+ nonSizerKids = [self.Panel1, self.Panel2]
else:
nonSizerKids = [kk for kk in kids
if not hasattr(kk,
"ControllingSizerItem")]
Modified: trunk/ClassDesignerControlMixin.py
===================================================================
--- trunk/ClassDesignerControlMixin.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesignerControlMixin.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -66,6 +66,8 @@
self.Application.onGridCellSelected)
self.bindEvent(dEvents.GridHeaderMouseLeftUp,
self.Application.onGridHeaderSelected)
+ elif isinstance(self, dabo.ui.dSplitter):
+ pass
else:
# This removes all previously-defined bindings
self.unbindEvent(None)
@@ -110,7 +112,8 @@
def onMouseMove(self, evt):
if evt.dragging:
if not self.Form.DragObject:
- self.Form.DragObject = self
+ if not isinstance(self, dabo.ui.dSplitter):
+ self.Form.DragObject = self
self.Form.onMouseDrag(evt)
else:
self.Form.DragObject = None
@@ -203,13 +206,13 @@
self.ControllingSizer.delete(self)
- def onGotFocus(self, evt):
- pass
-# self.raiseEvent(dEvents.KeyChar)
-
- def onLostFocus(self, evt):
- pass
-# print self.Name, "lostfocus"
+# def onGotFocus(self, evt):
+# pass
+# # self.raiseEvent(dEvents.KeyChar)
+#
+# def onLostFocus(self, evt):
+# pass
+# # print self.Name, "lostfocus"
def isSelected(self):
@@ -420,6 +423,12 @@
"SashPosition": {"type" : int, "readonly" :
False},
"ShowPanelSplitMenu" : {"type" : bool,
"readonly" : False},
"Split" : {"type" : bool, "readonly" : False}}
+ treeProps = {"Editable" : {"type" : bool, "readonly" : False},
+ "MultipleSelect" : {"type" : bool, "readonly" :
False},
+ "ShowButtons" : {"type" : bool, "readonly" :
False},
+ "ShowLines" : {"type" : bool, "readonly" :
False},
+ "ShowRootNode" : {"type" : bool, "readonly" :
False},
+ "ShowRootNodeLines" : {"type" : bool,
"readonly" : False}}
gridSizerProps = {"Sizer_RowExpand" : {"type" : bool,
"readonly" : False},
"Sizer_ColExpand" : {"type" : bool, "readonly"
: False},
"Sizer_RowSpan" : {"type" : int, "readonly" :
False},
@@ -552,6 +561,7 @@
ret.update(colorProps)
ret.update(fontProps)
elif isinstance(self, dabo.ui.dTreeView):
+ ret.update(treeProps)
ret.update(colorProps)
ret.update(fontProps)
ret.update(multiSelectProps)
Modified: trunk/ClassDesignerFormMixin.py
===================================================================
--- trunk/ClassDesignerFormMixin.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesignerFormMixin.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -38,6 +38,10 @@
self._dragOrigPos = (0, 0)
self._dragObjOffset = (0, 0)
self._appNotifiedClose = False
+ # Convenient flag for controls determining if
+ # they are being modified on a design surface
+ # or run interactively.
+ self.isDesignerForm = True
def onActivate(self, evt):
Modified: trunk/ClassDesignerPemForm.py
===================================================================
--- trunk/ClassDesignerPemForm.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesignerPemForm.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -50,21 +50,25 @@
sz.append(hsz, "x")
sz.appendSpacer(5)
- dabo.ui.dFoldPanelBar(pnl, SingleClick=True, Singleton=True,
+ self.mainPager = mp = dabo.ui.dPageFrameNoTabs(pnl, PageCount=2)
+ mp.bindEvent(dEvents.PageChanged, self.onMainPageChanged)
+ sz.append1x(mp)
+ sz.appendSpacer(brdr)
+ self.pemPage = pp = mp.Pages[0]
+ self.treePage = tp = mp.Pages[1]
+ psz = pp.Sizer = dabo.ui.dSizer("v")
+
+ dabo.ui.dFoldPanelBar(pp, SingleClick=True, Singleton=True,
CollapseToBottom=True, RegID="mainBar")
- pnl.Sizer.append1x(self.mainBar)
+ psz.append1x(self.mainBar)
self.mainBar.bindEvent(dEvents.FoldPanelChange,
self.onPanelChange)
dabo.ui.dFoldPanel(self.mainBar, Caption=_("Properties"),
RegID="propPage",
CaptionForeColor="blue")
dabo.ui.dFoldPanel(self.mainBar, Caption=_("Methods"),
RegID="methodPage",
CaptionForeColor="blue")
-# dabo.ui.dFoldPanel(self.mainBar, Caption=_("Object Tree"),
RegID="treePage",
-# CaptionForeColor="blue")
dabo.ui.dFoldPanel(self.mainBar, Caption=_("Custom
Properties"), RegID="objPropPage",
CaptionForeColor="blue")
- sz.appendSpacer(brdr)
-
# Add the PropSheet
ps = PropSheet(self.propPage, RegID="_propSheet")
self.propPage.Sizer = dabo.ui.dSizer("v")
@@ -79,42 +83,32 @@
self._methodList = ms.MethodList
# Create the tree
- self._tree = TreeSheet(self, Visible=False)
- self.bindEvent(dEvents.Resize, self._onResizeTree)
+ self._tree = TreeSheet(tp)
+ tp.Sizer.append1x(self._tree, border=10)
# Create the Object Properties sheet
ops = ObjectPropertySheet(self.objPropPage,
RegID="_objPropSheet")
self.objPropPage.Sizer = dabo.ui.dSizer("v")
self.objPropPage.Sizer.appendSpacer(self.methodPage.CaptionHeight)
- self.objPropPage.Sizer.append1x(ops)
+ self.objPropPage.Sizer.append1x(ops)
+ mp.SelectedPage = pp
+
ps.app = ms.app = self._tree.app = ops.app = self.Application
self.layout()
dabo.ui.callAfter(self.mainBar.expand, self.propPage)
def onToggleTree(self, evt):
- self._tree.Visible = not self._tree.Visible
- self.mainBar.Visible = not self._tree.Visible
+ self.mainPager.nextPage()
- def _onResizeTree(self, evt):
- """Need to use callAfter, since the layout may not have resized
the other
- objects yet.
- """
- dabo.ui.callAfter(self._resizeTree)
+ def onMainPageChanged(self, evt):
+ self.treeBtn.Value = self.mainPager.SelectedPage is
self.treePage
-
- def _resizeTree(self):
- tree= self._tree
- mb = self.mainBar
- tree.Size = mb.Size
- tree.Position = mb.Position
-
-
+
def hideTree(self):
- self._tree.Visible = False
- self.treeBtn.Value = False
+ self.mainPager.SelectedPage = self.pemPage
def onPanelChange(self, evt):
@@ -133,18 +127,19 @@
def showPropPage(self):
+ self.mainPager.SelectedPage = self.pemPage
self.refresh()
self.propPage.Expanded = True
self.bringToFront()
def showTreePage(self):
- self.treeBtn.Value = True
- self._tree.Visible = True
+ self.mainPager.SelectedPage = self.treePage
self.bringToFront()
def showMethodsPage(self):
+ self.mainPager.SelectedPage = self.pemPage
self.methodPage.Expanded = True
self.bringToFront()
Modified: trunk/ClassDesignerTreeSheet.py
===================================================================
--- trunk/ClassDesignerTreeSheet.py 2006-07-05 17:47:04 UTC (rev 598)
+++ trunk/ClassDesignerTreeSheet.py 2006-07-16 16:23:01 UTC (rev 599)
@@ -2,6 +2,7 @@
dabo.ui.loadUI("wx")
import dabo.dEvents as dEvents
from dabo.dLocalize import _
+from dabo.ui import dKeys
from ClassDesignerComponents import LayoutPanel
from ClassDesignerComponents import LayoutBasePanel
from ClassDesignerComponents import LayoutSpacerPanel
@@ -28,26 +29,32 @@
self.tree.bindEvent(dEvents.TreeSelection, self.onTreeSel)
self.tree.bindEvent(dEvents.TreeItemContextMenu,
self.onTreeContextMenu)
- self.tree.bindEvent(dEvents.TreeBeginDrag, self.onTreeBeginDrag)
- self.tree.bindEvent(dEvents.TreeEndDrag, self.onTreeEndDrag)
+ self.tree.bindEvent(dEvents.MouseLeftDoubleClick,
self.onTreeAction)
+ self.tree.bindKey("enter", self.onTreeAction)
+ self.tree.bindKey("numpad_enter", self.onTreeAction)
+# self.tree.bindEvent(dEvents.TreeBeginDrag, self.onTreeBeginDrag)
+# self.tree.bindEvent(dEvents.TreeEndDrag, self.onTreeEndDrag)
self.Sizer = dui.dSizer("v")
self.Sizer.append1x(self.tree)
-# self.Form.Tree = self
# Flag for determining if the user or the app is selecting
self._inAppSelection = False
- def onTreeBeginDrag(self, evt):
- print "BEGIN DRAG"
- print "ALLOWED?",evt._uiEvent.IsAllowed()
- print evt.EventData
- print evt.selectedCaption
+ def onTreeAction(self, evt):
+ self.Form.hideTree()
+
-
- def onTreeEndDrag(self, evt):
- print "End DRAG"
- print evt.EventData
- print evt.selectedCaption
+# def onTreeBeginDrag(self, evt):
+# print "BEGIN DRAG"
+# print "ALLOWED?",evt._uiEvent.IsAllowed()
+# print evt.EventData
+# print evt.selectedCaption
+#
+#
+# def onTreeEndDrag(self, evt):
+# print "End DRAG"
+# print evt.EventData
+# print evt.selectedCaption
def onTreeSel(self, evt):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev