daboide Commit
Revision 570
Date: 2006-05-14 11:16:18 -0700 (Sun, 14 May 2006)
Author: ed
Changed:
U trunk/ClassDesigner.py
U trunk/ClassDesignerFormMixin.py
U trunk/ClassDesignerMenu.py
U trunk/ClassDesignerTreeSheet.py
U trunk/Editor.py
Log:
Changed the 'New' menu so that it presents you with a choice of classes to
design. You are no longer limited to creating new form classes, and then using
'Save As Class' to create the individual classes; you can now create them
directly.
Modified the Object tree to only show the class being edited and its
components. Previously, if you were editing a saved class that wasn't a form,
it would still show the form at the top of the hierarchy.
Modified the designer form mixin to report its object hierarchy beginning with
the class being edited, instead of always starting with the form.
Removed all references to the dRadioGroup class from the Designer. It just
seems to me to have too many limitations imposed by the wxPython implementation
to be usable. I'm thinking that we need to create our own implementation, using
sizers and wx.RadioButtons.
Added a missing sizer default for the dPage class.
Fixed a parameter bug in the EditorForm.
Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py 2006-05-11 17:01:14 UTC (rev 569)
+++ trunk/ClassDesigner.py 2006-05-14 18:16:18 UTC (rev 570)
@@ -116,7 +116,7 @@
{"name" : "Line", "class" : dui.dLine, "order"
: 130},
{"name" : "ListBox", "class" : dui.dListBox,
"order" : 140},
{"name" : "ListControl", "class" :
dui.dListControl, "order" : 150},
- {"name" : "RadioGroup", "class" :
dui.dRadioGroup, "order" : 160},
+# {"name" : "RadioGroup", "class" :
dui.dRadioGroup, "order" : 160},
{"name" : "Panel", "class" : dui.dPanel,
"order" : 170},
{"name" : "ScrollPanel", "class" :
dui.dScrollPanel, "order" : 180},
{"name" : "PageFrame", "class" :
dui.dPageFrame, "order" : 190},
@@ -245,6 +245,7 @@
dct = defVals.copy()
self._sizerDefaults[dui.dRadioGroup] = dct
dct = defVals.copy()
+ self._sizerDefaults[dui.dPage] = {}
dct.update({"HAlign" : "center", "VAlign" : "middle"})
self._sizerDefaults[dui.dPanel] = dct
dct = defVals.copy()
@@ -298,10 +299,11 @@
dui.dCheckBox, dui.dComboBox, dui.dDateTextBox,
dui.dDialog,
dui.dDropdownList, dui.dEditBox, dui.dForm,
dui.dGauge, dui.dGrid, dui.dImage, dui.dLabel,
dui.dLine,
- dui.dListBox, dui.dListControl,
dui.dRadioGroup, dui.dPanel,
+ dui.dListBox, dui.dListControl, dui.dPanel,
dui.dScrollPanel, dui.dPage, dui.dPageFrame,
dui.dPageList,
dui.dPageSelect, dui.dPageFrameNoTabs,
dui.dSlider, dui.dSpinner,
dui.dSplitter, dui.dTextBox, dui.dToggleButton,
dui.dTreeView)
+# dui.dRadioGroup,
def evtsForClass(cls):
ret = []
@@ -364,20 +366,11 @@
return ret
- def openClass(self, pth):
- """Called when the user selects the 'Open' menu and selects
- a saved XML file. We need to open the file, and confirm that it
is
- indeed a valid class file. If so, we then re-construct the
class in
- a new ClassDesigner window.
+ def _reuseMainForm(self):
+ """Determines if the MainForm for the Class Designer is a
blank, unedited
+ form, which can be re-used when the user opens an existing
class or
+ creates a new class.
"""
- xml = open(pth).read()
- try:
- clsd = xmltodict(xml)
- except:
- raise IOError, _("This does not appear to be a valid
class file.")
-
- # See if it is a full form-based class, or an individual
component.
- isFormClass = (clsd["name"] == "dForm")
mf = self.MainForm
if mf:
mfCurrDict = mf.getDesignerDict()
@@ -392,9 +385,27 @@
try:
del
mf._initialStateDict["attributes"][att]
except: pass
- if mf and (mf._initialStateDict == mfCurrDict):
+ ret = mf and (mf._initialStateDict == mfCurrDict)
+ return ret
+
+
+ def openClass(self, pth):
+ """Called when the user selects the 'Open' menu and selects
+ a saved XML file. We need to open the file, and confirm that it
is
+ indeed a valid class file. If so, we then re-construct the
class in
+ a new ClassDesigner window.
+ """
+ xml = open(pth).read()
+ try:
+ clsd = xmltodict(xml)
+ except:
+ raise IOError, _("This does not appear to be a valid
class file.")
+
+ # See if it is a full form-based class, or an individual
component.
+ isFormClass = (clsd["name"] == "dForm")
+ if self._reuseMainForm():
# Original form hasn't changed, so just use it.
- frm = mf
+ frm = self.MainForm
else:
# For now, just create a standard dForm mixed-in
ClassDesigner
# form as the base.
@@ -449,9 +460,12 @@
# Show it!
frm.Visible = True
return frm
-
+
def recreateChildren(self, parent, chld, szr, fromSzr, debug=0):
+ """Recursive routine to re-create the sizer/object structure of
+ the class.
+ """
ret = None
if isinstance(chld, dict):
# Single child passed
@@ -1111,10 +1125,46 @@
def onNewDesign(self, evt):
- frmClass = self.getFormClass()
- frm = frmClass()
+ class NewClassPicker(dabo.ui.dOkCancelDialog):
+ def addControls(self):
+ # Create a dropdown list containing all the
choices.
+ # NOTE: This would be an excellent candidate
for usage ordering.
+ chc = ["dForm", "dPanel", "dScrollPanel",
"dPageFrame", "dPageList", "dPageSelect",
+ "dPageNoTabs", "dBox",
"dBitmap", "dBitmapButton", "dButton", "dCheckBox",
+ "dComboBox", "dDateTextBox",
"dDropdownList", "dEditBox", "dGauge", "dGrid",
+ "dImage", "dLabel", "dLine",
"dListBox", "dListControl", "dSlider",
+ "dSpinner", "dSplitter",
"dTextBox", "dToggleButton", "dTreeView"]
+# "dRadioGroup",
+ self.dd = dabo.ui.dDropdownList(self,
Choices=chc, Value="dForm")
+# self.dd.Value = "dForm"
+ self.Sizer.appendSpacer(25)
+ self.Sizer.append(dabo.ui.dLabel(self,
Caption="Select the class to create:"),
+ halign="center")
+ self.Sizer.append1x(self.dd, halign="Center",
border=40)
+ self.Sizer.appendSpacer(25)
+
+ dlg = NewClassPicker(Caption="New Class")
+ dlg.show()
+ if dlg.Accepted:
+ newClassName = dlg.dd.StringValue
+ else:
+ return
+ isFormClass = (newClassName == "dForm")
+
+ if self._reuseMainForm():
+ # Original form hasn't changed, so just use it.
+ frm = self.MainForm
+ else:
+ frmClass = self.getFormClass()
+ frm = frmClass(SaveRestorePosition=False)
frm.app = self
self.currentForm = frm
+ frm._formMode = isFormClass
+ if not isFormClass:
+ cls = dui.__dict__.get(newClassName)
+ obj = self.addNewControl(frm.initLayoutPanel, cls)
+ frm.Caption = _("Dabo Class Designer: %s") % obj.Name
+
frm.Visible = True
dui.callAfter(frm.bringToFront)
@@ -1656,7 +1706,7 @@
szit = pnl.ControllingSizerItem
if szit is None:
# Something is wrong; write it to the log and return
- dabo.errorLog.write(_("Attempted to add an object of
class %s to parent %s, " +
+ dabo.errorLog.write(_("Attempted to add an object of
class %s to parent %s, "
"but parent has no sizer information.")
% (cls, pnl))
return
@@ -1843,7 +1893,7 @@
pop.append("Add Grid", bindfunc=self.onNewGrid)
pop.append("Add ListBox", bindfunc=self.onNewListBox)
pop.append("Add ListControl",
bindfunc=self.onNewListControl)
- pop.append("Add RadioGroup",
bindfunc=self.onNewRadioGroup)
+# pop.append("Add RadioGroup",
bindfunc=self.onNewRadioGroup)
pop.append("Add Spinner", bindfunc=self.onNewSpinner)
pop.append("Add TextBox", bindfunc=self.onNewTextBox)
pop.append("Add ToggleButton",
bindfunc=self.onNewToggleButton)
@@ -2365,7 +2415,7 @@
def onAddControl(self, evt):
- """Called when the user clicks on a pallette button or selects
+ """Called when the user clicks on a palette button or selects
from the Controls menu.
"""
ctlCap = evt.EventObject.Caption
@@ -2391,7 +2441,7 @@
"Line" : self.onNewLine,
"ListBox" : self.onNewListBox,
"ListControl" : self.onNewListControl,
- "RadioGroup" : self.onNewRadioGroup,
+# "RadioGroup" : self.onNewRadioGroup,
"Panel" : self.onNewPanel,
"ScrollPanel" : self.onNewScrollPanel,
"PageFrame" : self.onNewPageFrame,
@@ -2583,9 +2633,10 @@
ctls = (_("Box"), _("Bitmap"), _("BitmapButton"),
_("Button"), _("CheckBox"),
_("ComboBox"), _("DateTextBox"),
_("DropdownList"), _("EditBox"), _("Gauge"),
_("Grid"), _("Image"), _("Label"),
_("Line"), _("ListBox"), _("ListControl"),
- _("RadioGroup"), _("Panel"),
_("ScrollPanel"), _("PageFrame"), _("PageList"),
+ _("Panel"), _("ScrollPanel"),
_("PageFrame"), _("PageList"),
_("PageSelect"), _("PageNoTabs"),
_("Slider"), _("Spinner"), _("Splitter"),
_("TextBox"), _("ToggleButton"),
_("TreeView"))
+# _("RadioGroup"),
for ctl in ctls:
btn = paletteButton(cp, Caption=ctl)
btn.bindEvent(dEvents.Hit, self.onPaletteClick)
Modified: trunk/ClassDesignerFormMixin.py
===================================================================
--- trunk/ClassDesignerFormMixin.py 2006-05-11 17:01:14 UTC (rev 569)
+++ trunk/ClassDesignerFormMixin.py 2006-05-14 18:16:18 UTC (rev 570)
@@ -97,9 +97,13 @@
and the second is the object. The objects are in the order
created, irrespective of sizer position.
"""
- return self._recurseObjects(self, 0)
+ if self._formMode:
+ obj = self
+ else:
+ obj = self.Children[0]
+ return self._recurseObjects(obj, 0)
+
-
def _recurseObjects(self, obj, level):
ret = [(level, obj)]
kids = None
@@ -198,11 +202,13 @@
self.Sizer.append(lbl, halign="center")
chc = [_("The contents of the form"), _("Just
the current selection")]
rgrp = dabo.ui.dRadioGroup(self, Choices=chc,
DataSource=self,
- DataField="saveType",
ValueMode="Position", Value=1)
+ DataField="saveType",
ValueMode="Position")
self.Sizer.append(rgrp, halign="center")
typ = None
dlg = ClassScopeDialog(self)
+ dlg.saveType = 1
+ dlg.update()
dlg.show()
if dlg.Accepted:
typ = dlg.saveType
@@ -214,6 +220,7 @@
topObj = self.mainPanel
else:
topObj = self.app._selection[0]
+
# Saving just a part of the design, so get the new file name
clsFile = dabo.ui.getSaveAs(wildcard="cdxml")
if not clsFile:
Modified: trunk/ClassDesignerMenu.py
===================================================================
--- trunk/ClassDesignerMenu.py 2006-05-11 17:01:14 UTC (rev 569)
+++ trunk/ClassDesignerMenu.py 2006-05-14 18:16:18 UTC (rev 570)
@@ -66,7 +66,7 @@
help=_("Save the ClassDesigner contents
as a form"))
fm.prepend(_("&Open\tCtrl+O"), bindfunc=app.onOpenDesign,
help=_("Open a saved design file"))
- fm.prepend(_("&New\tCtrl+N"), bindfunc=app.onNewDesign,
+ fm.prepend(_("&New Class...\tCtrl+N"),
bindfunc=app.onNewDesign,
help=_("Create a new design file"))
try:
Modified: trunk/ClassDesignerTreeSheet.py
===================================================================
--- trunk/ClassDesignerTreeSheet.py 2006-05-11 17:01:14 UTC (rev 569)
+++ trunk/ClassDesignerTreeSheet.py 2006-05-14 18:16:18 UTC (rev 570)
@@ -105,7 +105,8 @@
expState = [(nn._obj, nn.Expanded) for nn in self.tree.nodes]
self.tree.clear()
- self.recurseLayout(frm, None)
+ topObj = frm.getObjectHierarchy()[0][1]
+ self.recurseLayout(topObj, None)
self.tree.expandAll()
if sel:
self.select(selObjs)
Modified: trunk/Editor.py
===================================================================
--- trunk/Editor.py 2006-05-11 17:01:14 UTC (rev 569)
+++ trunk/Editor.py 2006-05-14 18:16:18 UTC (rev 570)
@@ -494,7 +494,7 @@
self.bindKey("alt+shift+Right", self.onMoveRight)
- def hasFile(self, evt):
+ def hasFile(self, evt=None):
"""Dynamic method for the Reload From Disk menu."""
# If there's a file, enable the menu
return self.CurrentEditor._fileName
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev