X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14f21d6d89225c8c567e5667c68dd8d81fc9b7e6..44fd6f721ad375033b2a2b64ac5f703ac70cb8f0:/src/html/htmlctrl/webkit/webkit.mm diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index 93609c9294..884b0a0257 100755 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -20,6 +20,8 @@ #include "wx/wx.h" #endif +#if wxUSE_WEBKIT + #ifdef __WXCOCOA__ #include "wx/cocoa/autorelease.h" #else @@ -31,7 +33,6 @@ #include "wx/html/webkit.h" #include "wx/notebook.h" -//#include "wx/html/wklisten.h" // ---------------------------------------------------------------------------- @@ -144,14 +145,15 @@ bool wxWebKitCtrl::Create(wxWindow *parent, SetInitialFrameRect(pos,sizeInstance); #else m_macIsUserPane = false; + m_peer = new wxMacControl(); wxControl::Create(parent, m_windowID, pos, size, style , validator , name); WebInitForCarbon(); - HIWebViewCreate( (HIViewRef*) &m_macControl ); + HIWebViewCreate( (HIViewRef*) *m_peer ); - m_webView = (WebView*) HIWebViewGetWebView( (HIViewRef) m_macControl ); + m_webView = (WebView*) HIWebViewGetWebView( (HIViewRef) *m_peer ); MacPostControlCreate(pos, size); - - HIViewSetVisible( (HIViewRef) m_macControl, true ); + HIViewSetVisible( (HIViewRef) *m_peer, true ); + [m_webView setHidden:false]; #endif // Register event listener interfaces @@ -255,18 +257,44 @@ void wxWebKitCtrl::SetPageSource(wxString& source, const wxString& baseUrl){ } void wxWebKitCtrl::OnSize(wxSizeEvent &event){ - if ( GetParent()->IsKindOf( CLASSINFO( wxNotebook) ) ){ + // This is a nasty hack because WebKit does not seem to recognize a Tabs control as its parent. + // Therefore, coordinates must be relative to the left-hand side of the screen, rather than + // relative to the Tabs control. + wxWindow* parent = GetParent(); + bool inNotebook = false; + int x = 0; + int y = 18; + while(parent != NULL) + { + // keep adding the position until we hit the notebook + if (!inNotebook){ + x += parent->GetPosition().x; + y += parent->GetPosition().y; + } + + if ( parent->GetClassInfo()->GetClassName() == wxT("wxSplitterWindow") ){ + x += 3; + } + + if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) ){ + inNotebook = true; + } + parent = parent->GetParent(); + } + + if (inNotebook){ NSRect bounds = [m_webView frame]; - bounds.origin.x += GetParent()->GetPosition().x; - bounds.origin.y += 18; + bounds.origin.x += x; + bounds.origin.y += y; [m_webView setFrame:bounds]; - } + } + [m_webView display]; event.Skip(); } void wxWebKitCtrl::MacVisibilityChanged(){ - bool isHidden = !IsControlVisible( (HIViewRef)m_macControl); + bool isHidden = !IsControlVisible( (HIViewRef)*m_peer); [m_webView setHidden:isHidden]; } @@ -345,3 +373,5 @@ void wxWebKitCtrl::MacVisibilityChanged(){ } } @end + +#endif //wxUSE_WEBKIT