Add the ability to trigger a print from JavaScript for the OSX backend of the wxWebView control. Closes #14241

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72284 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2012-08-03 03:56:59 +00:00
parent dac3f6b216
commit a1534b369c

View File

@ -310,6 +310,15 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxWebViewWebKitEventHandler )
@end
@interface WebViewUIDelegate : NSObject
{
wxWebViewWebKit* webKitWindow;
}
- initWithWxWindow: (wxWebViewWebKit*)inWindow;
@end
//We use a hash to map scheme names to wxWebViewHandler
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebViewHandler>, wxStringToWebHandlerMap);
@ -381,6 +390,11 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
[m_webView setPolicyDelegate:policyDelegate];
WebViewUIDelegate* uiDelegate =
[[WebViewUIDelegate alloc] initWithWxWindow: this];
[m_webView setUIDelegate:uiDelegate];
//Register our own class for custom scheme handling
[NSURLProtocol registerClass:[WebViewCustomProtocol class]];
@ -392,14 +406,19 @@ wxWebViewWebKit::~wxWebViewWebKit()
{
WebViewLoadDelegate* loadDelegate = [m_webView frameLoadDelegate];
WebViewPolicyDelegate* policyDelegate = [m_webView policyDelegate];
WebViewUIDelegate* uiDelegate = [m_webView UIDelegate];
[m_webView setFrameLoadDelegate: nil];
[m_webView setPolicyDelegate: nil];
[m_webView setUIDelegate: nil];
if (loadDelegate)
[loadDelegate release];
if (policyDelegate)
[policyDelegate release];
if (uiDelegate)
[uiDelegate release];
}
// ----------------------------------------------------------------------------
@ -1310,4 +1329,23 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
@end
@implementation WebViewUIDelegate
- initWithWxWindow: (wxWebViewWebKit*)inWindow
{
[super init];
webKitWindow = inWindow; // non retained
return self;
}
- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView
{
wxUnusedVar(sender);
wxUnusedVar(frameView);
webKitWindow->Print();
}
@end
#endif //wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT