From 14f21d6d89225c8c567e5667c68dd8d81fc9b7e6 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Tue, 1 Jun 2004 02:53:49 +0000 Subject: [PATCH] Fixes for wxWebKitCtrl to work with wxNotebook. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27547 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/html/webkit.h | 1 + src/html/htmlctrl/webkit/webkit.mm | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/wx/html/webkit.h b/include/wx/html/webkit.h index c363df7146..1bec21122e 100755 --- a/include/wx/html/webkit.h +++ b/include/wx/html/webkit.h @@ -70,6 +70,7 @@ public: void OnSize(wxSizeEvent &event); protected: DECLARE_EVENT_TABLE() + void MacVisibilityChanged(); private: wxWindow *m_parent; diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index 53e4c8438d..93609c9294 100755 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -30,6 +30,7 @@ #endif #include "wx/html/webkit.h" +#include "wx/notebook.h" //#include "wx/html/wklisten.h" @@ -105,7 +106,7 @@ bool wxWebKitCtrl::Create(wxWindow *parent, { m_currentURL = strURL; - m_pageTitle = wxT(""); + //m_pageTitle = _("Untitled Page"); //still needed for wxCocoa?? /* @@ -146,16 +147,17 @@ bool wxWebKitCtrl::Create(wxWindow *parent, wxControl::Create(parent, m_windowID, pos, size, style , validator , name); WebInitForCarbon(); HIWebViewCreate( (HIViewRef*) &m_macControl ); - MacPostControlCreate(pos, size); - - HIViewSetVisible( (HIViewRef) m_macControl, true ); m_webView = (WebView*) HIWebViewGetWebView( (HIViewRef) m_macControl ); + MacPostControlCreate(pos, size); + + HIViewSetVisible( (HIViewRef) m_macControl, true ); #endif // Register event listener interfaces MyFrameLoadMonitor* myFrameLoadMonitor = [[MyFrameLoadMonitor alloc] initWithWxWindow: (wxWindow*)this]; [m_webView setFrameLoadDelegate:myFrameLoadMonitor]; + LoadURL(m_currentURL); return true; } @@ -225,7 +227,7 @@ void wxWebKitCtrl::Stop(){ bool wxWebKitCtrl::CanGetPageSource(){ if ( !m_webView ) - return; + return false; WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; return ( [[dataSource representation] canProvideDocumentSource] ); @@ -233,7 +235,7 @@ bool wxWebKitCtrl::CanGetPageSource(){ wxString wxWebKitCtrl::GetPageSource(){ if ( !m_webView ) - return; + return wxT(""); if (CanGetPageSource()){ WebDataSource* dataSource = [[m_webView mainFrame] dataSource]; @@ -253,10 +255,21 @@ void wxWebKitCtrl::SetPageSource(wxString& source, const wxString& baseUrl){ } void wxWebKitCtrl::OnSize(wxSizeEvent &event){ + if ( GetParent()->IsKindOf( CLASSINFO( wxNotebook) ) ){ + NSRect bounds = [m_webView frame]; + bounds.origin.x += GetParent()->GetPosition().x; + bounds.origin.y += 18; + [m_webView setFrame:bounds]; + } [m_webView display]; event.Skip(); } +void wxWebKitCtrl::MacVisibilityChanged(){ + bool isHidden = !IsControlVisible( (HIViewRef)m_macControl); + [m_webView setHidden:isHidden]; +} + //------------------------------------------------------------ // Listener interfaces //------------------------------------------------------------