41
41
btn = wx.Button(self, -1, "<--", style=wx.BU_EXACTFIT)
42
42
self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
43
43
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
44
self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoBack, btn)
45
46
btn = wx.Button(self, -1, "-->", style=wx.BU_EXACTFIT)
46
47
self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
47
48
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
49
self.Bind(wx.EVT_UPDATE_UI, self.OnCheckCanGoForward, btn)
49
51
btn = wx.Button(self, -1, "Stop", style=wx.BU_EXACTFIT)
50
52
self.Bind(wx.EVT_BUTTON, self.OnStopButton, btn)
77
79
self.location.Append(self.current)
79
81
self.SetSizer(sizer)
80
# Since this is a wxWindow we have to call Layout ourselves
82
# Since this is a wx.Window we have to call Layout ourselves
81
83
self.Bind(wx.EVT_SIZE, self.OnSize)
83
# Hook up the event handlers for the IE window
84
self.Bind(iewin.EVT_BeforeNavigate2, self.OnBeforeNavigate2, self.ie)
85
self.Bind(iewin.EVT_NewWindow2, self.OnNewWindow2, self.ie)
86
self.Bind(iewin.EVT_DocumentComplete, self.OnDocumentComplete, self.ie)
87
##self.Bind(iewin.EVT_ProgressChange, self.OnProgressChange, self.ie)
88
self.Bind(iewin.EVT_StatusTextChange, self.OnStatusTextChange, self.ie)
89
self.Bind(iewin.EVT_TitleChange, self.OnTitleChange, self.ie)
86
## Hook up the event handlers for the IE window. Using
87
## AddEventSink is how we tell the COM system to look in this
88
## object for method names matching the COM Event names. They
89
## are automatically looked for in the ActiveXCtrl class, (so
90
## deriving a new class from IEHtmlWindow would also have been
91
## a good appraoch) and now they will be looked for here too.
92
self.ie.AddEventSink(self)
92
96
def ShutdownDemo(self):
148
157
self.ie.Refresh(iewin.REFRESH_COMPLETELY)
151
def logEvt(self, evt):
153
for name in evt.paramList:
154
pst += " %s:%s " % (name, repr(getattr(evt, name)))
155
self.log.write('%s: %s\n' % (evt.eventName, pst))
158
def OnBeforeNavigate2(self, evt):
161
def OnNewWindow2(self, evt):
163
# Veto the new window. Cancel is defined as an "out" param
164
# for this event. See iewin.py
167
def OnProgressChange(self, evt):
160
# Here are some of the event methods for the IE COM events. See
161
# the MSDN docs for DWenBrowserEvents2 for details on what events
162
# are available, and what the parameters are.
164
def BeforeNavigate2(self, this, pDisp, URL, Flags, TargetFrameName,
165
PostData, Headers, Cancel):
166
self.log.write('BeforeNavigate2: %s\n' % URL[0])
167
if URL[0] == 'http://www.microsoft.com/':
168
if wx.MessageBox("Are you sure you want to visit Microsoft?",
169
style=wx.YES_NO|wx.ICON_QUESTION) == wx.NO:
170
# This is how you can cancel loading a page. The
171
# Cancel parameter is defined as an [in,out] type and
172
# so setting the value means it will be returned and
173
# checked in the COM control.
177
def OnNewWindow3(self, this, pDisp, Cancel, Flags, urlContext, URL):
178
self.log.write('OnNewWindow2: %s\n' % URL)
179
Cancel[0] = True # Veto the creation of a new window.
181
#def ProgressChange(self, this, progress, progressMax):
182
# self.log.write('ProgressChange: %d of %d\n' % (progress, progressMax))
170
def OnDocumentComplete(self, evt):
172
self.current = evt.URL
184
def DocumentComplete(self, this, pDisp, URL):
185
self.current = URL[0]
173
186
self.location.SetValue(self.current)
175
def OnTitleChange(self, evt):
178
self.frame.SetTitle(self.titleBase + ' -- ' + evt.Text)
180
def OnStatusTextChange(self, evt):
183
self.frame.SetStatusText(evt.Text)
188
def TitleChange(self, this, Text):
190
self.frame.SetTitle(self.titleBase + ' -- ' + Text)
192
def StatusTextChange(self, this, Text):
194
self.frame.SetStatusText(Text)
186
198
#----------------------------------------------------------------------
187
199
# for the demo framework...