show and hide implementation added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2003-03-07 10:25:11 +00:00
parent e9d804ebea
commit ab89a5b59b
3 changed files with 140 additions and 25 deletions

View File

@@ -109,6 +109,7 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow
void SwapBuffers(); void SwapBuffers();
void UpdateContext(); void UpdateContext();
void SetViewport(); void SetViewport();
virtual bool Show(bool show = TRUE) ;
// Unlike some other platforms, this must get called if you override it. // Unlike some other platforms, this must get called if you override it.
// It sets the viewport correctly and update the context. // It sets the viewport correctly and update the context.
@@ -117,13 +118,15 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow
virtual void MacSuperChangedPosition() ; virtual void MacSuperChangedPosition() ;
virtual void MacTopLevelWindowChangedPosition() ; virtual void MacTopLevelWindowChangedPosition() ;
virtual void MacSuperShown( bool show ) ;
void MacUpdateView() ; void MacUpdateView() ;
inline wxGLContext* GetContext() const { return m_glContext; } inline wxGLContext* GetContext() const { return m_glContext; }
protected: protected:
wxGLContext* m_glContext; wxGLContext* m_glContext;
bool m_macCanvasIsShown ;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -224,7 +224,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID
wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") );
m_glContext = new wxGLContext(fmt, this, palette, shared); m_glContext = new wxGLContext(fmt, this, palette, shared);
m_macCanvasIsShown = true ;
aglDestroyPixelFormat(fmt); aglDestroyPixelFormat(fmt);
return true; return true;
@@ -249,18 +249,29 @@ void wxGLCanvas::SetViewport()
int x = 0 ; int x = 0 ;
int y = 0 ; int y = 0 ;
MacClientToRootWindow( &x , &y ) ; wxWindow* iter = this ;
int width, height; while( iter->GetParent() )
GetClientSize(& width, & height); {
Rect bounds ; iter = iter->GetParent() ;
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 ;
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) void wxGLCanvas::OnSize(wxSizeEvent& event)
@@ -304,6 +315,51 @@ void wxGLCanvas::SetColour(const char *colour)
m_glContext->SetColour(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 // wxGLApp

View File

@@ -224,7 +224,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID
wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") );
m_glContext = new wxGLContext(fmt, this, palette, shared); m_glContext = new wxGLContext(fmt, this, palette, shared);
m_macCanvasIsShown = true ;
aglDestroyPixelFormat(fmt); aglDestroyPixelFormat(fmt);
return true; return true;
@@ -249,18 +249,29 @@ void wxGLCanvas::SetViewport()
int x = 0 ; int x = 0 ;
int y = 0 ; int y = 0 ;
MacClientToRootWindow( &x , &y ) ; wxWindow* iter = this ;
int width, height; while( iter->GetParent() )
GetClientSize(& width, & height); {
Rect bounds ; iter = iter->GetParent() ;
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 ;
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) void wxGLCanvas::OnSize(wxSizeEvent& event)
@@ -304,6 +315,51 @@ void wxGLCanvas::SetColour(const char *colour)
m_glContext->SetColour(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 // wxGLApp