made Update() recursive under wxGTK2 (doesn't work for wxGTK1 because Refresh() is not recursive htere neither) and documented its behaviour

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33091 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-03-27 13:54:09 +00:00
parent f47af52bb4
commit a67f1484e0
3 changed files with 70 additions and 42 deletions

View File

@ -2222,13 +2222,13 @@ or frame).
\membersection{wxWindow::Refresh}\label{wxwindowrefresh}
\func{virtual void}{Refresh}{\param{bool}{ eraseBackground = {\tt true}}, \param{const wxRect* }{rect
= NULL}}
\func{virtual void}{Refresh}{\param{bool}{ eraseBackground = {\tt true}}, \param{const wxRect* }{rect = NULL}}
Causes this window, and all of its children recursively, to be repainted. Note
that repainting doesn't happen immediately but only during the next event loop
iteration, if you need to update the window immediately you should use
\helpref{Update}{wxwindowupdate} instead.
Causes this window, and all of its children recursively (except under wxGTK1
where this is not implemented), to be repainted. Note that repainting doesn't
happen immediately but only during the next event loop iteration, if you need
to update the window immediately you should use \helpref{Update}{wxwindowupdate}
instead.
\wxheading{Parameters}
@ -3489,12 +3489,12 @@ This function is currently only implemented under MSW.
\func{virtual void}{Update}{\void}
Calling this method immediately repaints the invalidated area of the window
while this would usually only happen when the flow of control returns to the
event loop. Notice that this function doesn't refresh the window and does
nothing if the window hadn't been already repainted. Use
\helpref{Refresh}{wxwindowrefresh} first if you want to immediately redraw the
window unconditionally.
Calling this method immediately repaints the invalidated area of the window and
all of its children recursively while this would usually only happen when the
flow of control returns to the event loop. Notice that this function doesn't
refresh the window and does nothing if the window hadn't been already
repainted. Use \helpref{Refresh}{wxwindowrefresh} first if you want to
immediately redraw the window unconditionally.
\membersection{wxWindow::UpdateWindowUI}\label{wxwindowupdatewindowui}

View File

@ -3927,35 +3927,38 @@ void wxWindowGTK::WarpPointer( int x, int y )
void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (!m_widget) return;
if (!m_widget->window) return;
if (!m_widget)
return;
if (!m_widget->window)
return;
#ifndef __WXGTK20__
if (g_isIdle)
wxapp_install_idle_handler();
wxRect myRect(0,0,0,0);
wxRect myRect;
if (m_wxwindow && rect)
{
myRect.SetSize(wxSize( m_wxwindow->allocation.width,
m_wxwindow->allocation.height));
myRect.Intersect(*rect);
if (!myRect.width || !myRect.height)
if ( myRect.Intersect(*rect).IsEmpty() )
{
// nothing to do, rectangle is empty
return;
}
rect = &myRect;
}
// schedule the area for later updating in GtkUpdate()
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height );
}
else
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_clearRegion.Clear();
m_clearRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
}
@ -3965,7 +3968,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (m_wxwindow)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
}
else
@ -3982,7 +3984,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (m_wxwindow)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_updateRegion.Clear();
m_updateRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
}
@ -3991,24 +3992,27 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
}
}
#else
#else // GTK+ 2
if (m_wxwindow)
{
GdkRectangle gdk_rect,
*p;
if (rect)
{
GdkRectangle gdk_rect;
gdk_rect.x = rect->x;
gdk_rect.y = rect->y;
gdk_rect.width = rect->width;
gdk_rect.height = rect->height;
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, &gdk_rect, TRUE );
p = &gdk_rect;
}
else
else // invalidate everything
{
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, NULL, TRUE );
p = NULL;
}
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE );
}
#endif
#endif // GTK+ 1/2
}
void wxWindowGTK::Update()
@ -4031,6 +4035,16 @@ void wxWindowGTK::GtkUpdate()
if (!m_updateRegion.IsEmpty())
GtkSendPaintEvents();
#endif
// for consistency with other platforms (and also because it's convenient
// to be able to update an entire TLW by calling Update() only once), we
// should also update all our children here
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
node;
node = node->GetNext() )
{
node->GetData()->GtkUpdate();
}
}
void wxWindowGTK::GtkSendPaintEvents()

View File

@ -3927,35 +3927,38 @@ void wxWindowGTK::WarpPointer( int x, int y )
void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (!m_widget) return;
if (!m_widget->window) return;
if (!m_widget)
return;
if (!m_widget->window)
return;
#ifndef __WXGTK20__
if (g_isIdle)
wxapp_install_idle_handler();
wxRect myRect(0,0,0,0);
wxRect myRect;
if (m_wxwindow && rect)
{
myRect.SetSize(wxSize( m_wxwindow->allocation.width,
m_wxwindow->allocation.height));
myRect.Intersect(*rect);
if (!myRect.width || !myRect.height)
if ( myRect.Intersect(*rect).IsEmpty() )
{
// nothing to do, rectangle is empty
return;
}
rect = &myRect;
}
// schedule the area for later updating in GtkUpdate()
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height );
}
else
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_clearRegion.Clear();
m_clearRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
}
@ -3965,7 +3968,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (m_wxwindow)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
}
else
@ -3982,7 +3984,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
{
if (m_wxwindow)
{
// Schedule for later Updating in ::Update() or ::OnInternalIdle().
m_updateRegion.Clear();
m_updateRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height );
}
@ -3991,24 +3992,27 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
}
}
#else
#else // GTK+ 2
if (m_wxwindow)
{
GdkRectangle gdk_rect,
*p;
if (rect)
{
GdkRectangle gdk_rect;
gdk_rect.x = rect->x;
gdk_rect.y = rect->y;
gdk_rect.width = rect->width;
gdk_rect.height = rect->height;
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, &gdk_rect, TRUE );
p = &gdk_rect;
}
else
else // invalidate everything
{
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, NULL, TRUE );
p = NULL;
}
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE );
}
#endif
#endif // GTK+ 1/2
}
void wxWindowGTK::Update()
@ -4031,6 +4035,16 @@ void wxWindowGTK::GtkUpdate()
if (!m_updateRegion.IsEmpty())
GtkSendPaintEvents();
#endif
// for consistency with other platforms (and also because it's convenient
// to be able to update an entire TLW by calling Update() only once), we
// should also update all our children here
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
node;
node = node->GetNext() )
{
node->GetData()->GtkUpdate();
}
}
void wxWindowGTK::GtkSendPaintEvents()