main logo
Subject: [dabo-dev] dabo Commit 686
Author: noreply .at. paulmcnett DO.T com
Posted: 2004/12/31 16:42:14
 
View Entire Thread
New Search


dabo Commit
Revision 686
Date: 2004-12-31 13:42:14 -0800 (Fri, 31 Dec 2004)
Author: ed

Log:
Commented out the code in dPemMixin that set the Size of any object to (0,0) if it was the default of (-1, -1). It was interfering with the auto-sizing of panels when their Layout() method was called. I tested this change with multiple programs, and it didn't seem to break anything.

Added a debugging routine 'listMembers()' to the SizerMixin. This will list all of the children and their sizer settings, and optionally recurse down all child sizers. Also added code to dGridSizer to enable it to also use the Orientation property.

The biggest changes are to dDialog, though. Pretty much re-worked the entire class, completely Dabo-izing it by adding dPemMixin and re-factoring the creation methods. Also added an AutoSize and Centered properties to control the dialog's size and position when it is shown.


Changed:
U trunk/ui/uiwx/dDialog.py
U trunk/ui/uiwx/dGridSizer.py
U trunk/ui/uiwx/dPemMixin.py
U trunk/ui/uiwx/dSizerMixin.py

Diff:
Modified: trunk/ui/uiwx/dDialog.py
===================================================================
--- trunk/ui/uiwx/dDialog.py 2004-12-31 21:35:08 UTC (rev 685)
+++ trunk/ui/uiwx/dDialog.py 2004-12-31 21:42:14 UTC (rev 686)
@@ -4,34 +4,75 @@
import dabo.dEvents as dEvents
import dabo.dConstants as k

-class dDialog(wx.Dialog):
+class dDialog(wx.Dialog, dabo.ui.dPemMixin):
_IsContainer = True

def __init__(self, parent=None, properties=None, *args, **kwargs):
self._baseClass = dDialog
- self.BaseClass = dDialog
- super(dDialog,self).__init__(parent=parent, style=wx.DEFAULT_DIALOG_STYLE)
- self.Centre()
self._modal = True
- self.Sizer = dabo.ui.dSizer("vertical")
+ self._centered = True
+ self._fit = True
+
+ try:
+ style = style | wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
+ except:
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
+
+ preClass = wx.PreDialog
+ dabo.ui.dPemMixin.__init__(self, preClass, parent, properties=properties,
+ style=style, *args, **kwargs)
+
+
+ def _afterInit(self):
+ super(dDialog, self)._afterInit()
+ self.Sizer = dabo.ui.dSizer("V")
+ # Hook method, so that we add the buttons last
+ self._addControls()
+

def show(self):
- if self._modal:
+ if self.AutoSize:
+ self.Fit()
+ if self.Centered:
+ self.Centre()
+ if self.Modal:
return self.ShowModal()
else:
return self.Show(True)
+
+ def _addControls(self):
+ """Any controls that need to be added to the dialog
+ can be added in this method in framework classes, or
+ in addControls() in instances.
+ """
+ self.addControls()

+ def addControls(self): pass
+
+
+ def _getAutoSize(self):
+ return self._fit
+ def _setAutoSize(self, val):
+ self._fit = val
def _getCaption(self):
return self.GetTitle()
def _setCaption(self, val):
self.SetTitle(val)
+ def _getCentered(self):
+ return self._centered
+ def _setCentered(self, val):
+ self._centered = val
def _getModal(self):
return self._modal
def _setModal(self, val):
self._modal = val

+ AutoSize = property(_getAutoSize, _setAutoSize, None,
+ "When True, the dialog resizes to fit the added controls. (bool)")
Caption = property(_getCaption, _setCaption, None,
"The text that appears in the dialog's title bar (str)" )
+ Centered = property(_getCentered, _setCentered, None,
+ "Determines if the dialog is displayed centered on the screen. (bool)")
Modal = property(_getModal, _setModal, None,
"Determines if the dialog is shown modal (default) or modeless. (bool)")

@@ -40,28 +81,42 @@
class dOkCancelDialog(dDialog):
def __init__(self, parent=None, properties=None, *args, **kwargs):
self._baseClass = dOkCancelDialog
- self.BaseClass = dOkCancelDialog
- super(dOkCancelDialog, self).__init__(parent=parent, properties=properties)
-
- # Hook method, so that we add the buttons last
- self.addControls()
-
+ super(dOkCancelDialog, self).__init__(parent=parent, properties=properties, *args, **kwargs)
+
+
+ def _addControls(self):
+ # We want every subclass to be able to add their controls
+ # before we add the OK/Cancel buttons.
+ super(dOkCancelDialog, self)._addControls()
+
+ pnl = dabo.ui.dPanel(self)
hs = dabo.ui.dSizer("H")
- self.btnOK = dabo.ui.dCommandButton(self, Caption="OK")
- hs.append(self.btnOK, 0, "expand")
+ pnl.Sizer = hs
+ hs.append( (24, 1) )
+ self.btnOK = dabo.ui.dCommandButton(pnl, Caption="OK")
self.btnOK.bindEvent(dEvents.Hit, self.OnOK)
+ hs.append(self.btnOK, 1)
hs.append( (16, 1) )
-
- self.btnCancel = dabo.ui.dCommandButton(self, Caption="Cancel")
+ self.btnCancel = dabo.ui.dCommandButton(pnl, Caption="Cancel")
self.btnCancel.bindEvent(dEvents.Hit, self.OnCancel)
- hs.append(self.btnCancel, 0, "expand")
+ hs.append(self.btnCancel, 1)
+ hs.append( (24, 1) )

- self.Sizer.append(hs, 0, "expand", alignment=("bottom", "middle"), border=10)
+ pnl.Layout()
+ pnl.Fit()
+ # Add a little breathing room
+ pnl.Width += 4
+ pnl.Height += 4
+ pnl.Layout()

+ # Add a 10-pixel spacer between the added controls and
+ # the OK/Cancel button panel
+ self.Sizer.append( (1, 10) )
+ self.Sizer.append(pnl, 0, alignment=("bottom", "right") )#, border=20)
+ self.Sizer.append( (1, 20) )
+
self.Layout()
- w, h = self.GetSize()
- self.Sizer.SetDimension(0, 0, w, h)
- self.Layout()
+

def addControls(self):
"""Use this method to add controls to the dialog. The OK/Cancel

Modified: trunk/ui/uiwx/dGridSizer.py
===================================================================
--- trunk/ui/uiwx/dGridSizer.py 2004-12-31 21:35:08 UTC (rev 685)
+++ trunk/ui/uiwx/dGridSizer.py 2004-12-31 21:42:14 UTC (rev 686)
@@ -223,8 +223,10 @@
MaxDimension = property(_getMaxDimension, _setMaxDimension, None,
_("When adding elements to the sizer, this property determines "
" if we use rows or columns as the limiting value. (char: 'r' or 'c'(default) )") )
-

+ Orientation = property(_getMaxDimension, _setMaxDimension, None,
+ "Alias for the MaxDimensions property.")
+

if __name__ == "__main__":
s = dGridSizer()

Modified: trunk/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/ui/uiwx/dPemMixin.py 2004-12-31 21:35:08 UTC (rev 685)
+++ trunk/ui/uiwx/dPemMixin.py 2004-12-31 21:42:14 UTC (rev 686)
@@ -145,11 +145,11 @@
# This is completely moot when sizers are employed.
self.Position = (0, 0)

- if self.Size == (-1, -1):
- # The object was instantiated with a default position,
- # which ended up being (-1,-1). Change this to (0,0).
- # This is completely moot when sizers are employed.
- self.Size = (0, 0)
+# if self.Size == (-1, -1):
+# # The object was instantiated with a default position,
+# # which ended up being (-1,-1). Change this to (0,0).
+# # This is completely moot when sizers are employed.
+# self.Size = (0, 0)
except:
pass


Modified: trunk/ui/uiwx/dSizerMixin.py
===================================================================
--- trunk/ui/uiwx/dSizerMixin.py 2004-12-31 21:35:08 UTC (rev 685)
+++ trunk/ui/uiwx/dSizerMixin.py 2004-12-31 21:42:14 UTC (rev 686)
@@ -152,9 +152,47 @@
w = ch.GetWindow()
w.Sizer.drawOutline(w, True)
except: pass
-
+
+
+ def listMembers(self, recurse=False, lvl=0):
+ """Debugging method. This will list all the members of this sizer,
+ and if recurse is True, drill down into all contained sizers.
+ """
+ ret = ""
+ indnt = "\t" * lvl
+ for chl in self.GetChildren():
+ ret += "SZITEM: %s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (
+ chl.GetBorder(),
+ chl.GetFlag(),
+ chl.GetMinSize(),
+ chl.GetPosition(),
+ chl.GetProportion(),
+ chl.GetRatio(),
+ chl.GetSize() )

+ if chl.IsSizer():
+ itm = chl.GetSizer()
+ ret += "%s%s (%s)\n" % (indnt, itm.__class__, itm.Orientation)
+ if recurse:
+ try:
+ ret += itm.listMembers(recurse=recurse, lvl=lvl+1)
+ except:
+ # not a Dabo sizer
+ pass
+ elif chl.IsWindow():
+ itm = chl.GetWindow()
+ try:
+ ret += "%s%s (%s) - Pos:%s,%s - Size:%s,%s\n" % (indnt,
+ itm.Name, itm.__class__, itm.Left, itm.Top, itm.Width, itm.Height)
+ except:
+ # Not a Dabo instance
+ ret += "%s%s\n" % (indnt, itm.__class__)
+ elif chl.IsSpacer():
+ itm = chl.GetSpacer()
+ ret += "%sSpacer: W=%s, H=%s\n" % (indnt, itm.GetWidth(), itm.GetHeight())
+ return ret

+
def _getWxFlags(self, alignment, borderFlags, layout):
# If alignment is passed as a single string instead of a tuple,
# convert it.




 
©2004 noreply .at. paulmcnett .D.O.T com
<-- Prior Message New Search Next Message -->