dabo Commit
Revision 4230
Date: 2008-07-04 10:10:15 -0700 (Fri, 04 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4230

Changed:
U   trunk/dabo/ui/uiwx/dForm.py

Log:
Added the FloatingPanel property. This references a borderless dialog that can 
be used similarly to a context menu, but which can contain any controls you 
want. Additionally, it will guarantee that it is displayed completely within 
the available screen real estate. 

It has two properties itself:
        Above: by default the dialog is positioned below its owning control. 
This changes the behavior so that it is positioned above the control.
        Owner: this is the control used to position the dialog.

Typical usage (written in a custom control):

fp = self.Form.FloatingPanel
fp.clear()
# Add controls
ctrl = dabo.ui.dTextBox(fp, ...)
ctrl2 = ...
# Set the Owner to the control
fp.Owner = self
fp.show()

The controls in the FloatingPanel should hide or release it, depending on 
whether you expect to re-use it. See the update to dDateTextBox for an 
implementation of it.




Diff:
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2008-07-04 17:00:01 UTC (rev 4229)
+++ trunk/dabo/ui/uiwx/dForm.py 2008-07-04 17:10:15 UTC (rev 4230)
@@ -10,8 +10,72 @@
 import dabo.dException as dException
 from dabo.dLocalize import _
 from dabo.ui import makeDynamicProperty
+from dDialog import dDialog
 
 
+class _FloatDialog(dDialog):
+       def __init__(self, owner, *args, **kwargs):
+               self._above = None
+               self._owner = None
+               kwargs["Borderless"] = True
+               kwargs["FloatOnParent"] = True
+               super(_FloatDialog, self).__init__(*args, **kwargs)
+
+
+       def clear(self):
+               """Releases any controls remaining from a previous usage."""
+               self.Sizer.clear(True)
+
+
+       def show(self):
+               # position by owner
+               if self.Owner is None:
+                       self.Centered = True
+               else:
+                       self.Centered = None
+                       left, top = self.Owner.absoluteCoordinates()
+                       self.Left = left
+                       if self.Above:
+                               self.Bottom = top
+                       else:
+                               self.Top = top + self.Owner.Height
+               # Make sure that we're within the display limits
+               maxW, maxH = dabo.ui.getDisplaySize()
+               self.Left = max(5, self.Left)
+               self.Top = max(5, self.Top)
+               self.Right = min(self.Right, maxW-5)
+               self.Bottom = min(self.Bottom, maxH-5)
+               super(_FloatDialog, self).show()
+               
+
+       def _getAbove(self):
+               return self._above
+
+       def _setAbove(self, val):
+               if self._constructed():
+                       self._above = val
+               else:
+                       self._properties["Above"] = val
+
+
+       def _getOwner(self):
+               return self._owner
+
+       def _setOwner(self, val):
+               if self._constructed():
+                       self._owner = val
+               else:
+                       self._properties["Owner"] = val
+
+
+       Above = property(_getAbove, _setAbove, None,
+                       _("Is this dialog positioned above its owner? 
Default=False  (bool)"))
+
+       Owner = property(_getOwner, _setOwner, None,
+                       _("Control which is currently managing this window.  
(varies)"))
+
+
+
 class BaseForm(fm.dFormMixin):
        """Creates a bizobj-aware form.
 
@@ -21,6 +85,7 @@
        def __init__(self, preClass, parent, properties, attProperties, *args, 
**kwargs):
                self.bizobjs = {}
                self._primaryBizobj = None
+               self._floatingPanel = None
                
                # If this is True, a panel will be automatically added to the
                # form and sized to fill the form.
@@ -80,6 +145,8 @@
                if not self._isClosed:
                        self.activeControlValid()
                        ret = self.confirmChanges()
+               if self._floatingPanel:
+                       self._floatingPanel.release()
                if ret:
                        ret = super(BaseForm, self)._beforeClose(evt)
                return ret
@@ -795,6 +862,12 @@
                self._checkForChanges = bool(value)
                
 
+       def _getFloatingPanel(self):
+               if not self._floatingPanel:
+                       self._floatingPanel = _FloatDialog(self)
+               return self._floatingPanel
+
+
        def _getPrimaryBizobj(self):
                """The attribute '_primaryBizobj' should be a bizobj, but due
                to old code design, might be a data source name. These methods
@@ -855,6 +928,11 @@
                        box asking whether to save changes, discard changes, or 
cancel the 
                        operation that led to the dialog being presented.""") )
 
+       FloatingPanel = property(_getFloatingPanel, None, None,
+                       _("""Small modal dialog that is designed to be used for 
temporary displays, 
+                       similar to context menus, but which can contain any 
controls.  
+                       (read-only) (dDialog)"""))
+
        PrimaryBizobj = property(_getPrimaryBizobj, _setPrimaryBizobj, None, 
                        _("Reference to the primary bizobj for this form  
(dBizobj)") )
 




_______________________________________________
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