+IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowCarbonImpl , wxNonOwnedWindowImpl )
+
+WXWindow wxNonOwnedWindowCarbonImpl::GetWXWindow() const
+{
+ return (WXWindow) m_macWindow;
+}
+void wxNonOwnedWindowCarbonImpl::Raise()
+{
+ ::SelectWindow( m_macWindow ) ;
+}
+
+void wxNonOwnedWindowCarbonImpl::Lower()
+{
+ ::SendBehind( m_macWindow , NULL ) ;
+}
+
+bool wxNonOwnedWindowCarbonImpl::Show(bool show)
+{
+ bool plainTransition = true;
+
+#if wxUSE_SYSTEM_OPTIONS
+ if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
+ plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
+#endif
+
+ if (show)
+ {
+#if wxOSX_USE_CARBON
+ if ( plainTransition )
+ ::ShowWindow( (WindowRef)m_macWindow );
+ else
+ ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
+
+ ::SelectWindow( (WindowRef)m_macWindow ) ;
+#endif
+ }
+ else
+ {
+#if wxOSX_USE_CARBON
+ if ( plainTransition )
+ ::HideWindow( (WindowRef)m_macWindow );
+ else
+ ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL );
+#endif
+ }
+ return true;
+}
+
+void wxNonOwnedWindowCarbonImpl::Update()
+{
+ HIWindowFlush(m_macWindow) ;
+}
+
+bool wxNonOwnedWindowCarbonImpl::SetTransparent(wxByte alpha)
+{
+ OSStatus result = SetWindowAlpha((WindowRef)m_macWindow, (CGFloat)((alpha)/255.0));
+ return result == noErr;
+}
+
+bool wxNonOwnedWindowCarbonImpl::SetBackgroundColour(const wxColour& col )
+{
+ if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDocumentWindowBackground)) )
+ {
+ SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDocumentWindowBackground, false ) ;
+ SetBackgroundStyle(wxBG_STYLE_SYSTEM);
+ }
+ else if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)) )
+ {
+ SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDialogBackgroundActive, false ) ;
+ SetBackgroundStyle(wxBG_STYLE_SYSTEM);
+ }
+ return true;
+}
+
+void wxNonOwnedWindowCarbonImpl::SetExtraStyle( long exStyle )
+{
+ if ( m_macWindow != NULL )
+ {
+ bool metal = exStyle & wxFRAME_EX_METAL ;
+
+ if ( MacGetMetalAppearance() != metal )
+ {
+ if ( MacGetUnifiedAppearance() )
+ MacSetUnifiedAppearance( !metal ) ;
+
+ MacSetMetalAppearance( metal ) ;
+ }
+ }
+}
+
+bool wxNonOwnedWindowCarbonImpl::SetBackgroundStyle(wxBackgroundStyle style)
+{
+ if ( style == wxBG_STYLE_TRANSPARENT )
+ {
+ OSStatus err = HIWindowChangeFeatures( m_macWindow, 0, kWindowIsOpaque );
+ verify_noerr( err );
+ err = ReshapeCustomWindow( m_macWindow );
+ verify_noerr( err );
+ }
+
+ return true ;
+}
+
+bool wxNonOwnedWindowCarbonImpl::CanSetTransparent()
+{
+ return true;
+}
+
+void wxNonOwnedWindowCarbonImpl::GetContentArea( int &left , int &top , int &width , int &height ) const
+{
+ Rect content, structure ;
+
+ GetWindowBounds( m_macWindow, kWindowStructureRgn , &structure ) ;
+ GetWindowBounds( m_macWindow, kWindowContentRgn , &content ) ;
+
+ left = content.left - structure.left ;
+ top = content.top - structure.top ;
+ width = content.right - content.left ;
+ height = content.bottom - content.top ;
+}
+
+void wxNonOwnedWindowCarbonImpl::MoveWindow(int x, int y, int width, int height)
+{
+ Rect bounds = { y , x , y + height , x + width } ;
+ verify_noerr(SetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
+}
+
+void wxNonOwnedWindowCarbonImpl::GetPosition( int &x, int &y ) const
+{
+ Rect bounds ;
+
+ verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
+
+ x = bounds.left ;
+ y = bounds.top ;
+}
+
+void wxNonOwnedWindowCarbonImpl::GetSize( int &width, int &height ) const
+{
+ Rect bounds ;
+
+ verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
+
+ width = bounds.right - bounds.left ;
+ height = bounds.bottom - bounds.top ;
+}
+
+bool wxNonOwnedWindowCarbonImpl::MacGetUnifiedAppearance() const
+{
+ return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
+}
+
+void wxNonOwnedWindowCarbonImpl::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
+{
+ ChangeWindowAttributes( m_macWindow, attributesToSet, attributesToClear ) ;
+}
+
+wxUint32 wxNonOwnedWindowCarbonImpl::MacGetWindowAttributes() const
+{
+ UInt32 attr = 0 ;
+ GetWindowAttributes( m_macWindow, &attr ) ;
+ return attr ;
+}
+
+void wxNonOwnedWindowCarbonImpl::MacSetMetalAppearance( bool set )
+{
+ if ( MacGetUnifiedAppearance() )
+ MacSetUnifiedAppearance( false ) ;
+
+ MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
+ set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
+}
+
+bool wxNonOwnedWindowCarbonImpl::MacGetMetalAppearance() const
+{
+ return MacGetWindowAttributes() & kWindowMetalAttribute ;
+}
+
+void wxNonOwnedWindowCarbonImpl::MacSetUnifiedAppearance( bool set )
+{
+ if ( MacGetMetalAppearance() )
+ MacSetMetalAppearance( false ) ;
+
+ MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
+ set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
+
+ // For some reason, Tiger uses white as the background color for this appearance,
+ // while most apps using it use the typical striped background. Restore that behavior
+ // for wx.
+ // TODO: Determine if we need this on Leopard as well. (should be harmless either way,
+ // though)
+ // since when creating the peering is not yet completely set-up we call both setters
+ // explicitely
+ m_wxPeer->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
+ SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
+}
+