fixes for popupwin
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,7 @@ class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPopupWindow() { }
|
wxPopupWindow() { }
|
||||||
|
~wxPopupWindow();
|
||||||
|
|
||||||
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
|
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
|
||||||
{ (void)Create(parent, flags); }
|
{ (void)Create(parent, flags); }
|
||||||
@@ -28,9 +29,16 @@ public:
|
|||||||
|
|
||||||
virtual bool Show(bool show = true);
|
virtual bool Show(bool show = true);
|
||||||
|
|
||||||
|
WXWindow MacGetPopupWindowRef() const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// popups handle the position like wxTopLevelWindow, not wxWindow
|
// popups handle the position like wxTopLevelWindow, not wxWindow
|
||||||
virtual void DoGetPosition(int *x, int *y) const;
|
virtual void DoGetPosition(int *x, int *y) const;
|
||||||
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||||
|
virtual void DoGetSize( int *width, int *height ) const;
|
||||||
|
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||||
|
|
||||||
|
WXWindow m_popupWindowRef ;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow)
|
||||||
};
|
};
|
||||||
|
@@ -1292,6 +1292,16 @@ private :
|
|||||||
|
|
||||||
// toplevel.cpp
|
// toplevel.cpp
|
||||||
|
|
||||||
|
class wxMacDeferredWindowDeleter : public wxObject
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
wxMacDeferredWindowDeleter( WindowRef windowRef );
|
||||||
|
virtual ~wxMacDeferredWindowDeleter();
|
||||||
|
|
||||||
|
protected :
|
||||||
|
WindowRef m_macWindow ;
|
||||||
|
} ;
|
||||||
|
|
||||||
ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
|
ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
|
||||||
|
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
|
@@ -120,7 +120,7 @@ wxWindowDC::wxWindowDC()
|
|||||||
wxWindowDC::wxWindowDC(wxWindow *window)
|
wxWindowDC::wxWindowDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
WindowRef rootwindow = (WindowRef) window->MacGetTopLevelWindowRef() ;
|
||||||
if (!rootwindow)
|
if (!rootwindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
window->MacWindowToRootWindow( &x , &y ) ;
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
m_macLocalOrigin.x = x ;
|
m_macLocalOrigin.x = x ;
|
||||||
m_macLocalOrigin.y = y ;
|
m_macLocalOrigin.y = y ;
|
||||||
m_macPort = UMAGetWindowPort( (WindowRef) rootwindow->MacGetWindowRef() ) ;
|
m_macPort = UMAGetWindowPort( rootwindow ) ;
|
||||||
|
|
||||||
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
// declarations
|
// declarations
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// CAUTION : This is not functional yet
|
// CAUTION : This is only experimental stuff right now
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// headers
|
// headers
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/popupwin.h"
|
#include "wx/popupwin.h"
|
||||||
|
#include "wx/tooltip.h"
|
||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
@@ -39,79 +40,131 @@
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
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 flags)
|
bool wxPopupWindow::Create(wxWindow *parent, int flags)
|
||||||
{
|
{
|
||||||
|
m_macIsUserPane = false ;
|
||||||
|
|
||||||
// popup windows are created hidden by default
|
// popup windows are created hidden by default
|
||||||
Hide();
|
Hide();
|
||||||
|
|
||||||
return wxPopupWindowBase::Create(parent) &&
|
if ( ! wxPopupWindowBase::Create(parent) )
|
||||||
wxWindow::Create(parent, wxID_ANY,
|
return false;
|
||||||
wxDefaultPosition, wxDefaultSize,
|
|
||||||
flags | wxPOPUP_WINDOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxPopupWindow::DoGetPosition(int *x, int *y) const
|
WindowClass wclass = kHelpWindowClass;
|
||||||
{
|
WindowAttributes attr = kWindowCompositingAttribute ;
|
||||||
// the position of a "top level" window such as this should be in
|
WindowRef parentWindow =(WindowRef) parent->MacGetTopLevelWindowRef();
|
||||||
// screen coordinates, not in the client ones which MSW gives us
|
|
||||||
// (because we are a child window)
|
|
||||||
wxPopupWindowBase::DoGetPosition(x, y);
|
|
||||||
|
|
||||||
GetParent()->ClientToScreen(x, y);
|
Rect bounds = { 0,0,0,0 };
|
||||||
}
|
OSStatus err = ::CreateNewWindow( wclass , attr , &bounds , (WindowRef*)&m_popupWindowRef ) ;
|
||||||
|
if ( err == noErr )
|
||||||
/*
|
|
||||||
WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const
|
|
||||||
{
|
|
||||||
// we only honour the border flags, the others don't make sense for us
|
|
||||||
WXDWORD style = wxWindow::MSWGetStyle(flags & wxBORDER_MASK, exstyle);
|
|
||||||
|
|
||||||
if ( exstyle )
|
|
||||||
{
|
{
|
||||||
// a popup window floats on top of everything
|
// SetWindowGroup( (WindowRef) m_popupWindowRef, GetWindowGroup(parentWindow)); // Put them in the same group so that their window layers are consistent
|
||||||
*exstyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
WXHWND wxPopupWindow::MSWGetParent() const
|
void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
// we must be a child of the desktop to be able to extend beyond the parent
|
Rect bounds = { y , x , y + height , x + width } ;
|
||||||
// window client area (like the comboboxes drop downs do)
|
verify_noerr(SetWindowBounds( (WindowRef) m_popupWindowRef, kWindowStructureRgn , &bounds )) ;
|
||||||
//
|
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
|
||||||
// NB: alternative implementation would be to use WS_POPUP instead of
|
}
|
||||||
// WS_CHILD but then showing a popup would deactivate the parent which
|
|
||||||
// is ugly and working around this, although possible, is even more
|
void wxPopupWindow::DoGetPosition( int *x, int *y ) const
|
||||||
// ugly
|
{
|
||||||
// GetDesktopWindow() is not always supported on WinCE, and if
|
Rect bounds ;
|
||||||
// it is, it often returns NULL.
|
|
||||||
#ifdef __WXWINCE__
|
verify_noerr(GetWindowBounds((WindowRef) m_popupWindowRef, kWindowStructureRgn , &bounds )) ;
|
||||||
return 0;
|
|
||||||
#else
|
if (x)
|
||||||
return (WXHWND)::GetDesktopWindow();
|
*x = bounds.left ;
|
||||||
#endif
|
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)
|
bool wxPopupWindow::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( !wxWindowMac::Show(show) )
|
if ( !wxWindowMac::Show(show) )
|
||||||
return false;
|
return false;
|
||||||
/*
|
|
||||||
if ( show )
|
|
||||||
{
|
|
||||||
// raise to top of z order
|
|
||||||
if (!::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
|
|
||||||
{
|
|
||||||
wxLogLastError(_T("SetWindowPos"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// and set it as the foreground window so the mouse can be captured
|
if (show)
|
||||||
::SetForegroundWindow(GetHwnd());
|
{
|
||||||
|
::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);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::HideWindow( (WindowRef)m_popupWindowRef );
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WXWindow wxPopupWindow::MacGetPopupWindowRef() const
|
||||||
|
{
|
||||||
|
return m_popupWindowRef;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // #if wxUSE_POPUPWIN
|
#endif // #if wxUSE_POPUPWIN
|
||||||
|
@@ -76,7 +76,6 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16
|
|||||||
BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
|
BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Carbon Events
|
// Carbon Events
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -909,22 +908,15 @@ void wxTopLevelWindowMac::Init()
|
|||||||
m_macFullScreenData = NULL ;
|
m_macFullScreenData = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxMacDeferredWindowDeleter : public wxObject
|
wxMacDeferredWindowDeleter::wxMacDeferredWindowDeleter( WindowRef windowRef )
|
||||||
{
|
{
|
||||||
public :
|
|
||||||
wxMacDeferredWindowDeleter( WindowRef windowRef )
|
|
||||||
{
|
|
||||||
m_macWindow = windowRef ;
|
m_macWindow = windowRef ;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~wxMacDeferredWindowDeleter()
|
wxMacDeferredWindowDeleter::~wxMacDeferredWindowDeleter()
|
||||||
{
|
{
|
||||||
UMADisposeWindow( (WindowRef) m_macWindow ) ;
|
UMADisposeWindow( (WindowRef) m_macWindow ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected :
|
|
||||||
WindowRef m_macWindow ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@@ -1064,16 +1056,19 @@ void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTopLevelWindowMacInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
|
||||||
|
{
|
||||||
|
InstallWindowEventHandler(window, GetwxMacTopLevelEventHandlerUPP(),
|
||||||
|
GetEventTypeCount(eventList), eventList, ref, handler );
|
||||||
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
|
void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
|
||||||
{
|
{
|
||||||
if ( m_macEventHandler != NULL )
|
if ( m_macEventHandler != NULL )
|
||||||
{
|
{
|
||||||
verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
|
verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
|
||||||
}
|
}
|
||||||
|
wxTopLevelWindowMacInstallTopLevelWindowEventHandler(MAC_WXHWND(m_macWindow),(EventHandlerRef *)&m_macEventHandler,this);
|
||||||
InstallWindowEventHandler(
|
|
||||||
MAC_WXHWND(m_macWindow), GetwxMacTopLevelEventHandlerUPP(),
|
|
||||||
GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacCreateRealWindow(
|
void wxTopLevelWindowMac::MacCreateRealWindow(
|
||||||
|
@@ -53,6 +53,10 @@
|
|||||||
#include "wx/caret.h"
|
#include "wx/caret.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_POPUPWIN
|
||||||
|
#include "wx/popupwin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
#include "wx/dnd.h"
|
#include "wx/dnd.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -3142,8 +3146,16 @@ WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
|
|||||||
while ( iter )
|
while ( iter )
|
||||||
{
|
{
|
||||||
if ( iter->IsTopLevel() )
|
if ( iter->IsTopLevel() )
|
||||||
return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ;
|
{
|
||||||
|
wxTopLevelWindow* toplevel = wxDynamicCast(iter,wxTopLevelWindow);
|
||||||
|
if ( toplevel )
|
||||||
|
return toplevel->MacGetWindowRef();
|
||||||
|
#if wxUSE_POPUPWIN
|
||||||
|
wxPopupWindow* popupwin = wxDynamicCast(iter,wxPopupWindow);
|
||||||
|
if ( popupwin )
|
||||||
|
return popupwin->MacGetPopupWindowRef();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
iter = iter->GetParent() ;
|
iter = iter->GetParent() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user