Ejemplo n.º 1
0
//-- Probe focus for each widget, till some get it (forward scan)
void FormWidget::CycleFocus( int mode )
{
    if (!!_cycler && !_dont_cycle )
    {
        if ( mode==NEXT || mode==PREVIOUS )
        {
            Widget *begin = _cycler->Who();
            bool accepted = false;
            int  loops=2;//W/A @todo
            int  dbg_iterations = 0;
            int  dbg_n_visible = 0;
            do {
                switch (mode)
                {
                    case NEXT:     loops -= !_cycler->CycleForward(); break;
                    case PREVIOUS: loops -= !_cycler->CycleBack();    break;
                }
                if ( !loops ) { break; }
                
                if ( !_cycler->Who() ) { loops=0; break; }// Break if cycler is not valid
                
                if ( _cycler->Who()->IsRealyVisible() ) // Widget must be visible
                {
                    Widget *next = _cycler->Who();
                    if ( &next->GetEnvironment()->GetForm() == this )
                    accepted = next->Accept( InputFocus() ); 
                    
                    ++dbg_n_visible;
                }
                ++dbg_iterations;

            } while ( !accepted && begin!=_cycler->Who() && loops>0 );

            if ( accepted )
            {
                C_assert( _actual_focus == _cycler->Who());
            }
            else
            {
                if (!loops) { CycleParentForm( mode ); }
                else
                {
                    assert( begin==_cycler->Who() );
                    if ( begin->IsRealyVisible() && begin!=this )
                    {
                        accepted = begin->Accept( InputFocus() );
                    }
                    else
                    {
                        FocusRelease();
                    }
                }
            }
        }// end if (mode==NEXT || mode==PREVIOUS)
    }
}
Ejemplo n.º 2
0
 void ActiveWidget::Init()
 {
     _handlers = new MethodPool<ActiveWidget, const Widget::Request >;
     _handlers->Add( &ActiveWidget::AcceptInputCursor,    InputCursor()  );
     _handlers->Add( &ActiveWidget::AcceptInputButton,    InputButton()  );
     _handlers->Add( &ActiveWidget::AcceptDoubleClick,    DoubleClick()  );
     _handlers->Add( &ActiveWidget::AcceptInputWheel ,    InputWheel()   );
     _handlers->Add( &ActiveWidget::AcceptInputReset ,    InputReset()   );
     _handlers->Add( &ActiveWidget::AcceptInputKeyboard , InputKeyboard());
     _handlers->Add( &ActiveWidget::AcceptInputChar ,     InputChar()    );
     _handlers->Add( &ActiveWidget::AcceptInputFocus,     InputFocus()   );
     _handlers->Add( &ActiveWidget::AcceptInputAccel,     InputAccel()   );
 }
Ejemplo n.º 3
0
//-- Assign focus to any widget
//-- This action is being taken when this Form gains focus
void FormWidget::AssignFocus()
{
    assert( _form_enabled );

    if ( _actual_focus && !_actual_focus->IsRealyVisible())
    {
        InvalidateFocus(_actual_focus);
    }
    
    if ( !_actual_focus && !_dont_cycle )
    {
        if ( !_cycler || !_stored_focus )
        {
            if ( !_default_focus || !_default_focus->Accept(InputFocus()) )
            {
                _cycler = new WidgetCycler(this);
                CycleFocus( NEXT );
            }
            else 
            {
                C_assert( _default_focus == _cycler->Who() ); 
            }
        }
        else if ( _stored_focus ) // check if stored ptr is valid
        {
            _cycler = new WidgetCycler(this); 
            
            do if ( _cycler->Who()==_stored_focus )
            {
                SetFocussed(_stored_focus);
                break;
            }
            while ( _cycler->CycleForward());
          
            _stored_focus=NULL;
        }
    }
}
Ejemplo n.º 4
0
void Events::onEvent(SDL_Event * Event) {
    switch (Event->type) {
        case SDL_ACTIVEEVENT:
        {
            switch (Event->active.state) {
                case SDL_APPMOUSEFOCUS:
                {
                    if (Event->active.gain) MouseFocus();
                    else MouseBlur();
                    break;
                }
                case SDL_APPINPUTFOCUS:
                {
                    if (Event->active.gain) InputFocus();
                    else InputBlur();
                    break;
                }
                case SDL_APPACTIVE:
                {
                    if (Event->active.gain) Restore();
                    else Minimaze();
                    break;
                }
                default: break;

            }
        }
        case SDL_KEYDOWN:
        {
            KeyPressed(Event->key.keysym.sym, Event->key.keysym.mod, Event->key.keysym.unicode);
            break;
        }
        case SDL_KEYUP:
        {
            KeyReleased(Event->key.keysym.sym, Event->key.keysym.mod, Event->key.keysym.unicode);
            break;
        }
        case SDL_MOUSEMOTION:
        {
            MouseMove(Event->motion.x, Event->motion.y, Event->motion.xrel, Event->motion.yrel, Event->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT), Event->motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE), Event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT));
            break;
        }
        case SDL_MOUSEBUTTONDOWN:
        {
            switch (Event->button.button) {
                case SDL_BUTTON_LEFT:
                {
                    LMBPressed(Event->button.x, Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE:
                {
                    MMBPressed(Event->button.x, Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT:
                {
                    RMBPressed(Event->button.x, Event->button.y);
                    break;
                }
                default: break;
            }
        }
        case SDL_MOUSEBUTTONUP:
        {
            switch (Event->button.button) {
                case SDL_BUTTON_LEFT:
                {
                    LMBReleased(Event->button.x, Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE:
                {
                    MMBReleased(Event->button.x, Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT:
                {
                    RMBReleased(Event->button.x, Event->button.y);
                    break;
                }
                default: break;
            }
        }
        case SDL_JOYAXISMOTION:
        {
            break;
        }
        case SDL_JOYBALLMOTION:
        {
            break;
        }
        case SDL_JOYHATMOTION:
        {
            break;
        }
        case SDL_JOYBUTTONDOWN:
        {
            break;
        }
        case SDL_JOYBUTTONUP:
        {
            break;
        }
        case SDL_QUIT:
        {
            QuitEv();
            break;
        }
        case SDL_SYSWMEVENT:
        {
            SystemWM();
            break;
        }
        case SDL_VIDEORESIZE:
        {
            ResizeEv(Event->resize.w, Event->resize.h);
            break;
        }
        case SDL_VIDEOEXPOSE:
        {
            ExposeEv();
            break;
        }
        default:
        {
            UserEv(Event->user.code, Event->user.data1, Event->user.data2);
            break;
        }
    }
}
 // The  window has received focus.
 void GraphicsWindow::OnInputFocus( Ill::Core::EventArgs& e )
 {
     InputFocus( e );
 }