]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/notebook.cpp
Fixed handling of keypress WXK_NUMPAD_NEXT
[wxWidgets.git] / src / gtk / notebook.cpp
index 364487fafcfb13b9f606a6c4fb26eab3f29012c8..a5363e40a9b8f3327fe49893f2e858cb781ba60e 100644 (file)
 #include "wx/gtk/win_gtk.h"
 #include "gdk/gdkkeysyms.h"
 
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
 
 extern bool   g_blockEventsOnDrag;
 
+//-----------------------------------------------------------------------------
+// debug
+//-----------------------------------------------------------------------------
+
+#ifdef __WXDEBUG__
+
+extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
+
+#endif
+
 //-----------------------------------------------------------------------------
 // wxNotebookPage
 //-----------------------------------------------------------------------------
@@ -86,6 +103,8 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
                                               gint nPage,
                                               gpointer data)
 {
+    if (g_isIdle) wxapp_install_idle_handler();
+
     wxNotebook *notebook = (wxNotebook *)data;
 
     int old = notebook->GetSelection();
@@ -104,6 +123,8 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
 
 static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
 {
+    if (g_isIdle) wxapp_install_idle_handler();
+    
     if ((win->m_x == alloc->x) &&
         (win->m_y == alloc->y) &&
         (win->m_width == alloc->width) &&
@@ -111,7 +132,7 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
     {
         return;
     }
-
+    
     win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
 
     if (win->GetAutoLayout()) win->Layout();
@@ -124,9 +145,11 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
 static gint
 gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
 {
+    if (g_isIdle) wxapp_install_idle_handler();
+
     if (g_blockEventsOnDrag) return FALSE;
 
-    if (!notebook->HasVMT()) return FALSE;
+    if (!notebook->m_hasVMT) return FALSE;
 
     /* this code makes jumping down from the handles of the notebooks
        to the actual items in the visible notebook page possible with
@@ -233,6 +256,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
 
     m_widget = gtk_notebook_new();
 
+#ifdef __WXDEBUG__
+    debug_focus_in( m_widget, _T("wxNotebook::m_widget"), name );
+#endif
+
     gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
 
     m_idHandler = gtk_signal_connect (
@@ -240,9 +267,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
                   GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
                   (gpointer)this );
 
-    m_parent->AddChild( this );
-
-    (m_parent->m_insertCallback)( m_parent, this );
+    m_parent->DoAddChild( this );
 
     gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
       GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
@@ -503,7 +528,7 @@ void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
     wxFAIL_MSG( _T("wxNotebook::SetPadding not implemented") );
 }
 
-void wxNotebook::SetTabSize(const wxSize& sz)
+void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
 {
     wxFAIL_MSG( _T("wxNotebook::SetTabSize not implemented") );
 }
@@ -545,6 +570,18 @@ bool wxNotebook::DeletePage( int page )
 
     m_pages.DeleteObject( nb_page );
 
+    /* adjust the notebook page numbers so that
+       m_id reflects the current position, Daniel Paull */ 
+    int count = 0;
+    wxNode *node = m_pages.First();
+    wxNotebookPage *pagePtr = (wxNotebookPage *) NULL;
+    while (node)
+    {
+        pagePtr = (wxNotebookPage*)node->Data();
+        pagePtr->m_id = count++;
+        node = node->Next();
+    }
+    
     return TRUE;
 }
 
@@ -668,6 +705,12 @@ void wxNotebook::ApplyWidgetStyle()
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
 
+bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
+{
+    return ((m_widget->window == window) ||
+            (GTK_NOTEBOOK(m_widget)->panel == window));
+}
+
 //-----------------------------------------------------------------------------
 // wxNotebookEvent
 //-----------------------------------------------------------------------------