daboide Commit
Revision 718
Date: 2006-12-19 09:29:27 -0800 (Tue, 19 Dec 2006)
Author: Ed
Changed:
U trunk/ClassDesigner.py
U trunk/ClassDesignerFormMixin.py
Log:
Initial support for creating container classes, such as Page controls, and then
adding them to other designs. Previously, adding such a custom container to a
design failed to wrap the contained controls to work in the Designer; this
addresses that failure.
There are still some shortcomings, such as code in the contained controls not
being executed, as well as them not preserving their class IDs. But at least
this is stable enough not to break anything else.
Improved the bizobj code format in the ClassDesignerFormMixin's addBizobjCode()
method.
Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py 2006-12-19 14:44:25 UTC (rev 717)
+++ trunk/ClassDesigner.py 2006-12-19 17:29:27 UTC (rev 718)
@@ -23,6 +23,7 @@
from ClassDesignerComponents import NoSizerBasePanel
from ClassDesignerControlMixin import ClassDesignerControlMixin as cmix
from ClassDesignerCustomPropertyDialog import ClassDesignerCustomPropertyDialog
+from dabo.lib.DesignerXmlConverter import DesignerXmlConverter
import ClassDesignerMenu
import dabo.lib.xmltodict as xtd
import dabo.lib.DesignerUtils as desUtil
@@ -37,7 +38,7 @@
isDesigner = True
def __init__(self, clsFile=""):
- super(ClassDesigner, self).__init__(showSplashScreen=True,
+ super(ClassDesigner, self).__init__(showSplashScreen=False,
splashTimeout=10)
self._basePrefKey = "dabo.ide.ClassDesigner"
@@ -96,6 +97,10 @@
gsa["MaxDimension"] = atts["MaxDimension"]
# Get rid of the update/refresh delays
dabo.useUpdateDelays = False
+ # Tuple of all paged-control classes
+ self.pagedControls = (dui.dPageFrame, dui.dPageList,
dui.dPageSelect,
+ dui.dPageFrameNoTabs)
+
# Define the controls that can be added to the ClassDesigner.
The
# 'order' value will determine their order in the menu. One plan
@@ -119,18 +124,19 @@
{"name" : "ListBox", "class" : dui.dListBox,
"order" : 140},
{"name" : "ListControl", "class" :
dui.dListControl, "order" : 150},
{"name" : "RadioList", "class" :
dui.dRadioList, "order" : 160},
- {"name" : "Panel", "class" : dui.dPanel,
"order" : 170},
- {"name" : "ScrollPanel", "class" :
dui.dScrollPanel, "order" : 180},
- {"name" : "PageFrame", "class" :
dui.dPageFrame, "order" : 190},
- {"name" : "PageList", "class" : dui.dPageList,
"order" : 200},
- {"name" : "PageSelect", "class" :
dui.dPageSelect, "order" : 210},
- {"name" : "PageFrameNoTabs", "class" :
dui.dPageFrameNoTabs, "order" : 220},
- {"name" : "Slider", "class" : dui.dSlider,
"order" : 230},
- {"name" : "Spinner", "class" : dui.dSpinner,
"order" : 240},
- {"name" : "Splitter", "class" : dui.dSplitter,
"order" : 250},
- {"name" : "TextBox", "class" : dui.dTextBox,
"order" : 260},
- {"name" : "ToggleButton", "class" :
dui.dToggleButton, "order" : 270},
- {"name" : "TreeView", "class" : dui.dTreeView,
"order" : 280}
+ {"name" : "Page", "class" : dui.dPage, "order"
: 170},
+ {"name" : "Panel", "class" : dui.dPanel,
"order" : 180},
+ {"name" : "ScrollPanel", "class" :
dui.dScrollPanel, "order" : 190},
+ {"name" : "PageFrame", "class" :
dui.dPageFrame, "order" : 200},
+ {"name" : "PageList", "class" : dui.dPageList,
"order" : 210},
+ {"name" : "PageSelect", "class" :
dui.dPageSelect, "order" : 220},
+ {"name" : "PageFrameNoTabs", "class" :
dui.dPageFrameNoTabs, "order" : 230},
+ {"name" : "Slider", "class" : dui.dSlider,
"order" : 240},
+ {"name" : "Spinner", "class" : dui.dSpinner,
"order" : 250},
+ {"name" : "Splitter", "class" : dui.dSplitter,
"order" : 260},
+ {"name" : "TextBox", "class" : dui.dTextBox,
"order" : 270},
+ {"name" : "ToggleButton", "class" :
dui.dToggleButton, "order" : 280},
+ {"name" : "TreeView", "class" : dui.dTreeView,
"order" : 290}
)
self._initSizerDefaults()
self._initClassEvents()
@@ -266,7 +272,7 @@
dct = defVals.copy()
self._sizerDefaults[dui.dRadioList] = dct
dct = defVals.copy()
- self._sizerDefaults[dui.dPage] = {}
+ self._sizerDefaults[dui.dPage] = dct
dct.update({"HAlign" : "center", "VAlign" : "middle"})
self._sizerDefaults[dui.dPanel] = dct
dct = defVals.copy()
@@ -320,7 +326,7 @@
dui.dCheckBox, dui.dComboBox, dui.dDateTextBox,
dui.dDialog,
dui.dDropdownList, dui.dEditBox, dui.dEditor,
dui.dForm,
dui.dGauge, dui.dGrid, dui.dImage, dui.dLabel,
dui.dLine,
- dui.dListBox, dui.dListControl, dui.dPanel,
+ dui.dListBox, dui.dListControl, dui.dPanel,
dui.dPage,
dui.dScrollPanel, dui.dPage, dui.dPageFrame,
dui.dPageList,
dui.dPageSelect, dui.dPageFrameNoTabs,
dui.dRadioList,
dui.dSlider, dui.dSpinner, dui.dSplitter,
dui.dTextBox,
@@ -682,8 +688,7 @@
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))
+ isPageControl = issubclass(newClass,
self.pagedControls)
noTabs = issubclass(newClass,
dui.dPageFrameNoTabs)
if isGrid:
try:
@@ -783,7 +788,7 @@
self._srcObj =
curr
else:
currPnl = self._srcObj
- if isinstance(obj, (dui.dPanel,
)):
+ if isinstance(obj, (dui.dPanel,
dui.dScrollPanel)):
self._srcObj = obj
self.recreateChildren(obj,
kids, None, False)
self._srcObj = currPnl
@@ -1148,7 +1153,8 @@
else:
frm = dui.dForm(None)
# We need to handle all the dependent class
types
- if issubclass(cls, dui.dPage):
+ if issubclass(cls, dui.dPage) and
isinstance(srcObj.Parent,
+ self.pagedControls):
pgf = srcObj.Parent
pp = pgf.PageCount
pgf.PageCount += 1
@@ -1331,6 +1337,7 @@
def onNewDesign(self, evt):
+ pcs = self.pagedControls
class NewClassPicker(dabo.ui.dOkCancelDialog):
def addControls(self):
# Create a dropdown list containing all the
choices.
@@ -1338,15 +1345,15 @@
chc = ("Form", "Panel", "ScrollPanel",
"PageFrame", "PageList", "PageSelect",
"PageNoTabs", "Box", "Bitmap",
"BitmapButton", "Button", "CheckBox",
"ComboBox", "DateTextBox",
"DropdownList", "EditBox", "Editor", "Gauge",
- "Grid", "Image", "Label",
"Line", "ListBox", "ListControl", "RadioList",
+ "Grid", "Image", "Label",
"Line", "ListBox", "ListControl", "Page", "RadioList",
"Slider", "Spinner",
"Splitter", "TextBox", "ToggleButton", "TreeView")
keys = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dPageFrame, dui.dPageList,
dui.dPageSelect,
dui.dPageFrameNoTabs, dui.dBox, dui.dBitmap, dui.dBitmapButton,
dui.dButton, dui.dCheckBox,
dui.dComboBox, dui.dDateTextBox,
dui.dDropdownList,
dui.dEditBox, dui.dEditor, dui.dGauge, dui.dGrid,
dui.dImage, dui.dLabel,
dui.dLine, dui.dListBox, dui.dListControl,
- dui.dRadioList, dui.dSlider,
dui.dSpinner, dui.dSplitter, dui.dTextBox,
- dui.dToggleButton,
dui.dTreeView)
+ dui.dPage, dui.dRadioList,
dui.dSlider, dui.dSpinner, dui.dSplitter,
+ dui.dTextBox,
dui.dToggleButton, dui.dTreeView)
self.dd = dabo.ui.dDropdownList(self,
Choices=chc, Keys=keys,
ValueMode="key")
self.dd.StringValue="Form"
@@ -1365,9 +1372,9 @@
def onClassSel(self, evt):
# This should be the key value, which is a
class name
cls = self.dd.KeyValue
- canUseSizer = cls in (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dPageFrame,
- dui.dPageList, dui.dPageSelect,
dui.dPageFrameNoTabs, dui.dSplitter)
- self.chk.Visible = canUseSizer
+ sizerClasses = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dPage,
+ dui.dSplitter) + pcs
+ self.chk.Visible = cls in sizerClasses
dlg = NewClassPicker(Caption=_("New Class"),
BasePrefKey=self.BasePrefKey+".NewClassPicker")
@@ -1985,11 +1992,10 @@
sz = szit = None
parent = pnl
- isPageControl = issubclass(cls, (dui.dPageFrame, dui.dPageList,
- dui.dPageSelect, dui.dPageFrameNoTabs))
+ isPageControl = issubclass(cls, self.pagedControls)
if isPageControl:
noTabs = issubclass(cls, dui.dPageFrameNoTabs)
- props["PageClass"] = self.getControlClass(dui.dPage)
+ pgCls = None
if not useSizers:
props["PageSizerClass"] = None
@@ -1998,6 +2004,7 @@
def __init__(self, *args, **kwargs):
self.noTabs =
self._extractKey(kwargs, "NoTabs", False)
self.pageCount = 3
+ self.pageClass = "<default>"
self.tabPositions = ("Top",
"Bottom", "Left", "Right")
self.tabPosSelection = 0
super(PageInfoDialog,
self).__init__(*args, **kwargs)
@@ -2018,11 +2025,31 @@
Value=0, DataSource="form", DataField="tabPosSelection")
gsz.append(lbl,
halign="right")
gsz.append(dd)
+
+ lbl = dui.dLabel(self,
Caption=_("Default Page Class:"))
+ txt = dui.dTextBox(self,
DataSource="form", DataField="pageClass",
+ Enabled=False)
+ btn = dui.dButton(self,
Caption="...")
+ btn.bindEvent(dEvents.Hit,
self.onSelectClass)
+ hsz = dui.dSizer("h")
+ hsz.append1x(txt)
+ hsz.appendSpacer(4)
+ hsz.append(btn)
+ gsz.append(lbl, halign="right")
+ gsz.append(hsz)
+
gsz.setColExpand("all", True)
self.Sizer.append1x(gsz,
border=30, halign="Center", valign="Middle")
- self.refresh()
+ self.update()
self.layout()
+
+ def onSelectClass(self, evt):
+ f = dui.getFile("cdxml")
+ if f:
+ self.pageClass = f
+ self.update()
+
dlg = PageInfoDialog(self.currentForm,
NoTabs=noTabs,
BasePrefKey=self.BasePrefKey+".PageInfoDialog")
@@ -2038,8 +2065,21 @@
except:
newPgs = 3
tabPos = "Top"
+ try:
+ pgCls = dlg.pageClass
+ except:
+ pgCls = ""
+ if not pgCls:
+ pgCls = dui.dPage
+
+ print "PGCLS", pgCls
dlg.release()
props["PageCount"] = newPgs
+ if isinstance(pgCls, basestring):
+ conv = DesignerXmlConverter()
+ conv.CreateDesignerControls = True
+ pgCls = conv.classFromXml(pgCls)
+ props["PageClass"] = pgCls
if not noTabs:
props["TabPosition"] = tabPos
else:
@@ -2131,12 +2171,21 @@
except AttributeError: pass
if isPageControl:
+ pgCtlCls = self.getControlClass(obj.PageClass)
+ obj.PageClass = pgCtlCls
obj.PageCount = pcount
pg0panel = None
if useSizers:
for pg in obj.Pages[::-1]:
- pg.Sizer = LayoutSizer("v")
- pg0panel = LayoutPanel(pg)
+ if not pg.Sizer or not
isinstance(pg.Sizer, (LayoutSizer, LayoutBorderSizer, LayoutGridSizer)):
+ pg.Sizer = LayoutSizer("v")
+ pg0panel = LayoutPanel(pg)
+
+ if isinstance(obj, dui.dPage) and not isinstance(obj.Parent,
self.pagedControls):
+ # This is a free standing page being designed. Add the
sizer, if required.
+ if useSizers:
+ obj.Sizer = LayoutSizer("v")
+ LayoutPanel(obj)
if useSizers:
newitem = obj.ControllingSizerItem
@@ -2182,6 +2231,9 @@
def getControlClass(self, base):
+ if issubclass(base, cmix):
+ # Already mixed-in
+ return base
ret = self._mixedControlClasses.get(base, None)
if not ret:
# Create a pref key that is the Designer key plus the
name of the control
@@ -2224,9 +2276,17 @@
items.append((_("Add Slot Right"),
self.onAddSlotAfter))
pos = obj.getPositionInSizer()
if pos > 0:
- items.append((_("Move Up One Slot"),
self.onMoveSlotUp))
+ if sz.Orientation == "Vertical":
+ direc = _("Up")
+ else:
+ direc = _("Left")
+ items.append((_("Move %s One Slot") % direc,
self.onMoveSlotUp))
if pos < len(sz.Children)-1:
- items.append((_("Move Down One Slot"),
self.onMoveSlotDown))
+ if sz.Orientation == "Vertical":
+ direc = _("Down")
+ else:
+ direc = _("Right")
+ items.append((_("Move %s One Slot") % direc,
self.onMoveSlotDown))
elif isinstance(sz, dui.dGridSizer):
pos = sz.getGridPos(obj)
if pos != (0, 0):
Modified: trunk/ClassDesignerFormMixin.py
===================================================================
--- trunk/ClassDesignerFormMixin.py 2006-12-19 14:44:25 UTC (rev 717)
+++ trunk/ClassDesignerFormMixin.py 2006-12-19 17:29:27 UTC (rev 718)
@@ -628,6 +628,7 @@
def addBizobjCode(self, info):
tbl = info["table"]
tblTitle = tbl.title()
+ lowbiz = tbl[0].lower() + tbl[1:] + "Bizobj"
pk = info["pk"]
flds = info["fldInfo"].keys()
if pk and pk not in flds:
@@ -1167,7 +1168,8 @@
# Add your business rules here.
return ret
- self.addBizobj(%(tblTitle)sBizobj(self.Connection))
+ %(lowbiz)s = %(tblTitle)sBizobj(self.Connection)
+ self.addBizobj(%(lowbiz)s)
"""
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev