void wxSpinButton::SetRange(int minVal, int maxVal) { const bool hadRange = m_min < m_max; wxSpinButtonBase::SetRange(minVal, maxVal); #ifdef UDM_SETRANGE32 if ( wxApp::GetComCtl32Version() >= 471 ) { // use the full 32 bit range if available ::SendMessage(GetHwnd(), UDM_SETRANGE32, minVal, maxVal); } else // we're limited to 16 bit #endif // UDM_SETRANGE32 { ::SendMessage(GetHwnd(), UDM_SETRANGE, 0, (LPARAM) MAKELONG((short)maxVal, (short)minVal)); } // the current value might be out of the new range, force it to be in it NormalizeValue(); // if range was valid but becomes degenerated (min == max) now or vice // versa then the spin buttons are automatically disabled/enabled back // but don't update themselves for some reason, so do it manually if ( hadRange != (m_min < m_max) ) { // update the visual state of the button Refresh(); } }
bool wxSpinButton::ChangeValue(int inc) { int valueNew = NormalizeValue(m_value + inc); if ( valueNew == m_value ) { // nothing changed - most likely because we are already at min/max // value return false; } wxSpinEvent event(inc > 0 ? wxEVT_SCROLL_LINEUP : wxEVT_SCROLL_LINEDOWN, GetId()); event.SetPosition(valueNew); event.SetEventObject(this); if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) { // programm has vetoed the event return false; } m_value = valueNew; // send wxEVT_SCROLL_THUMBTRACK as well event.SetEventType(wxEVT_SCROLL_THUMBTRACK); (void)GetEventHandler()->ProcessEvent(event); return true; }
void wxSpinCtrl::OnKillFocus(wxFocusEvent& event) { // ensure that a correct value is shown by the control NormalizeValue(); event.Skip(); }