Support wxSL_{LEFT,TOP,RIGHT,BOTTOM} in wxGTL version of wxSlider.
Make the display of the orientations in the slider page of the widgets sample
more clear.
Also document wxSL_<DIR> meaning better.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62655
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
compatible with wxSL_SELRANGE.
@endStyleTable
+ Notice that @c wxSL_LEFT, @c wxSL_TOP, @c wxSL_RIGHT and @c wxSL_BOTTOM
+ specify the position of the slider ticks in MSW implementation and that the
+ slider labels, if any, are positioned on the opposite side. So, to have a
+ label on the left side of a vertical slider, @b wxSL_RIGHT must be used (or
+ none of these styles at all should be specified as left and top are default
+ positions for the vertical and horizontal sliders respectively).
+
@beginEventEmissionTable{wxScrollEvent}
You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
scroll events from controls, or EVT_SCROLL... macros without window IDs for
// sides radiobox values
enum
{
+ SliderTicks_None,
SliderTicks_Top,
SliderTicks_Bottom,
SliderTicks_Left,
m_chkValueLabel = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Show &value label"));
static const wxString sides[] =
{
+ wxT("default"),
wxT("top"),
wxT("bottom"),
wxT("left"),
wxT("right"),
};
- m_radioSides = new wxRadioBox(this, SliderPage_RadioSides, wxT("&Ticks/Labels"),
+ m_radioSides = new wxRadioBox(this, SliderPage_RadioSides, wxT("&Label position"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(sides), sides,
1, wxRA_SPECIFY_COLS);
m_chkMinMaxLabels->SetValue(true);
m_chkBothSides->SetValue(false);
- m_radioSides->SetSelection(SliderTicks_Top);
+ m_radioSides->SetSelection(SliderTicks_None);
}
void SliderWidgetsPage::CreateSlider()
flags |= wxSL_AUTOTICKS;
}
+ // notice that the style names refer to the _ticks_ positions while we want
+ // to allow the user to select the label(s) positions and the labels are on
+ // the opposite side from the ticks, hence the apparent reversal below
switch ( m_radioSides->GetSelection() )
{
+ case SliderTicks_None:
+ break;
+
case SliderTicks_Top:
- flags |= wxSL_TOP;
+ flags |= wxSL_BOTTOM;
break;
case SliderTicks_Left:
- flags |= wxSL_LEFT | wxSL_VERTICAL;
+ flags |= wxSL_RIGHT | wxSL_VERTICAL;
break;
case SliderTicks_Bottom:
- flags |= wxSL_BOTTOM;
+ flags |= wxSL_TOP;
break;
case SliderTicks_Right:
- flags |= wxSL_RIGHT | wxSL_VERTICAL;
+ flags |= wxSL_LEFT | wxSL_VERTICAL;
break;
default:
!m_chkValueLabel->GetValue() ||
!m_chkMinMaxLabels->GetValue() ||
m_chkBothSides->GetValue() ||
- m_radioSides->GetSelection() != SliderTicks_Top );
+ m_radioSides->GetSelection() != SliderTicks_None );
}
void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
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 );
+ // 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;
+ }
- if (style & wxSL_VERTICAL)
- gtk_scale_set_value_pos( GTK_SCALE(m_scale), GTK_POS_LEFT );
- }
- else
- {
- gtk_scale_set_draw_value(GTK_SCALE (m_scale), FALSE );
+ gtk_scale_set_value_pos( GTK_SCALE(m_scale), posLabel );
}
// Keep full precision in position value