#include <Carbon/Carbon.h>
#include <WebKit/WebKit.h>
#include <WebKit/HIWebView.h>
#include <Carbon/Carbon.h>
#include <WebKit/WebKit.h>
#include <WebKit/HIWebView.h>
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassKeyboard, kEventRawKeyDown } ,
{ kEventClassKeyboard, kEventRawKeyRepeat } ,
{ kEventClassKeyboard, kEventRawKeyUp } ,
{ kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
{ kEventClassKeyboard, kEventRawKeyDown } ,
{ kEventClassKeyboard, kEventRawKeyRepeat } ,
{ kEventClassKeyboard, kEventRawKeyUp } ,
{ kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
{ kEventClassTextInput, kEventTextInputUpdateActiveInputArea } ,
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
{ kEventClassTextInput, kEventTextInputUpdateActiveInputArea } ,
#if DEBUG_WEBKIT_SIZING == 1
{ kEventClassControl, kEventControlBoundsChanged } ,
#endif
#if DEBUG_WEBKIT_SIZING == 1
{ kEventClassControl, kEventControlBoundsChanged } ,
#endif
if (thisWindow)
tlw = thisWindow->MacGetTopLevelWindow();
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
if (thisWindow)
tlw = thisWindow->MacGetTopLevelWindow();
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
case kEventClassTextInput:
{
result = wxMacUnicodeTextEventHandler(handler, event, data);
break;
}
case kEventClassTextInput:
{
result = wxMacUnicodeTextEventHandler(handler, event, data);
break;
}
{
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
SetupMouseEvent( wxevent , cEvent ) ;
{
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
SetupMouseEvent( wxevent , cEvent ) ;
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
wxevent.SetEventObject( currentMouseWindow ) ;
wxevent.SetId( currentMouseWindow->GetId() ) ;
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
wxevent.SetEventObject( currentMouseWindow ) ;
wxevent.SetId( currentMouseWindow->GetId() ) ;
wxWebKitStateChangedEvent::wxWebKitStateChangedEvent( wxWindow* win )
{
SetEventType( wxEVT_WEBKIT_STATE_CHANGED);
wxWebKitStateChangedEvent::wxWebKitStateChangedEvent( wxWindow* win )
{
SetEventType( wxEVT_WEBKIT_STATE_CHANGED);
wxWebKitBeforeLoadEvent::wxWebKitBeforeLoadEvent( wxWindow* win )
{
m_cancelled = false;
SetEventType( wxEVT_WEBKIT_BEFORE_LOAD);
wxWebKitBeforeLoadEvent::wxWebKitBeforeLoadEvent( wxWindow* win )
{
m_cancelled = false;
SetEventType( wxEVT_WEBKIT_BEFORE_LOAD);
- SetEventObject( win );
- SetId(win->GetId());
+ if ( win )
+ {
+ SetEventObject( win );
+ SetId(win->GetId());
+ }
+}
+
+
+IMPLEMENT_DYNAMIC_CLASS( wxWebKitNewWindowEvent, wxCommandEvent )
+
+wxDEFINE_EVENT( wxEVT_WEBKIT_NEW_WINDOW, wxWebKitNewWindowEvent )
+
+wxWebKitNewWindowEvent::wxWebKitNewWindowEvent( wxWindow* win )
+{
+ SetEventType( wxEVT_WEBKIT_NEW_WINDOW);
+ if ( win )
+ {
+ SetEventObject( win );
+ SetId(win->GetId());
+ }
//---------------------------------------------------------
// helper functions for NSString<->wxString conversion
//---------------------------------------------------------
//---------------------------------------------------------
// helper functions for NSString<->wxString conversion
//---------------------------------------------------------
inline int wxNavTypeFromWebNavType(int type){
if (type == WebNavigationTypeLinkClicked)
return wxWEBKIT_NAV_LINK_CLICKED;
inline int wxNavTypeFromWebNavType(int type){
if (type == WebNavigationTypeLinkClicked)
return wxWEBKIT_NAV_LINK_CLICKED;
HIWebViewCreate( m_peer->GetControlRefAddr() );
m_webView = (WebView*) HIWebViewGetWebView( m_peer->GetControlRef() );
HIWebViewCreate( m_peer->GetControlRefAddr() );
m_webView = (WebView*) HIWebViewGetWebView( m_peer->GetControlRef() );
MacPostControlCreate(pos, size);
HIViewSetVisible( m_peer->GetControlRef(), true );
[m_webView setHidden:false];
MacPostControlCreate(pos, size);
HIViewSetVisible( m_peer->GetControlRef(), true );
[m_webView setHidden:false];
// Register event listener interfaces
MyFrameLoadMonitor* myFrameLoadMonitor = [[MyFrameLoadMonitor alloc] initWithWxWindow: this];
[m_webView setFrameLoadDelegate:myFrameLoadMonitor];
// Register event listener interfaces
MyFrameLoadMonitor* myFrameLoadMonitor = [[MyFrameLoadMonitor alloc] initWithWxWindow: this];
[m_webView setFrameLoadDelegate:myFrameLoadMonitor];
// this is used to veto page loads, etc.
MyPolicyDelegate* myPolicyDelegate = [[MyPolicyDelegate alloc] initWithWxWindow: this];
[m_webView setPolicyDelegate:myPolicyDelegate];
// this is used to veto page loads, etc.
MyPolicyDelegate* myPolicyDelegate = [[MyPolicyDelegate alloc] initWithWxWindow: this];
[m_webView setPolicyDelegate:myPolicyDelegate];
+ MyFrameLoadMonitor* myFrameLoadMonitor = [m_webView frameLoadDelegate];
+ MyPolicyDelegate* myPolicyDelegate = [m_webView policyDelegate];
+ [m_webView setFrameLoadDelegate: nil];
+ [m_webView setPolicyDelegate: nil];
+
+ if (myFrameLoadMonitor)
+ [myFrameLoadMonitor release];
+
+ if (myPolicyDelegate)
+ [myPolicyDelegate release];
NSString* selectedText = [[m_webView selectedDOMRange] toString];
return wxStringWithNSString( selectedText );
}
NSString* selectedText = [[m_webView selectedDOMRange] toString];
return wxStringWithNSString( selectedText );
}
-
- id view = [[[m_webView mainFrame] frameView] documentView];
- NSPrintOperation *op = [NSPrintOperation printOperationWithView:view printInfo: [NSPrintInfo sharedPrintInfo]];
+
+ id view = [[[m_webView mainFrame] frameView] documentView];
+ NSPrintOperation *op = [NSPrintOperation printOperationWithView:view printInfo: [NSPrintInfo sharedPrintInfo]];
if (showPrompt){
[op setShowsPrintPanel: showPrompt];
// in my tests, the progress bar always freezes and it stops the whole print operation.
// do not turn this to true unless there is a workaround for the bug.
[op setShowsProgressPanel: false];
}
if (showPrompt){
[op setShowsPrintPanel: showPrompt];
// in my tests, the progress bar always freezes and it stops the whole print operation.
// do not turn this to true unless there is a workaround for the bug.
[op setShowsProgressPanel: false];
}
int wxWebKitCtrl::GetScrollPos(){
id result = [[m_webView windowScriptObject] evaluateWebScript:@"document.body.scrollTop"];
return [result intValue];
int wxWebKitCtrl::GetScrollPos(){
id result = [[m_webView windowScriptObject] evaluateWebScript:@"document.body.scrollTop"];
return [result intValue];
javascript.Printf(wxT("document.body.scrollTop = %d;"), pos);
[[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )];
}
wxString wxWebKitCtrl::RunScript(const wxString& javascript){
if ( !m_webView )
javascript.Printf(wxT("document.body.scrollTop = %d;"), pos);
[[m_webView windowScriptObject] evaluateWebScript:(NSString*)wxNSStringWithWxString( javascript )];
}
wxString wxWebKitCtrl::RunScript(const wxString& javascript){
if ( !m_webView )
NSString* resultAsString;
wxString resultAsWxString = wxEmptyString;
NSString* className = NSStringFromClass([result class]);
NSString* resultAsString;
wxString resultAsWxString = wxEmptyString;
NSString* className = NSStringFromClass([result class]);
#if DEBUG_WEBKIT_SIZING
fprintf(stderr,"Carbon window x=%d, y=%d, width=%d, height=%d\n", GetPosition().x, GetPosition().y, GetSize().x, GetSize().y);
fprintf(stderr, "Cocoa window frame x=%G, y=%G, width=%G, height=%G\n", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
#if DEBUG_WEBKIT_SIZING
fprintf(stderr,"Carbon window x=%d, y=%d, width=%d, height=%d\n", GetPosition().x, GetPosition().y, GetSize().x, GetSize().y);
fprintf(stderr, "Cocoa window frame x=%G, y=%G, width=%G, height=%G\n", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
// NB: In most cases, when calling HIViewConvertRect, what people want is to use GetRootControl(),
// and this tripped me up at first. But in fact, what we want is the root view, because we need to
// NB: In most cases, when calling HIViewConvertRect, what people want is to use GetRootControl(),
// and this tripped me up at first. But in fact, what we want is the root view, because we need to
- // make the y origin relative to the very top of the window, not its contents, since we later flip
- // the y coordinate for Cocoa.
- HIViewConvertRect (&rect, m_peer->GetControlRef(),
+ // make the y origin relative to the very top of the window, not its contents, since we later flip
+ // the y coordinate for Cocoa.
+ HIViewConvertRect (&rect, m_peer->GetControlRef(),
if (webKitWindow && frame == [sender mainFrame]){
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
wxWebKitStateChangedEvent thisEvent(webKitWindow);
if (webKitWindow && frame == [sender mainFrame]){
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
wxWebKitStateChangedEvent thisEvent(webKitWindow);
if (webKitWindow && frame == [sender mainFrame]){
NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString];
wxWebKitStateChangedEvent thisEvent(webKitWindow);
if (webKitWindow && frame == [sender mainFrame]){
NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString];
wxWebKitStateChangedEvent thisEvent(webKitWindow);
- // Get the navigation type.
- NSNumber *n = [actionInformation objectForKey:WebActionNavigationTypeKey];
+ // Get the navigation type.
+ NSNumber *n = [actionInformation objectForKey:WebActionNavigationTypeKey];
if (webKitWindow && webKitWindow->GetEventHandler())
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
if (webKitWindow && webKitWindow->GetEventHandler())
webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id < WebPolicyDecisionListener >)listener
+{
+ wxWebKitNewWindowEvent thisEvent(webKitWindow);
+
+ NSString *url = [[request URL] absoluteString];
+ thisEvent.SetURL( wxStringWithNSString( url ) );
+ thisEvent.SetTargetName( wxStringWithNSString( frameName ) );
+
+ if (webKitWindow && webKitWindow->GetEventHandler())
+ webKitWindow->GetEventHandler()->ProcessEvent(thisEvent);
+
+ [listener use];
+}