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