]> git.saurik.com Git - wxWidgets.git/commitdiff
wxSpinCtrl no longer emits event when changed programmatically.
authorRobert Roebling <robert@roebling.de>
Sun, 2 Jan 2000 16:25:28 +0000 (16:25 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 2 Jan 2000 16:25:28 +0000 (16:25 +0000)
  Some GUI thread things and tests,
  Change for borders around cmposite controls.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5173 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/gtk/changes.txt
include/wx/gtk/spinctrl.h
include/wx/gtk1/spinctrl.h
samples/controls/controls.cpp
samples/thread/test.cpp
src/gtk/app.cpp
src/gtk/spinctrl.cpp
src/gtk/window.cpp
src/gtk1/app.cpp
src/gtk1/spinctrl.cpp
src/gtk1/window.cpp

index 8148fdf3eab0b881d8365aacba0ba9d8a156ca8e..2c748f0ea38c7a530ebbca2568f3e03abe99131c 100644 (file)
@@ -6,6 +6,11 @@ and/or 16 bit colour mode? I need this for testing purposes, i.e. this
 person could help me by running a small testprogram and sending
 me the output.
 
+Added Calendar control.
+
+Added classes for recoding text (e.g. from Windows encoding to ISO encoding
+and for converting to and from Unicode).
+
 Updated the 64-bit long class (a class that substitutes a 64-bit int
 type on platforms which don't provide a native one).
 
index e51437430cb6f17038853a7046a616c1e763a7a3..14065fb96a2c0ea87ed1b95702974aa90ecb5ac6 100644 (file)
@@ -65,6 +65,8 @@ public:
     
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
+    void GtkDisableEvents();
+    void GtkEnableEvents();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index e51437430cb6f17038853a7046a616c1e763a7a3..14065fb96a2c0ea87ed1b95702974aa90ecb5ac6 100644 (file)
@@ -65,6 +65,8 @@ public:
     
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
+    void GtkDisableEvents();
+    void GtkEnableEvents();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index ac99563156aad51e459c620da8e02765713b9cbd..68df4747594f88c6c2697a72efb0b87aa9c0c8a2 100644 (file)
@@ -530,7 +530,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     panel = new wxPanel(m_notebook);
     (void)new wxStaticBox( panel, -1, "Box around combobox",
                            wxPoint(5, 5), wxSize(150, 100));
-    m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,20), wxSize(120,-1), 5, choices, wxCB_READONLY );
+    m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,25), wxSize(120,-1), 5, choices, wxCB_READONLY );
     (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
     (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
     (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
index 7996d8f532fa917a89872c95957e2d11ae4a158f..8133847ac55b979c2248d311549dd4cec13357f5 100644 (file)
@@ -235,11 +235,21 @@ void *MyWorkerThread::Entry()
         if ( TestDestroy() )
             break;
         
+        wxString text;
+        text.Printf("[%u] Thread 0x%x here!!", m_count, GetId());
+
+        // create any type of command event here        
         wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, WORKER_EVENT );
         event.SetInt( WORKER_EVENT );
+        event.SetString( text );
+        
+        // send in a thread-safe way
         wxPostEvent( m_frame, event );
+        
+        // same as:
+        // m_frame->AddPendingEvent( event );
 
-        // wxSleep() can't be called from non-GUI thread!
+        // wxSleep() can't be called from non-main thread!
         wxThread::Sleep(1000);
     }
 
@@ -495,7 +505,8 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
 {
     wxMessageDialog dialog(this, "wxWindows multithreaded application sample\n"
                                  "(c) 1998 Julian Smart, Guilhem Lavaux\n"
-                                 "(c) 1999 Vadim Zeitlin",
+                                 "(c) 1999 Vadim Zeitlin\n"
+                                 "(c) 2000 Robert Roebling",
                            "About wxThread sample",
                            wxOK | wxICON_INFORMATION);
 
@@ -519,8 +530,10 @@ void MyFrame::OnStartWorker(wxCommandEvent& WXUNUSED(event))
     thread->Run();
 }
 
-void MyFrame::OnWorkerEvent(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
 {
-    WriteText( "Got message from worker thread\n" );
+    WriteText( "Got message from worker thread: " );
+    WriteText( event.GetString() );
+    WriteText( "\n" );
 }
 
index 43a5a92aa9535f015f60ce647302d527bd17dd09..7bc83fdbd7deb4b3816b14b56c81aeed255db09e 100644 (file)
@@ -178,7 +178,7 @@ void wxapp_install_thread_wakeup()
 {
     if (wxTheApp->m_wakeUpTimerTag) return;
 
-    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 500, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL );
 }
 
 void wxapp_uninstall_thread_wakeup()
index 766b1c58ae6c5a98b7f2f455eaac30ae27b65ec2..80f42b1354cd1deedb56687820334290a9e0783e 100644 (file)
@@ -101,11 +101,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
     gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
                               (int)(m_windowStyle & wxSP_WRAP) );
 
-    gtk_signal_connect( GTK_OBJECT (m_adjust),
-                        "value_changed",
-                        (GtkSignalFunc) gtk_spinctrl_callback,
-                        (gpointer) this );
-
+    GtkEnableEvents();
     m_parent->DoAddChild( this );
 
     PostCreation();
@@ -119,6 +115,22 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
     return TRUE;
 }
 
+void wxSpinCtrl::GtkDisableEvents()
+{
+    gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust),
+                        GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
+                        (gpointer) this );
+
+}
+
+void wxSpinCtrl::GtkEnableEvents()
+{
+    gtk_signal_connect( GTK_OBJECT (m_adjust),
+                        "value_changed",
+                        GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
+                        (gpointer) this );
+}
+
 int wxSpinCtrl::GetMin() const
 {
     wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );
@@ -153,7 +165,9 @@ void wxSpinCtrl::SetValue( const wxString& value )
     else
     {
         // invalid number - set text as is (wxMSW compatible)
+        GtkDisableEvents();
         gtk_entry_set_text( GTK_ENTRY(m_widget), value.mbc_str() );
+        GtkEnableEvents();
     }
 }
 
@@ -167,7 +181,9 @@ void wxSpinCtrl::SetValue( int value )
 
     m_adjust->value = fpos;
 
+    GtkDisableEvents();
     gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" );
+    GtkEnableEvents();
 }
 
 void wxSpinCtrl::SetRange(int minVal, int maxVal)
index 6be2cdd8c583ece185db64058568f155212fe62d..a1484b14894b140a4aaaa86e26242d6009dcbc05 100644 (file)
@@ -327,7 +327,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
                          GTK_STATE_NORMAL,
                          GTK_SHADOW_OUT,
                          dx, dy,
-                         win->m_width-dw, win->m_height-dh );
+                         widget->allocation.width-dw, widget->allocation.height-dh );
         return;
     }
 
@@ -338,7 +338,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
                          GTK_STATE_NORMAL,
                          GTK_SHADOW_IN,
                          dx, dy,
-                         win->m_width-dw, win->m_height-dh );
+                         widget->allocation.width-dw, widget->allocation.height-dh );
         return;
     }
 
@@ -349,7 +349,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
         gdk_gc_set_foreground( gc, &widget->style->black );
         gdk_draw_rectangle( widget->window, gc, FALSE,
                          dx, dy,
-                         win->m_width-dw-1, win->m_height-dh-1 );
+                         widget->allocation.width-dw-1, widget->allocation.height-dh-1 );
         gdk_gc_unref( gc );
         return;
     }
index 43a5a92aa9535f015f60ce647302d527bd17dd09..7bc83fdbd7deb4b3816b14b56c81aeed255db09e 100644 (file)
@@ -178,7 +178,7 @@ void wxapp_install_thread_wakeup()
 {
     if (wxTheApp->m_wakeUpTimerTag) return;
 
-    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 500, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL );
 }
 
 void wxapp_uninstall_thread_wakeup()
index 766b1c58ae6c5a98b7f2f455eaac30ae27b65ec2..80f42b1354cd1deedb56687820334290a9e0783e 100644 (file)
@@ -101,11 +101,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
     gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
                               (int)(m_windowStyle & wxSP_WRAP) );
 
-    gtk_signal_connect( GTK_OBJECT (m_adjust),
-                        "value_changed",
-                        (GtkSignalFunc) gtk_spinctrl_callback,
-                        (gpointer) this );
-
+    GtkEnableEvents();
     m_parent->DoAddChild( this );
 
     PostCreation();
@@ -119,6 +115,22 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
     return TRUE;
 }
 
+void wxSpinCtrl::GtkDisableEvents()
+{
+    gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust),
+                        GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
+                        (gpointer) this );
+
+}
+
+void wxSpinCtrl::GtkEnableEvents()
+{
+    gtk_signal_connect( GTK_OBJECT (m_adjust),
+                        "value_changed",
+                        GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
+                        (gpointer) this );
+}
+
 int wxSpinCtrl::GetMin() const
 {
     wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );
@@ -153,7 +165,9 @@ void wxSpinCtrl::SetValue( const wxString& value )
     else
     {
         // invalid number - set text as is (wxMSW compatible)
+        GtkDisableEvents();
         gtk_entry_set_text( GTK_ENTRY(m_widget), value.mbc_str() );
+        GtkEnableEvents();
     }
 }
 
@@ -167,7 +181,9 @@ void wxSpinCtrl::SetValue( int value )
 
     m_adjust->value = fpos;
 
+    GtkDisableEvents();
     gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" );
+    GtkEnableEvents();
 }
 
 void wxSpinCtrl::SetRange(int minVal, int maxVal)
index 6be2cdd8c583ece185db64058568f155212fe62d..a1484b14894b140a4aaaa86e26242d6009dcbc05 100644 (file)
@@ -327,7 +327,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
                          GTK_STATE_NORMAL,
                          GTK_SHADOW_OUT,
                          dx, dy,
-                         win->m_width-dw, win->m_height-dh );
+                         widget->allocation.width-dw, widget->allocation.height-dh );
         return;
     }
 
@@ -338,7 +338,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
                          GTK_STATE_NORMAL,
                          GTK_SHADOW_IN,
                          dx, dy,
-                         win->m_width-dw, win->m_height-dh );
+                         widget->allocation.width-dw, widget->allocation.height-dh );
         return;
     }
 
@@ -349,7 +349,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win )
         gdk_gc_set_foreground( gc, &widget->style->black );
         gdk_draw_rectangle( widget->window, gc, FALSE,
                          dx, dy,
-                         win->m_width-dw-1, win->m_height-dh-1 );
+                         widget->allocation.width-dw-1, widget->allocation.height-dh-1 );
         gdk_gc_unref( gc );
         return;
     }