corrected hiding/showing of native mac controls

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9440 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2001-02-28 12:23:17 +00:00
parent 19ff2a7bd5
commit c809f3be86
8 changed files with 128 additions and 38 deletions

View File

@@ -103,6 +103,7 @@ protected:
protected: protected:
// For controls like radiobuttons which are really composite // For controls like radiobuttons which are really composite
ControlHandle m_macControl ; ControlHandle m_macControl ;
bool m_macControlIsShown ;
wxList m_subControls; wxList m_subControls;
int m_macHorizontalBorder ; int m_macHorizontalBorder ;
int m_macVerticalBorder ; int m_macVerticalBorder ;

View File

@@ -255,6 +255,7 @@ public :
static long MacRemoveBordersFromStyle( long style ) ; static long MacRemoveBordersFromStyle( long style ) ;
virtual void MacSuperChangedPosition() ; virtual void MacSuperChangedPosition() ;
virtual void MacSuperShown( bool show ) ; virtual void MacSuperShown( bool show ) ;
bool MacIsReallyShown() const ;
/* /*
bool MacSetupFocusPort() ; bool MacSetupFocusPort() ;
bool MacSetupDrawingPort() ; bool MacSetupDrawingPort() ;

View File

@@ -266,6 +266,7 @@ void wxControl::MacPostControlCreate()
ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
::UMAEmbedControl( m_macControl , container ) ; ::UMAEmbedControl( m_macControl , container ) ;
m_macControlIsShown = true ;
MacAdjustControlRect() ; MacAdjustControlRect() ;
wxAssociateControlWithMacControl( m_macControl , this ) ; wxAssociateControlWithMacControl( m_macControl , this ) ;
} }
@@ -416,12 +417,19 @@ void wxControl::MacSuperShown( bool show )
{ {
if ( !show ) if ( !show )
{ {
::UMAHideControl( m_macControl ) ; if ( m_macControlIsShown )
{
::UMAHideControl( m_macControl ) ;
m_macControlIsShown = false ;
}
} }
else else
{ {
if ( m_isShown ) if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( m_macControl ) ; ::UMAShowControl( m_macControl ) ;
m_macControlIsShown = true ;
}
} }
} }
@@ -541,10 +549,22 @@ bool wxControl::Show(bool show)
if ( m_macControl ) if ( m_macControl )
{ {
if ( show ) if ( !show )
::UMAShowControl( m_macControl ) ; {
if ( m_macControlIsShown )
{
::UMAHideControl( m_macControl ) ;
m_macControlIsShown = false ;
}
}
else else
::UMAHideControl( m_macControl ) ; {
if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( m_macControl ) ;
m_macControlIsShown = true ;
}
}
} }
return TRUE ; return TRUE ;
} }

View File

@@ -667,11 +667,11 @@ void UMAHideControl (ControlHandle theControl)
{ {
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::HideControl( theControl ) ; ::HideControl( theControl ) ;
} }
else else
{ {
::HideControl( theControl ) ; ::HideControl( theControl ) ;
} }
} }
@@ -1359,16 +1359,26 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
{ {
// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
// if ( inActivate != isHightlited ) // if ( inActivate != isHightlited )
HiliteWindow( inWindowRef , inActivate ) ; GrafPtr port ;
ControlHandle control = NULL ; GetPort( &port ) ;
UMAGetRootControl( inWindowRef , & control ) ; #if TARGET_CARBON
if ( control ) SetPort( GetWindowPort( inWindowRef ) ) ;
{ #else
if ( inActivate ) SetPort( inWindowRef ) ;
UMAActivateControl( control ) ; #endif
else SetOrigin( 0 , 0 ) ;
UMADeactivateControl( control ) ; 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 ) OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )

View File

@@ -32,6 +32,7 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/statusbr.h"
// TODO remove the line below, just for lookup-up convenience CS // TODO remove the line below, just for lookup-up convenience CS
#include "wx/window.h" #include "wx/window.h"
@@ -194,7 +195,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
m_width = WidthDefault( size.x ); m_width = WidthDefault( size.x );
m_height = HeightDefault( size.y ) ; m_height = HeightDefault( size.y ) ;
if ( ! IsKindOf( CLASSINFO ( wxControl ) ) ) if ( ! IsKindOf( CLASSINFO ( wxControl ) ) && ! IsKindOf( CLASSINFO( wxStatusBar ) ) )
{ {
MacCreateScrollBars( style ) ; MacCreateScrollBars( style ) ;
} }
@@ -584,7 +585,8 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if ( doResize ) if ( doResize )
::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height , true); ::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 ) ) ) 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 int wxWindow::GetCharHeight() const
{ {
wxClientDC dc ( (wxWindow*)this ) ; wxClientDC dc ( (wxWindow*)this ) ;

View File

@@ -266,6 +266,7 @@ void wxControl::MacPostControlCreate()
ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
::UMAEmbedControl( m_macControl , container ) ; ::UMAEmbedControl( m_macControl , container ) ;
m_macControlIsShown = true ;
MacAdjustControlRect() ; MacAdjustControlRect() ;
wxAssociateControlWithMacControl( m_macControl , this ) ; wxAssociateControlWithMacControl( m_macControl , this ) ;
} }
@@ -416,12 +417,19 @@ void wxControl::MacSuperShown( bool show )
{ {
if ( !show ) if ( !show )
{ {
::UMAHideControl( m_macControl ) ; if ( m_macControlIsShown )
{
::UMAHideControl( m_macControl ) ;
m_macControlIsShown = false ;
}
} }
else else
{ {
if ( m_isShown ) if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( m_macControl ) ; ::UMAShowControl( m_macControl ) ;
m_macControlIsShown = true ;
}
} }
} }
@@ -541,10 +549,22 @@ bool wxControl::Show(bool show)
if ( m_macControl ) if ( m_macControl )
{ {
if ( show ) if ( !show )
::UMAShowControl( m_macControl ) ; {
if ( m_macControlIsShown )
{
::UMAHideControl( m_macControl ) ;
m_macControlIsShown = false ;
}
}
else else
::UMAHideControl( m_macControl ) ; {
if ( MacIsReallyShown() && !m_macControlIsShown )
{
::UMAShowControl( m_macControl ) ;
m_macControlIsShown = true ;
}
}
} }
return TRUE ; return TRUE ;
} }

View File

@@ -667,11 +667,11 @@ void UMAHideControl (ControlHandle theControl)
{ {
if ( UMAHasAppearance() ) if ( UMAHasAppearance() )
{ {
::HideControl( theControl ) ; ::HideControl( theControl ) ;
} }
else else
{ {
::HideControl( theControl ) ; ::HideControl( theControl ) ;
} }
} }
@@ -1359,16 +1359,26 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
{ {
// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
// if ( inActivate != isHightlited ) // if ( inActivate != isHightlited )
HiliteWindow( inWindowRef , inActivate ) ; GrafPtr port ;
ControlHandle control = NULL ; GetPort( &port ) ;
UMAGetRootControl( inWindowRef , & control ) ; #if TARGET_CARBON
if ( control ) SetPort( GetWindowPort( inWindowRef ) ) ;
{ #else
if ( inActivate ) SetPort( inWindowRef ) ;
UMAActivateControl( control ) ; #endif
else SetOrigin( 0 , 0 ) ;
UMADeactivateControl( control ) ; 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 ) OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )

View File

@@ -32,6 +32,7 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/tabctrl.h" #include "wx/tabctrl.h"
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/statusbr.h"
// TODO remove the line below, just for lookup-up convenience CS // TODO remove the line below, just for lookup-up convenience CS
#include "wx/window.h" #include "wx/window.h"
@@ -194,7 +195,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
m_width = WidthDefault( size.x ); m_width = WidthDefault( size.x );
m_height = HeightDefault( size.y ) ; m_height = HeightDefault( size.y ) ;
if ( ! IsKindOf( CLASSINFO ( wxControl ) ) ) if ( ! IsKindOf( CLASSINFO ( wxControl ) ) && ! IsKindOf( CLASSINFO( wxStatusBar ) ) )
{ {
MacCreateScrollBars( style ) ; MacCreateScrollBars( style ) ;
} }
@@ -584,7 +585,8 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if ( doResize ) if ( doResize )
::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height , true); ::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 ) ) ) 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 int wxWindow::GetCharHeight() const
{ {
wxClientDC dc ( (wxWindow*)this ) ; wxClientDC dc ( (wxWindow*)this ) ;