From 956dbab1eb04b32a006303df25fd05116eb5ef11 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 5 Aug 1999 11:14:07 +0000 Subject: [PATCH] Applied patch for stipppled brushes, Corrected idle behaviour after popmenu call git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dnd/dnd.cpp | 1 + src/gtk/app.cpp | 58 ++++++++++++++++++++----------------------- src/gtk/dcclient.cpp | 19 ++++++-------- src/gtk/window.cpp | 6 ++++- src/gtk1/app.cpp | 58 ++++++++++++++++++++----------------------- src/gtk1/dcclient.cpp | 19 ++++++-------- src/gtk1/window.cpp | 6 ++++- 7 files changed, 81 insertions(+), 86 deletions(-) diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 3fc5583e92..046f943199 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -23,6 +23,7 @@ #include "wx/log.h" #include "wx/dnd.h" +#include "wx/dirdlg.h" #ifdef __WXMOTIF__ #error Sorry, drag and drop is not yet implemented on wxMotif. diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index c0ce494d7e..a81c4dd205 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -143,47 +143,37 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ); bool wxYield() { - /* it's necessary to call ProcessIdle() to update the frames sizes which - might have been changed (it also will update other things set from - OnUpdateUI() which is a nice (and desired) side effect) */ - while (wxTheApp->ProcessIdle()) { } - -#if 0 - for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = node->GetData(); - win->OnInternalIdle(); - } -#endif - - if (wxTheApp->m_idleTag) + bool has_idle = (wxTheApp->m_idleTag != 0); + + if (has_idle) { /* We need to temporarily remove idle callbacks or the loop will never finish. */ gtk_idle_remove( wxTheApp->m_idleTag ); wxTheApp->m_idleTag = 0; + } - while (gtk_events_pending()) - gtk_main_iteration(); + while (gtk_events_pending()) + gtk_main_iteration(); + /* it's necessary to call ProcessIdle() to update the frames sizes which + might have been changed (it also will update other things set from + OnUpdateUI() which is a nice (and desired) side effect) */ + while (wxTheApp->ProcessIdle()) { } + + if (has_idle) + { /* re-add idle handler */ wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); } - else - { - while (gtk_events_pending()) - gtk_main_iteration(); - } - + return TRUE; } gint wxapp_idle_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; - + #if (GTK_MINOR_VERSION > 0) /* when getting called from GDK's idle handler we are no longer within GDK's grab on the GUI @@ -424,18 +414,26 @@ bool wxApp::ProcessIdle() event.SetEventObject( this ); ProcessEvent( event ); + wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); + while (node) + { + wxWindow* win = node->GetData(); + win->OnInternalIdle(); + node = node->GetNext(); + } + return event.MoreRequested(); } void wxApp::OnIdle( wxIdleEvent &event ) { - static bool inOnIdle = FALSE; + static bool s_inOnIdle = FALSE; /* Avoid recursion (via ProcessEvent default case) */ - if (inOnIdle) + if (s_inOnIdle) return; - inOnIdle = TRUE; + s_inOnIdle = TRUE; #if wxUSE_THREADS /* Resend in the main thread events which have been prepared in other @@ -459,7 +457,7 @@ void wxApp::OnIdle( wxIdleEvent &event ) if (needMore) event.RequestMore(TRUE); - inOnIdle = FALSE; + s_inOnIdle = FALSE; } bool wxApp::SendIdleEvents() @@ -485,8 +483,6 @@ bool wxApp::SendIdleEvents( wxWindow* win ) wxIdleEvent event; event.SetEventObject(win); - win->OnInternalIdle(); - win->ProcessEvent(event); if (event.MoreRequested()) diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index cbfcc44f33..6ec3b44223 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -995,28 +995,25 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) m_brush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() ); - GdkFill fillStyle = GDK_SOLID; - switch (m_brush.GetStyle()) - { - case wxSOLID: - case wxTRANSPARENT: - break; - default: - fillStyle = GDK_STIPPLED; - } - - gdk_gc_set_fill( m_brushGC, fillStyle ); + gdk_gc_set_fill( m_brushGC, GDK_SOLID ); if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) { if (m_brush.GetStipple()->GetPixmap()) + { + gdk_gc_set_fill( m_brushGC, GDK_TILED ); gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() ); + } else + { + gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() ); + } } if (IS_HATCH(m_brush.GetStyle())) { + gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; gdk_gc_set_stipple( m_brushGC, hatches[num] ); } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index f43608af41..dfeb16b66f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2909,7 +2909,11 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) 0 //gs_timeLastClick // the time of activation ); - while (is_waiting) wxYield(); + while (is_waiting) + { + while (gtk_events_pending()) + gtk_main_iteration(); + } return TRUE; } diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index c0ce494d7e..a81c4dd205 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -143,47 +143,37 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ); bool wxYield() { - /* it's necessary to call ProcessIdle() to update the frames sizes which - might have been changed (it also will update other things set from - OnUpdateUI() which is a nice (and desired) side effect) */ - while (wxTheApp->ProcessIdle()) { } - -#if 0 - for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = node->GetData(); - win->OnInternalIdle(); - } -#endif - - if (wxTheApp->m_idleTag) + bool has_idle = (wxTheApp->m_idleTag != 0); + + if (has_idle) { /* We need to temporarily remove idle callbacks or the loop will never finish. */ gtk_idle_remove( wxTheApp->m_idleTag ); wxTheApp->m_idleTag = 0; + } - while (gtk_events_pending()) - gtk_main_iteration(); + while (gtk_events_pending()) + gtk_main_iteration(); + /* it's necessary to call ProcessIdle() to update the frames sizes which + might have been changed (it also will update other things set from + OnUpdateUI() which is a nice (and desired) side effect) */ + while (wxTheApp->ProcessIdle()) { } + + if (has_idle) + { /* re-add idle handler */ wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); } - else - { - while (gtk_events_pending()) - gtk_main_iteration(); - } - + return TRUE; } gint wxapp_idle_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; - + #if (GTK_MINOR_VERSION > 0) /* when getting called from GDK's idle handler we are no longer within GDK's grab on the GUI @@ -424,18 +414,26 @@ bool wxApp::ProcessIdle() event.SetEventObject( this ); ProcessEvent( event ); + wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); + while (node) + { + wxWindow* win = node->GetData(); + win->OnInternalIdle(); + node = node->GetNext(); + } + return event.MoreRequested(); } void wxApp::OnIdle( wxIdleEvent &event ) { - static bool inOnIdle = FALSE; + static bool s_inOnIdle = FALSE; /* Avoid recursion (via ProcessEvent default case) */ - if (inOnIdle) + if (s_inOnIdle) return; - inOnIdle = TRUE; + s_inOnIdle = TRUE; #if wxUSE_THREADS /* Resend in the main thread events which have been prepared in other @@ -459,7 +457,7 @@ void wxApp::OnIdle( wxIdleEvent &event ) if (needMore) event.RequestMore(TRUE); - inOnIdle = FALSE; + s_inOnIdle = FALSE; } bool wxApp::SendIdleEvents() @@ -485,8 +483,6 @@ bool wxApp::SendIdleEvents( wxWindow* win ) wxIdleEvent event; event.SetEventObject(win); - win->OnInternalIdle(); - win->ProcessEvent(event); if (event.MoreRequested()) diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index cbfcc44f33..6ec3b44223 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -995,28 +995,25 @@ void wxWindowDC::SetBrush( const wxBrush &brush ) m_brush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() ); - GdkFill fillStyle = GDK_SOLID; - switch (m_brush.GetStyle()) - { - case wxSOLID: - case wxTRANSPARENT: - break; - default: - fillStyle = GDK_STIPPLED; - } - - gdk_gc_set_fill( m_brushGC, fillStyle ); + gdk_gc_set_fill( m_brushGC, GDK_SOLID ); if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) { if (m_brush.GetStipple()->GetPixmap()) + { + gdk_gc_set_fill( m_brushGC, GDK_TILED ); gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() ); + } else + { + gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() ); + } } if (IS_HATCH(m_brush.GetStyle())) { + gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; gdk_gc_set_stipple( m_brushGC, hatches[num] ); } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index f43608af41..dfeb16b66f 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2909,7 +2909,11 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) 0 //gs_timeLastClick // the time of activation ); - while (is_waiting) wxYield(); + while (is_waiting) + { + while (gtk_events_pending()) + gtk_main_iteration(); + } return TRUE; } -- 2.47.2