|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 21 22 24 25 26 27 28 29 30 31 39 42 43 45 48 51 55 56 58 59 65 66 67 69 71 72 74 75 76 77 78 79 80 81 82 84 86 88 90 92 93 94 95 100 101 103 105 106 107 111 113 115 116 117 118 119 122 124 125 129 133 135 136 138 139 140 141 142 144 148 150 151 153 159 164 |
''' Task Coach - Your friendly task manager Copyright (C) 2004-2010 Task Coach developers <developers@taskcoach.org>
Task Coach is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Task Coach is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. '''
''' ViewerContainer is a container of viewers. It has a containerWidget that displays the viewers. The containerWidget can be a notebook or an AUI managed frame. The ViewerContainer knows which of its viewers is active and dispatches method calls to the active viewer or to the first viewer that can handle the method. This allows other GUI components, e.g. menu's, to talk to the ViewerContainer as were it a regular viewer. '''
# Prepare for an exception, because this setting used to be a string except ValueError: self.__desiredPageNumber = 0
pageChangedEvent=self.onPageChanged) handler)
return self.viewers[index]
# We need to use CallAfter because the AuiNotebook doesn't allow # PAGE_CHANGING events while the window is not active. See # widgets/notebook.py self.__desiredPageNumber) eventType=viewer.selectEventType(), eventSource=viewer)
event.Skip() for viewer in self.viewers: if event.EventObject == viewer.widget: # Don't activate the viewer immediately, it may cause another # AuiManager.Update call which could undock a viewer that is # in the process of being docked to an automatic notebook. wx.CallAfter(self.activateViewer, viewer) break
def selectEventType(class_):
def viewerChangeEventType(class_):
''' Return a function that will call the method on the first viewer that both has the requested method and does not raise an exception. Start looking in the current viewer. NB: this auto forwarding only works for methods, not for properties. ''' else: raise AttributeError
''' Return the active viewer, i.e. the viewer that has the focus. ''' # There is no pageChanged event for the AuiManager, so we have # to check which pane is active. return viewer
for viewer in self.viewers: info = self.containerWidget.manager.GetPane(viewer) info.SetFlag(info.optionActive, viewer==viewerToActivate) self.containerWidget.manager.Update()
patterns.Event(self.selectEventType(), self, *event.values()).send()
return else: window = self.containerWidget.GetPage(event.GetSelection()) # Window is a notebook, close each of its pages for pageIndex in range(window.GetPageCount()): self._closePage(window.GetPage(pageIndex)) else: # Window is a viewer, close it # Make sure the current pane is a valid pane
# When closing an AUI managed frame, we get two close events, # be prepared: return
|