gint m_tag;
};
-static gint wxlistbox_idle_callback( gpointer gdata )
+extern "C" gint wxlistbox_idle_callback( gpointer gdata )
{
wxlistbox_idle_struct* data = (wxlistbox_idle_struct*) gdata;
gdk_threads_enter();
if (!listbox->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
+
+ if (listbox->m_blockEvent) return;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetEventObject( listbox );
+
// MSW doesn't do that either
// event.SetExtraLong( (long) is_selection );
m_acceptsFocus = TRUE;
m_isListBox = TRUE;
m_prevSelection = 0; // or -1 ??
+ m_blockEvent = FALSE;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
gtk_widget_show( GTK_WIDGET(m_list) );
- SetBestSize( size );
-
if ( style & wxLB_SORT )
{
// this will change DoAppend() behaviour
DoAppend(choices[i]);
}
+ // call it after appending the strings to the listbox, otherwise it doesn't
+ // work correctly
+ SetBestSize( size );
+
m_parent->DoAddChild( this );
PostCreation();
- SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
+ SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) );
SetForegroundColour( parent->GetForegroundColour() );
SetFont( parent->GetFont() );
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
gtk_list_clear_items( m_list, 0, GetCount() );
+
+ if ( GTK_LIST(m_list)->last_focus_child != NULL )
+ {
+ // This should be NULL, I think.
+ GTK_LIST(m_list)->last_focus_child = NULL;
+ }
if ( HasClientObjectData() )
{
{
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
- GtkDisableEvents();
+ m_blockEvent = TRUE;
if (select)
{
else
gtk_list_unselect_item( m_list, n );
- GtkEnableEvents();
+ m_blockEvent = FALSE;
}
void wxListBox::DoSetFirstItem( int n )
}
#endif // wxUSE_TOOLTIPS
-void wxListBox::GtkDisableEvents()
-{
- GList *child = m_list->children;
- while (child)
- {
- gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
- GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
-
- if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
- gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
- GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );
-
- child = child->next;
- }
-}
-
-void wxListBox::GtkEnableEvents()
-{
- GList *child = m_list->children;
- while (child)
- {
- gtk_signal_connect( GTK_OBJECT(child->data), "select",
- GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
-
- if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
- gtk_signal_connect( GTK_OBJECT(child->data), "deselect",
- GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );
-
- child = child->next;
- }
-}
-
GtkWidget *wxListBox::GetConnectWidget()
{
return GTK_WIDGET(m_list);
}
// Add room for the scrollbar
- lbWidth += wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+ lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
// And just a bit more
int cx, cy;