From: Stefan Csomor <csomor@advancedconcepts.ch>
Date: Mon, 12 Apr 2010 20:39:51 +0000 (+0000)
Subject: correcting alpha and removing window shadow for overlay
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b61b8371b0d788b7900bc79417c61493161a3f62

correcting alpha and removing window shadow for overlay

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h
index eee92a7ea6..57de414d6c 100644
--- a/include/wx/osx/nonownedwnd.h
+++ b/include/wx/osx/nonownedwnd.h
@@ -75,6 +75,7 @@ public:
     // --------------------------
 
     virtual bool DoSetShape(const wxRegion& region);
+    const wxRegion& GetShape() const { return m_shape; }
 
     // activation hooks only necessary for MDI Implementation
     static void MacDelayedDeactivation(long timestamp);
@@ -126,7 +127,9 @@ protected:
 //    wxWindowMac* m_macFocus ;
 
     static wxNonOwnedWindow *s_macDeactivateWindow;
+    
 private :
+    wxRegion m_shape;
 };
 
 // list of all frames and modeless dialogs
diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm
index df2a894952..666864b9ad 100644
--- a/src/osx/cocoa/nonownedwnd.mm
+++ b/src/osx/cocoa/nonownedwnd.mm
@@ -485,6 +485,12 @@ long style, long extraStyle, const wxString& WXUNUSED(name) )
     [m_macWindow setDelegate:controller];
 
     [m_macWindow setAcceptsMouseMovedEvents: YES];
+    
+    if ( ( style & wxFRAME_SHAPED) )
+    {
+        [m_macWindow setOpaque:NO];
+        [m_macWindow setAlphaValue:1.0];
+    }
 }
 
 
diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm
index 8e579e45d0..890ccf7c99 100644
--- a/src/osx/cocoa/window.mm
+++ b/src/osx/cocoa/window.mm
@@ -1092,15 +1092,23 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd))
     [slf getRectsBeingDrawn:&rects count:&count];
     for ( int i = 0 ; i < count ; ++i )
     {
-        updateRgn.Union(wxFromNSRect(slf, rects[i]) );
+        updateRgn.Union(wxFromNSRect(slf, rects[i]));
     }
 
     wxWindow* wxpeer = GetWXPeer();
+    if ( wxpeer->MacGetTopLevelWindow()->GetWindowStyle() & wxFRAME_SHAPED )
+    {
+        int xoffset = 0, yoffset = 0;
+        wxRegion rgn = wxpeer->MacGetTopLevelWindow()->GetShape();
+        wxpeer->MacRootWindowToWindow( &xoffset, &yoffset );
+        rgn.Offset( xoffset, yoffset );
+        updateRgn.Intersect(rgn);
+    }
+    
     wxpeer->GetUpdateRegion() = updateRgn;
     wxpeer->MacSetCGContextRef( context );
 
     bool handled = wxpeer->MacDoRedraw( 0 );
-
     CGContextRestoreGState( context );
 
     CGContextSaveGState( context );
@@ -2077,6 +2085,7 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
 {
     NSWindow* tlw = now->GetWXWindow();
     wxNSView* v = [[wxNSView alloc] initWithFrame:[[tlw contentView] frame]];
+
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( now, v, true );
     c->InstallEventHandler();
     [tlw setContentView:v];
diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp
index 54ecb11f6d..a75e778ba8 100644
--- a/src/osx/nonownedwnd_osx.cpp
+++ b/src/osx/nonownedwnd_osx.cpp
@@ -453,6 +453,8 @@ bool wxNonOwnedWindow::DoSetShape(const wxRegion& region)
     wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
                  wxT("Shaped windows must be created with the wxFRAME_SHAPED style."));
 
+    m_shape = region;
+    
     // The empty region signifies that the shape
     // should be removed from the window.
     if ( region.IsEmpty() )