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.

32  :
33  wxSlider( aParent, aId, aValue, aMinValue, aMaxValue, aPos, aSize,
34  ( aStyle | wxSL_AUTOTICKS | wxSL_MIN_MAX_LABELS ),
35  aValidator,
36  aName ),
37  m_step( 1 )
38 {}

◆ ~STEPPED_SLIDER()

STEPPED_SLIDER::~STEPPED_SLIDER ( )
virtual

Definition at line 41 of file stepped_slider.cpp.

42 {}

Member Function Documentation

◆ GetStep()

int STEPPED_SLIDER::GetStep ( ) const

Get the step size.

Definition at line 65 of file stepped_slider.cpp.

66 {
67  return m_step;
68 }

References m_step.

◆ OnScroll()

void STEPPED_SLIDER::OnScroll ( wxScrollEvent &  aEvent)
private

Definition at line 71 of file stepped_slider.cpp.

72 {
73  // On Windows, moving the thumb can generate multiple subevents and wx is blindly
74  // calling SetValue for each one before calling this event handler
75  // We need to explicitly wait until the "final" sub event or else we end up fighting
76  // wx on the value it is setting and extreme glitchlyness will occur
77  // Not sure if other platforms have this issue
78 #ifdef __WXMSW__
79  if( aEvent.GetEventType() == wxEVT_SCROLL_CHANGED )
80  {
81 #endif // __WXMSW__
82  const int value = GetValue();
83  const int rounded = value - value % m_step;
84  SetValue( rounded );
85 #ifdef __WXMSW__
86  }
87 #endif // __WXMSW__
88  aEvent.Skip();
89 }

References m_step.

◆ SetStep()

void STEPPED_SLIDER::SetStep ( int  aSize)

Set the step size.

Definition at line 45 of file stepped_slider.cpp.

46 {
47  wxASSERT( aSize > 0 );
48  m_step = ( aSize > 0 ) ? aSize : 1;
49 
50  // configure pg up/down to increment by our steps
51  SetPageSize( aSize );
52 
53  //configure arrows to incrment by our steps
54  SetLineSize( aSize );
55 
56 #ifdef __WXMSW__
57  ClearTicks();
58 
59  if( aSize > 1 )
60  SetTickFreq( aSize );
61 #endif // __WXMSW__
62 }

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: