X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0aaa6ace7ede4240453251d6a1c84c918c54c321..bc5c09a3aa3662137da2d781c0b101a598d2650d:/src/osx/carbon/nonownedwnd.cpp diff --git a/src/osx/carbon/nonownedwnd.cpp b/src/osx/carbon/nonownedwnd.cpp index 192f8f5a24..88aedf36be 100644 --- a/src/osx/carbon/nonownedwnd.cpp +++ b/src/osx/carbon/nonownedwnd.cpp @@ -149,6 +149,13 @@ bool wxNonOwnedWindowCarbonImpl::SetBackgroundStyle(wxBackgroundStyle style) err = ReshapeCustomWindow( m_macWindow ); verify_noerr( err ); } + else + { + OSStatus err = HIWindowChangeFeatures( m_macWindow, kWindowIsOpaque, 0 ); + verify_noerr( err ); + err = ReshapeCustomWindow( m_macWindow ); + verify_noerr( err ); + } return true ; } @@ -254,6 +261,7 @@ void wxNonOwnedWindowCarbonImpl::MacSetUnifiedAppearance( bool set ) static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param); +void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ); // --------------------------------------------------------------------------- // Carbon Events @@ -537,8 +545,9 @@ void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) break ; } break ; - - case kEventMouseWheelMoved : + // TODO http://developer.apple.com/qa/qa2005/qa1453.html + // add declaration for 10.4 and change to kEventMouseScroll + case kEventMouseWheelMoved : { wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ; @@ -928,7 +937,7 @@ wxNonOwnedWindowEventHandler(EventHandlerCallRef WXUNUSED(handler), // mix this in from window.cpp pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; -pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) +static pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; @@ -1133,7 +1142,7 @@ wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl() m_macEventHandler = NULL ; } - if ( m_macWindow ) + if ( m_macWindow && !m_wxPeer->IsNativeWindowWrapper()) DisposeWindow( m_macWindow ); FullScreenData *data = (FullScreenData *) m_macFullScreenData ; @@ -1153,7 +1162,7 @@ void wxNonOwnedWindowCarbonImpl::WillBeDestroyed() } } -void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref) +static void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref) { InstallWindowEventHandler(window, GetwxNonOwnedEventHandlerUPP(), GetEventTypeCount(eventList), eventList, ref, handler ); @@ -1191,30 +1200,37 @@ void wxNonOwnedWindowCarbonImpl::MacInstallTopLevelWindowEventHandler() void wxNonOwnedWindowCarbonImpl::Create( wxWindow* parent, - const wxPoint& pos, - const wxSize& size, - long style, long extraStyle, - const wxString& WXUNUSED(name) ) + WXWindow nativeWindow ) { + m_macWindow = nativeWindow; +} +void wxNonOwnedWindowCarbonImpl::Create( + wxWindow* parent, + const wxPoint& pos, + const wxSize& size, + long style, long extraStyle, + const wxString& WXUNUSED(name) ) +{ + OSStatus err = noErr ; Rect theBoundsRect; - + int x = (int)pos.x; int y = (int)pos.y; - + int w = size.x; int h = size.y; - + ::SetRect(&theBoundsRect, x, y , x + w, y + h); - + // translate the window attributes in the appropriate window class and attributes WindowClass wclass = 0; WindowAttributes attr = kWindowNoAttributes ; WindowGroupRef group = NULL ; bool activationScopeSet = false; WindowActivationScope activationScope = kWindowActivationScopeNone; - + if ( style & wxFRAME_TOOL_WINDOW ) { if ( @@ -1227,7 +1243,7 @@ void wxNonOwnedWindowCarbonImpl::Create( wclass = kUtilityWindowClass; else wclass = kFloatingWindowClass ; - + if ( ( style &wxTINY_CAPTION_VERT) ) attr |= kWindowSideTitlebarAttribute ; } @@ -1286,81 +1302,81 @@ void wxNonOwnedWindowCarbonImpl::Create( wclass = kPlainWindowClass ; } } - + if ( wclass != kPlainWindowClass ) { if ( ( style & wxMINIMIZE_BOX ) ) attr |= kWindowCollapseBoxAttribute ; - + if ( ( style & wxMAXIMIZE_BOX ) ) attr |= kWindowFullZoomAttribute ; - + if ( ( style & wxRESIZE_BORDER ) ) attr |= kWindowResizableAttribute ; - + if ( ( style & wxCLOSE_BOX) ) attr |= kWindowCloseBoxAttribute ; } attr |= kWindowLiveResizeAttribute; - + if ( ( style &wxSTAY_ON_TOP) ) group = GetWindowGroupOfClass(kUtilityWindowClass) ; - + if ( ( style & wxFRAME_FLOAT_ON_PARENT ) ) group = GetWindowGroupOfClass(kFloatingWindowClass) ; - + if ( group == NULL && parent != NULL ) { WindowRef parenttlw = (WindowRef) parent->MacGetTopLevelWindowRef(); if( parenttlw ) group = GetWindowGroupParent( GetWindowGroup( parenttlw ) ); } - + attr |= kWindowCompositingAttribute; #if 0 // TODO : decide on overall handling of high dpi screens (pixel vs userscale) attr |= kWindowFrameworkScaledAttribute; #endif - + if ( ( style &wxFRAME_SHAPED) ) { WindowDefSpec customWindowDefSpec; customWindowDefSpec.defType = kWindowDefProcPtr; customWindowDefSpec.u.defProc = #ifdef __LP64__ - (WindowDefUPP) wxShapedMacWindowDef; + (WindowDefUPP) wxShapedMacWindowDef; #else - NewWindowDefUPP(wxShapedMacWindowDef); + NewWindowDefUPP(wxShapedMacWindowDef); #endif err = ::CreateCustomWindow( &customWindowDefSpec, wclass, - attr, &theBoundsRect, - (WindowRef*) &m_macWindow); + attr, &theBoundsRect, + (WindowRef*) &m_macWindow); } else { err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; } - + if ( err == noErr && m_macWindow != NULL && group != NULL ) SetWindowGroup( (WindowRef) m_macWindow , group ) ; - + wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") ); - + // setup a separate group for each window, so that overlays can be handled easily - + WindowGroupRef overlaygroup = NULL; verify_noerr( CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &overlaygroup )); verify_noerr( SetWindowGroupParent( overlaygroup, GetWindowGroup( (WindowRef) m_macWindow ))); verify_noerr( SetWindowGroup( (WindowRef) m_macWindow , overlaygroup )); - + if ( activationScopeSet ) { verify_noerr( SetWindowActivationScope( (WindowRef) m_macWindow , activationScope )); } - + // the create commands are only for content rect, // so we have to set the size again as structure bounds SetWindowBounds( m_macWindow , kWindowStructureRgn , &theBoundsRect ) ; - + // Causes the inner part of the window not to be metal // if the style is used before window creation. #if 0 // TARGET_API_MAC_OSX @@ -1370,24 +1386,24 @@ void wxNonOwnedWindowCarbonImpl::Create( MacSetMetalAppearance( true ) ; } #endif - + if ( m_macWindow != NULL ) { MacSetUnifiedAppearance( true ) ; } - + HIViewRef growBoxRef = 0 ; err = HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef ); if ( err == noErr && growBoxRef != 0 ) HIGrowBoxViewSetTransparent( growBoxRef, true ) ; - + // the frame window event handler InstallStandardEventHandler( GetWindowEventTarget(m_macWindow) ) ; MacInstallTopLevelWindowEventHandler() ; - + if ( extraStyle & wxFRAME_EX_METAL) MacSetMetalAppearance(true); - + if ( ( style &wxFRAME_SHAPED) ) { // default shape matches the window size @@ -1688,3 +1704,11 @@ wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWind now->Create( parent, pos, size, style , extraStyle, name ); return now; } + +wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow ) +{ + wxNonOwnedWindowCarbonImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer ); + now->Create( parent, nativeWindow ); + return now; +} +