X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/23645bfa01b6450257f140a30c87565225b1ef4a..d485bda109d5ef0fef36a3f737549e9b9f54baab:/src/univ/spinbutt.cpp diff --git a/src/univ/spinbutt.cpp b/src/univ/spinbutt.cpp index 07808d336a..08ef3db11e 100644 --- a/src/univ/spinbutt.cpp +++ b/src/univ/spinbutt.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: univ/spinbutt.cpp +// Name: src/univ/spinbutt.cpp // Purpose: implementation of the universal version of wxSpinButton // Author: Vadim Zeitlin // Modified by: @@ -17,11 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "spinbutt.h" - #pragma implementation "univspinbutt.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -43,9 +38,6 @@ // implementation of wxSpinButton // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent) -IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) - // ---------------------------------------------------------------------------- // creation // ---------------------------------------------------------------------------- @@ -101,13 +93,13 @@ bool wxSpinButton::Create(wxWindow *parent, if ( !wxSpinButtonBase::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; + return false; - SetBestSize(size); + SetInitialSize(size); CreateInputHandler(wxINP_HANDLER_SPINBTN); - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -144,14 +136,14 @@ int wxSpinButton::NormalizeValue(int value) const if ( value > m_max ) { if ( GetWindowStyleFlag() & wxSP_WRAP ) - value = m_min + (value - m_max) % (m_max - m_min); + value = m_min + (value - m_max - 1) % (m_max - m_min + 1); else value = m_max; } else if ( value < m_min ) { if ( GetWindowStyleFlag() & wxSP_WRAP ) - value = m_max - (m_min - value) % (m_max - m_min); + value = m_max - (m_min - value - 1) % (m_max - m_min + 1); else value = m_min; } @@ -167,7 +159,7 @@ bool wxSpinButton::ChangeValue(int inc) { // nothing changed - most likely because we are already at min/max // value - return FALSE; + return false; } wxSpinEvent event(inc > 0 ? wxEVT_SCROLL_LINEUP : wxEVT_SCROLL_LINEDOWN, @@ -178,7 +170,7 @@ bool wxSpinButton::ChangeValue(int inc) if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) { // programm has vetoed the event - return FALSE; + return false; } m_value = valueNew; @@ -187,7 +179,7 @@ bool wxSpinButton::ChangeValue(int inc) event.SetEventType(wxEVT_SCROLL_THUMBTRACK); (void)GetEventHandler()->ProcessEvent(event); - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -329,14 +321,14 @@ void wxSpinButton::CalcArrowRects(wxRect *rect1, wxRect *rect2) const } } -wxScrollArrows::Arrow wxSpinButton::HitTest(const wxPoint& pt) const +wxScrollArrows::Arrow wxSpinButton::HitTestArrow(const wxPoint& pt) const { wxRect rectArrow1, rectArrow2; CalcArrowRects(&rectArrow1, &rectArrow2); - if ( rectArrow1.Inside(pt) ) + if ( rectArrow1.Contains(pt) ) return wxScrollArrows::Arrow_First; - else if ( rectArrow2.Inside(pt) ) + else if ( rectArrow2.Contains(pt) ) return wxScrollArrows::Arrow_Second; else return wxScrollArrows::Arrow_None; @@ -357,7 +349,15 @@ bool wxSpinButton::PerformAction(const wxControlAction& action, else return wxControl::PerformAction(action, numArg, strArg); - return TRUE; + return true; +} + +/* static */ +wxInputHandler *wxSpinButton::GetStdInputHandler(wxInputHandler *handlerDef) +{ + static wxStdSpinButtonInputHandler s_handler(handlerDef); + + return &s_handler; } // ---------------------------------------------------------------------------- @@ -390,11 +390,11 @@ bool wxStdSpinButtonInputHandler::HandleKey(wxInputConsumer *consumer, break; } - if ( !!action ) + if ( !action.IsEmpty() ) { consumer->PerformAction(action); - return TRUE; + return true; } } @@ -409,7 +409,7 @@ bool wxStdSpinButtonInputHandler::HandleMouse(wxInputConsumer *consumer, if ( spinbtn->GetArrows().HandleMouse(event) ) { // don't refresh, everything is already done - return FALSE; + return false; } return wxStdInputHandler::HandleMouse(consumer, event); @@ -423,7 +423,7 @@ bool wxStdSpinButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer, if ( spinbtn->GetArrows().HandleMouseMove(event) ) { // processed by the arrows - return FALSE; + return false; } return wxStdInputHandler::HandleMouseMove(consumer, event);