#pragma implementation "listbox.h"
#endif
-#include "wx/dynarray.h"
#include "wx/listbox.h"
+
+#if wxUSE_LISTBOX
+
+#include "wx/dynarray.h"
#include "wx/utils.h"
#include "wx/intl.h"
#include "wx/checklst.h"
// "key_press_event"
//-----------------------------------------------------------------------------
+#if wxUSE_CHECKLISTBOX
static gint
gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox )
{
if (gdk_event->keyval != ' ') return FALSE;
-#if wxUSE_CHECKLISTBOX
int sel = listbox->GetIndex( widget );
wxCheckListBox *clb = (wxCheckListBox *)listbox;
event.SetEventObject( listbox );
event.SetInt( sel );
listbox->GetEventHandler()->ProcessEvent( event );
-#endif // wxUSE_CHECKLISTBOX
return FALSE;
}
+#endif // wxUSE_CHECKLISTBOX
//-----------------------------------------------------------------------------
// "select" and "deselect"
m_needParent = TRUE;
m_acceptsFocus = TRUE;
- PreCreation( parent, id, pos, size, style, name );
-
- SetValidator( validator );
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( _T("wxListBox creation failed") );
+ return FALSE;
+ }
m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
if (style & wxLB_ALWAYS_SB)
{
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
+ DisableEvents();
+
gtk_list_unselect_item( m_list, n );
+
+ EnableEvents();
}
int wxListBox::FindString( const wxString &item ) const
{
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
+ DisableEvents();
+
if (select)
gtk_list_select_item( m_list, n );
else
gtk_list_unselect_item( m_list, n );
+
+ EnableEvents();
}
void wxListBox::SetString( int n, const wxString &string )
GList *child = m_list->children;
while (child)
{
- gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConv_local.cWX2MB(tip), (gchar*) NULL );
+ gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
child = child->next;
}
}
}
#endif
+void wxListBox::DisableEvents()
+{
+ 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))
+ gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
+ GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
+
+ child = child->next;
+ }
+}
+
+void wxListBox::EnableEvents()
+{
+ 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))
+ gtk_signal_connect( GTK_OBJECT(child->data), "deselect",
+ GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
+
+ child = child->next;
+ }
+}
+
GtkWidget *wxListBox::GetConnectWidget()
{
return GTK_WIDGET(m_list);
child = child->next;
}
}
+
+#endif
\ No newline at end of file