dabo Commit
Revision 2522
Date: 2006-12-09 07:09:14 -0800 (Sat, 09 Dec 2006)
Author: Paul

Changed:
U   branches/stable/dabo/ui/uiwx/dPanel.py
U   branches/stable/dabo/ui/uiwx/dTreeView.py

Log:
Backported a couple things to the stable branch that were needed for
daboide-stable to work correctly. These are:

+ The refactoring of dPanel into common mixin class (2500)
+ Adding getBaseNodeClass() function to dTreeView 



Diff:
Modified: branches/stable/dabo/ui/uiwx/dPanel.py
===================================================================
--- branches/stable/dabo/ui/uiwx/dPanel.py      2006-12-09 01:18:49 UTC (rev 
2521)
+++ branches/stable/dabo/ui/uiwx/dPanel.py      2006-12-09 15:09:14 UTC (rev 
2522)
@@ -9,28 +9,24 @@
 from dabo.ui import makeDynamicProperty
 
 
-class dPanel(cm.dControlMixin, wx.Panel):
-       """Creates a panel, a basic container for controls.
-
-       Panels can contain subpanels to unlimited depth, making them quite
-       flexible for many uses. Consider laying out your forms on panels
-       instead, and then adding the panel to the form.
-       """
-       def __init__(self, parent, properties=None, *args, **kwargs):
-               self._baseClass = dPanel
+class _PanelMixin(cm.dControlMixin):
+       def __init__(self, preClass, parent, properties=None, *args, **kwargs):
                self._buffered = None
-               preClass = wx.PrePanel
+               buff = self._extractKey((properties, kwargs), "Buffered", False)
+               kwargs["Buffered"] = buff
                style = self._extractKey((properties, kwargs), "style", 0)
                style = style | wx.TAB_TRAVERSAL
                kwargs["style"] = style
-               buff = self._extractKey((properties, kwargs), "Buffered", False)
-               kwargs["Buffered"] = buff
                cm.dControlMixin.__init__(self, preClass, parent, properties, 
*args, **kwargs)
+       
 
-
        def layout(self):
                """ Wrap the wx version of the call, if possible. """
                self.Layout()
+               for child in self.Children:
+                       try:
+                               child.layout()
+                       except: pass
                try:
                        # Call the Dabo version, if present
                        self.Sizer.layout()
@@ -38,8 +34,8 @@
                        pass
                if self.Application.Platform == "Win":
                        self.refresh()
-                       
-       
+
+
        def _onPaintBuffer(self, evt):
                dc = wx.BufferedPaintDC(self, self._buffer)
        
@@ -67,7 +63,7 @@
                        if dc is None:
                                dc = wx.BufferedDC(wx.ClientDC(self), 
self._buffer)
                                dc.Clear() # make sure you clear the bitmap! 
-               super(dPanel, self)._redraw(dc)
+               super(_PanelMixin, self)._redraw(dc)
 
 
        def _getBuffered(self):
@@ -89,10 +85,24 @@
 
        Buffered = property(_getBuffered, _setBuffered, None,
                        _("Does this panel use double-buffering to create 
smooth redrawing?  (bool)"))
+
+
+
+class dPanel(_PanelMixin, wx.Panel):
+       """Creates a panel, a basic container for controls.
+
+       Panels can contain subpanels to unlimited depth, making them quite
+       flexible for many uses. Consider laying out your forms on panels
+       instead, and then adding the panel to the form.
+       """
+       def __init__(self, parent, properties=None, *args, **kwargs):
+               self._baseClass = dPanel
+               preClass = wx.PrePanel
+               _PanelMixin.__init__(self, preClass, parent, properties, *args, 
**kwargs)
        
                
 
-class dScrollPanel(cm.dControlMixin, wx.ScrolledWindow):
+class dScrollPanel(_PanelMixin, wx.ScrolledWindow):
        """ This is a basic container for controls that allows scrolling.
 
        Panels can contain subpanels to unlimited depth, making them quite
@@ -103,25 +113,9 @@
                self._horizontalScroll = self._verticalScroll = True
                self._baseClass = dScrollPanel
                preClass = wx.PreScrolledWindow
-               if "style" not in kwargs:
-                       kwargs["style"] = wx.TAB_TRAVERSAL
-               cm.dControlMixin.__init__(self, preClass, parent, properties, 
*args, **kwargs)
+               _PanelMixin.__init__(self, preClass, parent, properties, *args, 
**kwargs)
                self.SetScrollRate(10, 10)
 #              self.SetScrollbars(10, 10, -1, -1)
-       
-
-       def layout(self):
-               """ Wrap the wx version of the call, if possible. """
-               self.Layout()
-               for child in self.Children:
-                       try:
-                               child.layout()
-                       except: pass
-               try:
-                       # Call the Dabo version, if present
-                       self.Sizer.layout()
-               except:
-                       pass
                        
 
        def _getChildren(self):
@@ -176,11 +170,11 @@
        def afterInit(self):
                self.addObject(dPanel, BackColor = "green")
 
-       def onHover(self):
+       def onHover(self, evt):
                self._normBack = self.BackColor
-               self.BackColor = "yellow"
+               self.BackColor = dabo.dColors.randomColor()
        
-       def endHover(self):
+       def endHover(self, evt):
                self.BackColor = self._normBack
 
        def onMouseLeftDown(self, evt):

Modified: branches/stable/dabo/ui/uiwx/dTreeView.py
===================================================================
--- branches/stable/dabo/ui/uiwx/dTreeView.py   2006-12-09 01:18:49 UTC (rev 
2521)
+++ branches/stable/dabo/ui/uiwx/dTreeView.py   2006-12-09 15:09:14 UTC (rev 
2522)
@@ -718,7 +718,10 @@
                #               c23 = c2.appendChild("Grandkid #3")
                #               c221 = c22.appendChild("Great-Grandkid #1")
                
-
+       def getBaseNodeClass(cls):
+               return dNode
+       getBaseNodeClass = classmethod(getBaseNodeClass)
+       
        # Event-handling code
        def __onTreeSel(self, evt):
                self.raiseEvent(dEvents.TreeSelection, evt)




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

Reply via email to