]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxMenu::Append( wxMenuItem )
authorRobert Roebling <robert@roebling.de>
Sun, 28 Feb 1999 18:03:27 +0000 (18:03 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 28 Feb 1999 18:03:27 +0000 (18:03 +0000)
  added keyboard hooks to glcanvas
  fixed probs with slider/spin button etc

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

15 files changed:
include/wx/gtk/menu.h
include/wx/gtk1/menu.h
src/gtk/menu.cpp
src/gtk/scrolbar.cpp
src/gtk/slider.cpp
src/gtk/spinbutt.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/menu.cpp
src/gtk1/scrolbar.cpp
src/gtk1/slider.cpp
src/gtk1/spinbutt.cpp
src/gtk1/textctrl.cpp
src/gtk1/window.cpp
utils/glcanvas/gtk/glcanvas.cpp

index 08a63b914eee9406737e442e9c91125e242dbdb0..008be7e58a54b204dcca6d38b35ac51c452ce1d6 100644 (file)
@@ -98,6 +98,7 @@ public:
               const wxString &helpStr = "", bool checkable = FALSE);
   void Append(int id, const wxString &item,
               wxMenu *subMenu, const wxString &helpStr = "" );
+  void Append(wxMenuItem *pItem);
   void Break() {};
 
     // find item by name/id
index 08a63b914eee9406737e442e9c91125e242dbdb0..008be7e58a54b204dcca6d38b35ac51c452ce1d6 100644 (file)
@@ -98,6 +98,7 @@ public:
               const wxString &helpStr = "", bool checkable = FALSE);
   void Append(int id, const wxString &item,
               wxMenu *subMenu, const wxString &helpStr = "" );
+  void Append(wxMenuItem *pItem);
   void Break() {};
 
     // find item by name/id
index aff2211922fa246801ac7cd44f134b303dd956dc..0c0d9b98a5102583253c889d38d3856cb589505a 100644 (file)
@@ -62,7 +62,7 @@ wxMenuBar::wxMenuBar()
 
     m_menubar = gtk_menu_bar_new();
 
-        m_widget = GTK_WIDGET(m_menubar);
+    m_widget = GTK_WIDGET(m_menubar);
 
     PostCreation();
 
@@ -494,9 +494,9 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
     wxMenuItem *mitem = new wxMenuItem();
     mitem->SetId(id);
     mitem->SetText(text);
+    mitem->SetHelp(helpStr);
 
     GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
-    mitem->SetHelp(helpStr);
     mitem->SetMenuItem(menuItem);
     mitem->SetSubMenu(subMenu);
 
@@ -514,6 +514,43 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
     m_items.Append( mitem );
 }
 
+void wxMenu::Append( wxMenuItem *item )
+{
+    m_items.Append( item );
+    
+    GtkWidget *menuItem = (GtkWidget*) NULL;
+
+    if (item->IsSeparator()) 
+        menuItem = gtk_menu_item_new();
+    else if (item->IsSubMenu()) 
+        menuItem = gtk_menu_item_new_with_label(item->GetText());
+    else 
+        menuItem = item->IsCheckable() ? gtk_check_menu_item_new_with_label(item->GetText())
+                                       : gtk_menu_item_new_with_label(item->GetText());
+
+    if (!item->IsSeparator())
+    {
+        gtk_signal_connect( GTK_OBJECT(menuItem), "select",
+                            GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
+                            (gpointer*)this );
+
+        gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
+                            GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
+                            (gpointer*)this );
+                           
+       if (!item->IsSubMenu())
+       {
+            gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
+                                GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
+                                (gpointer*)this );
+       }
+    }
+    
+    gtk_menu_append( GTK_MENU(m_menu), menuItem );
+    gtk_widget_show( menuItem );
+    item->SetMenuItem(menuItem);
+}
+
 int wxMenu::FindItem( const wxString itemString ) const
 {
     wxString s( itemString );
index ee6d3eec70e5da7bd70943986c6b5a931f47fd48..39aba4ce4698c1624b0b0010966f4628a85f11ce 100644 (file)
@@ -37,6 +37,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi
     
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
index 5f9c8915b66b13acfc924024aafeab4e7e2a8924..08a4da1d1956fc0c097177709d6f533452f6afdd 100644 (file)
@@ -35,6 +35,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
     
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
@@ -56,11 +57,11 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
   
     wxScrollEvent event( command, win->GetId(), value, orient );
     event.SetEventObject( win );
-    win->ProcessEvent( event );
+    win->GetEventHandler()->ProcessEvent( event );
   
     wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
     cevent.SetEventObject( win );
-    win->ProcessEvent( cevent );
+    win->GetEventHandler()->ProcessEvent( cevent );
 }
 
 //-----------------------------------------------------------------------------
index dfe03b27a187b7f264f978730c7c448208974359..392310c3f9f1635a29c0bf7cadf8847b9e7b697c 100644 (file)
@@ -33,9 +33,10 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
 { 
     if (!win->HasVMT()) return;
     if (g_blockEventsOnDrag) return;
-  
+
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
@@ -55,7 +56,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
     event.SetOrientation( wxVERTICAL );
     event.SetEventObject( win );
   
-    win->ProcessEvent( event );
+    win->GetEventHandler()->ProcessEvent( event );
 }
 
 //-----------------------------------------------------------------------------
index d7f0dcd96e01af3d8aa5bd7c3fe60d5bcb35a6fb..7c6817aa3ef95ea76b399efa3e18b34d8c2d07c2 100644 (file)
@@ -300,6 +300,7 @@ void wxTextCtrl::WriteText( const wxString &text )
     {
         /* this moves the cursor pos to behind the inserted text */
        gint len = GTK_EDITABLE(m_text)->current_pos;
+       
         gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
        
        /* bring editable's cursor uptodate. bug in GTK. */
index 39a203d80476d847e28443880913a74deba41e66..89b75f8a9d54fc4b2912145e98800c26cdca4c18 100644 (file)
@@ -1081,6 +1081,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
 
     float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldVerticalPos = win->m_vAdjust->value;
 
     wxEventType command = wxEVT_NULL;
 
@@ -1128,6 +1129,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
 
     float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldHorizontalPos = win->m_hAdjust->value;
 
     wxEventType command = wxEVT_NULL;
 
@@ -2835,7 +2837,9 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
 void wxWindow::SetFont( const wxFont &font )
 {
     wxCHECK_RET( m_widget != NULL, "invalid window" );
-
+    
+    if (m_font == font) return;
+    
     if (((wxFont*)&font)->Ok())
         m_font = font;
     else
index aff2211922fa246801ac7cd44f134b303dd956dc..0c0d9b98a5102583253c889d38d3856cb589505a 100644 (file)
@@ -62,7 +62,7 @@ wxMenuBar::wxMenuBar()
 
     m_menubar = gtk_menu_bar_new();
 
-        m_widget = GTK_WIDGET(m_menubar);
+    m_widget = GTK_WIDGET(m_menubar);
 
     PostCreation();
 
@@ -494,9 +494,9 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
     wxMenuItem *mitem = new wxMenuItem();
     mitem->SetId(id);
     mitem->SetText(text);
+    mitem->SetHelp(helpStr);
 
     GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
-    mitem->SetHelp(helpStr);
     mitem->SetMenuItem(menuItem);
     mitem->SetSubMenu(subMenu);
 
@@ -514,6 +514,43 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
     m_items.Append( mitem );
 }
 
+void wxMenu::Append( wxMenuItem *item )
+{
+    m_items.Append( item );
+    
+    GtkWidget *menuItem = (GtkWidget*) NULL;
+
+    if (item->IsSeparator()) 
+        menuItem = gtk_menu_item_new();
+    else if (item->IsSubMenu()) 
+        menuItem = gtk_menu_item_new_with_label(item->GetText());
+    else 
+        menuItem = item->IsCheckable() ? gtk_check_menu_item_new_with_label(item->GetText())
+                                       : gtk_menu_item_new_with_label(item->GetText());
+
+    if (!item->IsSeparator())
+    {
+        gtk_signal_connect( GTK_OBJECT(menuItem), "select",
+                            GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
+                            (gpointer*)this );
+
+        gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
+                            GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
+                            (gpointer*)this );
+                           
+       if (!item->IsSubMenu())
+       {
+            gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
+                                GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
+                                (gpointer*)this );
+       }
+    }
+    
+    gtk_menu_append( GTK_MENU(m_menu), menuItem );
+    gtk_widget_show( menuItem );
+    item->SetMenuItem(menuItem);
+}
+
 int wxMenu::FindItem( const wxString itemString ) const
 {
     wxString s( itemString );
index ee6d3eec70e5da7bd70943986c6b5a931f47fd48..39aba4ce4698c1624b0b0010966f4628a85f11ce 100644 (file)
@@ -37,6 +37,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi
     
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
index 5f9c8915b66b13acfc924024aafeab4e7e2a8924..08a4da1d1956fc0c097177709d6f533452f6afdd 100644 (file)
@@ -35,6 +35,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
     
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
@@ -56,11 +57,11 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
   
     wxScrollEvent event( command, win->GetId(), value, orient );
     event.SetEventObject( win );
-    win->ProcessEvent( event );
+    win->GetEventHandler()->ProcessEvent( event );
   
     wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
     cevent.SetEventObject( win );
-    win->ProcessEvent( cevent );
+    win->GetEventHandler()->ProcessEvent( cevent );
 }
 
 //-----------------------------------------------------------------------------
index dfe03b27a187b7f264f978730c7c448208974359..392310c3f9f1635a29c0bf7cadf8847b9e7b697c 100644 (file)
@@ -33,9 +33,10 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
 { 
     if (!win->HasVMT()) return;
     if (g_blockEventsOnDrag) return;
-  
+
     float diff = win->m_adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldPos = win->m_adjust->value;
   
     wxEventType command = wxEVT_NULL;
   
@@ -55,7 +56,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
     event.SetOrientation( wxVERTICAL );
     event.SetEventObject( win );
   
-    win->ProcessEvent( event );
+    win->GetEventHandler()->ProcessEvent( event );
 }
 
 //-----------------------------------------------------------------------------
index d7f0dcd96e01af3d8aa5bd7c3fe60d5bcb35a6fb..7c6817aa3ef95ea76b399efa3e18b34d8c2d07c2 100644 (file)
@@ -300,6 +300,7 @@ void wxTextCtrl::WriteText( const wxString &text )
     {
         /* this moves the cursor pos to behind the inserted text */
        gint len = GTK_EDITABLE(m_text)->current_pos;
+       
         gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
        
        /* bring editable's cursor uptodate. bug in GTK. */
index 39a203d80476d847e28443880913a74deba41e66..89b75f8a9d54fc4b2912145e98800c26cdca4c18 100644 (file)
@@ -1081,6 +1081,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
 
     float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldVerticalPos = win->m_vAdjust->value;
 
     wxEventType command = wxEVT_NULL;
 
@@ -1128,6 +1129,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
 
     float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
     if (fabs(diff) < 0.2) return;
+    win->m_oldHorizontalPos = win->m_hAdjust->value;
 
     wxEventType command = wxEVT_NULL;
 
@@ -2835,7 +2837,9 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
 void wxWindow::SetFont( const wxFont &font )
 {
     wxCHECK_RET( m_widget != NULL, "invalid window" );
-
+    
+    if (m_font == font) return;
+    
     if (((wxFont*)&font)->Ok())
         m_font = font;
     else
index 47a21717e91f1dfe7e613dbebfe2147cfa48ce6e..3ee6ca77c0e9cf40199b2ba62bb6e145a9103bb4 100644 (file)
@@ -227,6 +227,9 @@ bool wxGLCanvas::Create( wxWindow *parent, wxWindowID id,
     gtk_signal_connect( GTK_OBJECT(m_glWidget), "draw",
       GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
       
+    /* connect to key press and mouse handlers etc. */  
+    ConnectWidget( m_glWidget );
+    
     gtk_widget_show( m_glWidget );
     
     m_glContext = new wxGLContext( TRUE, this, palette );