made SetFirstItem() work again (patch 1445170)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-03-09 13:47:25 +00:00
parent 0faa7620a5
commit 28354d90fc

View File

@ -972,41 +972,22 @@ void wxListBox::DoSetFirstItem( int n )
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_treeview)) if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_treeview))
return; return;
// terribly efficient (RN:???) GtkTreeIter iter;
// RN: Note that evidently the vadjustment property "vadjustment" from gtk_tree_model_iter_nth_child(
// GtkTreeView is different from the "gtk-vadjustment"... GTK_TREE_MODEL(m_liststore),
// (i.e. gtk_tree_view_get_vadjustment) &iter,
const gchar *vadjustment_key = "gtk-vadjustment"; NULL, //NULL = parent = get first
guint vadjustment_key_id = g_quark_from_static_string (vadjustment_key); n
);
GtkAdjustment *adjustment = GtkTreePath* path = gtk_tree_model_get_path(
(GtkAdjustment*) g_object_get_qdata(G_OBJECT (m_treeview), vadjustment_key_id); GTK_TREE_MODEL(m_liststore), &iter);
wxCHECK_RET( adjustment, wxT("invalid listbox code") );
// Get the greater of the item heights from each column // Scroll to the desired cell (0.0 == topleft alignment)
gint cellheight = 0, cellheightcur; gtk_tree_view_scroll_to_cell(m_treeview, path, NULL,
GList* columnlist = gtk_tree_view_get_columns(m_treeview); TRUE, 0.0f, 0.0f);
GList* curlist = columnlist;
while(curlist) gtk_tree_path_free(path);
{
gtk_tree_view_column_cell_get_size(
GTK_TREE_VIEW_COLUMN(curlist->data),
NULL, NULL, NULL, NULL,
&cellheightcur);
cellheight = cellheightcur > cellheight ?
cellheightcur : cellheight;
curlist = curlist->next;
}
g_list_free(columnlist);
float y = (float) (cellheight * n);
if (y > adjustment->upper - adjustment->page_size)
y = adjustment->upper - adjustment->page_size;
gtk_adjustment_set_value( adjustment, y );
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------