diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index 266d8ea585..8b1e29d317 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -186,6 +186,26 @@ void wxSpinButton::SetRange(int minVal, int maxVal) GtkDisableEvents(); gtk_spin_button_set_range((GtkSpinButton*)m_widget, minVal, maxVal); m_pos = int(gtk_spin_button_get_value((GtkSpinButton*)m_widget)); + + // Use smaller page increment in the case of a narrow range for convenience + // and to limit possible up/down ambiguity in gtk_value_changed() when + // wrapping is on (The maximal page increment of 10 is consistent with the + // default page increment set by gtk_spin_button_new_with_range(0, 100, 1) + // in wxSpinButton::Create().) + const int range = maxVal - minVal; + int pageInc; + if ( range < 10 ) + pageInc = 1; + else if ( range < 20 ) + pageInc = 2; + else if ( range < 50 ) + pageInc = 5; + else + pageInc = 10; + + GtkAdjustment* adj = gtk_spin_button_get_adjustment((GtkSpinButton*)m_widget); + gtk_adjustment_set_page_increment(adj, pageInc); + GtkEnableEvents(); }