dabo Commit
Revision 6400
Date: 2011-02-06 11:16:28 -0800 (Sun, 06 Feb 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6400

Changed:
U   trunk/dabo/ui/uiwx/dEditBox.py
U   trunk/dabo/ui/uiwx/dPemMixin.py
U   trunk/dabo/ui/uiwx/test.py

Log:
Improved the handling of the WordWrap property in dEditBox. Fixed some 
punctuation in the Love Boat lyrics in the test code that had been annoying me 
for some time. NOTE: the horizontal scrollbar doesn't seem to be drawn in OS X.

Fixed test.py to set the width of the frame, and not the object themselves. 
Previously, the MinSize for the object was being set via an explicit Width 
setting, making resizing problematic. Now the form is sized, allowing the sizer 
to handle the sizing of the object.

Added some saner minimum sizes in dPemMixin. Also eliminated an unnecessary 
call to get the color tuple for 'black'.


Diff:
Modified: trunk/dabo/ui/uiwx/dEditBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditBox.py      2011-02-06 17:56:16 UTC (rev 6399)
+++ trunk/dabo/ui/uiwx/dEditBox.py      2011-02-06 19:16:28 UTC (rev 6400)
@@ -11,7 +11,6 @@
 
 
 # The EditBox is just a TextBox with some additional styles.
-
 class dEditBox(tbm.dTextBoxMixin, wx.TextCtrl):
        """Creates an editbox, which allows editing of string data of unlimited 
size.
 
@@ -23,15 +22,16 @@
 
                preClass = wx.PreTextCtrl
                kwargs["style"] = wx.TE_MULTILINE
+               self._wordWrap = self._extractKey((properties, attProperties, 
kwargs),
+                               "WordWrap", True)
+               if self._wordWrap:
+                       kwargs["style"] = kwargs["style"] | wx.TE_BESTWRAP
+               else:
+                       kwargs["style"] = kwargs["style"] | wx.TE_DONTWRAP
                tbm.dTextBoxMixin.__init__(self, preClass, parent, 
properties=properties,
                                attProperties=attProperties, *args, **kwargs)
 
 
-       def _getInitPropertiesList(self):
-               additional = ["WordWrap",]
-               original = list(super(dEditBox, self)._getInitPropertiesList())
-               return tuple(original + additional)
-
        def scrollToBeginning(self):
                """Moves the insertion point to the beginning of the text"""
                self.SetInsertionPoint(0)
@@ -48,11 +48,10 @@
 
        #Property getters and setters
        def _getWordWrap(self):
-               return self._hasWindowStyleFlag(wx.TE_BESTWRAP)
+               return self._wordWrap
 
        def _setWordWrap(self, val):
-               if self._constructed():
-                       fontSize = self.GetFont().GetPointSize()
+               self._wordWrap = val
                self._delWindowStyleFlag(wx.TE_DONTWRAP)
                self._delWindowStyleFlag(wx.TE_WORDWRAP)
                self._delWindowStyleFlag(wx.TE_BESTWRAP)
@@ -60,24 +59,25 @@
                        self._addWindowStyleFlag(wx.TE_BESTWRAP)
                else:
                        self._addWindowStyleFlag(wx.TE_DONTWRAP)
-               if self._constructed():
-                       self.FontSize = fontSize
 
+
        # property definitions follow:
        WordWrap = property(_getWordWrap, _setWordWrap, None,
-                       _("""Specifies whether words get wrapped (the default). 
(bool)
+                       _("""Specifies whether lines longer than the width of 
the control
+                       get wrapped. This is a soft wrapping; newlines are not 
inserted.
 
-                       If False, a horizontal scrollbar will appear when a 
line is too long
-                       to fit in the horizontal space."""))
+                       If False, a horizontal scrollbar will appear when a 
line is
+                       too long to fit in the horizontal space. Note that this 
must
+                       be set when the object is created, and changing it after
+                       instantiation will have no effect. Default=True  
(bool)"""))
 
 
 
 class _dEditBox_test(dEditBox):
        def initProperties(self):
-               self.Size = (444, 244)
                self.Value = """Love, exciting and new
-Come aboard, were expecting you
-Love, lifes sweetest reward
+Come aboard, we're expecting you
+Love, life's sweetest reward
 Let it flow, it floats back to you
 
 Love Boat soon will be making another run
@@ -85,26 +85,33 @@
 Set a course for adventure
 Your mind on a new romance
 
-Love wont hurt anymore
-Its an open smile on a friendly shore
+Love won't hurt anymore
+It's an open smile on a friendly shore
 Yes love...
-Its love...
+It's love...
 
 Love Boat soon will be making another run
 The Love Boat promises something for everyone
 Set a course for adventure
 Your mind on a new romance
 
-Love wont hurt anymore
-Its an open smile on a friendly shore
-Its love...
-Its love...
-Its love...
-Its the Love Boat
-Its the Love Boat
+Love won't hurt anymore
+It's an open smile on a friendly shore
+It's love...
+It's love...
+It's love...
+It's the Love Boat
+It's the Love Boat
 """
+       def afterInit(self):
+               self.Form.Size = (444, 244)
+               dabo.ui.callAfter(self.adjustFormCaption)
+       def adjustFormCaption(self):
+               newcap = "%s - WordWrap: %s" % (self.Form.Caption, 
self.WordWrap)
+               self.Form.Caption = newcap
 
 
 if __name__ == "__main__":
        import test
-       test.Test().runTest(_dEditBox_test)
+       test.Test().runTest(_dEditBox_test, WordWrap=True)
+       test.Test().runTest(_dEditBox_test, WordWrap=False)

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2011-02-06 17:56:16 UTC (rev 6399)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2011-02-06 19:16:28 UTC (rev 6400)
@@ -262,11 +262,11 @@
                self._name = "?"
                self._pemObject = pre
                self._needRedraw = True
-               self._borderColor = dColors.colorTupleFromName("black")
+               self._borderColor = (0, 0, 0)
                self._borderWidth = 0
                self._borderLineStyle = "Solid"
-               self._minimumHeight = 0
-               self._minimumWidth = 0
+               self._minimumHeight = 10
+               self._minimumWidth = 10
                self._maximumHeight = -1
                self._maximumWidth = -1
 
@@ -325,9 +325,7 @@
                        # The app hasn't set a help provider, and one is needed
                        # to be able to save/restore help text.
                        wx.HelpProvider.Set(wx.SimpleHelpProvider())
-
                self.afterInit()
-
                if self.Form and self.Form.SaveRestorePosition:
                        self._restoreFontZoom()
 

Modified: trunk/dabo/ui/uiwx/test.py
===================================================================
--- trunk/dabo/ui/uiwx/test.py  2011-02-06 17:56:16 UTC (rev 6399)
+++ trunk/dabo/ui/uiwx/test.py  2011-02-06 19:16:28 UTC (rev 6400)
@@ -47,15 +47,14 @@
                        frame.testObjects = []
                        for class_ in classRefs:
                                obj = class_(parent=panel, LogEvents=logEvents, 
*args, **kwargs)
-                               obj.Width = 300
                                panel.Sizer.append(obj, 1, "expand")
                                frame.testObjects.append(obj)
 
                        # This will get a good approximation of the required 
size
                        w,h = panel.Sizer.GetMinSize()
                        # Some controls don't report sizing correctly, so set a 
minimum
-                       w = max(w, 100)
-                       h = max(h, 50)
+                       w = max(w, 400)
+                       h = max(h, 300)
 
                        frame.Size = ( (w+10, h+30) )
                        if len(classRefs) > 1:



_______________________________________________
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