daboide Commit
Revision 590
Date: 2006-06-12 11:43:00 -0700 (Mon, 12 Jun 2006)
Author: ed

Changed:
U   trunk/ClassDesigner.py
U   trunk/ClassDesignerComponents.py
U   trunk/ClassDesignerControlMixin.py
U   trunk/ClassDesignerFormMixin.py
U   trunk/ClassDesignerPropSheet.py
U   trunk/ClassDesignerTreeSheet.py

Log:
Modified most of the routines that assumed str type, and replaced them with 
unicode type instead. Tracker #0172.


Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py      2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesigner.py      2006-06-12 18:43:00 UTC (rev 590)
@@ -38,8 +38,7 @@
                super(ClassDesigner, self).__init__(showSplashScreen=False,
                                splashTimeout=10)
                
-               # The following are temporary. We will start with a generic
-               # form designer, and then specialize to non-form classes.
+               self._basePrefKey = "dabo.ide.ClassDesigner.app"
                self._desFormClass = None
                self._selectedClass = dui.dForm
                self.currentForm = None
@@ -352,6 +351,7 @@
                                self._isMain = formIsMain
                                base.__init__(self, parent=parent, *args, 
**kwargs)
                                dfm.__init__(self, parent=parent, *args, 
**kwargs)
+                               self._basePrefKey = 
"dabo.ide.ClassDesigner.ClassDesignerForm"
                        def _afterInit(self):
                                self._designerMode = True
                                self._formMode = True
@@ -698,7 +698,7 @@
                                                ShowCodeFolding=False)
                                self.Sizer.append1x(self.edtImport, border=12)
                
-               dlg = ImportEditDialog(None)
+               dlg = ImportEditDialog(None, 
BasePrefKey=self.BasePrefKey+".ImportEditDialog")
                dlg.edtImport.Text = txt
                dlg.show()
                if dlg.Accepted:
@@ -739,7 +739,10 @@
                                typ = eval("type(obj.%s)" % prop)
                        if typ is bool:
                                val = bool(val)
-                       strVal = str(val)
+                       if isinstance(val, basestring):
+                               strVal = val
+                       else:
+                               strVal = str(val)
                        if typ in (str, unicode) or ((typ is list) and 
isinstance(val, basestring)):
                                # Escape any single quotes, and then enclose 
                                # the value in single quotes
@@ -954,7 +957,7 @@
                # by the data binding. If they cancel, we have to revert them 
to 
                # the values in propDict.
                self._sizerObj = obj
-               dlg = SizerEditDlg(fillDlg)
+               dlg = SizerEditDlg(fillDlg, 
BasePrefKey=self.BasePrefKey+".SizerEditDlg")
                dlg.Caption = _("Sizer Settings")
                self.currentForm.bringToFront()
                # This is used to determine if anything has changed in 
@@ -1197,7 +1200,8 @@
                                self.Sizer.append1x(self.dd, halign="Center", 
border=40)
                                self.Sizer.appendSpacer(25)
                
-               dlg = NewClassPicker(Caption=_("New Class"))
+               dlg = NewClassPicker(Caption=_("New Class"), 
+                               BasePrefKey=self.BasePrefKey+".NewClassPicker")
                dlg.show()
                if dlg.Accepted:
                        newClassName = dlg.dd.StringValue
@@ -1808,7 +1812,8 @@
                                        self.layout()
                        
                        if not props.get("PageCount", 0):
-                               dlg = PageInfoDialog(self.currentForm, 
NoTabs=noTabs)
+                               dlg = PageInfoDialog(self.currentForm, 
NoTabs=noTabs, 
+                                               
BasePrefKey=self.BasePrefKey+".PageInfoDialog")
                                dlg.AutoSize = False
                                dlg.Centered = True
                                dlg.show()
@@ -1900,6 +1905,8 @@
        def getControlClass(self, 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
+                       prefkey = self.BasePrefKey + "." + 
str(base).split(".")[-1].split("'")[0]
                        class controlMix(cmix, base):
                                superControl = base
                                superMixin = cmix
@@ -1909,6 +1916,7 @@
                                        parent = args[0]
                                        cmix.__init__(self, parent, **kwargs)
                                        self.NameBase = 
str(self._baseClass).split(".")[-1].split("'")[0]
+                                       self._basePrefKey = prefkey
                        ret = controlMix
                        self._mixedControlClasses[base] = ret
                return ret
@@ -2516,7 +2524,7 @@
                                self.boxcaption.Enabled = self.chkBox.Value
                                self.layout()
                                
-               dlg = BoxSizerInfo(self.currentForm)
+               dlg = BoxSizerInfo(self.currentForm, 
BasePrefKey=self.BasePrefKey+".BoxSizerInfo")
                dlg.show()
                ret = (None, None, None)
                if dlg.Accepted:
@@ -2546,7 +2554,8 @@
                        def getCols(self):
                                return self.spnCols.Value
                                
-               dlg = RowColDialog(self.currentForm, Caption=_("Grid Sizer 
Dimensions"))
+               dlg = RowColDialog(self.currentForm, Caption=_("Grid Sizer 
Dimensions"),
+                               BasePrefKey=self.BasePrefKey+".RowColDialog")
                dlg.Centered = True
                dlg.show()
                ret = (None, None)
@@ -2769,12 +2778,14 @@
                                def onMenuOpen(self, evt):
                                        self.app.menuUpdate(evt, self.MenuBar)
                        
-                       cp = self._palette = PaletteForm(None, 
Caption=_("Control Palette"))
+                       cp = self._palette = PaletteForm(None, 
Caption=_("Control Palette"),
+                                       
BasePrefKey=self.BasePrefKey+".PaletteForm")
                        self._palette.app = self
                        # Until we get good graphics, just use regular buttons 
with
                        # captions instead of icons.
-                       class paletteButton(dui.dButton):
+                       class PaletteButton(dui.dButton):
                                def afterInit(self):
+                                       self.BasePrefKey = 
self.Parent.BasePrefKey + ".PaletteButton"
                                        self.FontSize = 8
                                        self.Height = 24
                        spacing = 3
@@ -2782,13 +2793,13 @@
                        
                        # Add the sizer buttons
                        sz.append(10)
-                       btn = paletteButton(cp, Caption=_("Vert. Sizer"))
+                       btn = PaletteButton(cp, Caption=_("Vert. Sizer"))
                        btn.bindEvent(dEvents.Hit, self.onPaletteClick)
                        sz.append(btn)
-                       btn = paletteButton(cp, Caption=_("Horiz. Sizer"))
+                       btn = PaletteButton(cp, Caption=_("Horiz. Sizer"))
                        btn.bindEvent(dEvents.Hit, self.onPaletteClick)
                        sz.append(btn)
-                       btn = paletteButton(cp, Caption=_("Grid Sizer"))
+                       btn = PaletteButton(cp, Caption=_("Grid Sizer"))
                        btn.bindEvent(dEvents.Hit, self.onPaletteClick)
                        sz.append(btn)
                        sz.append(10)
@@ -2802,7 +2813,7 @@
                                        _("Slider"), _("Spinner"), 
_("Splitter"), _("TextBox"), _("ToggleButton"), 
                                        _("TreeView"))
                        for ctl in ctls:
-                               btn = paletteButton(cp, Caption=ctl)
+                               btn = PaletteButton(cp, Caption=ctl)
                                btn.bindEvent(dEvents.Hit, self.onPaletteClick)
                                sz.append(btn)
                        cp.layout()

Modified: trunk/ClassDesignerComponents.py
===================================================================
--- trunk/ClassDesignerComponents.py    2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesignerComponents.py    2006-06-12 18:43:00 UTC (rev 590)
@@ -133,7 +133,10 @@
                                                if dv == val:
                                                        continue                
                        
-                       strval = str(val)
+                       if isinstance(val, basestring):
+                               strval = val
+                       else:
+                               strval = unicode(val)
                        # Special cases
                        try:
                                evalStrVal = eval(strval)
@@ -1171,7 +1174,7 @@
 
        def _getDesProps(self):
                ret = LayoutBorderSizer.doDefault()
-               ret.update({"Caption" : {"type" : str, "readonly" : False},
+               ret.update({"Caption" : {"type" : unicode, "readonly" : False},
                                "BackColor" : {"type" : "color", "readonly" : 
False, 
                                                "customEditor": "editColor"},
                                "FontBold": {"type" : bool, "readonly" : False},

Modified: trunk/ClassDesignerControlMixin.py
===================================================================
--- trunk/ClassDesignerControlMixin.py  2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesignerControlMixin.py  2006-06-12 18:43:00 UTC (rev 590)
@@ -307,12 +307,12 @@
 
        
        def _getDesProps(self):
-               ret = {"Name" : {"type" : str, "readonly" : False},
-                               "RegID" : {"type" : str, "readonly" : False},
-                               "ToolTipText" : {"type" : str, "readonly" : 
False},
+               ret = {"Name" : {"type" : unicode, "readonly" : False},
+                               "RegID" : {"type" : unicode, "readonly" : 
False},
+                               "ToolTipText" : {"type" : unicode, "readonly" : 
False},
                                "Height": {"type" : int, "readonly" : True},
                                "Width": {"type" : int, "readonly" : True}}
-               captionProps = {"Caption": {"type" : str, "readonly" : False}}
+               captionProps = {"Caption": {"type" : unicode, "readonly" : 
False}}
                choiceProps = {"Choices": {"type" : "choice", "readonly" : 
False, 
                                "customEditor": "editChoice"},
                                "ValueMode": {"type" : list, "readonly" : False,
@@ -323,7 +323,7 @@
                                        "customEditor": "editColor"}}
                columnProps = {"Order" :  {"type" : int, "readonly" : False}, 
                                 "Width" : {"type" : int, "readonly" : False},
-                               "DataField" : {"type" : str, "readonly" : 
False},
+                               "DataField" : {"type" : unicode, "readonly" : 
False},
                                "HeaderBackColor" : {"type" : "color", 
"readonly" : False,
                                        "customEditor": "editColor"},
                                "HeaderFont" : {"type" : "font", "readonly" : 
False, 
@@ -350,8 +350,8 @@
                                "Expand": {"type" : bool, "readonly" : False},
                                "Searchable": {"type" : bool, "readonly" : 
False},
                                "Sortable": {"type" : bool, "readonly" : False}}
-               dataProps = {"DataSource" : {"type" : str, "readonly" : False},
-                               "DataField" : {"type" : str, "readonly" : 
False},
+               dataProps = {"DataSource" : {"type" : unicode, "readonly" : 
False},
+                               "DataField" : {"type" : unicode, "readonly" : 
False},
                                "Value" : {"type" : "multi", "readonly" : 
False}}
                fontProps = {"Font": {"type" : "font", "readonly" : False, 
                                        "customEditor": "editFont"},
@@ -363,7 +363,7 @@
                                "FontUnderline": {"type" : bool, "readonly" : 
False}}
                gridProps = {"AlternateRowColoring" : {"type" : bool, 
"readonly" : False},
                                "ColumnCount" : {"type" : int, "readonly" : 
False},
-                               "DataSource" : {"type" : str, "readonly" : 
False},
+                               "DataSource" : {"type" : unicode, "readonly" : 
False},
                                "Editable": {"type" : bool, "readonly" : False},
                                "HeaderBackColor": {"type" : "color", 
"readonly" : False, 
                                        "customEditor": "editColor"},

Modified: trunk/ClassDesignerFormMixin.py
===================================================================
--- trunk/ClassDesignerFormMixin.py     2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesignerFormMixin.py     2006-06-12 18:43:00 UTC (rev 590)
@@ -187,7 +187,6 @@
                        cd = propDict.get("code", {})
                        cd.update({"importStatements": imp})
                        propDict["code"] = cd
-               
                xml = dicttoxml(propDict)
                # Try opening the file. If it is read-only, it will raise an
                # IOError that the calling method can catch.
@@ -578,16 +577,16 @@
                return self.Application.getClassEvents(self._baseClass)
 
        def _getDesProps(self):
-               return {"Caption": {"type" : str, "readonly" : False},
+               return {"Caption": {"type" : unicode, "readonly" : False},
                                "Height": {"type" : int, "readonly" : False},
                                "Width": {"type" : int, "readonly" : False},
-                               "Name" : {"type" : str, "readonly" : False},
+                               "Name" : {"type" : unicode, "readonly" : False},
                                "Left": {"type" : int, "readonly" : False},
                                "Right": {"type" : int, "readonly" : False},
                                "Top": {"type" : int, "readonly" : False},
                                "Bottom": {"type" : int, "readonly" : False},
                                "ShowCaption": {"type" : bool, "readonly" : 
False},
-                               "CxnName": {"type" : str, "readonly" : False},
+                               "CxnName": {"type" : unicode, "readonly" : 
False},
                                "SaveRestorePosition": {"type" : bool, 
"readonly" : False}}
                                
 

Modified: trunk/ClassDesignerPropSheet.py
===================================================================
--- trunk/ClassDesignerPropSheet.py     2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesignerPropSheet.py     2006-06-12 18:43:00 UTC (rev 590)
@@ -144,7 +144,7 @@
                                        props = [ p for p in props
                                                        if p in indivProps]
                        if len(props) == 0:             
-                               ds = [{"prop" : "", "val" : "", "type" : str, 
"readonly" : True}]
+                               ds = [{"prop" : "", "val" : "", "type" : 
unicode, "readonly" : True}]
                        else:
                                # Construct the data set from the props
                                ds = []
@@ -180,11 +180,11 @@
                                                                indPropDict = 
indiv.DesignerProps
                                                        indDict = 
indPropDict[prop]
                                                        if indDict["type"] != 
rec["type"]:
-                                                               # Default to 
displaying strings
-                                                               rec["type"] = 
str
+                                                               # Default to 
displaying unicode strings
+                                                               rec["type"] = 
unicode
                                                        # If any object is 
readonly, set 'em all that way
                                                        rec["readonly"] = 
rec["readonly"] or indDict["readonly"]
-                                                       # Unless they all have 
identical prop vals, don't display anything.
+                                                       # Unless they all have 
dentical prop vals, don't display anything.
                                                        if isinstance(indiv, 
LayoutPanel):
                                                                nextVal = 
indiv.ControllingSizer.getItemProp(indiv.ControllingSizerItem, prop)
                                                        else:
@@ -331,7 +331,7 @@
                newVal = dabo.ui.getFile("jpg", "png", "gif", "bmp", "*")
                if newVal is not None:
                        self.propGrid.CurrentValue = newVal
-                       self.updateVal(prop, newVal, str)
+                       self.updateVal(prop, newVal, unicode)
                        self.propGrid.refresh()
 
 
@@ -670,7 +670,7 @@
                        return []
        
                def _getDesProps(self):
-                       strType = {"type" : str, "readonly" : False}
+                       strType = {"type" : unicode, "readonly" : False}
                        floatType = {"type" : float, "readonly" : False}
                        return {"name": strType,
                                        "x": floatType}

Modified: trunk/ClassDesignerTreeSheet.py
===================================================================
--- trunk/ClassDesignerTreeSheet.py     2006-06-07 14:27:22 UTC (rev 589)
+++ trunk/ClassDesignerTreeSheet.py     2006-06-12 18:43:00 UTC (rev 590)
@@ -27,6 +27,8 @@
                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.Sizer = dui.dSizer("v")
                self.Sizer.append1x(self.tree)
 #              self.Form.Tree = self
@@ -34,6 +36,22 @@
                self._inAppSelection = False
        
        
+       
+       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):
                if self._inAppSelection:
                        # Otherwise, this would be infinite recursion




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

Reply via email to