dabo Commit
Revision 7069
Date: 2012-01-30 18:36:16 -0800 (Mon, 30 Jan 2012)
Author: Ed
Trac: http://trac.dabodev.com/changeset/7069

Changed:
U   trunk/dabo/ui/uiwx/dMenu.py
U   trunk/dabo/ui/uiwx/dMenuItem.py
U   trunk/dabo/ui/uiwx/dPemMixin.py

Log:
Added dSeparatorMenuItem as a Dabo wrapper to the raw wxPython menu separator 
item.

Diff:
Modified: trunk/dabo/ui/uiwx/dMenu.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenu.py 2012-01-31 02:34:01 UTC (rev 7068)
+++ trunk/dabo/ui/uiwx/dMenu.py 2012-01-31 02:36:16 UTC (rev 7069)
@@ -16,6 +16,7 @@
 NormalItemType = wx.ITEM_NORMAL
 CheckItemType =  wx.ITEM_CHECK
 RadioItemType = wx.ITEM_RADIO
+SeparatorItemType = wx.ITEM_SEPARATOR
 
 
 class dMenu(pm.dPemMixin, wx.Menu):
@@ -197,7 +198,8 @@
 
        def appendSeparator(self):
                """Insert a separator at the bottom of the menu."""
-               return self.AppendSeparator()
+               return self._createMenuItem(None, caption=None, help=None, 
bmp=None, picture=None,
+                               menutype="separator")
 
 
        def insertSeparator(self, pos):
@@ -383,7 +385,8 @@
                        itmSpecial = None
                cls = {NormalItemType: dabo.ui.dMenuItem,
                                CheckItemType: dabo.ui.dCheckMenuItem,
-                               RadioItemType: dabo.ui.dRadioMenuItem}[itmtyp]
+                               RadioItemType: dabo.ui.dRadioMenuItem,
+                               SeparatorItemType: 
dabo.ui.dSeparatorMenuItem}[itmtyp]
                itm = cls(self, HelpText=help, Icon=icon, kind=itmtyp, *args, 
**kwargs)
                if itmSpecial:
                        itm._special = itmSpecial
@@ -412,6 +415,8 @@
                        # use #if wxHAS_RADIO_MENU_ITEMS to test for
                        # availability of this feature.
                        ret = RadioItemType
+               elif typ == "sep":
+                       ret = SeparatorItemType
                return ret
 
 

Modified: trunk/dabo/ui/uiwx/dMenuItem.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenuItem.py     2012-01-31 02:34:01 UTC (rev 7068)
+++ trunk/dabo/ui/uiwx/dMenuItem.py     2012-01-31 02:36:16 UTC (rev 7069)
@@ -209,6 +209,57 @@
        DynamicHelpText = makeDynamicProperty(HelpText)
 
 
+
+class dSeparatorMenuItem(pm.dPemMixin, wx.MenuItem):
+       """Creates a menu separator."""
+       def __init__(self, parent=None, properties=None, *args, **kwargs):
+               self._baseClass = dSeparatorMenuItem
+               preClass = wx.MenuItem
+               self.Parent = parent
+               # Holds the unique ID, if any
+               self._itemID = None
+               pm.dPemMixin.__init__(self, preClass, parent, properties, 
*args, **kwargs)
+
+
+       # The following are methods designed to make separators work like other 
menu items.
+       def GetParent(self):
+               return self.Parent
+       def _dummy(self, *args, **kwargs):
+               pass
+       Bind = SetLabel = _dummy
+
+
+       def _getItemID(self):
+               return self._itemID
+
+       def _setItemID(self, val):
+               if self._constructed():
+                       self._itemID = val
+               else:
+                       self._properties["ItemID"] = val
+
+
+       def _getParent(self):
+               try:
+                       ret = self._parent
+               except AttributeError:
+                       ret = self._parent = None
+               return ret
+
+       def _setParent(self, val):
+               self._parent = val
+
+
+       ItemID = property(_getItemID, _setItemID, None,
+                       _("""Identifying value for this menuitem. NOTE: there 
is no checking for
+                       duplicate values; it is the responsibility to ensure 
that ItemID values
+                       are unique within a menu.  (varies)"""))
+
+       Parent = property(_getParent, _setParent, None,
+                       _("Specifies the parent menu."))
+
+
+
 class _AbstractExtendedMenuItem(dMenuItem):
        """Creates a checkbox-like item in a menu."""
        def __init__(self, parent=None, properties=None, *args, **kwargs):

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2012-01-31 02:34:01 UTC (rev 7068)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2012-01-31 02:36:16 UTC (rev 7069)
@@ -120,7 +120,7 @@
                                        continue
                                # Note: we may need to add more string props 
here.
                                if (val in builtinNames) and (prop in 
("Caption", "DataSource",
-                                               "DataField", "FontFace", 
"Picture", "RegID", "ToolTipText")):
+                                               "DataField", "FontFace", 
"Icon", "Picture", "RegID", "ToolTipText")):
                                        # It's a string that happens to be the 
same as a built-in name
                                        attVal = val
                                else:
@@ -135,12 +135,16 @@
                import dMenuBar, dMenuItem, dMenu, dSlidePanelControl, 
dToggleButton
                if wx.VERSION >= (2, 8, 8):
                        import dBorderlessButton
-               if isinstance(self, dMenuItem.dMenuItem):
+               if isinstance(self, (dMenuItem.dMenuItem, 
dMenuItem.dSeparatorMenuItem)):
                        # Hack: wx.MenuItem doesn't take a style arg,
                        # and the parent arg is parentMenu.
                        del self._preInitProperties["style"]
                        self._preInitProperties["parentMenu"] = parent
                        del self._preInitProperties["parent"]
+                       if isinstance(self, dMenuItem.dSeparatorMenuItem):
+                               del(self._preInitProperties["id"])
+                               for remove in ("HelpText", "Icon", "kind"):
+                                       self._extractKey((properties, 
self._properties, kwargs), remove)
                elif isinstance(self, (dMenu.dMenu, dMenuBar.dMenuBar)):
                        # Hack: wx.Menu has no style, parent, or id arg.
                        del(self._preInitProperties["style"])
@@ -1324,8 +1328,8 @@
 
        def setFocus(self):
                """Sets focus to the object."""
-               ## Up until r6816, the following was wrapped in a callAfter(), 
which made for 
-               ## lousy performance, especially on Windows. 
+               ## Up until r6816, the following was wrapped in a callAfter(), 
which made for
+               ## lousy performance, especially on Windows.
                self.SetFocus()
 
 



_______________________________________________
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