Skip to content

Commit

Permalink
ListBox: Add scroll_to() [PERFECTIVE]
Browse files Browse the repository at this point in the history
  • Loading branch information
Janne Kulmala committed Dec 19, 2010
1 parent 40f0c58 commit f7a7cb5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions tiny_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class ListBox: public Widget {
~ListBox();

void add_item(ListBoxItem *item);
void scroll_to(ListBoxItem *item);

private:
#ifdef TINYUI_GTK
Expand Down
8 changes: 8 additions & 0 deletions tinyui_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ void ListBox::add_item(ListBoxItem *item)
gtk_tree_path_free(path);
}

void ListBox::scroll_to(ListBoxItem *item)
{
GtkTreePath *path = gtk_tree_row_reference_get_path(item->m_rowref);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(m_gtkwidget), path, NULL,
false, 0, 0);
gtk_tree_path_free(path);
}

GtkWidget *ListBox::gtk_widget()
{
return m_gtkwidget;
Expand Down
5 changes: 5 additions & 0 deletions tinyui_qt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ void ListBox::add_item(ListBoxItem *item)
m_qtwidget->addItem(item->m_qtitem);
}

void ListBox::scroll_to(ListBoxItem *item)
{
m_qtwidget->scrollToItem(item->m_qtitem);
}

QWidget *ListBox::qt_widget()
{
return m_qtwidget;
Expand Down

0 comments on commit f7a7cb5

Please sign in to comment.