X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b8dab63399ef6feeb39eb9f7d57c9d0d0c7524f..9534c0039b9d708c7c0ab961f74c1b14f3bfec4c:/src/mac/carbon/nonownedwnd.cpp diff --git a/src/mac/carbon/nonownedwnd.cpp b/src/mac/carbon/nonownedwnd.cpp index c43ba0476f..4c8d95e72e 100644 --- a/src/mac/carbon/nonownedwnd.cpp +++ b/src/mac/carbon/nonownedwnd.cpp @@ -21,6 +21,8 @@ #include "wx/nonownedwnd.h" #include "wx/mac/private.h" +#include "wx/settings.h" +#include "wx/frame.h" #if wxUSE_SYSTEM_OPTIONS #include "wx/sysopt.h" @@ -40,9 +42,6 @@ // globals // ---------------------------------------------------------------------------- -// list of all frames and modeless dialogs -wxWindowList wxModelessWindows; - static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param); // ============================================================================ @@ -850,8 +849,6 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, if (GetExtraStyle() & wxFRAME_EX_METAL) MacSetMetalAppearance(true); - wxTopLevelWindows.Append(this); - if ( parent ) parent->AddChild(this); @@ -876,9 +873,6 @@ wxNonOwnedWindow::~wxNonOwnedWindow() wxRemoveMacWindowAssociation( this ) ; - if ( wxModelessWindows.Find(this) ) - wxModelessWindows.DeleteObject(this); - // avoid dangling refs if ( s_macDeactivateWindow == this ) s_macDeactivateWindow = NULL; @@ -901,18 +895,21 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) else if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) ) col = wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)); - if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol ) + if ( !wxWindow::SetBackgroundColour(col) && m_hasBgCol ) return false ; - if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDocumentWindowBackground)) ) - { - SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDocumentWindowBackground, false ) ; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); - } - else if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)) ) + if ( GetBackgroundStyle() != wxBG_STYLE_CUSTOM ) { - SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDialogBackgroundActive, false ) ; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + 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; } @@ -1003,17 +1000,19 @@ void wxNonOwnedWindow::DoMacCreateRealWindow( } else if ( HasFlag( wxPOPUP_WINDOW ) ) { - // TEMPORARY HACK! - // Until we've got a real wxPopupWindow class on wxMac make it a - // little easier for wxFrame to be used to emulate it and workaround - // the lack of wxPopupWindow. if ( HasFlag( wxBORDER_NONE ) ) + { wclass = kHelpWindowClass ; // has no border + attr |= kWindowNoShadowAttribute; + } else + { wclass = kPlainWindowClass ; // has a single line border, it will have to do for now - //attr |= kWindowNoShadowAttribute; // turn off the shadow Should we?? - group = GetWindowGroupOfClass( // float above other windows - kFloatingWindowClass) ; + } + group = GetWindowGroupOfClass(kFloatingWindowClass) ; + // make sure we don't deactivate something + activationScopeSet = true; + activationScope = kWindowActivationScopeNone; } else if ( HasFlag( wxCAPTION ) ) { @@ -1241,26 +1240,30 @@ bool wxNonOwnedWindow::Show(bool show) return true ; } -bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect, - unsigned timeout, - wxDirection dir) +bool wxNonOwnedWindow::MacShowWithEffect(bool show, + wxShowEffect effect, + unsigned timeout) { - // TODO factor common code - if ( !wxWindow::Show(true) ) + if ( !wxWindow::Show(show) ) return false; WindowTransitionEffect transition = 0 ; switch( effect ) { - case wxSHOW_EFFECT_ROLL : - case wxSHOW_EFFECT_SLIDE : + case wxSHOW_EFFECT_ROLL_TO_LEFT: + case wxSHOW_EFFECT_ROLL_TO_RIGHT: + case wxSHOW_EFFECT_ROLL_TO_TOP: + case wxSHOW_EFFECT_ROLL_TO_BOTTOM: + case wxSHOW_EFFECT_SLIDE_TO_LEFT: + case wxSHOW_EFFECT_SLIDE_TO_RIGHT: + case wxSHOW_EFFECT_SLIDE_TO_TOP: + case wxSHOW_EFFECT_SLIDE_TO_BOTTOM: transition = kWindowGenieTransitionEffect; break; - case wxSHOW_EFFECT_BLEND : + case wxSHOW_EFFECT_BLEND: transition = kWindowFadeTransitionEffect; break; - case wxSHOW_EFFECT_EXPAND : - default : + case wxSHOW_EFFECT_EXPAND: // having sheets would be fine, but this might lead to a repositioning #if 0 if ( GetParent() ) @@ -1269,113 +1272,72 @@ bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect, #endif transition = kWindowZoomTransitionEffect; break; + + case wxSHOW_EFFECT_MAX: + wxFAIL_MSG( "invalid effect flag" ); + return false; } - + TransitionWindowOptions options; options.version = 0; options.duration = timeout / 1000.0; options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) GetParent()->MacGetTopLevelWindowRef() :0; options.userData = 0; - + wxSize size = wxGetDisplaySize(); Rect bounds; GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds ); CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top ); - if ( dir & wxRIGHT ) - { - hiBounds.origin.x = size.x; - hiBounds.size.width = 0; - } - if ( dir & wxUP ) - { - hiBounds.origin.y = 0; - hiBounds.size.height = 0; - } - if ( dir & wxDOWN ) + switch ( effect ) { - hiBounds.origin.y = size.y; - hiBounds.size.height = 0; - } - if ( dir & wxLEFT ) - { - hiBounds.origin.x = 0; - hiBounds.size.width = 0; - } - - ::TransitionWindowWithOptions( (WindowRef)m_macWindow, transition, kWindowShowTransitionAction, transition == kWindowGenieTransitionEffect ? &hiBounds : NULL , - false, &options ); + case wxSHOW_EFFECT_ROLL_TO_RIGHT: + case wxSHOW_EFFECT_SLIDE_TO_RIGHT: + hiBounds.origin.x = 0; + hiBounds.size.width = 0; + break; - ::SelectWindow( (WindowRef)m_macWindow ) ; - - // because apps expect a size event to occur at this moment - wxSizeEvent event(GetSize() , m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); - - return true; -} + case wxSHOW_EFFECT_ROLL_TO_LEFT: + case wxSHOW_EFFECT_SLIDE_TO_LEFT: + hiBounds.origin.x = size.x; + hiBounds.size.width = 0; + break; -bool wxNonOwnedWindow::HideWithEffect(wxShowEffect effect, - unsigned timeout , - wxDirection dir ) -{ - if ( !wxWindow::Show(false) ) - return false; - - WindowTransitionEffect transition = 0 ; - switch( effect ) - { - case wxSHOW_EFFECT_ROLL : - case wxSHOW_EFFECT_SLIDE : - transition = kWindowGenieTransitionEffect; + case wxSHOW_EFFECT_ROLL_TO_TOP: + case wxSHOW_EFFECT_SLIDE_TO_TOP: + hiBounds.origin.y = size.y; + hiBounds.size.height = 0; break; - case wxSHOW_EFFECT_BLEND : - transition = kWindowFadeTransitionEffect; + + case wxSHOW_EFFECT_ROLL_TO_BOTTOM: + case wxSHOW_EFFECT_SLIDE_TO_BOTTOM: + hiBounds.origin.y = 0; + hiBounds.size.height = 0; break; - case wxSHOW_EFFECT_EXPAND : + default: -#if 0 - if ( GetParent() ) - transition = kWindowSheetTransitionEffect; - else -#endif - transition = kWindowZoomTransitionEffect; - break; + break; // direction doesn't make sense } - TransitionWindowOptions options; - options.version = 0; - options.duration = timeout / 1000.0; - options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) GetParent()->MacGetTopLevelWindowRef() :0; - options.userData = 0; - - wxSize size = wxGetDisplaySize(); - Rect bounds; - GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds ); - CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top ); - - if ( dir & wxRIGHT ) - { - hiBounds.origin.x = size.x; - hiBounds.size.width = 0; - } - if ( dir & wxUP ) - { - hiBounds.origin.y = 0; - hiBounds.size.height = 0; - } - if ( dir & wxDOWN ) - { - hiBounds.origin.y = size.y; - hiBounds.size.height = 0; - } - if ( dir & wxLEFT ) + + ::TransitionWindowWithOptions + ( + (WindowRef)m_macWindow, + transition, + show ? kWindowShowTransitionAction : kWindowHideTransitionAction, + transition == kWindowGenieTransitionEffect ? &hiBounds : NULL, + false, + &options + ); + + if ( show ) { - hiBounds.origin.x = 0; - hiBounds.size.width = 0; + ::SelectWindow( (WindowRef)m_macWindow ) ; + + // because apps expect a size event to occur at this moment + wxSizeEvent event(GetSize() , m_windowId); + event.SetEventObject(this); + HandleWindowEvent(event); } - ::TransitionWindowWithOptions( (WindowRef)m_macWindow, transition, kWindowHideTransitionAction, transition == kWindowGenieTransitionEffect ? &hiBounds : NULL , - false, &options ); return true; }