X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/72c1931497bd63d23e8cf02cbbb9b8795b7d501f..e1efca652844273c3e8d32c7e5f442b87e455ca7:/samples/widgets/slider.cpp diff --git a/samples/widgets/slider.cpp b/samples/widgets/slider.cpp index 8f151f8b90..c4f5135444 100644 --- a/samples/widgets/slider.cpp +++ b/samples/widgets/slider.cpp @@ -6,7 +6,7 @@ // Created: 16.04.01 // Id: $Id$ // Copyright: (c) 2001 Vadim Zeitlin -// License: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -80,6 +80,7 @@ enum // sides radiobox values enum { + SliderTicks_None, SliderTicks_Top, SliderTicks_Bottom, SliderTicks_Left, @@ -159,7 +160,8 @@ protected: // ------------ // the check/radio boxes for styles - wxCheckBox *m_chkLabels, + wxCheckBox *m_chkMinMaxLabels, + *m_chkValueLabel, *m_chkInverse, *m_chkTicks, *m_chkBothSides; @@ -238,7 +240,8 @@ SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book, m_chkInverse = m_chkTicks = - m_chkLabels = + m_chkMinMaxLabels = + m_chkValueLabel = m_chkBothSides = (wxCheckBox *)NULL; m_radioSides = (wxRadioBox *)NULL; @@ -257,15 +260,17 @@ void SliderWidgetsPage::CreateContent() m_chkInverse = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Inverse")); m_chkTicks = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Show &ticks")); - m_chkLabels = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Show &labels")); + m_chkMinMaxLabels = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("Show min/max &labels")); + 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); @@ -370,10 +375,11 @@ void SliderWidgetsPage::Reset() { m_chkInverse->SetValue(false); m_chkTicks->SetValue(true); - m_chkLabels->SetValue(true); + m_chkValueLabel->SetValue(true); + m_chkMinMaxLabels->SetValue(true); m_chkBothSides->SetValue(false); - m_radioSides->SetSelection(SliderTicks_Top); + m_radioSides->SetSelection(SliderTicks_None); } void SliderWidgetsPage::CreateSlider() @@ -385,9 +391,14 @@ void SliderWidgetsPage::CreateSlider() flags |= wxSL_INVERSE; } - if ( m_chkLabels->GetValue() ) + if ( m_chkMinMaxLabels->GetValue() ) { - flags |= wxSL_LABELS; + flags |= wxSL_MIN_MAX_LABELS; + } + + if ( m_chkValueLabel->GetValue() ) + { + flags |= wxSL_VALUE_LABEL; } if ( m_chkTicks->GetValue() ) @@ -395,22 +406,28 @@ 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 | wxSL_VERTICAL: - flags |= wxSL_RIGHT; + case SliderTicks_Right: + flags |= wxSL_LEFT | wxSL_VERTICAL; break; default: @@ -514,7 +531,7 @@ void SliderWidgetsPage::DoSetTickFreq() return; } - m_slider->SetTickFreq(freq, 0 /* unused */); + m_slider->SetTickFreq(freq); } void SliderWidgetsPage::DoSetThumbLen() @@ -645,9 +662,10 @@ void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) { event.Enable( m_chkInverse->GetValue() || !m_chkTicks->GetValue() || - !m_chkLabels->GetValue() || + !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)) @@ -662,7 +680,7 @@ void SliderWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event) void SliderWidgetsPage::OnUpdateUIRadioSides(wxUpdateUIEvent& event) { - event.Enable( m_chkLabels->GetValue() || m_chkTicks->GetValue() ); + event.Enable( m_chkValueLabel->GetValue() || m_chkTicks->GetValue() ); } void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)