-wxListBox::wxListBox(void)
-{
- m_list = NULL;
-};
-
-wxListBox::wxListBox( wxWindow *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
- int n, const wxString choices[],
- long style, const wxString &name )
-{
- Create( parent, id, pos, size, n, choices, style, name );
-};
-
-bool wxListBox::Create( wxWindow *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
- int n, const wxString choices[],
- long style, const wxString &name )
-{
- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- m_widget = gtk_scrolled_window_new( NULL, NULL );
- gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-
- m_list = GTK_LIST( gtk_list_new() );
-
- // @@ what's the difference between BROWSE and SINGLE?
- GtkSelectionMode mode = GTK_SELECTION_BROWSE;
- if ( style & wxLB_MULTIPLE )
- mode = GTK_SELECTION_MULTIPLE;
- else if ( style & wxLB_EXTENDED )
- mode = GTK_SELECTION_EXTENDED;
-
- gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
-
- gtk_container_add (GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
- gtk_widget_show( GTK_WIDGET(m_list) );
-
- for (int i = 0; i < n; i++)
- {
+wxListBox::wxListBox()
+{
+ m_list = (GtkList *) NULL;
+ m_hasCheckBoxes = FALSE;
+}
+
+bool wxListBox::Create( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size,
+ int n, const wxString choices[],
+ long style, const wxValidator& validator, const wxString &name )
+{
+ m_needParent = TRUE;
+ m_acceptsFocus = TRUE;
+
+ PreCreation( parent, id, pos, size, style, name );
+
+ SetValidator( validator );
+
+ m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+
+ m_list = GTK_LIST( gtk_list_new() );
+
+ GtkSelectionMode mode = GTK_SELECTION_BROWSE;
+ if (style & wxLB_MULTIPLE)
+ mode = GTK_SELECTION_MULTIPLE;
+ else if (style & wxLB_EXTENDED)
+ mode = GTK_SELECTION_EXTENDED;
+
+ gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
+
+#ifdef NEW_GTK_SCROLL_CODE
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), GTK_WIDGET(m_list) );
+#else
+ gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
+#endif
+
+#ifdef __WXDEBUG__
+ debug_focus_in( m_widget, "wxListBox::m_widget", name );
+
+ debug_focus_in( GTK_WIDGET(m_list), "wxListBox::m_list", name );
+
+ GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
+
+ debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
+ debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
+
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
+#else
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#endif
+
+ debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
+#endif
+
+ gtk_widget_show( GTK_WIDGET(m_list) );
+
+ wxSize newSize = size;
+ if (newSize.x == -1) newSize.x = 100;
+ if (newSize.y == -1) newSize.y = 110;
+ SetSize( newSize.x, newSize.y );
+
+ for (int i = 0; i < n; i++)
+ {
+ m_clientDataList.Append( (wxObject*) NULL );
+ m_clientObjectList.Append( (wxObject*) NULL );
+
+ GtkWidget *list_item;
+
+ if (m_hasCheckBoxes)
+ {
+ wxString str = "[-] ";
+ str += choices[i];
+ list_item = gtk_list_item_new_with_label( str );
+ }
+ else
+ {
+ list_item = gtk_list_item_new_with_label( choices[i] );
+ }
+
+#ifdef __WXDEBUG__
+ debug_focus_in( list_item, "wxListBox::list_item", name );
+#endif
+
+ gtk_container_add( GTK_CONTAINER(m_list), list_item );
+
+ gtk_signal_connect( GTK_OBJECT(list_item), "select",
+ GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
+
+ if (style & wxLB_MULTIPLE)
+ gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
+ GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(list_item),
+ "button_press_event",
+ (GtkSignalFunc)gtk_listbox_button_press_callback,
+ (gpointer) this );
+
+ if (m_hasCheckBoxes)
+ {
+ gtk_signal_connect( GTK_OBJECT(list_item),
+ "key_press_event",
+ (GtkSignalFunc)gtk_listbox_key_press_callback,
+ (gpointer)this );
+ }
+
+ ConnectWidget( list_item );
+
+ gtk_widget_show( list_item );
+ }
+
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
+ PostCreation();
+
+ gtk_widget_realize( GTK_WIDGET(m_list) );
+
+ SetBackgroundColour( parent->GetBackgroundColour() );
+ SetForegroundColour( parent->GetForegroundColour() );
+
+ Show( TRUE );
+
+ return TRUE;
+}
+
+wxListBox::~wxListBox()
+{
+ Clear();
+}
+
+void wxListBox::AppendCommon( const wxString &item )
+{
+ wxCHECK_RET( m_list != NULL, "invalid listbox" );
+