git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63969
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
public :
wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) ;
{
public :
wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) ;
wxNonOwnedWindowCarbonImpl();
virtual ~wxNonOwnedWindowCarbonImpl();
virtual void WillBeDestroyed() ;
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
wxNonOwnedWindowCarbonImpl();
virtual ~wxNonOwnedWindowCarbonImpl();
virtual void WillBeDestroyed() ;
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
+ void Create( wxWindow* parent, WXWindow nativeWindow );
WXWindow GetWXWindow() const;
void Raise();
WXWindow GetWXWindow() const;
void Raise();
virtual void WillBeDestroyed() ;
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
virtual void WillBeDestroyed() ;
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
+ void Create( wxWindow* parent, WXWindow nativeWindow );
WXWindow GetWXWindow() const;
void Raise();
WXWindow GetWXWindow() const;
void Raise();
// static creation methods, must be implemented by all toolkits
// static creation methods, must be implemented by all toolkits
+ static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow native) ;
+
static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) ;
long style = 0,
const wxString& name = wxPanelNameStr);
long style = 0,
const wxString& name = wxPanelNameStr);
+ bool Create(wxWindow *parent, WXWindow nativeWindow);
+
virtual ~wxNonOwnedWindow();
virtual wxPoint GetClientAreaOrigin() const;
virtual ~wxNonOwnedWindow();
virtual wxPoint GetClientAreaOrigin() const;
virtual void HandleResizing( double timestampsec, wxRect* rect );
virtual bool Destroy();
virtual void HandleResizing( double timestampsec, wxRect* rect );
virtual bool Destroy();
protected:
// common part of all ctors
void Init();
protected:
// common part of all ctors
void Init();
virtual bool OSXHandleClicked( double timestampsec );
virtual bool OSXHandleKeyEvent( wxKeyEvent& event );
virtual bool OSXHandleClicked( double timestampsec );
virtual bool OSXHandleKeyEvent( wxKeyEvent& event );
+
+ bool IsNativeWindowWrapper() const { return m_isNativeWindowWrapper; }
protected:
// For controls like radio buttons which are genuinely composite
wxList m_subControls;
protected:
// For controls like radio buttons which are genuinely composite
wxList m_subControls;
bool m_vScrollBarAlwaysShown;
wxWindow* m_growBox ;
wxString m_label ;
bool m_vScrollBarAlwaysShown;
wxWindow* m_growBox ;
wxString m_label ;
+
+ bool m_isNativeWindowWrapper;
// set to true if we do a sharp clip at the content area of this window
// must be dynamic as eg a panel normally is not clipping precisely, but if
// set to true if we do a sharp clip at the content area of this window
// must be dynamic as eg a panel normally is not clipping precisely, but if
m_macEventHandler = NULL ;
}
m_macEventHandler = NULL ;
}
+ if ( m_macWindow && !m_wxPeer->IsNativeWindowWrapper())
DisposeWindow( m_macWindow );
FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
DisposeWindow( m_macWindow );
FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
void wxNonOwnedWindowCarbonImpl::Create(
wxWindow* parent,
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;
OSStatus err = noErr ;
Rect theBoundsRect;
int x = (int)pos.x;
int y = (int)pos.y;
int x = (int)pos.x;
int y = (int)pos.y;
int w = size.x;
int h = size.y;
int w = size.x;
int h = size.y;
::SetRect(&theBoundsRect, x, y , x + w, y + h);
::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;
// 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 (
if ( style & wxFRAME_TOOL_WINDOW )
{
if (
wclass = kUtilityWindowClass;
else
wclass = kFloatingWindowClass ;
wclass = kUtilityWindowClass;
else
wclass = kFloatingWindowClass ;
if ( ( style &wxTINY_CAPTION_VERT) )
attr |= kWindowSideTitlebarAttribute ;
}
if ( ( style &wxTINY_CAPTION_VERT) )
attr |= kWindowSideTitlebarAttribute ;
}
wclass = kPlainWindowClass ;
}
}
wclass = kPlainWindowClass ;
}
}
if ( wclass != kPlainWindowClass )
{
if ( ( style & wxMINIMIZE_BOX ) )
attr |= kWindowCollapseBoxAttribute ;
if ( wclass != kPlainWindowClass )
{
if ( ( style & wxMINIMIZE_BOX ) )
attr |= kWindowCollapseBoxAttribute ;
if ( ( style & wxMAXIMIZE_BOX ) )
attr |= kWindowFullZoomAttribute ;
if ( ( style & wxMAXIMIZE_BOX ) )
attr |= kWindowFullZoomAttribute ;
if ( ( style & wxRESIZE_BORDER ) )
attr |= kWindowResizableAttribute ;
if ( ( style & wxRESIZE_BORDER ) )
attr |= kWindowResizableAttribute ;
if ( ( style & wxCLOSE_BOX) )
attr |= kWindowCloseBoxAttribute ;
}
attr |= kWindowLiveResizeAttribute;
if ( ( style & wxCLOSE_BOX) )
attr |= kWindowCloseBoxAttribute ;
}
attr |= kWindowLiveResizeAttribute;
if ( ( style &wxSTAY_ON_TOP) )
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
if ( ( style &wxSTAY_ON_TOP) )
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
if ( ( style & wxFRAME_FLOAT_ON_PARENT ) )
group = GetWindowGroupOfClass(kFloatingWindowClass) ;
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 ) );
}
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
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__
if ( ( style &wxFRAME_SHAPED) )
{
WindowDefSpec customWindowDefSpec;
customWindowDefSpec.defType = kWindowDefProcPtr;
customWindowDefSpec.u.defProc =
#ifdef __LP64__
- (WindowDefUPP) wxShapedMacWindowDef;
+ (WindowDefUPP) wxShapedMacWindowDef;
- NewWindowDefUPP(wxShapedMacWindowDef);
+ NewWindowDefUPP(wxShapedMacWindowDef);
#endif
err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
#endif
err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
- attr, &theBoundsRect,
- (WindowRef*) &m_macWindow);
+ attr, &theBoundsRect,
+ (WindowRef*) &m_macWindow);
}
else
{
err = ::CreateNewWindow( wclass , 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 ) ;
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") );
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
// 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 ));
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 ));
}
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 ) ;
// 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
// 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
MacSetMetalAppearance( true ) ;
}
#endif
MacSetMetalAppearance( true ) ;
}
#endif
if ( m_macWindow != NULL )
{
MacSetUnifiedAppearance( true ) ;
}
if ( m_macWindow != NULL )
{
MacSetUnifiedAppearance( true ) ;
}
HIViewRef growBoxRef = 0 ;
err = HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
if ( err == noErr && growBoxRef != 0 )
HIGrowBoxViewSetTransparent( growBoxRef, 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() ;
// the frame window event handler
InstallStandardEventHandler( GetWindowEventTarget(m_macWindow) ) ;
MacInstallTopLevelWindowEventHandler() ;
if ( extraStyle & wxFRAME_EX_METAL)
MacSetMetalAppearance(true);
if ( extraStyle & wxFRAME_EX_METAL)
MacSetMetalAppearance(true);
if ( ( style &wxFRAME_SHAPED) )
{
// default shape matches the window size
if ( ( style &wxFRAME_SHAPED) )
{
// default shape matches the window size
now->Create( parent, pos, size, style , extraStyle, name );
return now;
}
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;
+}
+
OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
if ( err != noErr )
{
OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
if ( err != noErr )
{
- wxFAIL_MSG("Unable to retrieve CGContextRef");
+ // for non-composite drawing, since we don't support it ourselves, send it through the
+ // the default handler
+ // CallNextEventHandler( handler,event ) ;
+ // result = noErr ;
+ if ( allocatedRgn )
+ CFRelease( allocatedRgn ) ;
+ break;
}
thisWindow->MacSetCGContextRef( cgContext ) ;
}
thisWindow->MacSetCGContextRef( cgContext ) ;
}
// the root control level handler
}
// the root control level handler
- contentview->InstallEventHandler() ;
+ if ( !now->IsNativeWindowWrapper() )
+ contentview->InstallEventHandler() ;
+
wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
{
wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
{
- [m_macWindow setImplementation:nil];
- [m_macWindow setDelegate:nil];
- [m_macWindow release];
+ if ( !m_wxPeer->IsNativeWindowWrapper() )
+ {
+ [m_macWindow setImplementation:nil];
+ [m_macWindow setDelegate:nil];
+ [m_macWindow release];
+ }
}
void wxNonOwnedWindowCocoaImpl::WillBeDestroyed()
{
}
void wxNonOwnedWindowCocoaImpl::WillBeDestroyed()
{
- [m_macWindow setDelegate:nil];
+ if ( !m_wxPeer->IsNativeWindowWrapper() )
+ {
+ [m_macWindow setDelegate:nil];
+ }
}
void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
}
void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
+void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), WXWindow nativeWindow )
+{
+ m_macWindow = nativeWindow;
+}
WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
{
WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
{
return [m_macWindow isDocumentEdited];
}
return [m_macWindow isDocumentEdited];
}
+wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow)
+{
+ wxNonOwnedWindowCocoaImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
+ now->Create( parent, nativeWindow );
+ return now;
+}
+
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name )
{
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name )
{
wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
{
NSWindow* tlw = now->GetWXWindow();
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];
+
+ wxWidgetCocoaImpl* c = NULL;
+ if ( now->IsNativeWindowWrapper() )
+ {
+ c = new wxWidgetCocoaImpl( now, [tlw contentView], true );
+ }
+ else
+ {
+ wxNSView* v = [[wxNSView alloc] initWithFrame:[[tlw contentView] frame]];
+ c = new wxWidgetCocoaImpl( now, v, true );
+ c->InstallEventHandler();
+ [tlw setContentView:v];
+ }
void wxNonOwnedWindow::Init()
{
m_nowpeer = NULL;
void wxNonOwnedWindow::Init()
{
m_nowpeer = NULL;
+ m_isNativeWindowWrapper = false;
}
bool wxNonOwnedWindow::Create(wxWindow *parent,
}
bool wxNonOwnedWindow::Create(wxWindow *parent,
long style,
const wxString& name)
{
long style,
const wxString& name)
{
- // init our fields
- Init();
-
m_windowStyle = style;
SetName( name );
m_windowStyle = style;
SetName( name );
+bool wxNonOwnedWindow::Create(wxWindow *parent, WXWindow nativeWindow)
+{
+ m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, parent, nativeWindow );
+ m_isNativeWindowWrapper = true;
+ wxAssociateWindowWithWXWindow( m_nowpeer->GetWXWindow() , this ) ;
+ m_peer = wxWidgetImpl::CreateContentView(this);
+
+ if ( parent )
+ parent->AddChild(this);
+
+ return true;
+}
+
wxNonOwnedWindow::~wxNonOwnedWindow()
{
SendDestroyEvent();
wxNonOwnedWindow::~wxNonOwnedWindow()
{
SendDestroyEvent();
m_macIsUserPane = true;
m_clipChildren = false ;
m_cachedClippedRectValid = false ;
m_macIsUserPane = true;
m_clipChildren = false ;
m_cachedClippedRectValid = false ;
+ m_isNativeWindowWrapper = false;
}
wxWindowMac::~wxWindowMac()
}
wxWindowMac::~wxWindowMac()