Changeset 1590
- Timestamp:
- 11/28/2005 06:56:33 AM (3 years ago)
- Files:
-
- trunk/dabo/dApp.py (modified) (2 diffs)
- trunk/dabo/dConstants.py (modified) (1 diff)
- trunk/dabo/ui/uiwx/dBaseMenuBar.py (modified) (1 diff)
- trunk/dabo/ui/uiwx/dForm.py (modified) (1 diff)
- trunk/dabo/ui/uiwx/uiApp.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/dApp.py
r1582 r1590 355 355 name = "%s@%s" % (ci.User, ci.Host) 356 356 self.dbConnectionDefs[name] = ci 357 358 359 def addConnectFile(self, connFile): 360 """Accepts a cnxml file path, and reads in the connections 361 defined in it, adding them to self.dbConnectionDefs. 362 """ 363 if os.path.exists(connFile): 364 connDefs = importConnections(connFile) 365 # For each connection definition, add an entry to 366 # self.dbConnectionDefs that contains a key on the 367 # name, and a value of a dConnectInfo object. 368 for k,v in connDefs.items(): 369 ci = dabo.db.dConnectInfo() 370 ci.setConnInfo(v) 371 self.dbConnectionDefs[k] = ci 357 372 358 373 … … 376 391 def onEditFind(self, evt): 377 392 self.uiApp.onEditFind(evt) 393 def onEditFindAlone(self, evt): 394 self.uiApp.onEditFindAlone(evt) 378 395 def onEditFindAgain(self, evt): 379 396 self.uiApp.onEditFindAgain(evt) trunk/dabo/dConstants.py
r1120 r1590 28 28 DLG_OK = 0 29 29 DLG_CANCEL = -1 30 31 FIND_DIALOG_FINDTEXT = -210 32 FIND_DIALOG_REPLACETEXT = -212 trunk/dabo/ui/uiwx/dBaseMenuBar.py
r1466 r1590 64 64 self.appendSeparator() 65 65 66 self.append(_("&Find") + "\tCtrl+F", bindfunc=app.onEditFind, bmp="find", 67 help=_("Find text in the active window") ) 66 # By default, the Find and Replace functions use a single dialog. The 67 # commented lines below this enable the plain Find dialog call. 68 self.append(_("&Find / Replace") + "\tCtrl+F", bindfunc=app.onEditFind, 69 bmp="find", help=_("Find text in the active window") ) 70 # self.append(_("Find") + "\tShift+Ctrl+F", bindfunc=app.onEditFindAlone, 71 # bmp="find", help=_("Find text in the active window") ) 68 72 69 73 self.append(_("Find Again") + "\tCtrl+G", bindfunc=app.onEditFindAgain, bmp="", 70 74 help=_("Repeat the last search") ) 75 76 self.append(_("&Find / Replace") + "\tCtrl+F", bindfunc=app.onEditFind, 77 bmp="find", help=_("Find text in the active window") ) 71 78 72 79 self.appendSeparator() trunk/dabo/ui/uiwx/dForm.py
r1580 r1590 762 762 763 763 764 class dToolForm(dFormSDI): 764 # class dToolForm(dFormSDI): 765 class dToolForm(wx.MiniFrame, dFormBase): 765 766 def __init__(self, parent=None, properties=None, *args, **kwargs): 766 style = self._extractKey(kwargs, "style", 0) 767 style = style | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | wx.RESIZE_BORDER 768 kwargs["style"] = style 767 self._baseClass = dToolForm 768 preClass = wx.PreMiniFrame 769 self._mdi = False 770 kwargs["TinyTitleBar"] = True 769 771 kwargs["ShowStatusBar"] = False 770 772 kwargs["ShowToolBar"] = False 771 self.MenuBarClass = None 773 dFormBase.__init__(self, preClass, parent, properties, *args, **kwargs) 774 # style = self._extractKey(kwargs, "style", 0) 775 # style = style | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | wx.RESIZE_BORDER 776 # kwargs["style"] = style 777 # kwargs["ShowStatusBar"] = False 778 # kwargs["ShowToolBar"] = False 779 # self.MenuBarClass = None 772 780 # kwargs[""] = 773 super(dToolForm, self).__init__(parent=parent, properties=properties, *args, **kwargs)781 # super(dToolForm, self).__init__(parent=parent, properties=properties, *args, **kwargs) 774 782 775 783 trunk/dabo/ui/uiwx/uiApp.py
r1585 r1590 6 6 from dabo.dObject import dObject 7 7 from dabo.dLocalize import _, n_ 8 import dabo.dConstants as kons 9 8 10 9 11 class uiApp(wx.App, dObject): … … 16 18 self._noneDisp = _("<null>") 17 19 self._drawSizerOutlines = False 20 # Various attributes used by the FindReplace dialog 21 self._findString = "" 22 self._replaceString = "" 23 self._findReplaceFlags = wx.FR_DOWN 24 self.findReplaceData = None 25 self.findDialog = None 18 26 19 27 … … 91 99 92 100 def _onWxActivate(self, evt): 93 """ Raise the Dabo Activate or Deactivate appropriately. 94 """ 101 """ Raise the Dabo Activate or Deactivate appropriately.""" 95 102 if bool(evt.GetActive()): 96 103 self.raiseEvent(dEvents.Activate, evt) … … 235 242 236 243 237 def onEditFind(self, evt): 238 """ Display a Find dialog. """ 244 def onEditFindAlone(self, evt): 245 self.onEditFind(evt, False) 246 247 248 def onEditFind(self, evt, replace=True): 249 """ Display a Find dialog. By default, both 'Find' and 'Find/Replace' 250 will be a single dialog. By calling this method with replace=False, 251 you will get a Find-only version of the dialog. 252 """ 253 if self.findDialog is not None: 254 self.findDialog.Raise() 255 return 239 256 if self.ActiveForm: 240 257 win = self.ActiveForm.ActiveControl 241 258 if win: 242 259 self.findWindow = win # Save reference for use by self.OnFind() 243 244 260 try: 245 261 data = self.findReplaceData … … 247 263 data = None 248 264 if data is None: 249 data = wx.FindReplaceData(wx.FR_DOWN) 265 data = wx.FindReplaceData(self._findReplaceFlags) 266 data.SetFindString(self._findString) 267 data.SetReplaceString(self._replaceString) 250 268 self.findReplaceData = data 251 dlg = wx.FindReplaceDialog(win, data, "Find") 269 if replace: 270 dlg = wx.FindReplaceDialog(win, data, _("Find/Replace"), 271 wx.FR_REPLACEDIALOG) 272 else: 273 dlg = wx.FindReplaceDialog(win, data, _("Find")) 252 274 253 275 # Map enter key to find button: … … 258 280 dlg.Bind(wx.EVT_FIND, self.OnFind) 259 281 dlg.Bind(wx.EVT_FIND_NEXT, self.OnFind) 282 dlg.Bind(wx.EVT_FIND_REPLACE, self.OnFindReplace) 283 dlg.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFindReplaceAll) 260 284 dlg.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose) 261 285 … … 275 299 for kid in kids: 276 300 if isinstance(kid, wx.TextCtrl): 277 frd.SetFindString(kid.GetValue()) 301 if kid.GetId() == kons.FIND_DIALOG_FINDTEXT: 302 frd.SetFindString(kid.GetValue()) 303 elif kid.GetId() == kons.FIND_DIALOG_REPLACETEXT: 304 frd.SetReplaceString(kid.GetValue()) 278 305 elif isinstance(kid, wx.CheckBox): 279 306 lbl = kid.GetLabel() … … 295 322 def onEditFindAgain(self, evt): 296 323 """Repeat the last search.""" 324 if self.findReplaceData is None: 325 if self._findString: 326 data = wx.FindReplaceData(self._findReplaceFlags) 327 data.SetFindString(self._findString) 328 data.SetReplaceString(self._replaceString) 329 self.findReplaceData = data 297 330 try: 298 331 fd = self.findReplaceData 299 332 self.OnFind(fd) 300 except AttributeError :333 except AttributeError, e: 301 334 self.onEditFind(None) 302 335 return … … 305 338 def OnFindClose(self, evt): 306 339 """ User clicked the close button, so hide the dialog.""" 340 frd = self.findReplaceData 341 self._findString = frd.GetFindString() 342 self._replaceString = frd.GetReplaceString() 343 self._findReplaceFlags = frd.GetFlags() 307 344 self.findReplaceData = None 308 345 self.findDialog.Destroy() 346 self.findDialog = None 309 347 evt.Skip() 310 348 311 312 def OnFind(self, evt): 349 350 def OnFindReplace(self, evt): 351 self.OnFind(evt, action="Replace") 352 353 354 def OnFindReplaceAll(self, evt): 355 total = 0 356 wx.BeginBusyCursor() 357 while True: 358 ret = self.OnFind(evt, action="Replace") 359 if not ret: 360 break 361 total += 1 362 wx.EndBusyCursor() 363 # Tell the user what was done 364 msg = _("%s replacements were made") % total 365 if total == 1: 366 msg = _("1 replacement was made") 367 dabo.ui.info(msg, title=_("Replacement Complete")) 368 369 370 def OnFind(self, evt, action="Find"): 313 371 """ User clicked the 'find' button in the find dialog. 314 372 Run the search on the current control, if it is a text-based control. … … 317 375 flags = self.findReplaceData.GetFlags() 318 376 findString = self.findReplaceData.GetFindString() 377 replaceString = self.findReplaceData.GetReplaceString() 378 replaceString2 = self.findReplaceData.GetReplaceString() 319 379 downwardSearch = (flags & wx.FR_DOWN) == wx.FR_DOWN 320 380 wholeWord = (flags & wx.FR_WHOLEWORD) == wx.FR_WHOLEWORD 321 381 matchCase = (flags & wx.FR_MATCHCASE) == wx.FR_MATCHCASE 322 382 383 ret = None 323 384 win = self.findWindow 324 385 if win: 325 386 if isinstance(win, wx.stc.StyledTextCtrl): 326 387 # STC 388 if action == "Replace": 389 # Make sure that there is something to replace 390 selectPos = win.GetSelection() 391 if selectPos[1] - selectPos[0] > 0: 392 # There is something selected to replace 393 win.ReplaceSelection(replaceString) 394 395 selectPos = win.GetSelection() 327 396 if downwardSearch: 328 start = win.GetSelection()[1]397 start = selectPos[1] 329 398 finish = win.GetTextLength() 330 399 pos = win.FindText(start, finish, findString, flags) 331 400 else: 332 start = win.GetSelection()[0]401 start = selectPos[0] 333 402 txt = win.GetText()[:start] 334 403 txRev = utils.reverseText(txt) … … 341 410 pos = len(txt) - posRev - len(fsRev) 342 411 if pos > -1: 412 ret = True 343 413 win.SetSelection(pos, pos+len(findString)) 344 414 return ret 415 345 416 else: 346 417 try: … … 352 423 return 353 424 425 if action == "Replace": 426 # If we have a selection, replace it. 427 selectPos = win.GetSelection() 428 if selectPos[1] - selectPos[0] > 0: 429 win.ReplaceSelection(replaceString) 430 431 selectPos = win.GetSelection() 354 432 if downwardSearch: 355 currentPos = win.GetSelection()[1]433 currentPos = selectPos[1] 356 434 value = win.GetValue()[currentPos:] 357 435 else: 358 currentPos = win.GetSelection()[0]436 currentPos = selectPos[0] 359 437 value = win.GetValue()[:currentPos] 360 438 value = utils.reverseText(value) … … 376 454 else: 377 455 dabo.infoLog.write(_("Not found")) 378 379 456 457 380 458 def onShowSizerLines(self, evt): 381 459 """Toggles whether sizer lines are drawn. This is simply a tool
