2001-06-26 17:05:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2004-05-25 07:20:37 -04:00
|
|
|
// Program: wxWidgets Widgets Sample
|
2001-06-26 17:05:06 -04:00
|
|
|
// Name: slider.cpp
|
|
|
|
// Purpose: Part of the widgets sample showing wxSlider
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 16.04.01
|
|
|
|
// Copyright: (c) 2001 Vadim Zeitlin
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 17:05:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// for compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2004-11-23 06:45:07 -05:00
|
|
|
#if wxUSE_SLIDER
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// for all others, include the necessary headers
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/log.h"
|
|
|
|
|
2003-03-23 10:12:41 -05:00
|
|
|
#include "wx/bitmap.h"
|
2001-06-26 17:05:06 -04:00
|
|
|
#include "wx/button.h"
|
|
|
|
#include "wx/checkbox.h"
|
|
|
|
#include "wx/radiobox.h"
|
|
|
|
#include "wx/slider.h"
|
|
|
|
#include "wx/statbox.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#endif
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
#include "wx/tooltip.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
#include "wx/sizer.h"
|
|
|
|
|
|
|
|
#include "widgets.h"
|
2004-11-23 06:45:07 -05:00
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
#include "icons/slider.xpm"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// control ids
|
|
|
|
enum
|
|
|
|
{
|
2002-07-09 19:33:46 -04:00
|
|
|
SliderPage_Reset = wxID_HIGHEST,
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_Clear,
|
|
|
|
SliderPage_SetValue,
|
|
|
|
SliderPage_SetMinAndMax,
|
2019-01-31 14:36:25 -05:00
|
|
|
SliderPage_SetRange,
|
2006-07-27 01:05:21 -04:00
|
|
|
SliderPage_SetLineSize,
|
|
|
|
SliderPage_SetPageSize,
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_SetTickFreq,
|
2003-01-24 06:55:29 -05:00
|
|
|
SliderPage_SetThumbLen,
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_CurValueText,
|
|
|
|
SliderPage_ValueText,
|
|
|
|
SliderPage_MinText,
|
|
|
|
SliderPage_MaxText,
|
2019-01-31 14:36:25 -05:00
|
|
|
SliderPage_RangeMinText,
|
|
|
|
SliderPage_RangeMaxText,
|
2006-07-27 01:05:21 -04:00
|
|
|
SliderPage_LineSizeText,
|
|
|
|
SliderPage_PageSizeText,
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_TickFreqText,
|
2003-01-24 06:55:29 -05:00
|
|
|
SliderPage_ThumbLenText,
|
|
|
|
SliderPage_RadioSides,
|
|
|
|
SliderPage_BothSides,
|
2019-01-31 14:36:25 -05:00
|
|
|
SliderPage_SelectRange,
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_Slider
|
|
|
|
};
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
// sides radiobox values
|
|
|
|
enum
|
|
|
|
{
|
2009-11-14 18:15:27 -05:00
|
|
|
SliderTicks_None,
|
2005-04-10 14:07:08 -04:00
|
|
|
SliderTicks_Top,
|
|
|
|
SliderTicks_Bottom,
|
|
|
|
SliderTicks_Left,
|
|
|
|
SliderTicks_Right
|
2003-01-24 06:55:29 -05:00
|
|
|
};
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// SliderWidgetsPage
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class SliderWidgetsPage : public WidgetsPage
|
|
|
|
{
|
|
|
|
public:
|
2006-05-17 15:49:09 -04:00
|
|
|
SliderWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2015-07-31 11:53:55 -04:00
|
|
|
virtual wxWindow *GetWidget() const wxOVERRIDE { return m_slider; }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void RecreateWidget() wxOVERRIDE { CreateSlider(); }
|
2004-11-19 14:03:04 -05:00
|
|
|
|
2006-06-06 10:10:06 -04:00
|
|
|
// lazy creation of the content
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void CreateContent() wxOVERRIDE;
|
2006-06-06 10:10:06 -04:00
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
protected:
|
|
|
|
// event handlers
|
|
|
|
void OnButtonReset(wxCommandEvent& event);
|
|
|
|
void OnButtonClear(wxCommandEvent& event);
|
|
|
|
void OnButtonSetValue(wxCommandEvent& event);
|
|
|
|
void OnButtonSetMinAndMax(wxCommandEvent& event);
|
2019-01-31 14:36:25 -05:00
|
|
|
void OnButtonSetRange(wxCommandEvent& event);
|
2006-07-27 01:05:21 -04:00
|
|
|
void OnButtonSetLineSize(wxCommandEvent& event);
|
|
|
|
void OnButtonSetPageSize(wxCommandEvent& event);
|
2001-06-26 17:05:06 -04:00
|
|
|
void OnButtonSetTickFreq(wxCommandEvent& event);
|
2003-01-24 06:55:29 -05:00
|
|
|
void OnButtonSetThumbLen(wxCommandEvent& event);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
void OnCheckOrRadioBox(wxCommandEvent& event);
|
|
|
|
|
2002-07-09 19:33:46 -04:00
|
|
|
void OnSlider(wxScrollEvent& event);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
void OnUpdateUIValueButton(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
|
2019-01-31 14:36:25 -05:00
|
|
|
void OnUpdateUIRangeButton(wxUpdateUIEvent& event);
|
2006-07-27 01:05:21 -04:00
|
|
|
void OnUpdateUILineSize(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUIPageSize(wxUpdateUIEvent& event);
|
2001-06-26 17:05:06 -04:00
|
|
|
void OnUpdateUITickFreq(wxUpdateUIEvent& event);
|
2003-01-24 06:55:29 -05:00
|
|
|
void OnUpdateUIThumbLen(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUIRadioSides(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUIBothSides(wxUpdateUIEvent& event);
|
2019-01-31 14:36:25 -05:00
|
|
|
void OnUpdateUISelectRange(wxUpdateUIEvent& event);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
void OnUpdateUIResetButton(wxUpdateUIEvent& event);
|
|
|
|
|
|
|
|
void OnUpdateUICurValueText(wxUpdateUIEvent& event);
|
|
|
|
|
|
|
|
// reset the slider parameters
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
// (re)create the slider
|
|
|
|
void CreateSlider();
|
|
|
|
|
2006-07-27 01:05:21 -04:00
|
|
|
// set the line size from the text field value
|
|
|
|
void DoSetLineSize();
|
|
|
|
|
|
|
|
// set the page size from the text field value
|
|
|
|
void DoSetPageSize();
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// set the tick frequency from the text field value
|
|
|
|
void DoSetTickFreq();
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
// set the thumb len from the text field value
|
|
|
|
void DoSetThumbLen();
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
// set the selection range from the text field values
|
|
|
|
void DoSetSelectionRange();
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// is this slider value in range?
|
|
|
|
bool IsValidValue(int val) const
|
|
|
|
{ return (val >= m_min) && (val <= m_max); }
|
|
|
|
|
|
|
|
// the slider range
|
|
|
|
int m_min, m_max;
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
// the slider selection range
|
|
|
|
int m_rangeMin, m_rangeMax;
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// the controls
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
// the check/radio boxes for styles
|
2009-11-14 11:31:06 -05:00
|
|
|
wxCheckBox *m_chkMinMaxLabels,
|
|
|
|
*m_chkValueLabel,
|
2005-01-23 15:17:21 -05:00
|
|
|
*m_chkInverse,
|
2003-01-24 06:55:29 -05:00
|
|
|
*m_chkTicks,
|
2019-01-31 14:36:25 -05:00
|
|
|
*m_chkBothSides,
|
|
|
|
*m_chkSelectRange;
|
2003-01-24 06:55:29 -05:00
|
|
|
|
|
|
|
wxRadioBox *m_radioSides;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// the slider itself and the sizer it is in
|
|
|
|
wxSlider *m_slider;
|
|
|
|
wxSizer *m_sizerSlider;
|
|
|
|
|
|
|
|
// the text entries for set value/range
|
|
|
|
wxTextCtrl *m_textValue,
|
|
|
|
*m_textMin,
|
|
|
|
*m_textMax,
|
2019-01-31 14:36:25 -05:00
|
|
|
*m_textRangeMin,
|
|
|
|
*m_textRangeMax,
|
2006-07-27 01:05:21 -04:00
|
|
|
*m_textLineSize,
|
|
|
|
*m_textPageSize,
|
2003-01-24 06:55:29 -05:00
|
|
|
*m_textTickFreq,
|
|
|
|
*m_textThumbLen;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
private:
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2001-11-25 10:18:38 -05:00
|
|
|
DECLARE_WIDGETS_PAGE(SliderWidgetsPage)
|
2001-06-26 17:05:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event tables
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2014-03-30 03:07:55 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(SliderWidgetsPage, WidgetsPage)
|
2001-06-26 17:05:06 -04:00
|
|
|
EVT_BUTTON(SliderPage_Reset, SliderWidgetsPage::OnButtonReset)
|
|
|
|
EVT_BUTTON(SliderPage_SetValue, SliderWidgetsPage::OnButtonSetValue)
|
|
|
|
EVT_BUTTON(SliderPage_SetMinAndMax, SliderWidgetsPage::OnButtonSetMinAndMax)
|
2019-01-31 14:36:25 -05:00
|
|
|
EVT_BUTTON(SliderPage_SetRange, SliderWidgetsPage::OnButtonSetRange)
|
2006-07-27 01:05:21 -04:00
|
|
|
EVT_BUTTON(SliderPage_SetLineSize, SliderWidgetsPage::OnButtonSetLineSize)
|
|
|
|
EVT_BUTTON(SliderPage_SetPageSize, SliderWidgetsPage::OnButtonSetPageSize)
|
2001-06-26 17:05:06 -04:00
|
|
|
EVT_BUTTON(SliderPage_SetTickFreq, SliderWidgetsPage::OnButtonSetTickFreq)
|
2003-01-24 06:55:29 -05:00
|
|
|
EVT_BUTTON(SliderPage_SetThumbLen, SliderWidgetsPage::OnButtonSetThumbLen)
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
EVT_UPDATE_UI(SliderPage_SetValue, SliderWidgetsPage::OnUpdateUIValueButton)
|
|
|
|
EVT_UPDATE_UI(SliderPage_SetMinAndMax, SliderWidgetsPage::OnUpdateUIMinMaxButton)
|
2019-01-31 14:36:25 -05:00
|
|
|
EVT_UPDATE_UI(SliderPage_SetRange, SliderWidgetsPage::OnUpdateUIRangeButton)
|
2006-07-27 01:05:21 -04:00
|
|
|
EVT_UPDATE_UI(SliderPage_SetLineSize, SliderWidgetsPage::OnUpdateUILineSize)
|
|
|
|
EVT_UPDATE_UI(SliderPage_SetPageSize, SliderWidgetsPage::OnUpdateUIPageSize)
|
2001-06-26 17:05:06 -04:00
|
|
|
EVT_UPDATE_UI(SliderPage_SetTickFreq, SliderWidgetsPage::OnUpdateUITickFreq)
|
2003-01-24 06:55:29 -05:00
|
|
|
EVT_UPDATE_UI(SliderPage_SetThumbLen, SliderWidgetsPage::OnUpdateUIThumbLen)
|
|
|
|
EVT_UPDATE_UI(SliderPage_RadioSides, SliderWidgetsPage::OnUpdateUIRadioSides)
|
|
|
|
EVT_UPDATE_UI(SliderPage_BothSides, SliderWidgetsPage::OnUpdateUIBothSides)
|
2019-01-31 14:36:25 -05:00
|
|
|
EVT_UPDATE_UI(SliderPage_SelectRange, SliderWidgetsPage::OnUpdateUISelectRange)
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
EVT_UPDATE_UI(SliderPage_Reset, SliderWidgetsPage::OnUpdateUIResetButton)
|
|
|
|
|
|
|
|
EVT_UPDATE_UI(SliderPage_CurValueText, SliderWidgetsPage::OnUpdateUICurValueText)
|
|
|
|
|
2002-07-09 19:33:46 -04:00
|
|
|
EVT_COMMAND_SCROLL(SliderPage_Slider, SliderWidgetsPage::OnSlider)
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2003-12-11 05:32:15 -05:00
|
|
|
EVT_CHECKBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
|
|
|
|
EVT_RADIOBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
|
2014-03-30 03:07:55 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
2006-05-22 06:39:40 -04:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#define FAMILY_CTRLS UNIVERSAL_CTRLS
|
|
|
|
#else
|
|
|
|
#define FAMILY_CTRLS NATIVE_CTRLS
|
|
|
|
#endif
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, "Slider", FAMILY_CTRLS );
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2006-05-17 15:49:09 -04:00
|
|
|
SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
|
2004-11-23 06:45:07 -05:00
|
|
|
wxImageList *imaglist)
|
2006-05-26 10:07:47 -04:00
|
|
|
: WidgetsPage(book, imaglist, slider_xpm)
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
|
|
|
// init everything
|
|
|
|
m_min = 0;
|
|
|
|
m_max = 100;
|
2019-01-31 14:36:25 -05:00
|
|
|
m_rangeMin = 20;
|
|
|
|
m_rangeMax = 80;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2005-01-28 15:56:09 -05:00
|
|
|
m_chkInverse =
|
2001-06-26 17:05:06 -04:00
|
|
|
m_chkTicks =
|
2009-11-14 11:31:06 -05:00
|
|
|
m_chkMinMaxLabels =
|
|
|
|
m_chkValueLabel =
|
2019-01-31 14:36:25 -05:00
|
|
|
m_chkBothSides =
|
|
|
|
m_chkSelectRange =(wxCheckBox *)NULL;
|
2003-01-24 06:55:29 -05:00
|
|
|
|
|
|
|
m_radioSides = (wxRadioBox *)NULL;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
m_slider = (wxSlider *)NULL;
|
|
|
|
m_sizerSlider = (wxSizer *)NULL;
|
2006-06-06 10:10:06 -04:00
|
|
|
}
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2006-06-06 10:10:06 -04:00
|
|
|
void SliderWidgetsPage::CreateContent()
|
|
|
|
{
|
2001-06-26 17:05:06 -04:00
|
|
|
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
|
|
|
// left pane
|
2018-09-28 21:45:15 -04:00
|
|
|
wxStaticBox *box = new wxStaticBox(this, wxID_ANY, "&Set style");
|
2001-06-26 17:05:06 -04:00
|
|
|
wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
m_chkInverse = CreateCheckBoxAndAddToSizer(sizerLeft, "&Inverse");
|
|
|
|
m_chkTicks = CreateCheckBoxAndAddToSizer(sizerLeft, "Show &ticks");
|
|
|
|
m_chkMinMaxLabels = CreateCheckBoxAndAddToSizer(sizerLeft, "Show min/max &labels");
|
|
|
|
m_chkValueLabel = CreateCheckBoxAndAddToSizer(sizerLeft, "Show &value label");
|
2003-01-24 06:55:29 -05:00
|
|
|
static const wxString sides[] =
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
"default",
|
|
|
|
"top",
|
|
|
|
"bottom",
|
|
|
|
"left",
|
|
|
|
"right",
|
2003-01-24 06:55:29 -05:00
|
|
|
};
|
2018-09-28 21:45:15 -04:00
|
|
|
m_radioSides = new wxRadioBox(this, SliderPage_RadioSides, "&Label position",
|
2003-01-24 06:55:29 -05:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
WXSIZEOF(sides), sides,
|
|
|
|
1, wxRA_SPECIFY_COLS);
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerLeft->Add(m_radioSides, wxSizerFlags().Expand().Border());
|
2003-01-24 06:55:29 -05:00
|
|
|
m_chkBothSides = CreateCheckBoxAndAddToSizer
|
2018-09-28 21:45:15 -04:00
|
|
|
(sizerLeft, "&Both sides", SliderPage_BothSides);
|
2019-01-31 14:36:25 -05:00
|
|
|
m_chkSelectRange = CreateCheckBoxAndAddToSizer
|
|
|
|
(sizerLeft, "&Selection range", SliderPage_SelectRange);
|
2003-01-24 06:55:29 -05:00
|
|
|
#if wxUSE_TOOLTIPS
|
2018-09-28 21:45:15 -04:00
|
|
|
m_chkBothSides->SetToolTip("\"Both sides\" is only supported \nin Universal");
|
2019-01-31 14:36:25 -05:00
|
|
|
m_chkSelectRange->SetToolTip("\"Select range\" is only supported \nin wxMSW");
|
2003-01-24 06:55:29 -05:00
|
|
|
#endif // wxUSE_TOOLTIPS
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerLeft->AddSpacer(5);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
wxButton *btn = new wxButton(this, SliderPage_Reset, "&Reset");
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerLeft->Add(btn, wxSizerFlags().CentreHorizontal().Border(wxALL, 15));
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// middle pane
|
2018-09-28 21:45:15 -04:00
|
|
|
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Change slider value");
|
2001-06-26 17:05:06 -04:00
|
|
|
wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
|
|
|
|
|
|
|
|
wxTextCtrl *text;
|
2018-09-28 21:45:15 -04:00
|
|
|
wxSizer *sizerRow = CreateSizerWithTextAndLabel("Current value",
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_CurValueText,
|
|
|
|
&text);
|
2003-12-11 05:32:15 -05:00
|
|
|
text->SetEditable(false);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetValue,
|
2018-09-28 21:45:15 -04:00
|
|
|
"Set &value",
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_ValueText,
|
|
|
|
&m_textValue);
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetMinAndMax,
|
2018-09-28 21:45:15 -04:00
|
|
|
"&Min and max",
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_MinText,
|
|
|
|
&m_textMin);
|
|
|
|
|
2003-12-11 05:32:15 -05:00
|
|
|
m_textMax = new wxTextCtrl(this, SliderPage_MaxText, wxEmptyString);
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerRow->Add(m_textMax, wxSizerFlags(1).CentreVertical().Border(wxLEFT));
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
m_textMin->SetValue( wxString::Format("%d", m_min) );
|
|
|
|
m_textMax->SetValue( wxString::Format("%d", m_max) );
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetRange,
|
|
|
|
"&Selection",
|
|
|
|
SliderPage_RangeMinText,
|
|
|
|
&m_textRangeMin);
|
|
|
|
|
|
|
|
m_textRangeMax = new wxTextCtrl(this, SliderPage_RangeMaxText, wxEmptyString);
|
|
|
|
sizerRow->Add(m_textRangeMax, wxSizerFlags(1).CentreVertical().Border(wxLEFT));
|
|
|
|
|
|
|
|
m_textRangeMin->SetValue( wxString::Format("%d", m_rangeMin) );
|
|
|
|
m_textRangeMax->SetValue( wxString::Format("%d", m_rangeMax) );
|
|
|
|
|
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
|
|
|
|
2006-07-27 01:05:21 -04:00
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetLineSize,
|
2018-09-28 21:45:15 -04:00
|
|
|
"Li&ne size",
|
2006-07-27 01:05:21 -04:00
|
|
|
SliderPage_LineSizeText,
|
|
|
|
&m_textLineSize);
|
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2006-07-27 01:05:21 -04:00
|
|
|
|
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetPageSize,
|
2018-09-28 21:45:15 -04:00
|
|
|
"P&age size",
|
2006-07-27 01:05:21 -04:00
|
|
|
SliderPage_PageSizeText,
|
|
|
|
&m_textPageSize);
|
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2006-07-27 01:05:21 -04:00
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetTickFreq,
|
2018-09-28 21:45:15 -04:00
|
|
|
"Tick &frequency",
|
2001-06-26 17:05:06 -04:00
|
|
|
SliderPage_TickFreqText,
|
|
|
|
&m_textTickFreq);
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
m_textTickFreq->SetValue("10");
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetThumbLen,
|
2018-09-28 21:45:15 -04:00
|
|
|
"Thumb &length",
|
2003-01-24 06:55:29 -05:00
|
|
|
SliderPage_ThumbLenText,
|
|
|
|
&m_textThumbLen);
|
|
|
|
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
2003-01-24 06:55:29 -05:00
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// right pane
|
|
|
|
wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
m_sizerSlider = sizerRight; // save it to modify it later
|
|
|
|
|
|
|
|
Reset();
|
|
|
|
CreateSlider();
|
|
|
|
|
|
|
|
// the 3 panes panes compose the window
|
2019-01-31 14:32:10 -05:00
|
|
|
sizerTop->Add(sizerLeft,
|
|
|
|
wxSizerFlags(0).Expand().Border((wxALL & ~wxLEFT), 10));
|
|
|
|
sizerTop->Add(sizerMiddle,
|
|
|
|
wxSizerFlags(1).Expand().Border(wxALL, 10));
|
|
|
|
sizerTop->Add(sizerRight,
|
|
|
|
wxSizerFlags(1).Expand().Border((wxALL & ~wxRIGHT), 10));
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// final initializations
|
|
|
|
SetSizer(sizerTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// operations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SliderWidgetsPage::Reset()
|
|
|
|
{
|
2005-01-23 15:17:21 -05:00
|
|
|
m_chkInverse->SetValue(false);
|
2003-12-11 05:32:15 -05:00
|
|
|
m_chkTicks->SetValue(true);
|
2009-11-14 11:31:06 -05:00
|
|
|
m_chkValueLabel->SetValue(true);
|
|
|
|
m_chkMinMaxLabels->SetValue(true);
|
2003-12-11 05:32:15 -05:00
|
|
|
m_chkBothSides->SetValue(false);
|
2019-01-31 14:36:25 -05:00
|
|
|
m_chkSelectRange->SetValue(false);
|
2003-01-24 06:55:29 -05:00
|
|
|
|
2009-11-14 18:15:27 -05:00
|
|
|
m_radioSides->SetSelection(SliderTicks_None);
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::CreateSlider()
|
|
|
|
{
|
2015-01-02 09:26:53 -05:00
|
|
|
int flags = GetAttrs().m_defaultFlags;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2005-01-23 15:17:21 -05:00
|
|
|
if ( m_chkInverse->GetValue() )
|
|
|
|
{
|
|
|
|
flags |= wxSL_INVERSE;
|
|
|
|
}
|
|
|
|
|
2009-11-14 11:31:06 -05:00
|
|
|
if ( m_chkMinMaxLabels->GetValue() )
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
2009-11-14 11:31:06 -05:00
|
|
|
flags |= wxSL_MIN_MAX_LABELS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_chkValueLabel->GetValue() )
|
|
|
|
{
|
|
|
|
flags |= wxSL_VALUE_LABEL;
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_chkTicks->GetValue() )
|
|
|
|
{
|
|
|
|
flags |= wxSL_AUTOTICKS;
|
|
|
|
}
|
|
|
|
|
2009-11-14 18:15:27 -05:00
|
|
|
// 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
|
2003-01-24 06:55:29 -05:00
|
|
|
switch ( m_radioSides->GetSelection() )
|
|
|
|
{
|
2009-11-14 18:15:27 -05:00
|
|
|
case SliderTicks_None:
|
|
|
|
break;
|
|
|
|
|
2005-04-10 14:07:08 -04:00
|
|
|
case SliderTicks_Top:
|
2009-11-14 18:15:27 -05:00
|
|
|
flags |= wxSL_BOTTOM;
|
2003-01-24 06:55:29 -05:00
|
|
|
break;
|
2005-04-10 14:07:08 -04:00
|
|
|
|
|
|
|
case SliderTicks_Left:
|
2009-11-14 18:15:27 -05:00
|
|
|
flags |= wxSL_RIGHT | wxSL_VERTICAL;
|
2003-01-24 06:55:29 -05:00
|
|
|
break;
|
2005-04-10 14:07:08 -04:00
|
|
|
|
|
|
|
case SliderTicks_Bottom:
|
2009-11-14 18:15:27 -05:00
|
|
|
flags |= wxSL_TOP;
|
2003-01-24 06:55:29 -05:00
|
|
|
break;
|
2005-04-10 14:07:08 -04:00
|
|
|
|
2009-11-14 18:15:07 -05:00
|
|
|
case SliderTicks_Right:
|
2009-11-14 18:15:27 -05:00
|
|
|
flags |= wxSL_LEFT | wxSL_VERTICAL;
|
2003-01-24 06:55:29 -05:00
|
|
|
break;
|
2005-04-10 14:07:08 -04:00
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
default:
|
2018-09-28 21:45:15 -04:00
|
|
|
wxFAIL_MSG("unexpected radiobox selection");
|
2003-01-24 06:55:29 -05:00
|
|
|
// fall through
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_chkBothSides->GetValue() )
|
|
|
|
{
|
|
|
|
flags |= wxSL_BOTH;
|
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
if ( m_chkSelectRange->GetValue() )
|
|
|
|
{
|
|
|
|
flags |= wxSL_SELRANGE;
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
int val = m_min;
|
|
|
|
if ( m_slider )
|
|
|
|
{
|
|
|
|
int valOld = m_slider->GetValue();
|
2019-01-31 14:39:15 -05:00
|
|
|
if ( IsValidValue(valOld) )
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
|
|
|
val = valOld;
|
|
|
|
}
|
|
|
|
|
Deprecated wxSizer::Remove( wxWindow* ), s/Remove/Detach/ in most places.
Made wxSizer child list typesafe. I've not added the wxList implicit
conversion kludge yet, let's see who complains first perhaps..
Deprecated wxSizer::{G,S}etOption in favour of {G,S}etProportion in line
with the parameter name change in the docs.
Added {G,S}etSpacer consistent with the accessors for windows/sizers.
Made all wxSizer index parameters size_t -- we support no sensible
interpretation for negative indexes in them. Hopefully this will
cause no real problems, but code doing (eg. Remove( 0 )) will need
to change to use 0u to resolve the ambiguity with overloaded members.
This is probably a Good Thing though, ymmv.
s/FALSE/false/g ; s/TRUE/true/g ; s/wxASSERT/wxASSERT_MSG/g in sizer.{cpp,h}
Fixed (I hope) the brokenness in wxSizer::Show -- I have no code to test
this yet, so it's a blind change, but spacers should now be hidden correctly
instead of ignored, and it should be properly reversable over multiple
calls now too.
removed pointless private scoping around DECLARE_CLASS macros.
Replace 0's I added previously with NULL -- not like that will end the
email thread either..
Added Add( wxSizerItem * ) & co. There are probably a couple of other
places we can usefully do something like this too. Stopped short of
refactoring everything to raise some issues about sizer method recursion
on -dev.
Updated wxSizer docs some more, they are still incomplete but getting
better.
wrapped KeyCode in wxDEPRECATED, converted all (gtk build) instances
to GetKeyCode. There may be a few left for other ports.
Fixed a couple of other random compile warnings along the way.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-01-07 05:22:07 -05:00
|
|
|
m_sizerSlider->Detach( m_slider );
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
if ( m_sizerSlider->GetChildren().GetCount() )
|
|
|
|
{
|
|
|
|
// we have 2 spacers, remove them too
|
2003-01-26 09:03:29 -05:00
|
|
|
m_sizerSlider->Remove( 0 );
|
|
|
|
m_sizerSlider->Remove( 0 );
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete m_slider;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_slider = new wxSlider(this, SliderPage_Slider,
|
|
|
|
val, m_min, m_max,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
flags);
|
|
|
|
|
2005-04-10 14:07:08 -04:00
|
|
|
if ( m_slider->HasFlag(wxSL_VERTICAL) )
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
2019-01-31 14:32:10 -05:00
|
|
|
m_sizerSlider->AddStretchSpacer(1);
|
|
|
|
m_sizerSlider->Add(m_slider, wxSizerFlags(0).Expand().Border());
|
|
|
|
m_sizerSlider->AddStretchSpacer(1);
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-31 14:32:10 -05:00
|
|
|
m_sizerSlider->Add(m_slider, wxSizerFlags(1).Centre().Border());
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-01-31 14:39:15 -05:00
|
|
|
m_textLineSize->SetValue(wxString::Format("%d", m_slider->GetLineSize()));
|
|
|
|
m_textPageSize->SetValue(wxString::Format("%d", m_slider->GetPageSize()));
|
|
|
|
m_textThumbLen->SetValue(wxString::Format("%d", m_slider->GetThumbLength()));
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
if ( m_chkTicks->GetValue() )
|
|
|
|
{
|
|
|
|
DoSetTickFreq();
|
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
if ( m_chkSelectRange->GetValue() )
|
|
|
|
{
|
|
|
|
DoSetSelectionRange();
|
|
|
|
}
|
|
|
|
|
2019-01-31 14:39:15 -05:00
|
|
|
Layout();
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2006-07-27 01:05:21 -04:00
|
|
|
void SliderWidgetsPage::DoSetLineSize()
|
|
|
|
{
|
|
|
|
long lineSize;
|
|
|
|
if ( !m_textLineSize->GetValue().ToLong(&lineSize) )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid slider line size");
|
2006-07-27 01:05:21 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_slider->SetLineSize(lineSize);
|
|
|
|
|
|
|
|
if ( m_slider->GetLineSize() != lineSize )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid line size in slider.");
|
2006-07-27 01:05:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::DoSetPageSize()
|
|
|
|
{
|
|
|
|
long pageSize;
|
|
|
|
if ( !m_textPageSize->GetValue().ToLong(&pageSize) )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid slider page size");
|
2006-07-27 01:05:21 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_slider->SetPageSize(pageSize);
|
|
|
|
|
|
|
|
if ( m_slider->GetPageSize() != pageSize )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid page size in slider.");
|
2006-07-27 01:05:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::DoSetTickFreq()
|
|
|
|
{
|
|
|
|
long freq;
|
|
|
|
if ( !m_textTickFreq->GetValue().ToLong(&freq) )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid slider tick frequency");
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-05 11:36:30 -05:00
|
|
|
m_slider->SetTickFreq(freq);
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
void SliderWidgetsPage::DoSetThumbLen()
|
|
|
|
{
|
|
|
|
long len;
|
|
|
|
if ( !m_textThumbLen->GetValue().ToLong(&len) )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid slider thumb length");
|
2003-01-24 06:55:29 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_slider->SetThumbLength(len);
|
2019-01-31 14:23:38 -05:00
|
|
|
|
|
|
|
if ( m_slider->GetThumbLength() != len )
|
|
|
|
{
|
|
|
|
wxLogWarning(wxString::Format("Invalid thumb length in slider: %d",
|
|
|
|
m_slider->GetThumbLength()));
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout();
|
2003-01-24 06:55:29 -05:00
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
void SliderWidgetsPage::DoSetSelectionRange()
|
|
|
|
{
|
|
|
|
long minNew,
|
|
|
|
maxNew = 0; // init to suppress compiler warning
|
|
|
|
if ( !m_textRangeMin->GetValue().ToLong(&minNew) ||
|
|
|
|
!m_textRangeMax->GetValue().ToLong(&maxNew) ||
|
|
|
|
minNew >= maxNew || minNew < m_min || maxNew > m_max )
|
|
|
|
{
|
|
|
|
wxLogWarning("Invalid selection range for the slider.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rangeMin = minNew;
|
|
|
|
m_rangeMax = maxNew;
|
|
|
|
|
|
|
|
m_slider->SetSelection(m_rangeMin, m_rangeMax);
|
|
|
|
|
|
|
|
if ( m_slider->GetSelStart() != m_rangeMin ||
|
|
|
|
m_slider->GetSelEnd() != m_rangeMax )
|
|
|
|
{
|
|
|
|
wxLogWarning("Invalid selection range in slider.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event handlers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
|
|
|
|
CreateSlider();
|
|
|
|
}
|
|
|
|
|
2006-07-27 01:05:21 -04:00
|
|
|
void SliderWidgetsPage::OnButtonSetLineSize(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
DoSetLineSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnButtonSetPageSize(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
DoSetPageSize();
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnButtonSetTickFreq(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
DoSetTickFreq();
|
|
|
|
}
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
void SliderWidgetsPage::OnButtonSetThumbLen(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
DoSetThumbLen();
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
long minNew,
|
|
|
|
maxNew = 0; // init to suppress compiler warning
|
|
|
|
if ( !m_textMin->GetValue().ToLong(&minNew) ||
|
|
|
|
!m_textMax->GetValue().ToLong(&maxNew) ||
|
|
|
|
minNew >= maxNew )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid min/max values for the slider.");
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_min = minNew;
|
|
|
|
m_max = maxNew;
|
|
|
|
|
|
|
|
m_slider->SetRange(minNew, maxNew);
|
2005-03-21 12:30:10 -05:00
|
|
|
|
|
|
|
if ( m_slider->GetMin() != m_min ||
|
|
|
|
m_slider->GetMax() != m_max )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid range in slider.");
|
2005-03-21 12:30:10 -05:00
|
|
|
}
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
void SliderWidgetsPage::OnButtonSetRange(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
DoSetSelectionRange();
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
long val;
|
|
|
|
if ( !m_textValue->GetValue().ToLong(&val) || !IsValidValue(val) )
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogWarning("Invalid slider value.");
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_slider->SetValue(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long val;
|
|
|
|
event.Enable( m_textValue->GetValue().ToLong(&val) && IsValidValue(val) );
|
|
|
|
}
|
|
|
|
|
2006-07-27 01:05:21 -04:00
|
|
|
void SliderWidgetsPage::OnUpdateUILineSize(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long lineSize;
|
|
|
|
event.Enable( m_textLineSize->GetValue().ToLong(&lineSize) &&
|
|
|
|
(lineSize > 0) && (lineSize <= m_max - m_min) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnUpdateUIPageSize(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long pageSize;
|
|
|
|
event.Enable( m_textPageSize->GetValue().ToLong(&pageSize) &&
|
|
|
|
(pageSize > 0) && (pageSize <= m_max - m_min) );
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnUpdateUITickFreq(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long freq;
|
|
|
|
event.Enable( m_chkTicks->GetValue() &&
|
|
|
|
m_textTickFreq->GetValue().ToLong(&freq) &&
|
|
|
|
(freq > 0) && (freq <= m_max - m_min) );
|
|
|
|
}
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
void SliderWidgetsPage::OnUpdateUIThumbLen(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long val;
|
|
|
|
event.Enable( m_textThumbLen->GetValue().ToLong(&val));
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long mn, mx;
|
|
|
|
event.Enable( m_textMin->GetValue().ToLong(&mn) &&
|
|
|
|
m_textMax->GetValue().ToLong(&mx) &&
|
|
|
|
mn < mx);
|
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
void SliderWidgetsPage::OnUpdateUIRangeButton(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
long mn, mx;
|
|
|
|
event.Enable( m_chkSelectRange->GetValue() &&
|
|
|
|
m_textRangeMin->GetValue().ToLong(&mn) &&
|
|
|
|
m_textRangeMax->GetValue().ToLong(&mx) &&
|
|
|
|
mn < mx &&
|
|
|
|
mn >= m_min && mx <= m_max );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
|
|
|
{
|
2005-04-10 14:07:08 -04:00
|
|
|
event.Enable( m_chkInverse->GetValue() ||
|
2003-01-24 06:55:29 -05:00
|
|
|
!m_chkTicks->GetValue() ||
|
2009-11-14 11:31:06 -05:00
|
|
|
!m_chkValueLabel->GetValue() ||
|
|
|
|
!m_chkMinMaxLabels->GetValue() ||
|
2005-04-10 14:07:08 -04:00
|
|
|
m_chkBothSides->GetValue() ||
|
2019-01-31 14:36:25 -05:00
|
|
|
m_chkSelectRange->GetValue() ||
|
2009-11-14 18:15:27 -05:00
|
|
|
m_radioSides->GetSelection() != SliderTicks_None );
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2003-07-31 09:59:28 -04:00
|
|
|
void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
|
|
|
CreateSlider();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event)
|
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
event.SetText( wxString::Format("%d", m_slider->GetValue()) );
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2003-01-24 06:55:29 -05:00
|
|
|
void SliderWidgetsPage::OnUpdateUIRadioSides(wxUpdateUIEvent& event)
|
|
|
|
{
|
2009-11-14 11:31:06 -05:00
|
|
|
event.Enable( m_chkValueLabel->GetValue() || m_chkTicks->GetValue() );
|
2003-01-24 06:55:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
2005-12-19 05:47:44 -05:00
|
|
|
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
2019-01-31 14:39:15 -05:00
|
|
|
event.Enable( true );
|
2003-01-24 06:55:29 -05:00
|
|
|
#else
|
2003-12-11 05:32:15 -05:00
|
|
|
event.Enable( false );
|
2005-12-19 05:47:44 -05:00
|
|
|
#endif // defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2019-01-31 14:36:25 -05:00
|
|
|
void SliderWidgetsPage::OnUpdateUISelectRange(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
#if defined(__WXMSW__)
|
|
|
|
event.Enable( true );
|
|
|
|
#else
|
|
|
|
event.Enable( false );
|
|
|
|
#endif // defined(__WXMSW__)
|
|
|
|
}
|
|
|
|
|
2002-07-09 19:33:46 -04:00
|
|
|
void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
wxASSERT_MSG( event.GetInt() == m_slider->GetValue(),
|
2018-09-28 21:45:15 -04:00
|
|
|
"slider value should be the same" );
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2002-07-09 19:33:46 -04:00
|
|
|
wxEventType eventType = event.GetEventType();
|
|
|
|
|
|
|
|
/*
|
|
|
|
This array takes the EXACT order of the declarations in
|
|
|
|
include/wx/event.h
|
|
|
|
(section "wxScrollBar and wxSlider event identifiers")
|
|
|
|
*/
|
2018-09-28 21:45:15 -04:00
|
|
|
static const wxString eventNames[] =
|
2002-07-09 19:33:46 -04:00
|
|
|
{
|
2018-09-28 21:45:15 -04:00
|
|
|
"wxEVT_SCROLL_TOP",
|
|
|
|
"wxEVT_SCROLL_BOTTOM",
|
|
|
|
"wxEVT_SCROLL_LINEUP",
|
|
|
|
"wxEVT_SCROLL_LINEDOWN",
|
|
|
|
"wxEVT_SCROLL_PAGEUP",
|
|
|
|
"wxEVT_SCROLL_PAGEDOWN",
|
|
|
|
"wxEVT_SCROLL_THUMBTRACK",
|
|
|
|
"wxEVT_SCROLL_THUMBRELEASE",
|
|
|
|
"wxEVT_SCROLL_CHANGED"
|
2002-07-09 19:33:46 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
int index = eventType - wxEVT_SCROLL_TOP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
If this assert is triggered, there is an unknown slider event which
|
|
|
|
should be added to the above eventNames array.
|
|
|
|
*/
|
2002-08-22 15:22:52 -04:00
|
|
|
wxASSERT_MSG(index >= 0 && (size_t)index < WXSIZEOF(eventNames),
|
2018-09-28 21:45:15 -04:00
|
|
|
"Unknown slider event" );
|
2002-07-09 19:33:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
static int s_numSliderEvents = 0;
|
|
|
|
|
2018-09-28 21:45:15 -04:00
|
|
|
wxLogMessage("Slider event #%d: %s (pos = %d, int value = %d)",
|
2002-07-10 10:11:05 -04:00
|
|
|
s_numSliderEvents++,
|
2002-07-09 19:33:46 -04:00
|
|
|
eventNames[index],
|
2005-01-23 15:17:21 -05:00
|
|
|
event.GetPosition(),
|
|
|
|
event.GetInt());
|
2001-06-26 17:05:06 -04:00
|
|
|
}
|
|
|
|
|
2004-11-23 06:45:07 -05:00
|
|
|
#endif // wxUSE_SLIDER
|