]> git.saurik.com Git - wxWidgets.git/commitdiff
corrected hiding/showing of native mac controls
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 28 Feb 2001 12:23:17 +0000 (12:23 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 28 Feb 2001 12:23:17 +0000 (12:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9440 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/control.h
include/wx/mac/window.h
src/mac/carbon/control.cpp
src/mac/carbon/uma.cpp
src/mac/carbon/window.cpp
src/mac/control.cpp
src/mac/uma.cpp
src/mac/window.cpp

index fb050681615c34a86f40558e5e8b5bdf39ad30c2..cf3288535d108b375a9eade1776a973c4d361dfe 100644 (file)
@@ -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 ;
index 3692c3cfb83e86fbd3e8a65b702f0c5a51ebcbfd..252b73fa8809bddc2d756393529de26fc3cd875d 100644 (file)
@@ -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() ;
index 0953356de7d7f53f1ed4bc45d2387e22e4935e98..15bc46b48e4a0f402107e7eb493af79085a69195 100644 (file)
@@ -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 ;
 }
index 78f6706ac3b50fcda36cd5f1040a8a2c5914d502..f34db6bc39a87e40076949b9f6af275ea26b00e6 100644 (file)
@@ -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 ) 
index 6aa38ca851694ac1760d6fe557e887c65e4d3535..b88a8a395948e5ce0ab9ff302d84789d427d923b 100644 (file)
@@ -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 ) ;
index 0953356de7d7f53f1ed4bc45d2387e22e4935e98..15bc46b48e4a0f402107e7eb493af79085a69195 100644 (file)
@@ -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 ;
 }
index 78f6706ac3b50fcda36cd5f1040a8a2c5914d502..f34db6bc39a87e40076949b9f6af275ea26b00e6 100644 (file)
@@ -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 ) 
index 6aa38ca851694ac1760d6fe557e887c65e4d3535..b88a8a395948e5ce0ab9ff302d84789d427d923b 100644 (file)
@@ -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 ) ;