dabo Commit
Revision 5050
Date: 2009-02-09 11:29:24 -0800 (Mon, 09 Feb 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5050

Changed:
U   trunk/dabo/ui/uiwx/dFormMain.py
U   trunk/dabo/ui/uiwx/dFormMixin.py
U   trunk/dabo/ui/uiwx/dPemMixin.py

Log:
The window saving/restoration had two problems on Windows when the MDI Parent 
had a toolbar: 1) if the toolbar is created after the child windows are loaded, 
the child windows get sized to the size of the main form's client area. 
Resolved by creating the toolbar first. 2) setting Top results in a value 
offset by the height of the toolbar. I think this is a bug in wx where they 
meant to do subtraction but instead did addition, or something. Fixed by 
overriding SetPosition() in dFormMixin.

Diff:
Modified: trunk/dabo/ui/uiwx/dFormMain.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMain.py     2009-02-09 02:29:03 UTC (rev 5049)
+++ trunk/dabo/ui/uiwx/dFormMain.py     2009-02-09 19:29:24 UTC (rev 5050)
@@ -13,12 +13,7 @@
        def __init__(self, preClass, parent=None, properties=None, *args, 
**kwargs):
                fm.dFormMixin.__init__(self, preClass, parent, properties, 
*args, **kwargs)
        
-#              self.Size = (640, 480)
-#              self.Position = (-1, -1)
 
-               if wx.Platform != '__WXMAC__':
-                       self.CreateStatusBar()
-
        def _beforeClose(self, evt=None):
                forms2close = [frm for frm in self.Application.uiForms
                                if frm is not self and not isinstance(frm, 
dabo.ui.deadObject)]

Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py    2009-02-09 02:29:03 UTC (rev 5049)
+++ trunk/dabo/ui/uiwx/dFormMixin.py    2009-02-09 19:29:24 UTC (rev 5050)
@@ -23,6 +23,20 @@
                                and not self.IsMaximized():
                        return
                super(dFormMixin, self).Maximize(maximize, *args, **kwargs)
+
+       def SetPosition(self, val):
+               # On Windows MDI Child frames when the main form has a toolbar, 
setting the
+               # top position results in a position too low by the height of 
the toolbar. 
+               left, top = val
+               tb = None
+               if self.Form:
+                       tb = self.Form.ToolBar
+               if sys.platform.startswith("win") \
+                               and self.MDI \
+                               and tb:
+                       top -= tb.Height 
+               super(dFormMixin, self).SetPosition((left, top))
+
        
        def __init__(self, preClass, parent=None, properties=None, 
attProperties=None, 
                        src=None, *args, **kwargs):
@@ -76,6 +90,8 @@
                super(dFormMixin, self).__init__(preClass, parent, properties, 
                                attProperties, *args, **kwargs)
 
+               self._createStatusBar()
+               self._createToolBar()   
                if not self._designerMode:      
                        self.restoreSizeAndPosition()
 
@@ -142,7 +158,6 @@
                super(dFormMixin, self)._initEvents()
                self.Bind(wx.EVT_ACTIVATE, self.__onWxActivate)
                self.Bind(wx.EVT_CLOSE, self.__onWxClose)
-               self.bindEvent(dEvents.Activate, self.__onActivate)
                self.bindEvent(dEvents.Deactivate, self.__onDeactivate)
                self.bindEvent(dEvents.Close, self.__onClose)
                self.bindEvent(dEvents.Paint, self.__onPaint)
@@ -159,22 +174,17 @@
                """ Raise the Dabo Activate or Deactivate appropriately."""
                if bool(evt.GetActive()):
                        self.raiseEvent(dEvents.Activate, evt)
+                       app = self.Application
+                       if app is not None:
+                               if app.Platform != "Win":
+                                       app.ActiveForm = self
                else:
                        self.raiseEvent(dEvents.Deactivate, evt)
                evt.Skip()
                        
                        
-       def __onActivate(self, evt): 
-               # If the ShowStatusBar property was set to True, this will 
create it
-               self._createStatusBar()
-               # If the ShowToolBar property was set to True, this will create 
it
-               self._createToolBar()
 
-               if self.Application is not None:
-                       if self.Application.Platform != "Win":
-                               self.Application.ActiveForm = self
 
-
        def _createToolBar(self):
                if self.ShowToolBar and self.ToolBar is None:
                        try:
@@ -493,23 +503,24 @@
 
        def saveSizeAndPosition(self):
                """ Save the current size and position of this form."""
-               if self.Application:
+               app = self.Application
+               if app:
                        if self.SaveRestorePosition and not self.TempForm:
                                name = self.getAbsoluteName()
                                state = self.WindowState
-                               
self.Application.setUserSetting("%s.windowstate" % name, state)
+                               app.setUserSetting("%s.windowstate" % name, 
state)
 
                                if state == "Normal":
                                        # Don't save size and position when the 
window
                                        # is minimized, maximized or fullscreen 
because
                                        # windows doesn't supply correct value 
if the window
                                        # is in one of these states.
-                                       pos = self.Position
-                                       size = self.Size
-                                       
self.Application.setUserSetting("%s.left" % name, pos[0])
-                                       
self.Application.setUserSetting("%s.top" % name, pos[1])
-                                       
self.Application.setUserSetting("%s.width" % name, size[0])
-                                       
self.Application.setUserSetting("%s.height" % name, size[1])
+                                       left, top = self.Position
+                                       width, height = self.Size
+                                       app.setUserSetting("%s.left" % name, 
left)
+                                       app.setUserSetting("%s.top" % name, top)
+                                       app.setUserSetting("%s.width" % name, 
width)
+                                       app.setUserSetting("%s.height" % name, 
height)
                                
 
        def setStatusText(self, *args):

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2009-02-09 02:29:03 UTC (rev 5049)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2009-02-09 19:29:24 UTC (rev 5050)
@@ -1568,9 +1568,6 @@
                        obj.draw(dc)
                # Call the hook
                self.redraw(dc)
-#-             if self.Application.Platform == "Win":
-#-                     print "REFRESH", time.time()
-#-                     dabo.ui.callAfterInterval(300, self.refresh)
                        
 
        def redraw(self, dc): 
@@ -2342,15 +2339,17 @@
                else:
                        self._properties["Parent"] = val
 
-               
+
+
        def _getPosition(self):
                return self.GetPosition().Get()
 
        def _setPosition(self, val):
                if self._constructed():
-                       self.SetPosition(val)
-               if isinstance(self, dabo.ui.dFormMixin):
-                       self._defaultLeft, self._defaultTop = val
+                       left, top = val
+                       if isinstance(self, dabo.ui.dFormMixin):
+                               self._defaultLeft, self._defaultTop = (left, 
top)
+                       self.SetPosition((left, top))
                else:
                        self._properties["Position"] = val
 
@@ -2475,9 +2474,9 @@
        
        def _setTop(self, val):
                if self._constructed():
+                       if isinstance(self, dabo.ui.dFormMixin):
+                               self._defaultTop = val
                        self.SetPosition((self.Left, int(val)))
-               if isinstance(self, dabo.ui.dFormMixin):
-                       self._defaultTop = val
                else:
                        self._properties["Top"] = val
 
@@ -3662,8 +3661,6 @@
                                        
self._fileHandle.processDroppedFiles(self.fileData.Filenames)
                        elif format == wx.DF_TEXT or wx.DF_HTML:
                                
self._textHandle.processDroppedText(self.textData.Text)
-#              else:
-#                      print false
                return defResult
 
 



_______________________________________________
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