dabo Commit
Revision 1591
Date: 2005-11-28 10:18:45 -0800 (Mon, 28 Nov 2005)
Author: ed

Changed:
U   trunk/dabo/dConstants.py
U   trunk/dabo/ui/uiwx/uiApp.py

Log:
Changed the Find/Replace dialog behavior so that it can now determine the Find 
and Replace textboxes on all platforms. Removed the constants previously 
defined for this purpose, as they are platform-dependent and no longer needed.


Diff:
Modified: trunk/dabo/dConstants.py
===================================================================
--- trunk/dabo/dConstants.py    2005-11-28 14:56:33 UTC (rev 1590)
+++ trunk/dabo/dConstants.py    2005-11-28 18:18:45 UTC (rev 1591)
@@ -27,6 +27,3 @@
 
 DLG_OK = 0
 DLG_CANCEL = -1
-
-FIND_DIALOG_FINDTEXT = -210
-FIND_DIALOG_REPLACETEXT = -212

Modified: trunk/dabo/ui/uiwx/uiApp.py
===================================================================
--- trunk/dabo/ui/uiwx/uiApp.py 2005-11-28 14:56:33 UTC (rev 1590)
+++ trunk/dabo/ui/uiwx/uiApp.py 2005-11-28 18:18:45 UTC (rev 1591)
@@ -21,6 +21,7 @@
                self._findString = ""
                self._replaceString = ""
                self._findReplaceFlags = wx.FR_DOWN
+               self._findDlgID = self._replaceDlgID = None
                self.findReplaceData = None
                self.findDialog = None
                
@@ -287,6 +288,22 @@
                                self.findDialog = dlg
                        
        
+       def setFindDialogIDs(self):
+               """Since the Find dialog is a wxPython control, we can't 
determine
+               which text control holds the Find value, and which holds the 
Replace
+               value. One thing that is certain, though, on all platforms is 
that the
+               Find textbox is physically above the Replace textbox, so we can 
use
+               its position to determine its function.
+               """
+               tbs = [{ctl.GetPosition()[1] : ctl.GetId()} 
+                               for ctl in self.findDialog.GetChildren()
+                               if isinstance(ctl, wx.TextCtrl)]
+               
+               tbs.sort()
+               self._findDlgID = tbs[0].values()[0]
+               self._replaceDlgID = tbs[1].values()[0]
+               
+               
        def onEnterInFindDialog(self, evt):
                """We need to simulate what happens in the Find dialog when
                the user clicks the Find button. This requires that we manually 
@@ -296,11 +313,13 @@
                frd = self.findReplaceData
                kids = self.findDialog.GetChildren()
                flags = 0
+               if self._findDlgID is None:
+                       self.setFindDialogIDs()
                for kid in kids:
                        if isinstance(kid, wx.TextCtrl):
-                               if kid.GetId() == kons.FIND_DIALOG_FINDTEXT:
+                               if kid.GetId() == self._findDlgID:
                                        frd.SetFindString(kid.GetValue())
-                               elif kid.GetId() == 
kons.FIND_DIALOG_REPLACETEXT:
+                               elif kid.GetId() == self._replaceDlgID:
                                        frd.SetReplaceString(kid.GetValue())
                        elif isinstance(kid, wx.CheckBox):
                                lbl = kid.GetLabel()
@@ -391,7 +410,6 @@
                                        if selectPos[1] - selectPos[0] > 0:     
                                                # There is something selected 
to replace
                                                
win.ReplaceSelection(replaceString)
-
                                selectPos = win.GetSelection()
                                if downwardSearch:
                                        start = selectPos[1]
@@ -407,7 +425,10 @@
                                                txRev = txRev.lower()
                                        # Don't have the code to implement 
Whole Word search yet.
                                        posRev = txRev.find(fsRev)
-                                       pos = len(txt) - posRev - len(fsRev)
+                                       if posRev > -1:
+                                               pos = len(txt) - posRev - 
len(fsRev)
+                                       else:
+                                               pos = -1
                                if pos > -1:
                                        ret = True
                                        win.SetSelection(pos, 
pos+len(findString))




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to