// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
-// #pragma implementation "butbase.h"
- #pragma implementation "spinbutt.h"
-#endif
-
#include "wx/wxprec.h"
#ifdef __BORLANDC__
if ( !wxSpinButtonBase::Create(parent, id, pos, size, style,
wxDefaultValidator, name) )
- return FALSE;
+ return false;
SetBestSize(size);
CreateInputHandler(wxINP_HANDLER_SPINBTN);
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
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;
}
{
// 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,
if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
{
// programm has vetoed the event
- return FALSE;
+ return false;
}
m_value = valueNew;
event.SetEventType(wxEVT_SCROLL_THUMBTRACK);
(void)GetEventHandler()->ProcessEvent(event);
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
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;
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;
}
// ----------------------------------------------------------------------------
{
}
-bool wxStdSpinButtonInputHandler::HandleKey(wxControl *control,
+bool wxStdSpinButtonInputHandler::HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed)
{
break;
}
- if ( !!action )
+ if ( !action.IsEmpty() )
{
- control->PerformAction(action);
+ consumer->PerformAction(action);
- return TRUE;
+ return true;
}
}
- return wxStdInputHandler::HandleKey(control, event, pressed);
+ return wxStdInputHandler::HandleKey(consumer, event, pressed);
}
-bool wxStdSpinButtonInputHandler::HandleMouse(wxControl *control,
+bool wxStdSpinButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
- wxSpinButton *spinbtn = wxStaticCast(control, wxSpinButton);
+ wxSpinButton *spinbtn = wxStaticCast(consumer->GetInputWindow(), wxSpinButton);
if ( spinbtn->GetArrows().HandleMouse(event) )
{
// don't refresh, everything is already done
- return FALSE;
+ return false;
}
- return wxStdInputHandler::HandleMouse(control, event);
+ return wxStdInputHandler::HandleMouse(consumer, event);
}
-bool wxStdSpinButtonInputHandler::HandleMouseMove(wxControl *control,
+bool wxStdSpinButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
- wxSpinButton *spinbtn = wxStaticCast(control, wxSpinButton);
+ wxSpinButton *spinbtn = wxStaticCast(consumer->GetInputWindow(), wxSpinButton);
if ( spinbtn->GetArrows().HandleMouseMove(event) )
{
// processed by the arrows
- return FALSE;
+ return false;
}
- return wxStdInputHandler::HandleMouseMove(control, event);
+ return wxStdInputHandler::HandleMouseMove(consumer, event);
}