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 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()
};

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") );
m_glContext = new wxGLContext(fmt, this, palette, shared);
m_macCanvasIsShown = true ;
aglDestroyPixelFormat(fmt);
return true;
@@ -249,6 +249,14 @@ void wxGLCanvas::SetViewport()
int x = 0 ;
int y = 0 ;
wxWindow* iter = this ;
while( iter->GetParent() )
{
iter = iter->GetParent() ;
}
if ( iter && iter->IsTopLevel() )
{
MacClientToRootWindow( &x , &y ) ;
int width, height;
GetClientSize(& width, & height);
@@ -260,8 +268,11 @@ void wxGLCanvas::SetViewport()
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

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") );
m_glContext = new wxGLContext(fmt, this, palette, shared);
m_macCanvasIsShown = true ;
aglDestroyPixelFormat(fmt);
return true;
@@ -249,6 +249,14 @@ void wxGLCanvas::SetViewport()
int x = 0 ;
int y = 0 ;
wxWindow* iter = this ;
while( iter->GetParent() )
{
iter = iter->GetParent() ;
}
if ( iter && iter->IsTopLevel() )
{
MacClientToRootWindow( &x , &y ) ;
int width, height;
GetClientSize(& width, & height);
@@ -260,8 +268,11 @@ void wxGLCanvas::SetViewport()
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