dabo Commit
Revision 6065
Date: 2010-10-03 10:07:56 -0700 (Sun, 03 Oct 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6065

Changed:
U   trunk/ide/ClassDesigner.py
U   trunk/ide/ClassDesignerControlMixin.py
U   trunk/ide/ClassDesignerFormMixin.py
U   trunk/ide/ClassDesignerPropSheet.py

Log:
Added support for dMaskedTextBox to the Class Designer.

Modified the 'readonly' setting in the DesignerProps so that it supports 
callables.

Removed has_key() calls.


Diff:
Modified: trunk/ide/ClassDesigner.py
===================================================================
--- trunk/ide/ClassDesigner.py  2010-10-03 17:04:01 UTC (rev 6064)
+++ trunk/ide/ClassDesigner.py  2010-10-03 17:07:56 UTC (rev 6065)
@@ -208,6 +208,7 @@
                                {"name" : "Line", "class" : dui.dLine, "order" 
: 130},
                                {"name" : "ListBox", "class" : dui.dListBox, 
"order" : 140},
                                {"name" : "ListControl", "class" : 
dui.dListControl, "order" : 150},
+                               {"name" : "MaskedTextBox", "class" : 
dui.dMaskedTextBox, "order" : 155},
                                {"name" : "RadioList", "class" : 
dui.dRadioList, "order" : 160},
                                {"name" : "Page", "class" : dui.dPage, "order" 
: 170},
                                {"name" : "Panel", "class" : dui.dPanel, 
"order" : 180},
@@ -300,10 +301,11 @@
                                "ListEvent", "MenuEvent", "MouseEvent", 
"SashEvent",
                                "CalendarEvent", "TreeEvent")
                classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton, 
dui.dButton, dui.dCheckBox, dui.dComboBox,
-                               dui.dDateTextBox, dui.dDialog, 
dui.dDropdownList, dui.dEditBox, dui.dEditor, dui.dSlidePanelControl,
-                               dui.dForm, dui.dFormMain, dui.dDockForm, 
dui.dGauge, dui.dGrid, dui.dHtmlBox, dui.dImage,
-                               dui.dLabel, dui.dLed, dui.dLine, dui.dListBox, 
dui.dListControl, dui.dOkCancelDialog, dui.dPanel,
-                               dui.dPage, dui.dScrollPanel, dui.dPage, 
dui.dPageFrame, dui.dPageList, dui.dPageSelect, dui.dPageStyled,
+                               dui.dDateTextBox, dui.dDialog, 
dui.dDropdownList, dui.dEditBox, dui.dEditor,
+                               dui.dSlidePanelControl, dui.dForm, 
dui.dFormMain, dui.dDockForm, dui.dGauge,
+                               dui.dGrid, dui.dHtmlBox, dui.dImage, 
dui.dLabel, dui.dLed, dui.dLine, dui.dListBox,
+                               dui.dListControl, dui.dMaskedTextBox, 
dui.dOkCancelDialog, dui.dPanel, dui.dPage,
+                               dui.dScrollPanel, dui.dPage, dui.dPageFrame, 
dui.dPageList, dui.dPageSelect, dui.dPageStyled,
                                dui.dPageFrameNoTabs, dui.dRadioList, 
dui.dSlider, dui.dSpinner, dui.dSplitter, dui.dTextBox,
                                dui.dToggleButton, dui.dTreeView, dlgs.Wizard, 
dlgs.WizardPage)
 
@@ -1696,7 +1698,8 @@
                                else:
                                        obj = cls(frm)
                        for prop in obj.DesignerProps:
-                               ret[prop] = eval("obj.%s" % prop)
+                               ret[prop] = getattr(obj, prop)
+#                              ret[prop] = eval("obj.%s" % prop)
                        self._classDefaultVals[cls] = ret
                        if cleanup:
                                exec cleanup in locals()
@@ -1924,16 +1927,16 @@
                                                "Plain Dialog", "OK/Cancel 
Dialog", "Wizard", "WizardPage", "PageFrame", "PageList",
                                                "PageSelect", "PageStyled", 
"PageNoTabs", "Box", "Bitmap", "BitmapButton", "Button",
                                                "CheckBox", "ComboBox", 
"DateTextBox", "DropdownList", "EditBox", "Editor", "Gauge",
-                                               "Grid", "HtmlBox", "Image", 
"Label", "LED", "Line", "ListBox", "ListControl", "Page",
-                                               "RadioList", "Slider", 
"Spinner", "Splitter", "TextBox", "ToggleButton", "TreeView"]
+                                               "Grid", "HtmlBox", "Image", 
"Label", "LED", "Line", "ListBox", "ListControl", "MaskedTextBox",
+                                               "Page", "RadioList", "Slider", 
"Spinner", "Splitter", "TextBox", "ToggleButton", "TreeView"]
                                keys = [dui.dForm, dui.dFormMain, 
dui.dDockForm, dui.dPanel, dui.dScrollPanel,
                                                dui.dSlidePanelControl, 
dui.dDialog, dui.dOkCancelDialog, dlgs.Wizard, dlgs.WizardPage,
                                                dui.dPageFrame, dui.dPageList, 
dui.dPageSelect, dui.dPageStyled, 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.dHtmlBox, dui.dImage, 
dui.dLabel, dui.dLine, dui.dLed, dui.dListBox, dui.dListControl,
-                                               dui.dPage, dui.dRadioList, 
dui.dSlider, dui.dSpinner, dui.dSplitter, dui.dTextBox,
-                                               dui.dToggleButton, 
dui.dTreeView]
+                                               dui.dMaskedTextBox, dui.dPage, 
dui.dRadioList, dui.dSlider, dui.dSpinner, dui.dSplitter,
+                                               dui.dTextBox, 
dui.dToggleButton, dui.dTreeView]
                                if not _USE_DOCKFORM:
                                        # The dock form reference is position 1
                                        chc.pop(1)
@@ -2622,7 +2625,7 @@
                # Add the panels
                pnlClass = self.getControlClass(obj.PanelClass)
                obj.createPanes(cls=pnlClass)
-               if attProperties is None or (not 
attProperties.has_key("Split")):
+               if attProperties is None or ("Split" not in attProperties):
                        obj.Split = True
                try:
                        obj.Panel1.Sizer = LayoutSizer("v")
@@ -3149,6 +3152,7 @@
                        pop.append(_("Add HtmlBox"), OnHit=self.onNewHtmlBox)
                        pop.append(_("Add ListBox"), OnHit=self.onNewListBox)
                        pop.append(_("Add ListControl"), 
OnHit=self.onNewListControl)
+                       pop.append(_("Add MaskedTextBox"), 
OnHit=self.onNewMaskedTextBox)
                        pop.append(_("Add RadioList"), 
OnHit=self.onNewRadioList)
                        pop.append(_("Add Spinner"), OnHit=self.onNewSpinner)
                        pop.append(_("Add TextBox"), OnHit=self.onNewTextBox)
@@ -3379,6 +3383,8 @@
                dui.callAfter(self.addNewControl, None, dui.dListBox)
        def onNewListControl(self, evt):
                dui.callAfter(self.addNewControl, None, dui.dListControl)
+       def onNewMaskedTextBox(self, evt):
+               dui.callAfter(self.addNewControl, None, dui.dMaskedTextBox)
        def onNewRadioList(self, evt):
                dui.callAfter(self.addNewControl, None, dui.dRadioList)
        def onNewPanel(self, evt):
@@ -3751,6 +3757,7 @@
                                        _("Line") : self.onNewLine,
                                        _("ListBox") : self.onNewListBox,
                                        _("ListControl") : 
self.onNewListControl,
+                                       _("MaskedTextBox") : 
self.onNewMaskedTextBox,
                                        _("RadioList") : self.onNewRadioList,
                                        _("Panel") : self.onNewPanel,
                                        _("ScrollPanel") : 
self.onNewScrollPanel,
@@ -4174,6 +4181,7 @@
                                        (_("LED"), dui.dLed),
                                        (_("ListBox"), dui.dListBox),
                                        (_("ListControl"), dui.dListControl),
+                                       (_("MaskedTextBox"), 
dui.dMaskedTextBox),
                                        (_("Panel"), dui.dPanel),
                                        (_("ScrollPanel"), dui.dScrollPanel),
                                        (_("PageFrame"), dui.dPageFrame),
@@ -4196,65 +4204,7 @@
                        cp.Fit()
                return self._palette
 
-#      def _getPalette(self):
-#              noPalette = self._palette is None
-#              if not noPalette:
-#                      # Make sure it's still a live object
-#                      try:
-#                              junk = self._palette.Visible
-#                      except dui.deadObjectException:
-#                              noPalette = True
-#              if noPalette:
-#                      class PaletteForm(dui.dToolForm):
-#                              def afterSetMenuBar(self):
-#                                      ClassDesignerMenu.mkDesignerMenu(self)
-#
-#                              def onMenuOpen(self, evt):
-#                                      self.Controller.menuUpdate(evt, 
self.MenuBar)
-#
-#                      cp = self._palette = PaletteForm(None, 
Caption=_("Control Palette"),
-#                                      
BasePrefKey=self.BasePrefKey+".PaletteForm")
-#                      self._palette.Controller = self
-#                      # Until we get good graphics, just use regular buttons 
with
-#                      # captions instead of icons.
-#                      class PaletteButton(dui.dButton):
-#                              def afterInit(self):
-#                                      self.BasePrefKey = 
self.Parent.BasePrefKey + ".PaletteButton"
-#                                      self.FontSize = 8
-#                                      self.Height = 24
-#                      spacing = 3
-#                      sz = cp.Sizer = dui.dGridSizer(MaxCols=5, HGap=spacing, 
VGap=spacing)
-#
-#                      # Add the sizer buttons
-#                      sz.append(10)
-#                      btn = PaletteButton(cp, Caption=_("Vert. Sizer"))
-#                      btn.bindEvent(dEvents.Hit, self.onPaletteClick)
-#                      sz.append(btn)
-#                      btn = PaletteButton(cp, Caption=_("Horiz. Sizer"))
-#                      btn.bindEvent(dEvents.Hit, self.onPaletteClick)
-#                      sz.append(btn)
-#                      btn = PaletteButton(cp, Caption=_("Grid Sizer"))
-#                      btn.bindEvent(dEvents.Hit, self.onPaletteClick)
-#                      sz.append(btn)
-#                      sz.append(10)
-#
-#                      # Now add the control buttons
-#                      ctls = (_("Box"), _("Bitmap"), _("BitmapButton"), 
_("Button"), _("CheckBox"),
-#                                      _("ComboBox"), _("DateTextBox"), 
_("DropdownList"), _("EditBox"),
-#                                      _("Gauge"), _("Grid"), _("Image"), 
_("Label"), _("Line"), _("ListBox"),
-#                                      _("ListControl"), _("Panel"), 
_("ScrollPanel"), _("PageFrame"),
-#                                      _("PageList"), _("PageSelect"), 
_("PageNoTabs"), _("RadioList"),
-#                                      _("Slider"), _("Spinner"), 
_("Splitter"), _("TextBox"), _("ToggleButton"),
-#                                      _("TreeView"))
-#                      for ctl in ctls:
-#                              btn = PaletteButton(cp, Caption=ctl)
-#                              btn.bindEvent(dEvents.Hit, self.onPaletteClick)
-#                              sz.append(btn)
-#                      cp.layout()
-#                      cp.Fit()
-#              return self._palette
 
-
        def _getCurrentForm(self):
                return self._currentForm
 

Modified: trunk/ide/ClassDesignerControlMixin.py
===================================================================
--- trunk/ide/ClassDesignerControlMixin.py      2010-10-03 17:04:01 UTC (rev 
6064)
+++ trunk/ide/ClassDesignerControlMixin.py      2010-10-03 17:07:56 UTC (rev 
6065)
@@ -785,6 +785,17 @@
                                "SortOnHeaderClick": {"type": bool, "readonly": 
False},
                                "ValueColumn": {"type": int, "readonly": False},
                                "VerticalRules": {"type": bool, "readonly": 
False}}
+               
+               def haz_format(self):
+                       # Cannot edit the Mask property when Format is set to 
something
+                       return bool(self.Format)
+
+               maskedTextBoxProps = {"Format": {"type": list, "readonly": 
False,
+                                               "values": 
[""]+dui.dMaskedTextBox.getFormats()},
+                               "InputCodes": {"type": unicode, "readonly": 
False},
+                               "Mask": {"type": unicode, "readonly": 
haz_format},
+                               "ValueMode": {"type": list, "readonly": False,
+                                       "values": ["Masked", "Unmasked"]}}
                multiSelectProps = {"MultipleSelect": {"type": bool, 
"readonly": False}}
                nodeProps = {"Image": {"type": "path", "readonly": False,
                                        "customEditor": "editStdPicture"}}
@@ -1050,13 +1061,16 @@
                        ret.update(splitterProps)
                elif isinstance(self, dui.dStatusBar):
                        ret.update(fontProps)
-               elif isinstance(self, (dui.dEditBox, dui.dTextBox)):
+               elif isinstance(self, (dui.dEditBox, dui.dTextBox, 
dui.dMaskedTextBox)):
                        ret.update(colorProps)
                        ret.update(fontProps)
                        ret.update(textProps)
                        if isinstance(self, dui.dTextBox):
                                ret.update({"PasswordEntry": {"type": bool, 
"readonly": False},
                                                "TextLength": {"type": int, 
"readonly": False}})
+                       elif isinstance(self, dui.dMaskedTextBox):
+                               ret.update(maskedTextBoxProps)
+                               del ret["ForceCase"]
                elif isinstance(self, dui.dHtmlBox):
                        ret.update(htmlTextProps)
                        ret.update(scrollProps)

Modified: trunk/ide/ClassDesignerFormMixin.py
===================================================================
--- trunk/ide/ClassDesignerFormMixin.py 2010-10-03 17:04:01 UTC (rev 6064)
+++ trunk/ide/ClassDesignerFormMixin.py 2010-10-03 17:07:56 UTC (rev 6065)
@@ -654,7 +654,7 @@
                if code:
                        # Add it to the code dict
                        codeIDbase = codeID = atts.get("code-ID", "%s-%s" % 
(nm, prntName))
-                       while cd.has_key(codeID):
+                       while codeID in cd:
                                codeID = "%s-%s" % (codeIDbase, 
random.randrange(999))
                        pd["attributes"].update({"code-ID": codeID})
                        cd[codeID] = code

Modified: trunk/ide/ClassDesignerPropSheet.py
===================================================================
--- trunk/ide/ClassDesignerPropSheet.py 2010-10-03 17:04:01 UTC (rev 6064)
+++ trunk/ide/ClassDesignerPropSheet.py 2010-10-03 17:07:56 UTC (rev 6065)
@@ -254,7 +254,13 @@
                                                val = self.getObjPropVal(ob, 
prop)
                                        rec["val"] = val
                                        rec["type"] = propInfo["type"]
-                                       rec["readonly"] = propInfo["readonly"]
+                                       ro = propInfo["readonly"]
+                                       if callable(ro):
+                                               ro = ro(ob)
+                                               print "CALL", prop, ro
+                                       if prop == "Mask":
+                                               print "MASK RO", ro
+                                       rec["readonly"] = ro
 
                                        if mult:
                                                # Make sure that all the other 
objects share the values.
@@ -836,7 +842,10 @@
                if col == 1:
                        # Only the second column is directly editable, and only
                        # if the property permits editing.
-                       self.Editable = not pd["readonly"]
+                       isRO = pd["readonly"]
+                       if callable(isRO):
+                               isRO = isRO(sel[0])
+                       self.Editable = not isRO
                else:
                        self.Editable = False
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to