From c809f3be86c79dc44854433fec4ccfc030d4f7b9 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 28 Feb 2001 12:23:17 +0000 Subject: [PATCH] corrected hiding/showing of native mac controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9440 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/control.h | 1 + include/wx/mac/window.h | 1 + src/mac/carbon/control.cpp | 30 +++++++++++++++++++++++++----- src/mac/carbon/uma.cpp | 34 ++++++++++++++++++++++------------ src/mac/carbon/window.cpp | 18 ++++++++++++++++-- src/mac/control.cpp | 30 +++++++++++++++++++++++++----- src/mac/uma.cpp | 34 ++++++++++++++++++++++------------ src/mac/window.cpp | 18 ++++++++++++++++-- 8 files changed, 128 insertions(+), 38 deletions(-) diff --git a/include/wx/mac/control.h b/include/wx/mac/control.h index fb05068161..cf3288535d 100644 --- a/include/wx/mac/control.h +++ b/include/wx/mac/control.h @@ -103,6 +103,7 @@ protected: protected: // For controls like radiobuttons which are really composite ControlHandle m_macControl ; + bool m_macControlIsShown ; wxList m_subControls; int m_macHorizontalBorder ; int m_macVerticalBorder ; diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index 3692c3cfb8..252b73fa88 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -255,6 +255,7 @@ public : static long MacRemoveBordersFromStyle( long style ) ; virtual void MacSuperChangedPosition() ; virtual void MacSuperShown( bool show ) ; + bool MacIsReallyShown() const ; /* bool MacSetupFocusPort() ; bool MacSetupDrawingPort() ; diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 0953356de7..15bc46b48e 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -266,6 +266,7 @@ void wxControl::MacPostControlCreate() ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; ::UMAEmbedControl( m_macControl , container ) ; + m_macControlIsShown = true ; MacAdjustControlRect() ; wxAssociateControlWithMacControl( m_macControl , this ) ; } @@ -416,12 +417,19 @@ void wxControl::MacSuperShown( bool show ) { if ( !show ) { - ::UMAHideControl( m_macControl ) ; + if ( m_macControlIsShown ) + { + ::UMAHideControl( m_macControl ) ; + m_macControlIsShown = false ; + } } else { - if ( m_isShown ) + if ( MacIsReallyShown() && !m_macControlIsShown ) + { ::UMAShowControl( m_macControl ) ; + m_macControlIsShown = true ; + } } } @@ -541,10 +549,22 @@ bool wxControl::Show(bool show) if ( m_macControl ) { - if ( show ) - ::UMAShowControl( m_macControl ) ; + if ( !show ) + { + if ( m_macControlIsShown ) + { + ::UMAHideControl( m_macControl ) ; + m_macControlIsShown = false ; + } + } else - ::UMAHideControl( m_macControl ) ; + { + if ( MacIsReallyShown() && !m_macControlIsShown ) + { + ::UMAShowControl( m_macControl ) ; + m_macControlIsShown = true ; + } + } } return TRUE ; } diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 78f6706ac3..f34db6bc39 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -667,11 +667,11 @@ void UMAHideControl (ControlHandle theControl) { if ( UMAHasAppearance() ) { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } else { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } } @@ -1359,16 +1359,26 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) { // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // if ( inActivate != isHightlited ) - HiliteWindow( inWindowRef , inActivate ) ; - ControlHandle control = NULL ; - UMAGetRootControl( inWindowRef , & control ) ; - if ( control ) - { - if ( inActivate ) - UMAActivateControl( control ) ; - else - UMADeactivateControl( control ) ; - } + GrafPtr port ; + GetPort( &port ) ; +#if TARGET_CARBON + SetPort( GetWindowPort( inWindowRef ) ) ; +#else + SetPort( inWindowRef ) ; +#endif + SetOrigin( 0 , 0 ) ; + HiliteWindow( inWindowRef , inActivate ) ; + ControlHandle control = NULL ; + UMAGetRootControl( inWindowRef , & control ) ; + if ( control ) + { + if ( inActivate ) + UMAActivateControl( control ) ; + else + UMADeactivateControl( control ) ; + } + SetPort( port ) ; + wxDC::MacInvalidateSetup() ; } } OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 6aa38ca851..b88a8a3959 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -32,6 +32,7 @@ #include "wx/notebook.h" #include "wx/tabctrl.h" #include "wx/tooltip.h" +#include "wx/statusbr.h" // TODO remove the line below, just for lookup-up convenience CS #include "wx/window.h" @@ -194,7 +195,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, m_width = WidthDefault( size.x ); m_height = HeightDefault( size.y ) ; - if ( ! IsKindOf( CLASSINFO ( wxControl ) ) ) + if ( ! IsKindOf( CLASSINFO ( wxControl ) ) && ! IsKindOf( CLASSINFO( wxStatusBar ) ) ) { MacCreateScrollBars( style ) ; } @@ -584,7 +585,8 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) if ( doResize ) ::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height , true); - // the OS takes care of invalidating and erasing + // the OS takes care of invalidating and erasing the new area + // we have erased the old one if ( IsKindOf( CLASSINFO( wxFrame ) ) ) { @@ -710,6 +712,18 @@ void wxWindow::MacSuperShown( bool show ) } } +bool wxWindow::MacIsReallyShown() const +{ + bool status = m_isShown ; + wxWindow * win = this ; + while ( status && win->m_parent != NULL ) + { + win = win->m_parent ; + status = win->m_isShown ; + } + return status ; +} + int wxWindow::GetCharHeight() const { wxClientDC dc ( (wxWindow*)this ) ; diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 0953356de7..15bc46b48e 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -266,6 +266,7 @@ void wxControl::MacPostControlCreate() ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; ::UMAEmbedControl( m_macControl , container ) ; + m_macControlIsShown = true ; MacAdjustControlRect() ; wxAssociateControlWithMacControl( m_macControl , this ) ; } @@ -416,12 +417,19 @@ void wxControl::MacSuperShown( bool show ) { if ( !show ) { - ::UMAHideControl( m_macControl ) ; + if ( m_macControlIsShown ) + { + ::UMAHideControl( m_macControl ) ; + m_macControlIsShown = false ; + } } else { - if ( m_isShown ) + if ( MacIsReallyShown() && !m_macControlIsShown ) + { ::UMAShowControl( m_macControl ) ; + m_macControlIsShown = true ; + } } } @@ -541,10 +549,22 @@ bool wxControl::Show(bool show) if ( m_macControl ) { - if ( show ) - ::UMAShowControl( m_macControl ) ; + if ( !show ) + { + if ( m_macControlIsShown ) + { + ::UMAHideControl( m_macControl ) ; + m_macControlIsShown = false ; + } + } else - ::UMAHideControl( m_macControl ) ; + { + if ( MacIsReallyShown() && !m_macControlIsShown ) + { + ::UMAShowControl( m_macControl ) ; + m_macControlIsShown = true ; + } + } } return TRUE ; } diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 78f6706ac3..f34db6bc39 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -667,11 +667,11 @@ void UMAHideControl (ControlHandle theControl) { if ( UMAHasAppearance() ) { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } else { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } } @@ -1359,16 +1359,26 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) { // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // if ( inActivate != isHightlited ) - HiliteWindow( inWindowRef , inActivate ) ; - ControlHandle control = NULL ; - UMAGetRootControl( inWindowRef , & control ) ; - if ( control ) - { - if ( inActivate ) - UMAActivateControl( control ) ; - else - UMADeactivateControl( control ) ; - } + GrafPtr port ; + GetPort( &port ) ; +#if TARGET_CARBON + SetPort( GetWindowPort( inWindowRef ) ) ; +#else + SetPort( inWindowRef ) ; +#endif + SetOrigin( 0 , 0 ) ; + HiliteWindow( inWindowRef , inActivate ) ; + ControlHandle control = NULL ; + UMAGetRootControl( inWindowRef , & control ) ; + if ( control ) + { + if ( inActivate ) + UMAActivateControl( control ) ; + else + UMADeactivateControl( control ) ; + } + SetPort( port ) ; + wxDC::MacInvalidateSetup() ; } } OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 6aa38ca851..b88a8a3959 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -32,6 +32,7 @@ #include "wx/notebook.h" #include "wx/tabctrl.h" #include "wx/tooltip.h" +#include "wx/statusbr.h" // TODO remove the line below, just for lookup-up convenience CS #include "wx/window.h" @@ -194,7 +195,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, m_width = WidthDefault( size.x ); m_height = HeightDefault( size.y ) ; - if ( ! IsKindOf( CLASSINFO ( wxControl ) ) ) + if ( ! IsKindOf( CLASSINFO ( wxControl ) ) && ! IsKindOf( CLASSINFO( wxStatusBar ) ) ) { MacCreateScrollBars( style ) ; } @@ -584,7 +585,8 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) if ( doResize ) ::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height , true); - // the OS takes care of invalidating and erasing + // the OS takes care of invalidating and erasing the new area + // we have erased the old one if ( IsKindOf( CLASSINFO( wxFrame ) ) ) { @@ -710,6 +712,18 @@ void wxWindow::MacSuperShown( bool show ) } } +bool wxWindow::MacIsReallyShown() const +{ + bool status = m_isShown ; + wxWindow * win = this ; + while ( status && win->m_parent != NULL ) + { + win = win->m_parent ; + status = win->m_isShown ; + } + return status ; +} + int wxWindow::GetCharHeight() const { wxClientDC dc ( (wxWindow*)this ) ; -- 2.45.2