X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3312ee03a7b1b378a880d5ace627f937f9cc6a72..d6a658ff0cd928953efdaf1ea56ff04b9cf281c1:/src/gtk/slider.cpp diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index a0998bc13b..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,15 +356,33 @@ bool wxSlider::Create(wxWindow *parent, m_maxLabel = NULL; m_minLabel = NULL; } - - if (style & wxSL_VALUE_LABEL) + + 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), TRUE ); - - if (style & wxSL_VERTICAL) - gtk_scale_set_value_pos( GTK_SCALE(m_scale), GTK_POS_LEFT ); + // 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); @@ -433,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() ); - + } }