Derive wxWebViewEvent from wxNotifyEvent.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4d0dddc7ad
commit
3225a4b8b8
@ -171,36 +171,23 @@ public:
|
||||
wxDECLARE_ABSTRACT_CLASS(wxWebView);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_WEB wxWebViewEvent : public wxCommandEvent
|
||||
class WXDLLIMPEXP_WEB wxWebViewEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
wxWebViewEvent() {}
|
||||
wxWebViewEvent(wxEventType type, int id, const wxString url,
|
||||
const wxString target, bool canVeto)
|
||||
: wxCommandEvent(type, id)
|
||||
{
|
||||
m_url = url;
|
||||
m_target = target;
|
||||
m_vetoed = false;
|
||||
m_canVeto = canVeto;
|
||||
}
|
||||
const wxString target)
|
||||
: wxNotifyEvent(type, id), m_url(url), m_target(target)
|
||||
{}
|
||||
|
||||
|
||||
const wxString& GetURL() const { return m_url; }
|
||||
const wxString& GetTarget() const { return m_target; }
|
||||
|
||||
virtual wxEvent* Clone() const { return new wxWebViewEvent(*this); }
|
||||
|
||||
bool CanVeto() const { return m_canVeto; }
|
||||
bool IsVetoed() const { return m_vetoed; }
|
||||
|
||||
void Veto() { wxASSERT(m_canVeto); m_vetoed = true; }
|
||||
|
||||
private:
|
||||
wxString m_url;
|
||||
wxString m_target;
|
||||
bool m_canVeto;
|
||||
bool m_vetoed;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebViewEvent);
|
||||
};
|
||||
|
@ -243,7 +243,7 @@ public:
|
||||
|
||||
@library{wxweb}
|
||||
@category{ctrl,web}
|
||||
@see wxWebHandler, wxWebViewEvent
|
||||
@see wxWebViewHandler, wxWebViewEvent
|
||||
*/
|
||||
class wxWebView : public wxControl
|
||||
{
|
||||
@ -626,12 +626,12 @@ public:
|
||||
|
||||
@see wxWebView
|
||||
*/
|
||||
class wxWebViewEvent : public wxCommandEvent
|
||||
class wxWebViewEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
wxWebViewEvent();
|
||||
wxWebViewEvent(wxEventType type, int id, const wxString href,
|
||||
const wxString target, bool canVeto);
|
||||
const wxString target);
|
||||
|
||||
/**
|
||||
Get the name of the target frame which the url of this event
|
||||
@ -644,24 +644,4 @@ public:
|
||||
Get the URL being visited
|
||||
*/
|
||||
const wxString& GetURL() const;
|
||||
|
||||
virtual wxEvent* Clone() const;
|
||||
|
||||
/**
|
||||
Get whether this event may be vetoed (stopped/prevented). Only
|
||||
meaningful for events fired before navigation takes place.
|
||||
*/
|
||||
bool CanVeto() const;
|
||||
|
||||
/**
|
||||
Whether this event was vetoed (stopped/prevented). Only meaningful for
|
||||
events fired before navigation takes place or new window events.
|
||||
*/
|
||||
bool IsVetoed() const;
|
||||
|
||||
/**
|
||||
Veto (prevent/stop) this event. Only meaningful for events fired
|
||||
before navigation takes place. Only valid if CanVeto() returned true.
|
||||
*/
|
||||
void Veto();
|
||||
};
|
@ -46,7 +46,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
|
||||
webKitCtrl->m_busy = false;
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
|
||||
webKitCtrl->GetId(),
|
||||
url, target, false);
|
||||
url, target);
|
||||
|
||||
if (webKitCtrl && webKitCtrl->GetEventHandler())
|
||||
webKitCtrl->GetEventHandler()->ProcessEvent(event);
|
||||
@ -56,7 +56,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
|
||||
webKitCtrl->m_busy = true;
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
|
||||
webKitCtrl->GetId(),
|
||||
url, target, false);
|
||||
url, target);
|
||||
|
||||
if (webKitCtrl && webKitCtrl->GetEventHandler())
|
||||
webKitCtrl->GetEventHandler()->ProcessEvent(event);
|
||||
@ -89,13 +89,12 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
|
||||
webKitCtrl->GetId(),
|
||||
wxString( uri, wxConvUTF8 ),
|
||||
target,
|
||||
true);
|
||||
target);
|
||||
|
||||
if (webKitCtrl && webKitCtrl->GetEventHandler())
|
||||
webKitCtrl->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
if (event.IsVetoed())
|
||||
if (!event.IsAllowed())
|
||||
{
|
||||
webKitCtrl->m_busy = false;
|
||||
webkit_web_policy_decision_ignore(policy_decision);
|
||||
@ -262,7 +261,7 @@ wxgtk_webview_webkit_error(WebKitWebView*,
|
||||
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
|
||||
webKitWindow->GetId(),
|
||||
uri, "", false);
|
||||
uri, "");
|
||||
event.SetString(description);
|
||||
event.SetInt(type);
|
||||
|
||||
@ -288,8 +287,7 @@ wxgtk_webview_webkit_new_window(WebKitWebView*,
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
|
||||
webKitCtrl->GetId(),
|
||||
wxString( uri, wxConvUTF8 ),
|
||||
target,
|
||||
true);
|
||||
target);
|
||||
|
||||
if (webKitCtrl && webKitCtrl->GetEventHandler())
|
||||
webKitCtrl->GetEventHandler()->ProcessEvent(event);
|
||||
@ -308,7 +306,7 @@ wxgtk_webview_webkit_title_changed(WebKitWebView*,
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
|
||||
webKitCtrl->GetId(),
|
||||
webKitCtrl->GetCurrentURL(),
|
||||
"", true);
|
||||
"");
|
||||
event.SetString(wxString(title, wxConvUTF8));
|
||||
|
||||
if (webKitCtrl && webKitCtrl->GetEventHandler())
|
||||
|
@ -110,7 +110,7 @@ void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
|
||||
//We send the events when we are done to mimic webkit
|
||||
//Navigated event
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
|
||||
GetId(), baseUrl, "", false);
|
||||
GetId(), baseUrl, "");
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
|
||||
@ -723,11 +723,11 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
wxString target = evt[3].GetString();
|
||||
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
|
||||
GetId(), url, target, true);
|
||||
GetId(), url, target);
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
|
||||
if (event.IsVetoed())
|
||||
if (!event.IsAllowed())
|
||||
{
|
||||
wxActiveXEventNativeMSW* nativeParams =
|
||||
evt.GetNativeParameters();
|
||||
@ -749,7 +749,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
// TODO: set target parameter if possible
|
||||
wxString target = wxEmptyString;
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
|
||||
GetId(), url, target, false);
|
||||
GetId(), url, target);
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
break;
|
||||
@ -798,7 +798,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
// TODO: set target parameter if possible
|
||||
wxString target = wxEmptyString;
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
|
||||
url, target, false);
|
||||
url, target);
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
break;
|
||||
@ -814,7 +814,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
wxString title = evt[0].GetString();
|
||||
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
|
||||
GetId(), GetCurrentURL(), wxEmptyString, true);
|
||||
GetId(), GetCurrentURL(), "");
|
||||
event.SetString(title);
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
@ -938,7 +938,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
wxString url = evt[1].GetString();
|
||||
wxString target = evt[2].GetString();
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
|
||||
url, target, false);
|
||||
url, target);
|
||||
event.SetEventObject(this);
|
||||
event.SetInt(errorType);
|
||||
event.SetString(errorCode);
|
||||
@ -950,7 +950,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
wxString url = evt[4].GetString();
|
||||
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
|
||||
GetId(), url, wxEmptyString, true);
|
||||
GetId(), url, wxEmptyString);
|
||||
event.SetEventObject(this);
|
||||
HandleWindowEvent(event);
|
||||
|
||||
|
@ -1018,13 +1018,13 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
if (webKitWindow && frame == [sender mainFrame]){
|
||||
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
||||
wxString target = wxStringWithNSString([frame name]);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
target, false);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
target);
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,13 +1036,13 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
||||
|
||||
wxString target = wxStringWithNSString([frame name]);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_LOADED,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
target, false);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
target);
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1130,16 +1130,16 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
||||
|
||||
wxWebViewNavigationError type;
|
||||
wxString description = nsErrorToWxHtmlError(error, &type);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
wxEmptyString, false);
|
||||
thisEvent.SetString(description);
|
||||
thisEvent.SetInt(type);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
wxEmptyString);
|
||||
event.SetString(description);
|
||||
event.SetInt(type);
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
{
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1156,15 +1156,15 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
||||
|
||||
wxWebViewNavigationError type;
|
||||
wxString description = nsErrorToWxHtmlError(error, &type);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_ERROR,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
wxEmptyString, false);
|
||||
thisEvent.SetString(description);
|
||||
thisEvent.SetInt(type);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ),
|
||||
wxEmptyString);
|
||||
event.SetString(description);
|
||||
event.SetInt(type);
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1172,15 +1172,15 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
||||
forFrame:(WebFrame *)frame
|
||||
{
|
||||
wxString target = wxStringWithNSString([frame name]);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
|
||||
webKitWindow->GetId(),
|
||||
webKitWindow->GetCurrentURL(),
|
||||
target, true);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
|
||||
webKitWindow->GetId(),
|
||||
webKitWindow->GetCurrentURL(),
|
||||
target);
|
||||
|
||||
thisEvent.SetString(wxStringWithNSString(title));
|
||||
event.SetString(wxStringWithNSString(title));
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
@end
|
||||
|
||||
@ -1204,14 +1204,14 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
||||
webKitWindow->m_busy = true;
|
||||
NSString *url = [[request URL] absoluteString];
|
||||
wxString target = wxStringWithNSString([frame name]);
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ), target, true);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ), target);
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
if (thisEvent.IsVetoed())
|
||||
if (!event.IsAllowed())
|
||||
{
|
||||
webKitWindow->m_busy = false;
|
||||
[listener ignore];
|
||||
@ -1231,12 +1231,12 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
||||
wxUnusedVar(actionInformation);
|
||||
|
||||
NSString *url = [[request URL] absoluteString];
|
||||
wxWebViewNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ), "", true);
|
||||
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
|
||||
webKitWindow->GetId(),
|
||||
wxStringWithNSString( url ), "");
|
||||
|
||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
|
||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
[listener ignore];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user