X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/04dc0a11d5ff79cce6fb1fb3e489f5e324b1a664..7bc740719c93355e447db5c9bcb24cf7cdc29b61:/src/html/htmlctrl/webkit/webkit.mm diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index daa08b03de..f3944da585 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -390,6 +390,15 @@ inline int wxNavTypeFromWebNavType(int type){ @end +@interface MyUIDelegate : NSObject +{ + wxWebKitCtrl* webKitWindow; +} + +- initWithWxWindow: (wxWebKitCtrl*)inWindow; + +@end + // ---------------------------------------------------------------------------- // creation/destruction // ---------------------------------------------------------------------------- @@ -481,6 +490,10 @@ bool wxWebKitCtrl::Create(wxWindow *parent, MyPolicyDelegate* myPolicyDelegate = [[MyPolicyDelegate alloc] initWithWxWindow: this]; [m_webView setPolicyDelegate:myPolicyDelegate]; + // this is used to provide printing support for JavaScript + MyUIDelegate* myUIDelegate = [[MyUIDelegate alloc] initWithWxWindow: this]; + [m_webView setUIDelegate:myUIDelegate]; + LoadURL(m_currentURL); return true; } @@ -489,14 +502,19 @@ wxWebKitCtrl::~wxWebKitCtrl() { MyFrameLoadMonitor* myFrameLoadMonitor = [m_webView frameLoadDelegate]; MyPolicyDelegate* myPolicyDelegate = [m_webView policyDelegate]; + MyUIDelegate* myUIDelegate = [m_webView UIDelegate]; [m_webView setFrameLoadDelegate: nil]; [m_webView setPolicyDelegate: nil]; + [m_webView setUIDelegate: nil]; if (myFrameLoadMonitor) [myFrameLoadMonitor release]; if (myPolicyDelegate) [myPolicyDelegate release]; + + if (myUIDelegate) + [myUIDelegate release]; } // ---------------------------------------------------------------------------- @@ -921,4 +939,23 @@ void wxWebKitCtrl::MacVisibilityChanged(){ } @end + +@implementation MyUIDelegate + +- initWithWxWindow: (wxWebKitCtrl*)inWindow +{ + self = [super init]; + webKitWindow = inWindow; // non retained + return self; +} + +- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView +{ + wxUnusedVar(sender); + wxUnusedVar(frameView); + + webKitWindow->Print(true); +} +@end + #endif //wxUSE_WEBKIT