guard against an m_peer being NULL which is the case for a wxMenuBar, and here tools with introspection from python crash on OS X because they display all attributes in inheritance ...
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52217 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -946,6 +946,9 @@ wxMAC_DEFINE_PROC_GETTER( ControlActionUPP , wxMacLiveScrollbarActionProc ) ;
|
|||||||
// implementation
|
// implementation
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
// note that we are now guarding against m_peer being NULL which happens if the real class used
|
||||||
|
// is a wxMenuBar, as in wx inheritance this also is a wxWindow
|
||||||
|
|
||||||
WX_DECLARE_HASH_MAP(ControlRef, wxWindowMac*, wxPointerHash, wxPointerEqual, MacControlMap);
|
WX_DECLARE_HASH_MAP(ControlRef, wxWindowMac*, wxPointerHash, wxPointerEqual, MacControlMap);
|
||||||
|
|
||||||
static MacControlMap wxWinMacControlList;
|
static MacControlMap wxWinMacControlList;
|
||||||
@@ -1109,7 +1112,10 @@ wxWindowMac::~wxWindowMac()
|
|||||||
|
|
||||||
WXWidget wxWindowMac::GetHandle() const
|
WXWidget wxWindowMac::GetHandle() const
|
||||||
{
|
{
|
||||||
return (WXWidget) m_peer->GetControlRef() ;
|
if( m_peer )
|
||||||
|
return (WXWidget) m_peer->GetControlRef() ;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacInstallEventHandler( WXWidget control )
|
void wxWindowMac::MacInstallEventHandler( WXWidget control )
|
||||||
@@ -1282,7 +1288,8 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
|
|||||||
|
|
||||||
void wxWindowMac::MacUpdateControlFont()
|
void wxWindowMac::MacUpdateControlFont()
|
||||||
{
|
{
|
||||||
m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
|
if ( m_peer )
|
||||||
|
m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
|
||||||
// do not trigger refreshes upon invisible and possible partly created objects
|
// do not trigger refreshes upon invisible and possible partly created objects
|
||||||
if ( MacIsReallyShown() )
|
if ( MacIsReallyShown() )
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
@@ -1331,7 +1338,9 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
|
|||||||
void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
m_macBackgroundBrush = brush ;
|
m_macBackgroundBrush = brush ;
|
||||||
m_peer->SetBackground( brush ) ;
|
|
||||||
|
if ( m_peer )
|
||||||
|
m_peer->SetBackground( brush ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMac::MacCanFocus() const
|
bool wxWindowMac::MacCanFocus() const
|
||||||
@@ -1350,7 +1359,8 @@ bool wxWindowMac::MacCanFocus() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UInt32 features = 0 ;
|
UInt32 features = 0 ;
|
||||||
m_peer->GetFeatures( &features ) ;
|
if ( m_peer )
|
||||||
|
m_peer->GetFeatures( &features ) ;
|
||||||
|
|
||||||
return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ;
|
return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ;
|
||||||
}
|
}
|
||||||
@@ -1358,8 +1368,11 @@ bool wxWindowMac::MacCanFocus() const
|
|||||||
|
|
||||||
void wxWindowMac::SetFocus()
|
void wxWindowMac::SetFocus()
|
||||||
{
|
{
|
||||||
|
if ( m_peer == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( !AcceptsFocus() )
|
if ( !AcceptsFocus() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
wxWindow* former = FindFocus() ;
|
wxWindow* former = FindFocus() ;
|
||||||
if ( former == this )
|
if ( former == this )
|
||||||
@@ -1371,6 +1384,8 @@ void wxWindowMac::SetFocus()
|
|||||||
wxLogTrace(_T("Focus"), _T("SetFocus(%p)"), wx_static_cast(void*, this));
|
wxLogTrace(_T("Focus"), _T("SetFocus(%p)"), wx_static_cast(void*, this));
|
||||||
|
|
||||||
OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
|
OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
|
||||||
|
wxLogTrace(_T("Focus"), _T("m_peer->SetFocus received %d"), err);
|
||||||
|
|
||||||
if ( err == errCouldntSetFocus )
|
if ( err == errCouldntSetFocus )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
@@ -1498,8 +1513,9 @@ bool wxWindowMac::MacGetBoundsForControl(
|
|||||||
// Get window size (not client size)
|
// Get window size (not client size)
|
||||||
void wxWindowMac::DoGetSize(int *x, int *y) const
|
void wxWindowMac::DoGetSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
Rect bounds ;
|
Rect bounds = { 0,0,0,0 };
|
||||||
m_peer->GetRect( &bounds ) ;
|
if( m_peer )
|
||||||
|
m_peer->GetRect( &bounds ) ;
|
||||||
|
|
||||||
if (x)
|
if (x)
|
||||||
*x = bounds.right - bounds.left + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
*x = bounds.right - bounds.left + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
||||||
@@ -1510,8 +1526,9 @@ void wxWindowMac::DoGetSize(int *x, int *y) const
|
|||||||
// get the position of the bounds of this window in client coordinates of its parent
|
// get the position of the bounds of this window in client coordinates of its parent
|
||||||
void wxWindowMac::DoGetPosition(int *x, int *y) const
|
void wxWindowMac::DoGetPosition(int *x, int *y) const
|
||||||
{
|
{
|
||||||
Rect bounds ;
|
Rect bounds = { 0,0,0,0 };
|
||||||
m_peer->GetRect( &bounds ) ;
|
if ( m_peer )
|
||||||
|
m_peer->GetRect( &bounds ) ;
|
||||||
|
|
||||||
int x1 = bounds.left ;
|
int x1 = bounds.left ;
|
||||||
int y1 = bounds.top ;
|
int y1 = bounds.top ;
|
||||||
@@ -1710,7 +1727,7 @@ void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , in
|
|||||||
{
|
{
|
||||||
RgnHandle rgn = NewRgn() ;
|
RgnHandle rgn = NewRgn() ;
|
||||||
|
|
||||||
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
if ( m_peer != NULL && m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
||||||
{
|
{
|
||||||
Rect structure, content ;
|
Rect structure, content ;
|
||||||
|
|
||||||
@@ -1736,7 +1753,7 @@ wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const
|
|||||||
wxSize sizeTotal = size;
|
wxSize sizeTotal = size;
|
||||||
|
|
||||||
RgnHandle rgn = NewRgn() ;
|
RgnHandle rgn = NewRgn() ;
|
||||||
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
if ( m_peer != NULL && m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
||||||
{
|
{
|
||||||
Rect content, structure ;
|
Rect content, structure ;
|
||||||
GetRegionBounds( rgn , &content ) ;
|
GetRegionBounds( rgn , &content ) ;
|
||||||
@@ -1761,13 +1778,16 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const
|
|||||||
{
|
{
|
||||||
int ww, hh;
|
int ww, hh;
|
||||||
|
|
||||||
RgnHandle rgn = NewRgn() ;
|
Rect content = { 0,0,0,0 };
|
||||||
Rect content ;
|
if ( m_peer )
|
||||||
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
{
|
||||||
GetRegionBounds( rgn , &content ) ;
|
RgnHandle rgn = NewRgn() ;
|
||||||
else
|
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
||||||
m_peer->GetRect( &content ) ;
|
GetRegionBounds( rgn , &content ) ;
|
||||||
DisposeRgn( rgn ) ;
|
else
|
||||||
|
m_peer->GetRect( &content ) ;
|
||||||
|
DisposeRgn( rgn ) ;
|
||||||
|
}
|
||||||
|
|
||||||
ww = content.right - content.left ;
|
ww = content.right - content.left ;
|
||||||
hh = content.bottom - content.top ;
|
hh = content.bottom - content.top ;
|
||||||
@@ -1989,7 +2009,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
if ( actualWidth != former_w || actualHeight != former_h )
|
if ( actualWidth != former_w || actualHeight != former_h )
|
||||||
doResize = true ;
|
doResize = true ;
|
||||||
|
|
||||||
if ( doMove || doResize )
|
if ( m_peer != NULL && ( doMove || doResize ) )
|
||||||
{
|
{
|
||||||
// as the borders are drawn outside the native control, we adjust now
|
// as the borders are drawn outside the native control, we adjust now
|
||||||
|
|
||||||
@@ -2034,7 +2054,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
|
|
||||||
wxSize wxWindowMac::DoGetBestSize() const
|
wxSize wxWindowMac::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
if ( m_macIsUserPane || IsTopLevel() )
|
if ( m_peer == NULL || m_macIsUserPane || IsTopLevel() )
|
||||||
return wxWindowBase::DoGetBestSize() ;
|
return wxWindowBase::DoGetBestSize() ;
|
||||||
|
|
||||||
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
Rect bestsize = { 0 , 0 , 0 , 0 } ;
|
||||||
@@ -2146,19 +2166,23 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
|
|
||||||
wxPoint wxWindowMac::GetClientAreaOrigin() const
|
wxPoint wxWindowMac::GetClientAreaOrigin() const
|
||||||
{
|
{
|
||||||
RgnHandle rgn = NewRgn() ;
|
Rect content = { 0,0,0,0 };
|
||||||
Rect content ;
|
if ( m_peer )
|
||||||
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
|
||||||
{
|
{
|
||||||
GetRegionBounds( rgn , &content ) ;
|
RgnHandle rgn = NewRgn() ;
|
||||||
}
|
|
||||||
else
|
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
|
||||||
{
|
{
|
||||||
content.left =
|
GetRegionBounds( rgn , &content ) ;
|
||||||
content.top = 0 ;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
content.left =
|
||||||
|
content.top = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
DisposeRgn( rgn ) ;
|
DisposeRgn( rgn ) ;
|
||||||
|
}
|
||||||
|
|
||||||
return wxPoint( content.left + MacGetLeftBorderSize() , content.top + MacGetTopBorderSize() );
|
return wxPoint( content.left + MacGetLeftBorderSize() , content.top + MacGetTopBorderSize() );
|
||||||
}
|
}
|
||||||
@@ -2218,7 +2242,8 @@ bool wxWindowMac::Enable(bool enable)
|
|||||||
if ( !wxWindowBase::Enable(enable) )
|
if ( !wxWindowBase::Enable(enable) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_peer->Enable( enable ) ;
|
if ( m_peer )
|
||||||
|
m_peer->Enable( enable ) ;
|
||||||
|
|
||||||
if ( former != MacIsReallyEnabled() )
|
if ( former != MacIsReallyEnabled() )
|
||||||
MacPropagateEnabledStateChanged() ;
|
MacPropagateEnabledStateChanged() ;
|
||||||
@@ -2331,12 +2356,18 @@ bool wxWindowMac::MacIsReallyShown()
|
|||||||
|
|
||||||
bool wxWindowMac::MacIsReallyEnabled()
|
bool wxWindowMac::MacIsReallyEnabled()
|
||||||
{
|
{
|
||||||
return m_peer->IsEnabled() ;
|
if ( m_peer )
|
||||||
|
return m_peer->IsEnabled() ;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMac::MacIsReallyHilited()
|
bool wxWindowMac::MacIsReallyHilited()
|
||||||
{
|
{
|
||||||
return m_peer->IsActive();
|
if ( m_peer )
|
||||||
|
return m_peer->IsActive();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacFlashInvalidAreas()
|
void wxWindowMac::MacFlashInvalidAreas()
|
||||||
@@ -2348,16 +2379,24 @@ void wxWindowMac::MacFlashInvalidAreas()
|
|||||||
|
|
||||||
int wxWindowMac::GetCharHeight() const
|
int wxWindowMac::GetCharHeight() const
|
||||||
{
|
{
|
||||||
wxClientDC dc( (wxWindow*)this ) ;
|
if ( m_peer )
|
||||||
|
{
|
||||||
return dc.GetCharHeight() ;
|
wxClientDC dc( (wxWindow*)this ) ;
|
||||||
|
return dc.GetCharHeight() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 16; // an arbitrary amount, just to avoid problems with introspection on a wxMenuBar
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxWindowMac::GetCharWidth() const
|
int wxWindowMac::GetCharWidth() const
|
||||||
{
|
{
|
||||||
wxClientDC dc( (wxWindow*)this ) ;
|
if ( m_peer )
|
||||||
|
{
|
||||||
return dc.GetCharWidth() ;
|
wxClientDC dc( (wxWindow*)this ) ;
|
||||||
|
return dc.GetCharWidth() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 8; // an arbitrary amount, just to avoid problems with introspection on a wxMenuBar
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
|
void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
|
||||||
@@ -2547,7 +2586,7 @@ void wxWindowMac::MacPaintGrowBox()
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
if ( MacHasScrollBarCorner() )
|
if ( m_peer != NULL && MacHasScrollBarCorner() )
|
||||||
{
|
{
|
||||||
Rect rect ;
|
Rect rect ;
|
||||||
|
|
||||||
@@ -2579,7 +2618,7 @@ void wxWindowMac::MacPaintGrowBox()
|
|||||||
|
|
||||||
void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
||||||
{
|
{
|
||||||
if ( IsTopLevel() )
|
if ( m_peer == NULL || IsTopLevel() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
Rect rect ;
|
Rect rect ;
|
||||||
@@ -2725,12 +2764,13 @@ void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible,
|
|||||||
// Does a physical scroll
|
// Does a physical scroll
|
||||||
void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
||||||
{
|
{
|
||||||
if ( dx == 0 && dy == 0 )
|
if ( dx == 0 && dy == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
int width , height ;
|
int width , height ;
|
||||||
GetClientSize( &width , &height ) ;
|
GetClientSize( &width , &height ) ;
|
||||||
|
|
||||||
|
if ( m_peer != NULL )
|
||||||
{
|
{
|
||||||
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
||||||
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
||||||
@@ -2852,7 +2892,7 @@ void wxWindowMac::OnSetFocus( wxFocusEvent& event )
|
|||||||
//wxChildFocusEvent eventFocus(this);
|
//wxChildFocusEvent eventFocus(this);
|
||||||
//(void)GetEventHandler()->ProcessEvent(eventFocus);
|
//(void)GetEventHandler()->ProcessEvent(eventFocus);
|
||||||
|
|
||||||
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
|
if ( m_peer != NULL && MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
GetParent()->Refresh() ;
|
GetParent()->Refresh() ;
|
||||||
@@ -2901,13 +2941,15 @@ void wxWindowMac::OnInternalIdle()
|
|||||||
// Raise the window to the top of the Z order
|
// Raise the window to the top of the Z order
|
||||||
void wxWindowMac::Raise()
|
void wxWindowMac::Raise()
|
||||||
{
|
{
|
||||||
m_peer->SetZOrder( true , NULL ) ;
|
if( m_peer )
|
||||||
|
m_peer->SetZOrder( true , NULL ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lower the window to the bottom of the Z order
|
// Lower the window to the bottom of the Z order
|
||||||
void wxWindowMac::Lower()
|
void wxWindowMac::Lower()
|
||||||
{
|
{
|
||||||
m_peer->SetZOrder( false , NULL ) ;
|
if ( m_peer )
|
||||||
|
m_peer->SetZOrder( false , NULL ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static wxWindow *gs_lastWhich = NULL;
|
// static wxWindow *gs_lastWhich = NULL;
|
||||||
@@ -2966,6 +3008,8 @@ void wxWindowMac::ClearBackground()
|
|||||||
|
|
||||||
void wxWindowMac::Update()
|
void wxWindowMac::Update()
|
||||||
{
|
{
|
||||||
|
if ( m_peer == NULL )
|
||||||
|
return ;
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
|
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
|
||||||
if (top)
|
if (top)
|
||||||
@@ -3028,6 +3072,9 @@ void wxWindowMac::MacUpdateClippedRects() const
|
|||||||
{
|
{
|
||||||
if ( m_cachedClippedRectValid )
|
if ( m_cachedClippedRectValid )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
if ( m_peer == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
// includeOuterStructures is true if we try to draw somthing like a focus ring etc.
|
// includeOuterStructures is true if we try to draw somthing like a focus ring etc.
|
||||||
// also a window dc uses this, in this case we only clip in the hierarchy for hard
|
// also a window dc uses this, in this case we only clip in the hierarchy for hard
|
||||||
@@ -3590,12 +3637,14 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// copied from MacPostControlCreate
|
// copied from MacPostControlCreate
|
||||||
ControlRef container = (ControlRef) GetParent()->GetHandle() ;
|
if ( m_peer )
|
||||||
|
{
|
||||||
|
ControlRef container = (ControlRef) GetParent()->GetHandle() ;
|
||||||
|
|
||||||
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
|
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
|
||||||
|
|
||||||
::EmbedControl( m_peer->GetControlRef() , container ) ;
|
|
||||||
|
|
||||||
|
::EmbedControl( m_peer->GetControlRef() , container ) ;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user