KiCad PCB EDA Suite
STEPPED_SLIDER Class Reference

Customized wxSlider with forced stepping. More...

#include <stepped_slider.h>

Inheritance diagram for STEPPED_SLIDER:

Public Member Functions

 STEPPED_SLIDER (wxWindow *aParent, wxWindowID aId, int aValue, int aMinValue, int aMaxValue, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxSL_HORIZONTAL, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxSliderNameStr)
 
virtual ~STEPPED_SLIDER ()
 
void SetStep (int aSize)
 Set the step size. More...
 
int GetStep () const
 Get the step size. More...
 

Private Member Functions

void OnScroll (wxScrollEvent &aEvent)
 

Private Attributes

int m_step
 

Detailed Description

Customized wxSlider with forced stepping.

Definition at line 28 of file stepped_slider.h.

Constructor & Destructor Documentation

◆ STEPPED_SLIDER()

STEPPED_SLIDER::STEPPED_SLIDER ( wxWindow *  aParent,
wxWindowID  aId,
int  aValue,
int  aMinValue,
int  aMaxValue,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = wxSL_HORIZONTAL,
const wxValidator &  aValidator = wxDefaultValidator,
const wxString &  aName = wxSliderNameStr 
)

Definition at line 29 of file stepped_slider.cpp.

40  :wxSlider( aParent, aId, aValue, aMinValue, aMaxValue,
41  aPos, aSize, aStyle, aValidator, aName ),
42  m_step( 1 )
43 {}

◆ ~STEPPED_SLIDER()

STEPPED_SLIDER::~STEPPED_SLIDER ( )
virtual

Definition at line 46 of file stepped_slider.cpp.

47 {}

Member Function Documentation

◆ GetStep()

int STEPPED_SLIDER::GetStep ( ) const

Get the step size.

Definition at line 64 of file stepped_slider.cpp.

65 {
66  return m_step;
67 }

References m_step.

◆ OnScroll()

void STEPPED_SLIDER::OnScroll ( wxScrollEvent &  aEvent)
private

Definition at line 70 of file stepped_slider.cpp.

71 {
72  const int value = GetValue();
73  const int rounded = value - value % m_step;
74 
75  SetValue( rounded );
76  aEvent.Skip();
77 }

References m_step.

◆ SetStep()

void STEPPED_SLIDER::SetStep ( int  aSize)

Set the step size.

Definition at line 50 of file stepped_slider.cpp.

51 {
52  wxASSERT( aSize > 0 );
53  m_step = ( aSize > 0 ) ? aSize : 1;
54 
55 #ifdef __WXMSW__
56  ClearTicks();
57 
58  if( aSize > 1 )
59  SetTickFreq( aSize );
60 #endif // __WXMSW__
61 }

References m_step.

Referenced by PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS().

Member Data Documentation

◆ m_step

int STEPPED_SLIDER::m_step
private

Definition at line 59 of file stepped_slider.h.

Referenced by GetStep(), OnScroll(), and SetStep().


The documentation for this class was generated from the following files: