예제 #1
0
void wxListBox::DoSetSelection( int n, bool select )
{
    wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );

    wxGtkEventsDisabler<wxListBox> noEvents(this);

    GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview);

    // passing -1 to SetSelection() is documented to deselect all items
    if ( n == wxNOT_FOUND )
    {
        gtk_tree_selection_unselect_all(selection);
        return;
    }

    wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetSelection") );


    GtkTreeIter iter;
    wxCHECK_RET( GTKGetIteratorFor(n, &iter), wxT("Invalid index") );

    if (select)
        gtk_tree_selection_select_iter(selection, &iter);
    else
        gtk_tree_selection_unselect_iter(selection, &iter);

    wxGtkTreePath path(
            gtk_tree_model_get_path(GTK_TREE_MODEL(m_liststore), &iter));

    gtk_tree_view_scroll_to_cell(m_treeview, path, NULL, FALSE, 0.0f, 0.0f);
}
예제 #2
0
void wxChoice::SetSelection( int n )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid control") );

    wxGtkEventsDisabler<wxChoice> noEvents(this);

    GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
    gtk_combo_box_set_active( combobox, n );
}
예제 #3
0
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
{
    wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));

    if (state == GetValue())
        return;

    wxGtkEventsDisabler<wxToggleButton> noEvents(this);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state);
}
예제 #4
0
void wxListBox::DoClear()
{
    wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );

    {
        wxGtkEventsDisabler<wxListBox> noEvents(this);

        InvalidateBestSize();

        gtk_list_store_clear( m_liststore ); /* well, THAT was easy :) */
    }

    UpdateOldSelections();
}
예제 #5
0
void wxListBox::DoDeleteOneItem(unsigned int n)
{
    wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );

    InvalidateBestSize();

    wxGtkEventsDisabler<wxListBox> noEvents(this);

    GtkTreeIter iter;
    wxCHECK_RET( GTKGetIteratorFor(n, &iter), wxT("wrong listbox index") );

    // this returns false if iter is invalid (e.g. deleting item at end) but
    // since we don't use iter, we ignore the return value
    gtk_list_store_remove(m_liststore, &iter);
}
예제 #6
0
void wxChoice::DoClear()
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid control") );

    wxGtkEventsDisabler<wxChoice> noEvents(this);

    GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
    GtkTreeModel* model = gtk_combo_box_get_model( combobox );
    if (model)
        gtk_list_store_clear(GTK_LIST_STORE(model));

    m_clientData.Clear();

    if (m_strings)
        m_strings->Clear();

    InvalidateBestSize();
}