Here it is again... on the archive i cant see my message
correctly...sending the patch in the mail body
Pedro Vale de Gato
Index: ui/uiwx/dMdiLayoutPanel.py
===================================================================
--- ui/uiwx/dMdiLayoutPanel.py (revision 0)
+++ ui/uiwx/dMdiLayoutPanel.py (revision 0)
@@ -0,0 +1,170 @@
+# -*- coding: utf-8 -*-
+""" dMdiLayoutPanel.py
+
+A special panel used together with dMainForm in MDI mode (windows only).
+
+Panels can be positioned inside the MDI client area at a given place
and can
+be user resized.
+
+Example:
+ lp = dMdiLayoutPanel(self, Size=(150,50),
+ Resizable=True, Alignment="Left",
+ Orientation="Vertical")
+"""
+
+import wx
+import dabo
+import dabo.ui
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+import dControlMixin as dcm
+
+class dMdiLayoutPanel(dcm.dControlMixin, wx.SashLayoutWindow):
+ def __init__(self, parent=None, properties=None,
attProperties=None, *args, **kwargs):
+ self._baseClass = dMdiLayoutPanel
+ preClass = wx.SashLayoutWindow
+
+ self.__do_resizable_after = False
+ self.__resizable = False
+
+ dcm.dControlMixin.__init__(self, preClass, parent, properties,
attProperties, *args, **kwargs)
+
+ #main panel creation
+ self.__pnl = dabo.ui.dPanel(self)
+ self.__pnl.Sizer = dabo.ui.dSizer("v")
+
+ self.super()
+
+ def initEvents(self):
+ self.Bind(wx.EVT_SASH_DRAGGED, self.__OnWxSashDragged)
+ self.bindEvent(dabo.dEvents.ChildBorn, self._childBorn)
+
+ def _afterSetProperties(self):
+ if self.__do_resizable_after:
+ self.Resizable = self.__resizable
+
+ self.super()
+
+ def __OnWxSashDragged(self, evt):
+ if evt.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
+ return
+
+ if self.Alignment == "Top" or self.Alignment == "Bottom":
+ self.SetDefaultSize((1, evt.GetDragRect().height))
+ else:
+ self.SetDefaultSize((evt.GetDragRect().width, 1))
+
+ #re-layout the parent frame
+ wx.LayoutAlgorithm().LayoutMDIFrame(self.Parent)
+
+ # We need to re-parent all childs except the main panel
+ def _childBorn(self, evt):
+ if not isinstance(evt.Child, dabo.ui.dPanel):
+ evt.Child.Parent = self.__pnl
+
+ # Proxy method re-parenting the added objects to the main panel
+ def addObject(self, classRef, Name=None, *args, **kwargs):
+ return self.__pnl.addObject(classRef, Name, *args, **kwargs)
+
+
+ # Properties getters/setters
+ def _getSize(self):
+ return self.GetDefaultSize()
+
+ def _setSize(self, size):
+ self.SetDefaultSize(size)
+
+ def _getOrientation(self):
+ if self.GetOrientation() == wx.LAYOUT_VERTICAL:
+ return "Vertical"
+ return "Horizontal"
+
+ def _setOrientation(self, orientation):
+ if self._constructed():
+ if orientation[0].lower() == "h":
+ self.SetOrientation(wx.LAYOUT_HORIZONTAL)
+ else:
+ self.SetOrientation(wx.LAYOUT_VERTICAL)
+ else:
+ self._properties["Orientation"] = orientation
+
+ def _getAlignment(self):
+ al = self.GetAlignment()
+
+ if al == wx.LAYOUT_TOP:
+ return "Top"
+ elif al == wx.LAYOUT_LEFT:
+ return "Left"
+ elif al == wx.LAYOUT_RIGHT:
+ return "Right"
+ elif al == wx.LAYOUT_BOTTOM:
+ return "Bottom"
+ else:
+ return ""
+
+ def _setAlignment(self, alignment):
+ if self._constructed():
+ al = alignment[0].lower()
+
+ if al == "t":
+ self.SetAlignment(wx.LAYOUT_TOP)
+ elif al == "l":
+ self.SetAlignment(wx.LAYOUT_LEFT)
+ elif al == "r":
+ self.SetAlignment(wx.LAYOUT_RIGHT)
+ elif al == "b":
+ self.SetAlignment(wx.LAYOUT_BOTTOM)
+
+ else:
+ self._properties["Alignment"] = alignment
+
+ def _getSizer(self):
+ return self.__pnl.Sizer
+
+ def _setSizer(self, sizer):
+ self.__pnl.Sizer = sizer
+
+ def _getResizable(self):
+ if self.Alignment == "Top":
+ return self.GetSashVisible(wx.SASH_BOTTOM)
+ elif self.Alignment == "Bottom":
+ return self.GetSashVisible(wx.SASH_TOP)
+ elif self.Alignment == "Left":
+ return self.GetSashVisible(wx.SASH_RIGHT)
+ elif self.Alignment == "Right":
+ return self.GetSashVisible(wx.SASH_LEFT)
+ else:
+ return False
+
+
+ def _setResizable(self, resizable):
+ if self._constructed():
+ if self.Alignment == "Top":
+ self.SetSashVisible(wx.SASH_BOTTOM, resizable)
+ elif self.Alignment == "Bottom":
+ self.SetSashVisible(wx.SASH_TOP, resizable)
+ elif self.Alignment == "Left":
+ self.SetSashVisible(wx.SASH_RIGHT, resizable)
+ elif self.Alignment == "Right":
+ self.SetSashVisible(wx.SASH_LEFT, resizable)
+ else:
+ # Resizable depends on Alignment, as we cannot order the
+ # properties we will init Resizable later in
_afterSetProperties
+ self.__resizable = resizable
+ self.__do_resizable_after = True
+ else:
+ self._properties["Resizable"] = resizable
+
+ # Properties
+
+ Size = property(_getSize, _setSize, (100,100), _("The size of the
MDI panel, it will grow on the oposite coordinate of its Orientation"))
+
+ Orientation = property(_getOrientation, _setOrientation,
"Horizontal", _("The orientation of the MDI panel, valid values are
Horizontal or Vertical"))
+
+ Alignment = property(_getAlignment, _setAlignment, "Top", _("The
alignment of the MDI panel, valid values are Top, Left, Right or Bottom"))
+
+ Sizer = property(_getSizer, _setSizer, None, _("The sizer used in
this MDI panel"))
+
+ Resizable = property(_getResizable, _setResizable, False, _("Is
this MDI panel resizable?"))
+
Index: ui/uiwx/__init__.py
===================================================================
--- ui/uiwx/__init__.py (revision 3902)
+++ ui/uiwx/__init__.py (working copy)
@@ -146,6 +146,7 @@
from dLed import dLed
import dUICursors as dUICursors
import dShell
+from dMdiLayoutPanel import dMdiLayoutPanel
try:
from dLinePlot import dLinePlot
Index: ui/uiwx/dFormMain.py
===================================================================
--- ui/uiwx/dFormMain.py (revision 3902)
+++ ui/uiwx/dFormMain.py (working copy)
@@ -57,6 +57,16 @@
dFormMainBase.__init__(self, preClass, parent, properties,
*args, **kwargs)
+ def initEvents(self):
+ self.Bind(wx.EVT_SIZE, self.__onWxSize)
+
+ def __onWxSize(self, evt):
+ try:
+ if self._mdi and isinstance(self, dabo.ui.dFormMain):
+ wx.LayoutAlgorithm().LayoutMDIFrame(self)
+ except:
+ pass
+
def Show(self, show=True, *args, **kwargs):
self._gtk_show_fix(show)
dFormMain.__bases__[-1].Show(self, show, *args, **kwargs)
_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]