From 871d4e1b0c95d622f38146097ed043e819039297 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 25 Mar 2008 07:42:06 +0000 Subject: [PATCH] non owned window implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/popupwin.cpp | 123 ++---------------------------------- 1 file changed, 5 insertions(+), 118 deletions(-) diff --git a/src/mac/carbon/popupwin.cpp b/src/mac/carbon/popupwin.cpp index b60673a5f2..c2ecd3cf59 100644 --- a/src/mac/carbon/popupwin.cpp +++ b/src/mac/carbon/popupwin.cpp @@ -42,131 +42,18 @@ wxPopupWindow::~wxPopupWindow() { - if ( m_popupWindowRef ) - { -#if wxUSE_TOOLTIPS - wxToolTip::NotifyWindowDelete(m_popupWindowRef) ; -#endif - wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_popupWindowRef ) ) ; - } } -bool wxPopupWindow::Create(wxWindow *parent, int WXUNUSED(flags)) +bool wxPopupWindow::Create(wxWindow *parent, int flags) { - m_macIsUserPane = false ; - // popup windows are created hidden by default Hide(); - if ( ! wxPopupWindowBase::Create(parent) ) - return false; - - WindowClass wclass = kHelpWindowClass; - WindowAttributes attr = kWindowCompositingAttribute ; - - Rect bounds = { 0,0,0,0 }; - OSStatus err = ::CreateNewWindow( wclass , attr , &bounds , (WindowRef*)&m_popupWindowRef ) ; - if ( err == noErr ) - { -#if 0 - WindowRef parentWindow =(WindowRef) parent->MacGetTopLevelWindowRef(); - SetWindowGroup( (WindowRef) m_popupWindowRef, GetWindowGroup(parentWindow)); // Put them in the same group so that their window layers are consistent -#endif -} - - m_peer = new wxMacControl(this , true /*isRootControl*/) ; - - HIViewFindByID( HIViewGetRoot( (WindowRef) m_popupWindowRef ) , kHIViewWindowContentID , - m_peer->GetControlRefAddr() ) ; - if ( !m_peer->Ok() ) -{ - // compatibility mode fallback - GetRootControl( (WindowRef) m_popupWindowRef , m_peer->GetControlRefAddr() ) ; - if ( !m_peer->Ok() ) - CreateRootControl( (WindowRef) m_popupWindowRef , m_peer->GetControlRefAddr() ) ; - } - - // the root control level handler - MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ; - - // the frame window event handler - InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_popupWindowRef)) ) ; - // MacInstallTopLevelWindowEventHandler() ; - - if ( parent ) - parent->AddChild(this); - - return true; -} - -void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height) -{ - Rect bounds = { y , x , y + height , x + width } ; - verify_noerr(SetWindowBounds( (WindowRef) m_popupWindowRef, kWindowStructureRgn , &bounds )) ; - wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified -} - -void wxPopupWindow::DoGetPosition( int *x, int *y ) const - { - Rect bounds ; - - verify_noerr(GetWindowBounds((WindowRef) m_popupWindowRef, kWindowStructureRgn , &bounds )) ; + return wxPopupWindowBase::Create(parent) && + wxNonOwnedWindow::Create(parent, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + flags | wxPOPUP_WINDOW); - if (x) - *x = bounds.left ; - if (y) - *y = bounds.top ; - } - -void wxPopupWindow::DoGetSize( int *width, int *height ) const -{ - Rect bounds ; - - verify_noerr(GetWindowBounds((WindowRef) m_popupWindowRef, kWindowStructureRgn , &bounds )) ; - - if (width) - *width = bounds.right - bounds.left ; - if (height) - *height = bounds.bottom - bounds.top ; -} - -void wxPopupWindow::DoGetClientSize( int *width, int *height ) const -{ - Rect bounds ; - - verify_noerr(GetWindowBounds((WindowRef) m_popupWindowRef, kWindowContentRgn , &bounds )) ; - - if (width) - *width = bounds.right - bounds.left ; - if (height) - *height = bounds.bottom - bounds.top ; -} - -bool wxPopupWindow::Show(bool show) -{ - if ( !wxWindowMac::Show(show) ) - return false; - - if ( show ) - { - ::ShowWindow( (WindowRef)m_popupWindowRef ); - ::SelectWindow( (WindowRef)m_popupWindowRef ) ; - - // because apps expect a size event to occur at this moment - wxSizeEvent event(GetSize() , m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); - } - else - { - ::HideWindow( (WindowRef)m_popupWindowRef ); - } - return true; -} - -WXWindow wxPopupWindow::MacGetPopupWindowRef() const -{ - return m_popupWindowRef; } #endif // #if wxUSE_POPUPWIN -- 2.45.2