]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlctrl/webkit/webkit.mm
fixed handling of the accelerators of menu items added to already attached submenus
[wxWidgets.git] / src / html / htmlctrl / webkit / webkit.mm
index 592f68fe0939d88889c4b1129b170418cb69d918..b25b47c315100a95b22e2acd26658f28a7ba4975 100755 (executable)
@@ -15,6 +15,7 @@
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
+#include "wx/splitter.h"
 
 #ifndef WX_PRECOMP
     #include "wx/wx.h"
@@ -27,6 +28,7 @@
 #else
 #include "wx/mac/uma.h"
 #include <Carbon/Carbon.h>
+#include <WebKit/WebKit.h>
 #include <WebKit/HIWebView.h>
 #include <WebKit/CarbonUtils.h>
 #endif
@@ -39,9 +41,7 @@
 // macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxWebKitCtrl, wxControl)
-#endif
 
 BEGIN_EVENT_TABLE(wxWebKitCtrl, wxControl)
     EVT_SIZE(wxWebKitCtrl::OnSize)
@@ -145,7 +145,7 @@ bool wxWebKitCtrl::Create(wxWindow *parent,
     SetInitialFrameRect(pos,sizeInstance);
 #else
     m_macIsUserPane = false;
-       wxControl::Create(parent, m_windowID, pos, size, style , validator , name);
+       wxControl::Create(parent, winID, pos, size, style , validator , name);
     m_peer = new wxMacControl(this);
     WebInitForCarbon();
     HIWebViewCreate( m_peer->GetControlRefAddr() );
@@ -154,6 +154,10 @@ bool wxWebKitCtrl::Create(wxWindow *parent,
     MacPostControlCreate(pos, size);
     HIViewSetVisible( m_peer->GetControlRef(), true );
     [m_webView setHidden:false];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+       if ( UMAGetSystemVersion() >= 0x1030 )
+    HIViewChangeFeatures( m_peer->GetControlRef() , kHIViewIsOpaque , 0 ) ;
+#endif
 #endif
 
     // Register event listener interfaces
@@ -284,8 +288,32 @@ void wxWebKitCtrl::OnSize(wxSizeEvent &event){
                                        
        while(parent != NULL)
        {
-               if ( parent->GetClassInfo()->GetClassName() == wxT("wxSplitterWindow") ){
-                       //do nothing in this case
+               if ( parent->IsKindOf( CLASSINFO( wxSplitterWindow ) ) && GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow ) ) ){
+                               // When parent is not a wxSplitterWindow, we can rely on it's GetPosition() to give us the correct
+                               // coordinates, but when the parent is a wxSplitterWindow, we need to manually calculate 
+                               // the sash position of it and any parent wxSplitterWindows into the webkit's position.
+                               wxSplitterWindow* splitter;
+                               splitter = dynamic_cast<wxSplitterWindow*>(parent);
+                               if (splitter->GetSplitMode() == wxSPLIT_HORIZONTAL){
+                                       if (splitter->GetPosition().y > 0)
+                                               y += splitter->GetPosition().y;
+                                       
+                                       if (splitter->GetSashSize() > 0)
+                                               y += splitter->GetSashSize();
+                                               
+                                       if (splitter->GetSashPosition() > 0)
+                                               y += splitter->GetSashPosition();
+                               }
+                               else{
+                                       if (splitter->GetPosition().x > 0)
+                                               x += splitter->GetPosition().x;
+                                       
+                                       if (splitter->GetSashSize() > 0)
+                                               x += splitter->GetSashSize();
+                                               
+                                       if (splitter->GetSashPosition() > 0)
+                                               x += splitter->GetSashPosition();
+                               }
                }
                else{
                        if (!parent->IsTopLevel()) {
@@ -321,7 +349,7 @@ void wxWebKitCtrl::OnSize(wxSizeEvent &event){
 
                        if ( parent->IsKindOf( CLASSINFO( wxNotebook ) )  ){
                                //Not sure why calcs are off in this one scenario...
-                               x -= 3;
+                               y -= 4;
                                //printf("x: %d, y:%d\n", x, y);
                        }
                        
@@ -363,14 +391,14 @@ void wxWebKitCtrl::OnSize(wxSizeEvent &event){
 
     //printf("Carbon position x=%d, y=%d\n", GetPosition().x, GetPosition().y);
     if (IsShown())
-        [m_webView display];
+        [(WebView*)m_webView display];
     event.Skip();
 }
 
 void wxWebKitCtrl::MacVisibilityChanged(){
     bool isHidden = !IsControlVisible( m_peer->GetControlRef());
     if (!isHidden)
-        [m_webView display];
+        [(WebView*)m_webView display];
 
     [m_webView setHidden:isHidden];
 }