From e55ff14df0f058c6fef5452d8bbcc25f0618518f Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 20 Oct 2000 14:38:07 +0000 Subject: [PATCH] Minor correction to listbox::SetFirstItem so that it doesn't scroll beyond the legal range. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/listbox.cpp | 5 ++++- src/gtk1/listbox.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index b8daf15ec1..563385ef1f 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -803,7 +803,10 @@ void wxListBox::DoSetFirstItem( int n ) GtkWidget *item = GTK_WIDGET(target->data); wxCHECK_RET( item, wxT("invalid listbox code") ); - gtk_adjustment_set_value( adjustment, item->allocation.y ); + float y = item->allocation.y; + if (y > adjustment->upper - adjustment->page_size) + y = adjustment->upper - adjustment->page_size; + gtk_adjustment_set_value( adjustment, y ); } // ---------------------------------------------------------------------------- diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index b8daf15ec1..563385ef1f 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -803,7 +803,10 @@ void wxListBox::DoSetFirstItem( int n ) GtkWidget *item = GTK_WIDGET(target->data); wxCHECK_RET( item, wxT("invalid listbox code") ); - gtk_adjustment_set_value( adjustment, item->allocation.y ); + float y = item->allocation.y; + if (y > adjustment->upper - adjustment->page_size) + y = adjustment->upper - adjustment->page_size; + gtk_adjustment_set_value( adjustment, y ); } // ----------------------------------------------------------------------------