+// ----------------------------------------------------------------------------
+// construction
+// ----------------------------------------------------------------------------
+
+wxListBox::wxListBox()
+{
+ m_list = (GtkList *) NULL;
+#if wxUSE_CHECKLISTBOX
+ m_hasCheckBoxes = FALSE;
+#endif // wxUSE_CHECKLISTBOX
+}
+
+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;
+
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxListBox creation failed") );
+ return FALSE;
+ }
+
+ m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
+ if (style & wxLB_ALWAYS_SB)
+ {
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
+ }
+ else
+ {
+ 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
+
+ /* make list scroll when moving the focus down using cursor keys */
+ gtk_container_set_focus_vadjustment(
+ GTK_CONTAINER(m_list),
+ gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(m_widget)));
+
+ 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 );
+
+ if ( style & wxLB_SORT )
+ {
+ // this will change DoAppend() behaviour
+ m_strings = new wxSortedArrayString;
+ }
+ else
+ {
+ m_strings = (wxSortedArrayString *)NULL;
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ // add one by one
+ DoAppend(choices[i]);
+ }
+
+ m_parent->DoAddChild( this );
+
+ PostCreation();
+
+ SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW ) );
+ SetForegroundColour( parent->GetForegroundColour() );
+ SetFont( parent->GetFont() );
+
+ Show( TRUE );
+
+ return TRUE;
+}
+
+wxListBox::~wxListBox()