X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5e7e9e1b68c236fc0701e8313ff20f9768b667c2..5d33ed2c6bc3065bf9dc77742da6c924b9e00fa5:/src/gtk/notebook.cpp diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index ead3936605..b9b68d5f59 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -128,9 +128,9 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* here in order to make repositioning after resizing to take effect. */ if ((gtk_major_version == 1) && (gtk_minor_version == 2) && - (gtk_micro_version < 6) && + (gtk_micro_version < 6) && (win->m_wxwindow) && - (GTK_WIDGET_REALIZED(win->m_wxwindow))) + (GTK_WIDGET_REALIZED(win->m_wxwindow))) { gtk_widget_size_allocate( win->m_wxwindow, alloc ); } @@ -153,6 +153,44 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) return FALSE; } +//----------------------------------------------------------------------------- +// "key_press_event" +//----------------------------------------------------------------------------- + +static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; + + /* win is a control: tab can be propagated up */ + if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) + { + wxNode *node = win->m_pages.Nth( win->GetSelection() ); + if (!node) return FALSE; + + wxNotebookPage *page = (wxNotebookPage*) node->Data(); + + wxNavigationKeyEvent event; + event.SetEventObject( win ); + /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */ + event.SetDirection( (gdk_event->keyval == GDK_Tab) ); + /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ + event.SetCurrentFocus( win ); + if (!page->m_client->GetEventHandler()->ProcessEvent( event )) + { + page->m_client->SetFocus(); + } + + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); + return TRUE; + } + + return FALSE; +} + //----------------------------------------------------------------------------- // InsertChild callback for wxNotebook //----------------------------------------------------------------------------- @@ -213,7 +251,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxNoteBook creation failed") ); - return FALSE; + return FALSE; } @@ -230,15 +268,20 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - if(m_windowStyle & wxNB_RIGHT) + if (m_windowStyle & wxNB_RIGHT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT ); - if(m_windowStyle & wxNB_LEFT) + if (m_windowStyle & wxNB_LEFT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT ); - if(m_windowStyle & wxNB_BOTTOM) + if (m_windowStyle & wxNB_BOTTOM) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM ); + gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", + GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); + PostCreation(); + SetFont( parent->GetFont() ); + gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); @@ -247,19 +290,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, return TRUE; } -void wxNotebook::SetFocus() -{ - if (m_pages.GetCount() == 0) return; - - wxNode *node = m_pages.Nth( GetSelection() ); - - if (!node) return; - - wxNotebookPage *page = (wxNotebookPage*) node->Data(); - - page->m_client->SetFocus(); -} - int wxNotebook::GetSelection() const { wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") ); @@ -625,6 +655,8 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) void wxNotebook::ApplyWidgetStyle() { + // TODO, font for labels etc + SetWidgetStyle(); gtk_widget_set_style( m_widget, m_widgetStyle ); }