]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/FindInDirService.py
Applied patch [ 1212020 ] MediaCtrl DirectShow drawing and sample
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / FindInDirService.py
index f3e9da16c2d7a6571d7b44d9ba870d55f43bcfc6..63eea49a130f066ace38739f39458612dc814c0e 100644 (file)
@@ -58,10 +58,18 @@ class FindInDirService(FindService.FindService):
     def ProcessEvent(self, event):
         id = event.GetId()
         if id == FindInDirService.FINDALL_ID:
-            self.ShowFindAllDialog()
+            view = wx.GetApp().GetDocumentManager().GetCurrentView()
+            if hasattr(view, "GetCtrl") and view.GetCtrl() and hasattr(view.GetCtrl(), "GetSelectedText"):
+                self.ShowFindAllDialog(view.GetCtrl().GetSelectedText())
+            else:
+                self.ShowFindAllDialog()
             return True
         elif id == FindInDirService.FINDDIR_ID:
-            self.ShowFindDirDialog()
+            view = wx.GetApp().GetDocumentManager().GetCurrentView()
+            if hasattr(view, "GetCtrl") and view.GetCtrl() and hasattr(view.GetCtrl(), "GetSelectedText"):
+                self.ShowFindDirDialog(view.GetCtrl().GetSelectedText())
+            else:
+                self.ShowFindDirDialog()
             return True
         else:
             return FindService.FindService.ProcessEvent(self, event)
@@ -83,7 +91,7 @@ class FindInDirService(FindService.FindService):
             return FindService.FindService.ProcessUpdateUIEvent(self, event)
 
 
-    def ShowFindDirDialog(self):
+    def ShowFindDirDialog(self, findString=None):
         config = wx.ConfigBase_Get()
 
         frame = wx.Dialog(None, -1, _("Find in Directory"), size= (320,200))
@@ -95,7 +103,7 @@ class FindInDirService(FindService.FindService):
         dirCtrl = wx.TextCtrl(frame, -1, config.Read(FIND_MATCHDIR, ""), size=(200,-1))
         dirCtrl.SetToolTipString(dirCtrl.GetValue())
         lineSizer.Add(dirCtrl, 0, wx.LEFT, HALF_SPACE)
-        findDirButton = wx.Button(frame, -1, "Browse...")
+        findDirButton = wx.Button(frame, -1, _("Browse..."))
         lineSizer.Add(findDirButton, 0, wx.LEFT, HALF_SPACE)
         contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
         
@@ -112,7 +120,7 @@ class FindInDirService(FindService.FindService):
             dlg.Destroy()
         wx.EVT_BUTTON(findDirButton, -1, OnBrowseButton)
 
-        subfolderCtrl = wx.CheckBox(frame, -1, _("Search in subfolders"))
+        subfolderCtrl = wx.CheckBox(frame, -1, _("Search in subdirectories"))
         subfolderCtrl.SetValue(config.ReadInt(FIND_MATCHDIRSUBFOLDERS, True))
         contentSizer.Add(subfolderCtrl, 0, wx.BOTTOM, SPACE)
 
@@ -122,7 +130,11 @@ class FindInDirService(FindService.FindService):
         
         lineSizer = wx.BoxSizer(wx.HORIZONTAL)
         lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
-        findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
+        if not findString:
+            findString = config.Read(FindService.FIND_MATCHPATTERN, "")
+        findCtrl = wx.TextCtrl(frame, -1, findString, size=(200,-1))
+        findCtrl.SetFocus()
+        findCtrl.SetSelection(0,-1)
         lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
         contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
         wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
@@ -140,7 +152,7 @@ class FindInDirService(FindService.FindService):
         findBtn = wx.Button(frame, wx.ID_OK, _("Find"))
         findBtn.SetDefault()
         buttonSizer.Add(findBtn, 0, wx.BOTTOM, HALF_SPACE)
-        buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL, _("Cancel")), 0)
+        buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL), 0)
         borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)
 
         frame.SetSizer(borderSizer)
@@ -270,7 +282,7 @@ class FindInDirService(FindService.FindService):
         config.WriteInt(FIND_MATCHDIRSUBFOLDERS, searchSubfolders)
     
 
-    def ShowFindAllDialog(self):
+    def ShowFindAllDialog(self, findString=None):
         config = wx.ConfigBase_Get()
 
         frame = wx.Dialog(None, -1, _("Find in Project"), size= (320,200))
@@ -279,7 +291,9 @@ class FindInDirService(FindService.FindService):
         contentSizer = wx.BoxSizer(wx.VERTICAL)
         lineSizer = wx.BoxSizer(wx.HORIZONTAL)
         lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
-        findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
+        if not findString:
+            findString = config.Read(FindService.FIND_MATCHPATTERN, "")
+        findCtrl = wx.TextCtrl(frame, -1, findString, size=(200,-1))
         lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
         contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
         wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
@@ -297,7 +311,7 @@ class FindInDirService(FindService.FindService):
         findBtn = wx.Button(frame, wx.ID_OK, _("Find"))
         findBtn.SetDefault()
         buttonSizer.Add(findBtn, 0, wx.BOTTOM, HALF_SPACE)
-        buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL, _("Cancel")), 0)
+        buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL), 0)
         borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)
 
         frame.SetSizer(borderSizer)