void ScrollBar::ScrollBarDraggedListener::mouseDragged(const MouseEventUnrecPtr e)
{
    Pnt2f ComponentMousePosition(ViewportToComponent(e->getLocation(), _ScrollBar, e->getViewport()));

    _ScrollBar->setMajorAxisScrollBarPosition(_InitialScrollBarPosition + (ComponentMousePosition - _InitialMousePosition));
    //std::cout << "Diff "<< _InitialMousePosition[AxisIndex] - ComponentMousePosition[AxisIndex] << std::endl;
}
void ScrollBar::ScrollFieldListener::actionPerformed(const ActionEventUnrecPtr e)
{
	if(_ScrollBar->getEnabled())
	{
		UInt32 AxisIndex(0);
		if(_ScrollBar->getOrientation() == ScrollBar::HORIZONTAL_ORIENTATION ) AxisIndex = 0;
		else  AxisIndex = 1;

		Pnt2f ComponentMousePosition(DrawingSurfaceToComponent(_ScrollBar->getParentWindow()->getDrawingSurface()->getMousePosition(), _ScrollBar));
		//Is Mouse Major axis on the min or max side of the scroll bar
		if(ComponentMousePosition[AxisIndex] < _ScrollBar->editScrollBar()->getPosition()[AxisIndex])
		{
			//Move the Bounded range model one block in the Min direction
			_ScrollBar->scrollBlock(-1);
		}
		else if(ComponentMousePosition[AxisIndex] > 
			(_ScrollBar->editScrollBar()->getPosition()[AxisIndex] + _ScrollBar->editScrollBar()->getSize()[AxisIndex]))
		{
			//Move the Bounded range model one block in the Max direction
			_ScrollBar->scrollBlock(1);
		}
	}
}
void ScrollBar::handleScrollFieldAction(ActionEventDetails* const e)
{
	if(getEnabled())
	{
		UInt32 AxisIndex(0);
		if(getOrientation() == ScrollBar::HORIZONTAL_ORIENTATION ) AxisIndex = 0;
		else  AxisIndex = 1;

		Pnt2f ComponentMousePosition(DrawingSurfaceToComponent(getParentWindow()->getParentDrawingSurface()->getMousePosition(), this));
		//Is Mouse Major axis on the min or max side of the scroll bar
		if(ComponentMousePosition[AxisIndex] < getScrollBar()->getPosition()[AxisIndex])
		{
			//Move the Bounded range model one block in the Min direction
			scrollBlock(-1);
		}
		else if(ComponentMousePosition[AxisIndex] > 
			(getScrollBar()->getPosition()[AxisIndex] + getScrollBar()->getSize()[AxisIndex]))
		{
			//Move the Bounded range model one block in the Max direction
			scrollBlock(1);
		}
	}
}
void ScrollBar::handleScrollBarDragMouseDragged(MouseEventDetails* const e)
{
    Pnt2f ComponentMousePosition(ViewportToComponent(e->getLocation(), this, e->getViewport()));

    setMajorAxisScrollBarPosition(_ScrollBarInitialScrollBarPosition + (ComponentMousePosition - _ScrollBarInitialMousePosition));
}