]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/tool/MarkerService.py
1 #----------------------------------------------------------------------------
2 # Name: MarkerService.py
3 # Purpose: Adding and removing line markers in text for easy searching
9 # Copyright: (c) 2004-2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
16 import wx
.lib
.pydocview
21 class MarkerService(wx
.lib
.pydocview
.DocService
):
22 MARKERTOGGLE_ID
= wx
.NewId()
23 MARKERDELALL_ID
= wx
.NewId()
24 MARKERNEXT_ID
= wx
.NewId()
25 MARKERPREV_ID
= wx
.NewId()
31 def InstallControls(self
, frame
, menuBar
= None, toolBar
= None, statusBar
= None, document
= None):
32 if document
and document
.GetDocumentTemplate().GetDocumentType() != STCTextEditor
.TextDocument
:
34 if not document
and wx
.GetApp().GetDocumentManager().GetFlags() & wx
.lib
.docview
.DOC_SDI
:
37 editMenu
= menuBar
.GetMenu(menuBar
.FindMenu(_("&Edit")))
38 editMenu
.AppendSeparator()
39 editMenu
.Append(MarkerService
.MARKERTOGGLE_ID
, _("Toggle &Bookmark\tCtrl+M"), _("Toggles a bookmark at text line"))
40 wx
.EVT_MENU(frame
, MarkerService
.MARKERTOGGLE_ID
, frame
.ProcessEvent
)
41 wx
.EVT_UPDATE_UI(frame
, MarkerService
.MARKERTOGGLE_ID
, frame
.ProcessUpdateUIEvent
)
42 editMenu
.Append(MarkerService
.MARKERDELALL_ID
, _("Clear Bookmarks"), _("Removes all jump bookmarks from selected file"))
43 wx
.EVT_MENU(frame
, MarkerService
.MARKERDELALL_ID
, frame
.ProcessEvent
)
44 wx
.EVT_UPDATE_UI(frame
, MarkerService
.MARKERDELALL_ID
, frame
.ProcessUpdateUIEvent
)
45 editMenu
.Append(MarkerService
.MARKERNEXT_ID
, _("Bookmark Next\tF4"), _("Moves to next bookmark in selected file"))
46 wx
.EVT_MENU(frame
, MarkerService
.MARKERNEXT_ID
, frame
.ProcessEvent
)
47 wx
.EVT_UPDATE_UI(frame
, MarkerService
.MARKERNEXT_ID
, frame
.ProcessUpdateUIEvent
)
48 editMenu
.Append(MarkerService
.MARKERPREV_ID
, _("Bookmark Previous\tShift+F4"), _("Moves to previous bookmark in selected file"))
49 wx
.EVT_MENU(frame
, MarkerService
.MARKERPREV_ID
, frame
.ProcessEvent
)
50 wx
.EVT_UPDATE_UI(frame
, MarkerService
.MARKERPREV_ID
, frame
.ProcessUpdateUIEvent
)
53 def ProcessEvent(self
, event
):
55 if id == MarkerService
.MARKERTOGGLE_ID
:
56 wx
.GetApp().GetDocumentManager().GetCurrentView().MarkerToggle()
58 elif id == MarkerService
.MARKERDELALL_ID
:
59 wx
.GetApp().GetDocumentManager().GetCurrentView().MarkerDeleteAll()
61 elif id == MarkerService
.MARKERNEXT_ID
:
62 wx
.GetApp().GetDocumentManager().GetCurrentView().MarkerNext()
64 elif id == MarkerService
.MARKERPREV_ID
:
65 wx
.GetApp().GetDocumentManager().GetCurrentView().MarkerPrevious()
71 def ProcessUpdateUIEvent(self
, event
):
73 if id == MarkerService
.MARKERTOGGLE_ID
:
74 view
= wx
.GetApp().GetDocumentManager().GetCurrentView()
75 event
.Enable(hasattr(view
, "MarkerToggle"))
77 elif id == MarkerService
.MARKERDELALL_ID
:
78 view
= wx
.GetApp().GetDocumentManager().GetCurrentView()
79 event
.Enable(hasattr(view
, "MarkerDeleteAll") and view
.GetMarkerCount())
81 elif id == MarkerService
.MARKERNEXT_ID
:
82 view
= wx
.GetApp().GetDocumentManager().GetCurrentView()
83 event
.Enable(hasattr(view
, "MarkerNext") and view
.GetMarkerCount())
85 elif id == MarkerService
.MARKERPREV_ID
:
86 view
= wx
.GetApp().GetDocumentManager().GetCurrentView()
87 event
.Enable(hasattr(view
, "MarkerPrevious") and view
.GetMarkerCount())