Add the ability to trigger a print from JavaScript for the old wxWebKitCtrl.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72283 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0a898d4ca0
commit
dac3f6b216
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user