From: Stefan Csomor Date: Fri, 7 Mar 2003 10:25:11 +0000 (+0000) Subject: show and hide implementation added X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ab89a5b59b104dcbac4d30217209dc873c07d036 show and hide implementation added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/mac/glcanvas.h b/include/wx/mac/glcanvas.h index dae7bff782..1f7281a7ea 100644 --- a/include/wx/mac/glcanvas.h +++ b/include/wx/mac/glcanvas.h @@ -109,6 +109,7 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow void SwapBuffers(); void UpdateContext(); void SetViewport(); + virtual bool Show(bool show = TRUE) ; // Unlike some other platforms, this must get called if you override it. // It sets the viewport correctly and update the context. @@ -117,13 +118,15 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow virtual void MacSuperChangedPosition() ; virtual void MacTopLevelWindowChangedPosition() ; + virtual void MacSuperShown( bool show ) ; + void MacUpdateView() ; inline wxGLContext* GetContext() const { return m_glContext; } protected: wxGLContext* m_glContext; - + bool m_macCanvasIsShown ; DECLARE_EVENT_TABLE() }; diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp index 345fc2aeaf..aca2b5be13 100644 --- a/src/mac/carbon/glcanvas.cpp +++ b/src/mac/carbon/glcanvas.cpp @@ -224,7 +224,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); m_glContext = new wxGLContext(fmt, this, palette, shared); - + m_macCanvasIsShown = true ; aglDestroyPixelFormat(fmt); return true; @@ -249,18 +249,29 @@ void wxGLCanvas::SetViewport() int x = 0 ; int y = 0 ; - MacClientToRootWindow( &x , &y ) ; - int width, height; - GetClientSize(& width, & height); - Rect bounds ; - GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; - GLint parms[4] ; - parms[0] = x ; - parms[1] = bounds.bottom - bounds.top - ( y + height ) ; - parms[2] = width ; - parms[3] = height ; + wxWindow* iter = this ; + while( iter->GetParent() ) + { + iter = iter->GetParent() ; + } - aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + if ( iter && iter->IsTopLevel() ) + { + MacClientToRootWindow( &x , &y ) ; + int width, height; + GetClientSize(& width, & height); + Rect bounds ; + GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; + GLint parms[4] ; + parms[0] = x ; + parms[1] = bounds.bottom - bounds.top - ( y + height ) ; + parms[2] = width ; + parms[3] = height ; + + if ( !m_macCanvasIsShown ) + parms[0] += 20000 ; + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + } } void wxGLCanvas::OnSize(wxSizeEvent& event) @@ -304,6 +315,51 @@ void wxGLCanvas::SetColour(const char *colour) m_glContext->SetColour(colour); } +bool wxGLCanvas::Show(bool show) +{ + if ( !wxWindow::Show( show ) ) + return FALSE ; + + if ( !show ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( MacIsReallyShown() && !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } + return TRUE ; +} + +void wxGLCanvas::MacSuperShown( bool show ) +{ + if ( !show ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( MacIsReallyShown() && !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } + + wxWindow::MacSuperShown( show ) ; +} //--------------------------------------------------------------------------- // wxGLApp diff --git a/src/mac/glcanvas.cpp b/src/mac/glcanvas.cpp index 345fc2aeaf..aca2b5be13 100644 --- a/src/mac/glcanvas.cpp +++ b/src/mac/glcanvas.cpp @@ -224,7 +224,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); m_glContext = new wxGLContext(fmt, this, palette, shared); - + m_macCanvasIsShown = true ; aglDestroyPixelFormat(fmt); return true; @@ -249,18 +249,29 @@ void wxGLCanvas::SetViewport() int x = 0 ; int y = 0 ; - MacClientToRootWindow( &x , &y ) ; - int width, height; - GetClientSize(& width, & height); - Rect bounds ; - GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; - GLint parms[4] ; - parms[0] = x ; - parms[1] = bounds.bottom - bounds.top - ( y + height ) ; - parms[2] = width ; - parms[3] = height ; + wxWindow* iter = this ; + while( iter->GetParent() ) + { + iter = iter->GetParent() ; + } - aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + if ( iter && iter->IsTopLevel() ) + { + MacClientToRootWindow( &x , &y ) ; + int width, height; + GetClientSize(& width, & height); + Rect bounds ; + GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; + GLint parms[4] ; + parms[0] = x ; + parms[1] = bounds.bottom - bounds.top - ( y + height ) ; + parms[2] = width ; + parms[3] = height ; + + if ( !m_macCanvasIsShown ) + parms[0] += 20000 ; + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + } } void wxGLCanvas::OnSize(wxSizeEvent& event) @@ -304,6 +315,51 @@ void wxGLCanvas::SetColour(const char *colour) m_glContext->SetColour(colour); } +bool wxGLCanvas::Show(bool show) +{ + if ( !wxWindow::Show( show ) ) + return FALSE ; + + if ( !show ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( MacIsReallyShown() && !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } + return TRUE ; +} + +void wxGLCanvas::MacSuperShown( bool show ) +{ + if ( !show ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( MacIsReallyShown() && !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } + + wxWindow::MacSuperShown( show ) ; +} //--------------------------------------------------------------------------- // wxGLApp