X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f050bdbd5b69ed1a6752102f0c4c13bc7cb4ed3c..79b7701c0bc547dc4b579258c7116700e5925162:/src/gtk/slider.cpp diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index 872537d2f1..83deaec5f3 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -302,7 +302,7 @@ bool wxSlider::Create(wxWindow *parent, wxFAIL_MSG( wxT("wxSlider creation failed") ); return false; } - + if (style & wxSL_VERTICAL) m_scale = gtk_vscale_new( NULL ); @@ -313,7 +313,7 @@ bool wxSlider::Create(wxWindow *parent, if (style & wxSL_MIN_MAX_LABELS) { gtk_widget_show( m_scale ); - + if (style & wxSL_VERTICAL) m_widget = gtk_hbox_new(false, 0); else @@ -330,20 +330,20 @@ bool wxSlider::Create(wxWindow *parent, g_object_ref(box); gtk_widget_show(box); gtk_container_add( GTK_CONTAINER(m_widget), box ); - + m_minLabel = gtk_label_new(NULL); g_object_ref(m_minLabel); gtk_widget_show( m_minLabel ); gtk_container_add( GTK_CONTAINER(box), m_minLabel ); gtk_box_set_child_packing( GTK_BOX(box), m_minLabel, FALSE, FALSE, 0, GTK_PACK_START ); - + // expanding empty space between the min/max labels GtkWidget *space = gtk_label_new(NULL); g_object_ref(space); gtk_widget_show( space ); gtk_container_add( GTK_CONTAINER(box), space ); gtk_box_set_child_packing( GTK_BOX(box), space, TRUE, FALSE, 0, GTK_PACK_START ); - + m_maxLabel = gtk_label_new(NULL); g_object_ref(m_maxLabel); gtk_widget_show( m_maxLabel ); @@ -356,19 +356,33 @@ bool wxSlider::Create(wxWindow *parent, m_maxLabel = NULL; m_minLabel = NULL; } - - if (style & wxSL_VALUE_LABEL) - { - gtk_scale_set_draw_value(GTK_SCALE (m_scale), TRUE ); - - if (style & wxSL_VERTICAL) - gtk_scale_set_value_pos( GTK_SCALE(m_scale), GTK_POS_LEFT ); - } - else + + const bool showValueLabel = (style & wxSL_VALUE_LABEL) != 0; + gtk_scale_set_draw_value(GTK_SCALE (m_scale), showValueLabel ); + if ( showValueLabel ) { - gtk_scale_set_draw_value(GTK_SCALE (m_scale), FALSE ); + // position the label appropriately: notice that wxSL_DIRECTION flags + // specify the position of the ticks, not label, under MSW and so the + // label is on the opposite side + GtkPositionType posLabel; + if ( style & wxSL_VERTICAL ) + { + if ( style & wxSL_LEFT ) + posLabel = GTK_POS_RIGHT; + else // if ( style & wxSL_RIGHT ) -- this is also the default + posLabel = GTK_POS_LEFT; + } + else // horizontal slider + { + if ( style & wxSL_TOP ) + posLabel = GTK_POS_BOTTOM; + else // if ( style & wxSL_BOTTOM) -- this is again the default + posLabel = GTK_POS_TOP; + } + + gtk_scale_set_value_pos( GTK_SCALE(m_scale), posLabel ); } - + // Keep full precision in position value gtk_scale_set_digits(GTK_SCALE (m_scale), -1); @@ -437,23 +451,23 @@ void wxSlider::SetRange( int minValue, int maxValue ) gtk_range_set_range(GTK_RANGE (m_scale), minValue, maxValue); gtk_range_set_increments(GTK_RANGE (m_scale), 1, (maxValue - minValue + 9) / 10); GTKEnableEvents(); - + if (HasFlag(wxSL_MIN_MAX_LABELS)) { wxString str; - + str.Printf( "%d", minValue ); if (HasFlag(wxSL_INVERSE)) gtk_label_set_text( GTK_LABEL(m_maxLabel), str.utf8_str() ); else gtk_label_set_text( GTK_LABEL(m_minLabel), str.utf8_str() ); - + str.Printf( "%d", maxValue ); if (HasFlag(wxSL_INVERSE)) gtk_label_set_text( GTK_LABEL(m_minLabel), str.utf8_str() ); else gtk_label_set_text( GTK_LABEL(m_maxLabel), str.utf8_str() ); - + } }