Esempio n. 1
0
void Spinner::setModel(SpinnerModelPtr model)
{
    _Model = model;
    setEditor(ComponentUnrecPtr(createEditor(_Model)));
}
Esempio n. 2
0
void Component::moveFocus(Int32 MoveAmount)
{
    //Follow a depth first search of Components that are isFocusInteractable 
    ComponentUnrecPtr ComponentToFocus = ComponentUnrecPtr(this);
    if(MoveAmount > 0)
    {
        //Focus forward the given amount
        for(Int32 i(0) ; i<MoveAmount ; ++i)
        {
            //Find the next component that is Focus Interactable
            do
            {
                ComponentToFocus = ComponentToFocus->getNextDepthFirstComponent();
            }while(ComponentToFocus != NULL &&               //None found
                   ComponentToFocus != this &&               //Looped back to this component
                   !ComponentToFocus->isFocusInteractable());

            //Has the Depth first order reached the end
            if(ComponentToFocus == NULL &&
               getParentWindow() != NULL)
            {
                ComponentToFocus = getParentWindow()->getLeftmostDecendent();
            }

            //Is the focus allowed to go here
            ComponentContainer* ParentTest(getParentContainer());
            while(ParentTest != NULL &&
                  !ParentTest->isDecendent(ComponentToFocus))
            {
                if(!ParentTest->allowFocusToLeave())
                {
                    //Change the focus to the first child of this parent
                    ComponentToFocus = ParentTest->getLeftmostDecendent();
                    break;
                }
                ParentTest = ParentTest->getParentContainer();
            }
        }
    }
    else if(MoveAmount < 0)
    {
        //Focus backward the given amount
        for(Int32 i(0) ; i>MoveAmount ; --i)
        {
            //Find the next component that is Focus Interactable
            do
            {
                ComponentToFocus = ComponentToFocus->getPrevDepthFirstComponent();
            }while(ComponentToFocus != NULL &&               //None found
                   ComponentToFocus != this &&               //Looped back to this component
                   !ComponentToFocus->isFocusInteractable());

            //Has the Depth first order reached the first
            if(ComponentToFocus == NULL &&
               getParentWindow() != NULL)
            {
                ComponentToFocus = getParentWindow()->getRightmostDecendent();
            }

            //Is the focus allowed to go here
            ComponentContainer* ParentTest(getParentContainer());
            while(ParentTest != NULL &&
                  !ParentTest->isDecendent(ComponentToFocus))
            {
                if(!ParentTest->allowFocusToLeave())
                {
                    //Change the focus to the first child of this parent
                    ComponentToFocus = ParentTest->getRightmostDecendent();
                    break;
                }
                ParentTest = ParentTest->getParentContainer();
            }
        }
    }

    //If a component was found to move to
    if(ComponentToFocus != NULL &&
       ComponentToFocus != this)
    {
        ComponentToFocus->takeFocus();
    }
}