Example #1
0
    def __init__(self, parent, ID, mainControl):
        EnhancedListControl.__init__(self,
                                     parent,
                                     ID,
                                     style=wx.LC_REPORT | wx.LC_SINGLE_SEL
                                     | wx.LC_NO_HEADER)

        self.mainControl = mainControl

        self.InsertColumn(0, u"", width=3000)

        self.updatingThreadHolder = Utilities.ThreadHolder()
        self.tocList = [
        ]  # List of tuples (char. start in text, headLevel, heading text)
        self.tocListStarts = [
        ]  # List of the char. start items of self.tocList
        self.mainControl.getMiscEvent().addListener(self)
        self.sizeVisible = True  # False if this window has a size
        # that it can't be read (one dim. less than 5 pixels)
        self.ignoreOnChange = False

        self.docPagePresenterSink = wxKeyFunctionSink(
            (("loaded current doc page", self.onUpdateNeeded),
             ("changed live text", self.onUpdateNeeded)
             #                 ("options changed", self.onUpdateNeeded)
             ))

        self.__sinkApp = wxKeyFunctionSink(
            (("options changed", self.onUpdateNeeded), ),
            wx.GetApp().getMiscEvent(), self)

        #         if not self.mainControl.isMainWindowConstructed():
        #             # Install event handler to wait for construction
        #             self.__sinkMainFrame = wxKeyFunctionSink((
        #                     ("constructed main window", self.onConstructedMainWindow),
        #             ), self.mainControl.getMiscEvent(), self)
        #         else:
        #             self.onConstructedMainWindow(None)

        self.__sinkMainFrame = wxKeyFunctionSink(
            (("idle visible", self.onIdleVisible), ),
            self.mainControl.getMiscEvent(), self)

        currPres = self.mainControl.getCurrentDocPagePresenter()
        if currPres is not None:
            self.docPagePresenterSink.setEventSource(currPres.getMiscEvent())

        self.lastSelection = (-1, -1)

        self.updateList()

        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
        wx.EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected)
        wx.EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
        wx.EVT_SIZE(self, self.OnSize)

        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
Example #2
0
    def __init__(self, parent, ID, mainControl):
        EnhancedListControl.__init__(self, parent, ID,
                style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER)

        self.mainControl = mainControl

        self.InsertColumn(0, u"", width=3000)

        self.updatingThreadHolder = Utilities.ThreadHolder()
        self.tocList = [] # List of tuples (char. start in text, headLevel, heading text)
        self.tocListStarts = []   # List of the char. start items of self.tocList
        self.mainControl.getMiscEvent().addListener(self)
        self.sizeVisible = True   # False if this window has a size
                # that it can't be read (one dim. less than 5 pixels)
        self.ignoreOnChange = False

        self.docPagePresenterSink = wxKeyFunctionSink((
                ("loaded current doc page", self.onUpdateNeeded),
                ("changed live text", self.onUpdateNeeded)
#                 ("options changed", self.onUpdateNeeded)
        ))

        self.__sinkApp = wxKeyFunctionSink((
                ("options changed", self.onUpdateNeeded),
        ), wx.GetApp().getMiscEvent(), self)

#         if not self.mainControl.isMainWindowConstructed():
#             # Install event handler to wait for construction
#             self.__sinkMainFrame = wxKeyFunctionSink((
#                     ("constructed main window", self.onConstructedMainWindow),
#             ), self.mainControl.getMiscEvent(), self)
#         else:
#             self.onConstructedMainWindow(None)

        self.__sinkMainFrame = wxKeyFunctionSink((
                ("idle visible", self.onIdleVisible),
        ), self.mainControl.getMiscEvent(), self)

        currPres = self.mainControl.getCurrentDocPagePresenter()
        if currPres is not None:
            self.docPagePresenterSink.setEventSource(currPres.getMiscEvent())
        
        self.lastSelection = (-1, -1)

        self.updateList()

        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, 
                id=self.GetId())
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, 
                id=self.GetId())
        self.Bind(wx.EVT_SIZE, self.OnSize)
        
        self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
Example #3
0
    def __init__(self, presenter, parent, ID, drivingMoz):
        self.drivingMoz = drivingMoz

        if self.drivingMoz:
#             wx.activex.IEHtmlWindowBase.__init__(self, parent,    # wx.activex.CLSID(
            wx.lib.activex.ActiveXCtrl.__init__(self, parent,
                '{1339B54C-3453-11D2-93B9-000000000000}',
                ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0,
                name='MozHtmlWindow')
            self.LinkConverterForPreview = LinkConverterForPreviewMoz
        else:
#             wx.activex.IEHtmlWindowBase.__init__(self, parent,
            wx.lib.activex.ActiveXCtrl.__init__(self, parent,
#                 '{8856F961-340A-11D0-A96B-00C04FD705A2}',
                'Shell.Explorer.2', 
                ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0,
                name='IEHtmlWindow')
            self.LinkConverterForPreview = LinkConverterForPreviewIe


        self._canGoBack = False
        self._canGoForward = False


        self.presenter = presenter

        self.presenterListener = wxKeyFunctionSink((
                ("loaded current wiki page", self.onLoadedCurrentWikiPage),
                ("reloaded current doc page", self.onReloadedCurrentPage),
                ("opened wiki", self.onOpenedWiki),
                ("closing current wiki", self.onClosingCurrentWiki)
#                 ("options changed", self.onOptionsChanged),
        ), self.presenter.getMiscEvent())

        self.__sinkApp = wxKeyFunctionSink((
                ("options changed", self.onOptionsChanged),
        ), wx.GetApp().getMiscEvent())

        self.__sinkDocPage = wxKeyFunctionSink((
                ("updated wiki page", self.onUpdatedWikiPage),
                ("changed live text", self.onChangedLiveText)
        ), self.presenter.getCurrentDocPageProxyEvent())

        self.visible = False
        self.outOfSync = True   # HTML content is out of sync with live content
        self.deferredScrollPos = None  # Used by scrollDeferred()

        self.currentLoadedWikiWord = None
        self.currentLoadedUrl = None  # Contains the URL of the temporary HTML
                # file without anchors

        self.anchor = None  # Name of anchor to jump to when view gets visible
        self.lastAnchor = None
        self.passNavigate = 0


        # TODO Should be changed to presenter as controller
        self.exporterInstance = PluginManager.getExporterTypeDict(
                self.presenter.getMainControl(), False)[u"html_single"][0]\
                (self.presenter.getMainControl())

        # TODO More elegantly
        if self.drivingMoz:
            self.exporterInstance.exportType = u"html_previewMOZ"
        else:
            self.exporterInstance.exportType = u"html_previewIE"

        self.exporterInstance.tempFileSet = TempFileSet()
        self._updateTempFilePrefPath()

        self.exporterInstance.setWikiDocument(
                self.presenter.getWikiDocument())
        self.exporterInstance.setLinkConverter(
                self.LinkConverterForPreview(self.presenter.getWikiDocument()))

        # Create two temporary html files (IE 7 needs two to work)
        self.htpaths = [None, None]
        self.htpaths[0] = self.exporterInstance.tempFileSet.createTempFile(
                    u"", ".html", relativeTo="").decode("latin-1")
        self.htpaths[1] = self.exporterInstance.tempFileSet.createTempFile(
                    u"", ".html", relativeTo="").decode("latin-1")

        self.normHtpaths = [os.path.normcase(getLongPath(self.htpaths[0])),
                os.path.normcase(getLongPath(self.htpaths[1]))]
                
        self.currentHtpath = 0 # index into self.htpaths

#         iewin.EVT_BeforeNavigate2(self, self.GetId(), self.OnBeforeNavigate)

        wx.EVT_SET_FOCUS(self, self.OnSetFocus)
Example #4
0
    def __init__(self, presenter, parent, ID, drivingMoz):
        self.drivingMoz = drivingMoz

        if self.drivingMoz:
            #             wx.activex.IEHtmlWindowBase.__init__(self, parent,    # wx.activex.CLSID(
            wx.lib.activex.ActiveXCtrl.__init__(
                self,
                parent,
                '{1339B54C-3453-11D2-93B9-000000000000}',
                ID,
                pos=wx.DefaultPosition,
                size=wx.DefaultSize,
                style=0,
                name='MozHtmlWindow')
            self.LinkConverterForPreview = LinkConverterForPreviewMoz
        else:
            #             wx.activex.IEHtmlWindowBase.__init__(self, parent,
            wx.lib.activex.ActiveXCtrl.__init__(
                self,
                parent,
                #                 '{8856F961-340A-11D0-A96B-00C04FD705A2}',
                'Shell.Explorer.2',
                ID,
                pos=wx.DefaultPosition,
                size=wx.DefaultSize,
                style=0,
                name='IEHtmlWindow')
            self.LinkConverterForPreview = LinkConverterForPreviewIe

        self._canGoBack = False
        self._canGoForward = False

        self.presenter = presenter

        self.presenterListener = wxKeyFunctionSink(
            (("loaded current wiki page", self.onLoadedCurrentWikiPage),
             ("reloaded current doc page", self.onReloadedCurrentPage),
             ("opened wiki", self.onOpenedWiki),
             ("closing current wiki", self.onClosingCurrentWiki)
             #                 ("options changed", self.onOptionsChanged),
             ),
            self.presenter.getMiscEvent())

        self.__sinkApp = wxKeyFunctionSink(
            (("options changed", self.onOptionsChanged), ),
            wx.GetApp().getMiscEvent())

        self.__sinkDocPage = wxKeyFunctionSink(
            (("updated wiki page", self.onUpdatedWikiPage),
             ("changed live text", self.onChangedLiveText)),
            self.presenter.getCurrentDocPageProxyEvent())

        self.visible = False
        self.outOfSync = True  # HTML content is out of sync with live content
        self.deferredScrollPos = None  # Used by scrollDeferred()

        self.currentLoadedWikiWord = None
        self.currentLoadedUrl = None  # Contains the URL of the temporary HTML
        # file without anchors

        self.anchor = None  # Name of anchor to jump to when view gets visible
        self.lastAnchor = None
        self.passNavigate = 0

        # TODO Should be changed to presenter as controller
        self.exporterInstance = PluginManager.getExporterTypeDict(
                self.presenter.getMainControl(), False)[u"html_single"][0]\
                (self.presenter.getMainControl())

        # TODO More elegantly
        if self.drivingMoz:
            self.exporterInstance.exportType = u"html_previewMOZ"
        else:
            self.exporterInstance.exportType = u"html_previewIE"

        self.exporterInstance.tempFileSet = TempFileSet()
        self._updateTempFilePrefPath()

        self.exporterInstance.setWikiDocument(self.presenter.getWikiDocument())
        self.exporterInstance.setLinkConverter(
            self.LinkConverterForPreview(self.presenter.getWikiDocument()))

        # Create two temporary html files (IE 7 needs two to work)
        self.htpaths = [None, None]
        self.htpaths[0] = self.exporterInstance.tempFileSet.createTempFile(
            u"", ".html", relativeTo="").decode("latin-1")
        self.htpaths[1] = self.exporterInstance.tempFileSet.createTempFile(
            u"", ".html", relativeTo="").decode("latin-1")

        self.normHtpaths = [
            os.path.normcase(getLongPath(self.htpaths[0])),
            os.path.normcase(getLongPath(self.htpaths[1]))
        ]

        self.currentHtpath = 0  # index into self.htpaths

        #         iewin.EVT_BeforeNavigate2(self, self.GetId(), self.OnBeforeNavigate)

        wx.EVT_SET_FOCUS(self, self.OnSetFocus)