1. undid wxGTK timer hack, corrected bug in my code

2. clip wxPaintDC to the client area


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-09-12 16:20:34 +00:00
parent e45a8e8b4e
commit 6e6616f755
9 changed files with 48 additions and 89 deletions

View File

@@ -134,20 +134,6 @@ private:
DECLARE_DYNAMIC_CLASS(wxWindowDC) DECLARE_DYNAMIC_CLASS(wxWindowDC)
}; };
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
class wxPaintDC : public wxWindowDC
{
public:
wxPaintDC();
wxPaintDC( wxWindow *win );
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxClientDC // wxClientDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -162,4 +148,18 @@ private:
DECLARE_DYNAMIC_CLASS(wxClientDC) DECLARE_DYNAMIC_CLASS(wxClientDC)
}; };
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
class wxPaintDC : public wxClientDC
{
public:
wxPaintDC() { }
wxPaintDC( wxWindow *win );
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
#endif // __GTKDCCLIENTH__ #endif // __GTKDCCLIENTH__

View File

@@ -134,20 +134,6 @@ private:
DECLARE_DYNAMIC_CLASS(wxWindowDC) DECLARE_DYNAMIC_CLASS(wxWindowDC)
}; };
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
class wxPaintDC : public wxWindowDC
{
public:
wxPaintDC();
wxPaintDC( wxWindow *win );
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxClientDC // wxClientDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -162,4 +148,18 @@ private:
DECLARE_DYNAMIC_CLASS(wxClientDC) DECLARE_DYNAMIC_CLASS(wxClientDC)
}; };
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
class wxPaintDC : public wxClientDC
{
public:
wxPaintDC() { }
wxPaintDC( wxWindow *win );
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
#endif // __GTKDCCLIENTH__ #endif // __GTKDCCLIENTH__

View File

@@ -421,5 +421,7 @@ void MyUnivCanvas::OnPaint(wxPaintEvent& event)
dc.DrawText(_T("This is the top of the canvas"), 10, 10); dc.DrawText(_T("This is the top of the canvas"), 10, 10);
dc.DrawLabel(_T("This is the bottom of the canvas"), dc.DrawLabel(_T("This is the bottom of the canvas"),
wxRect(0, 950, 950, 50), wxALIGN_RIGHT | wxBOTTOM); wxRect(0, 950, 950, 50), wxALIGN_RIGHT | wxBOTTOM);
event.Skip();
} }

View File

@@ -2208,15 +2208,10 @@ void wxWindowDC::DoDrawSpline( wxList *points )
// wxPaintDC // wxPaintDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
wxPaintDC::wxPaintDC()
: wxWindowDC()
{
}
wxPaintDC::wxPaintDC( wxWindow *win ) wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win ) : wxClientDC( win )
{ {
#if USE_PAINT_REGION #if USE_PAINT_REGION
if (!win->m_clipPaintRegion) if (!win->m_clipPaintRegion)
@@ -2233,7 +2228,11 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, region ); gdk_gc_set_clip_region( m_textGC, region );
gdk_gc_set_clip_region( m_bgGC, region ); gdk_gc_set_clip_region( m_bgGC, region );
} }
#endif #endif // USE_PAINT_REGION
#ifdef __WXUNIVERSAL__
SetClippingRegion(win->GetClientRect());
#endif // __WXUNIVERSAL__
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -16,18 +16,6 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
// ----------------------------------------------------------------------------
// This is a hack to work around a crash in wxGTK which happens (sometimes)
// when the timer is deleted from the GTK event handler. In this case even
// though the timer is stopped in its dtor, it is apparently too late to
// prevent the dead timer from being called from g_timeout_dispatch() during
// the same iteration of g_main_dispatch(). A better solution must be found,
// possibly by deferring the timer deletion until later, this is only a
// temporary hack! (VZ)
// ----------------------------------------------------------------------------
static wxTimer *gs_timerDead = (wxTimer *)NULL;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTimer // wxTimer
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -37,13 +25,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
static gint timeout_callback( gpointer data ) static gint timeout_callback( gpointer data )
{ {
wxTimer *timer = (wxTimer*)data; wxTimer *timer = (wxTimer*)data;
if ( timer == gs_timerDead )
{
// shouldn't be called more than once for the dead timer anyhow
gs_timerDead = NULL;
return FALSE;
}
/* when getting called from GDK's timer handler we /* when getting called from GDK's timer handler we
are no longer within GDK's grab on the GUI are no longer within GDK's grab on the GUI
@@ -69,8 +50,6 @@ void wxTimer::Init()
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
gs_timerDead = this;
wxTimer::Stop(); wxTimer::Stop();
} }

View File

@@ -2208,15 +2208,10 @@ void wxWindowDC::DoDrawSpline( wxList *points )
// wxPaintDC // wxPaintDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
wxPaintDC::wxPaintDC()
: wxWindowDC()
{
}
wxPaintDC::wxPaintDC( wxWindow *win ) wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win ) : wxClientDC( win )
{ {
#if USE_PAINT_REGION #if USE_PAINT_REGION
if (!win->m_clipPaintRegion) if (!win->m_clipPaintRegion)
@@ -2233,7 +2228,11 @@ wxPaintDC::wxPaintDC( wxWindow *win )
gdk_gc_set_clip_region( m_textGC, region ); gdk_gc_set_clip_region( m_textGC, region );
gdk_gc_set_clip_region( m_bgGC, region ); gdk_gc_set_clip_region( m_bgGC, region );
} }
#endif #endif // USE_PAINT_REGION
#ifdef __WXUNIVERSAL__
SetClippingRegion(win->GetClientRect());
#endif // __WXUNIVERSAL__
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -16,18 +16,6 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
// ----------------------------------------------------------------------------
// This is a hack to work around a crash in wxGTK which happens (sometimes)
// when the timer is deleted from the GTK event handler. In this case even
// though the timer is stopped in its dtor, it is apparently too late to
// prevent the dead timer from being called from g_timeout_dispatch() during
// the same iteration of g_main_dispatch(). A better solution must be found,
// possibly by deferring the timer deletion until later, this is only a
// temporary hack! (VZ)
// ----------------------------------------------------------------------------
static wxTimer *gs_timerDead = (wxTimer *)NULL;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTimer // wxTimer
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -37,13 +25,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
static gint timeout_callback( gpointer data ) static gint timeout_callback( gpointer data )
{ {
wxTimer *timer = (wxTimer*)data; wxTimer *timer = (wxTimer*)data;
if ( timer == gs_timerDead )
{
// shouldn't be called more than once for the dead timer anyhow
gs_timerDead = NULL;
return FALSE;
}
/* when getting called from GDK's timer handler we /* when getting called from GDK's timer handler we
are no longer within GDK's grab on the GUI are no longer within GDK's grab on the GUI
@@ -69,8 +50,6 @@ void wxTimer::Init()
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
gs_timerDead = this;
wxTimer::Stop(); wxTimer::Stop();
} }

View File

@@ -451,6 +451,7 @@ void wxScrollBarTimer::Notify()
if ( m_skipNext ) if ( m_skipNext )
{ {
// scroll normally now - reduce the delay // scroll normally now - reduce the delay
Stop();
Start(50); // FIXME: hardcoded delay Start(50); // FIXME: hardcoded delay
m_skipNext = FALSE; m_skipNext = FALSE;

View File

@@ -514,9 +514,9 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
ptDest = ptDest =
ptOrigin = GetClientAreaOrigin(); ptOrigin = GetClientAreaOrigin();
wxSize size; wxSize size;
size.x = sizeTotal.x - abs(dx); size.x = sizeTotal.x - abs(dx) - 1;
size.y = sizeTotal.y - abs(dy); size.y = sizeTotal.y - abs(dy) - 1;
if ( size.x < 0 || size.y < 0 ) if ( size.x <= 0 || size.y <= 0 )
{ {
// just redraw everything as nothing of the displayed image will stay // just redraw everything as nothing of the displayed image will stay
wxLogTrace(_T("scroll"), _T("refreshing everything")); wxLogTrace(_T("scroll"), _T("refreshing everything"));