]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlctrl/webkit/webkit.mm
Add wxControlWithItems::SendSelectionChangedEvent() helper.
[wxWidgets.git] / src / html / htmlctrl / webkit / webkit.mm
index daa08b03ded8872b49cd9d24de1a9d7869e55e77..f3944da5850f3a73a39603a4d1c210c78de277fa 100644 (file)
@@ -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