+void wxListBox::OnInternalIdle()
+{
+ wxCursor cursor = m_cursor;
+ if (g_globalCursor.Ok()) cursor = g_globalCursor;
+
+ if (GTK_WIDGET(m_list)->window && cursor.Ok())
+ {
+ /* I now set the cursor the anew in every OnInternalIdle call
+ as setting the cursor in a parent window also effects the
+ windows above so that checking for the current cursor is
+ not possible. */
+
+ gdk_window_set_cursor( GTK_WIDGET(m_list)->window, cursor.GetCursor() );
+
+ GList *child = m_list->children;
+ while (child)
+ {
+ GtkBin *bin = GTK_BIN( child->data );
+ GtkWidget *label = GTK_WIDGET( bin->child );
+
+ if (!label->window)
+ break;
+ else
+ gdk_window_set_cursor( label->window, cursor.GetCursor() );
+
+ child = child->next;
+ }
+ }
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
+ if (wxUpdateUIEvent::CanUpdate(this))
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+}
+
+wxSize wxListBox::DoGetBestSize() const
+{
+ int lbWidth = 100; // some defaults
+ int lbHeight = 110;
+ int wLine;
+
+ // Find the widest line
+ for(int i = 0; i < GetCount(); i++) {
+ wxString str(GetString(i));
+ GetTextExtent(str, &wLine, NULL);
+ lbWidth = wxMax(lbWidth, wLine);
+ }
+
+ // Add room for the scrollbar
+ lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+
+ // And just a bit more
+ int cx, cy;
+ GetTextExtent( wxT("X"), &cx, &cy);
+ lbWidth += 3 * cx;
+
+ // don't make the listbox too tall (limit height to around 10 items) but don't
+ // make it too small neither
+ lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
+
+ return wxSize(lbWidth, lbHeight);
+}
+
+void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y)
+{
+ // the mouse event coords are relative to the listbox items, we need to
+ // translate them to the normal client coords
+ x += widget->allocation.x;
+ y += widget->allocation.y;
+}
+
+#endif // wxUSE_LISTBOX
+