From: Mart Raudsepp Date: Tue, 13 Dec 2005 01:20:41 +0000 (+0000) Subject: Fix HitTest to return the proper tab index in case there are more tabs than fit ... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f660b2062cff776ee12563a49d562ad662c01d7f Fix HitTest to return the proper tab index in case there are more tabs than fit (and therefore there are scrolling arrows), and the first visible tab isn't the first real tab. Before counting started from the visible tab, not real tab. While doing this, I noticed lots of "interesting" bugs wrt tab indexes and the whole wxGtkNotebookPage hack in the code. In my opinion, to fix some of the bugs I noticed during testing, wxGtkNotebookPage has to be nuked and the necessary parts rewritten. Meanwhile, the HitTest fix works with wxNB_TOP styled notebooks that haven't modified tabs in a way that would have mess up the wxGtkNotebookPage index sync. For other cases it might depend on the phase of the moon, and other factors. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36376 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 3b0b8fe5ab..fa18809974 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -736,7 +736,15 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const const gint y = m_widget->allocation.y; const size_t count = GetPageCount(); - for ( size_t i = 0; i < count; i++ ) + size_t i = 0; + +#ifdef __WXGTK20__ + GtkNotebook * notebook = GTK_NOTEBOOK(m_widget); + if (gtk_notebook_get_scrollable(notebook)); + i = g_list_position( notebook->children, notebook->first_tab ); +#endif + + for ( ; i < count; i++ ) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); GtkWidget *box = nb_page->m_box; diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 3b0b8fe5ab..fa18809974 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -736,7 +736,15 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const const gint y = m_widget->allocation.y; const size_t count = GetPageCount(); - for ( size_t i = 0; i < count; i++ ) + size_t i = 0; + +#ifdef __WXGTK20__ + GtkNotebook * notebook = GTK_NOTEBOOK(m_widget); + if (gtk_notebook_get_scrollable(notebook)); + i = g_list_position( notebook->children, notebook->first_tab ); +#endif + + for ( ; i < count; i++ ) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); GtkWidget *box = nb_page->m_box;