Ejemplo n.º 1
0
 public override void OnInit()
 {
     base.OnInit();
     // ensure that we are always the last entry in the GUIWindow.Children
     // -> HitTest always starts from the last entry
     _parentWin = GUIWindowManager.GetWindow(_windowId);
     if (_parentWin != null)
     {
         _parentWin.Children.Remove(this);
         _parentWin.Children.Add(this);
         _isWinOverlayAllowed = _parentWin.IsOverlayAllowed;
     }
     SetDefaultControl();
     _buttonState = NextButtonStates.Activation;
 }
Ejemplo n.º 2
0
        public override bool HitTest(int x, int y, out int controlID, out bool focused)
        {
            switch (_buttonState)
            {
            case NextButtonStates.Activation:
                if (Dimmed == false) // let us check if something changed by keyboard input
                {
                    _buttonState = NextButtonStates.Deaktivation;
                    focused      = !Dimmed;
                    controlID    = _defaultcontrol;
                    return(true);
                }
                if (_imageFocused.HitTest(x, y, out controlID, out focused))
                {
                    focused      = !Dimmed;
                    controlID    = _defaultcontrol;
                    _buttonState = NextButtonStates.Outside;
                    return(true);
                }
                return(false);

            case NextButtonStates.Outside:
                if (Dimmed == true) // let us check if something changed by keyboard input
                {
                    _buttonState = NextButtonStates.Activation;
                    focused      = !Dimmed;
                    controlID    = -1;
                    return(false);
                }
                if (!_imageFocused.HitTest(x, y, out controlID, out focused))
                {
                    _buttonState = NextButtonStates.Deaktivation;
                }
                break;

            case NextButtonStates.Deaktivation:
                if (Dimmed == true) // let us check if something changed by keyboard input
                {
                    _buttonState = NextButtonStates.Activation;
                    focused      = !Dimmed;
                    controlID    = -1;
                    return(false);
                }
                if (_imageFocused.HitTest(x, y, out controlID, out focused))
                {
                    GUIMessage msg;
                    if (_exitcontrol == -1)
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LOSTFOCUS, _windowId, 0, GetFocusControlId(), 0, 0,
                                             null);
                    }
                    else
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, _windowId, 0, _exitcontrol, 0, 0, null);
                    }
                    GUIWindow win = GUIWindowManager.GetWindow(_windowId);
                    if (win != null)
                    {
                        win.OnMessage(msg);
                    }
                    controlID    = -1;
                    _buttonState = NextButtonStates.Outside2;
                    return(false);
                }
                break;

            case NextButtonStates.Outside2:
                if (Dimmed == false) // let us check if something changed by keyboard input
                {
                    _buttonState = NextButtonStates.Deaktivation;
                    focused      = !Dimmed;
                    controlID    = _defaultcontrol;
                    return(true);
                }
                if (!_imageFocused.HitTest(x, y, out controlID, out focused))
                {
                    _buttonState = NextButtonStates.Activation;
                }
                return(false);
            }
            if (base.HitTest(x, y, out controlID, out focused))
            {
                return(true);
            }

            int posX   = Math.Min(_buttonX, _positionX);
            int posY   = Math.Min(_buttonY, _positionY);
            int width  = Math.Max(_buttonWidth, _width);
            int height = Math.Max(_buttonHeight, _height);

            focused   = !Dimmed;
            controlID = GetFocusControlId();

            if (controlID == -1)
            {
                controlID = _defaultcontrol;
            }
            if ((x >= posX) && (x <= posX + width) && (y >= posY) && (y <= posY + height))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 public override void OnDeInit()
 {
     base.OnDeInit();
     _buttonState = NextButtonStates.Activation;
 }
Ejemplo n.º 4
0
    public override bool HitTest(int x, int y, out int controlID, out bool focused)
    {
      switch (_buttonState)
      {
        case NextButtonStates.Activation:
          if (Dimmed == false) // let us check if something changed by keyboard input
          {
            _buttonState = NextButtonStates.Deaktivation;
            focused = !Dimmed;
            controlID = _defaultcontrol;
            return true;
          }
          if (_imageFocused.HitTest(x, y, out controlID, out focused))
          {
            focused = !Dimmed;
            controlID = _defaultcontrol;
            _buttonState = NextButtonStates.Outside;
            return true;
          }
          return false;

        case NextButtonStates.Outside:
          if (Dimmed == true) // let us check if something changed by keyboard input
          {
            _buttonState = NextButtonStates.Activation;
            focused = !Dimmed;
            controlID = -1;
            return false;
          }
          if (!_imageFocused.HitTest(x, y, out controlID, out focused))
          {
            _buttonState = NextButtonStates.Deaktivation;
          }
          break;

        case NextButtonStates.Deaktivation:
          if (Dimmed == true) // let us check if something changed by keyboard input
          {
            _buttonState = NextButtonStates.Activation;
            focused = !Dimmed;
            controlID = -1;
            return false;
          }
          if (_imageFocused.HitTest(x, y, out controlID, out focused))
          {
            GUIMessage msg;
            if (_exitcontrol == -1)
            {
              msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LOSTFOCUS, _windowId, 0, GetFocusControlId(), 0, 0,
                                   null);
            }
            else
            {
              msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, _windowId, 0, _exitcontrol, 0, 0, null);
            }
            GUIWindow win = GUIWindowManager.GetWindow(_windowId);
            if (win != null)
            {
              win.OnMessage(msg);
            }
            controlID = -1;
            _buttonState = NextButtonStates.Outside2;
            return false;
          }
          break;

        case NextButtonStates.Outside2:
          if (Dimmed == false) // let us check if something changed by keyboard input
          {
            _buttonState = NextButtonStates.Deaktivation;
            focused = !Dimmed;
            controlID = _defaultcontrol;
            return true;
          }
          if (!_imageFocused.HitTest(x, y, out controlID, out focused))
          {
            _buttonState = NextButtonStates.Activation;
          }
          return false;
      }
      if (base.HitTest(x, y, out controlID, out focused))
      {
        return true;
      }

      int posX = Math.Min(_buttonX, _positionX);
      int posY = Math.Min(_buttonY, _positionY);
      int width = Math.Max(_buttonWidth, _width);
      int height = Math.Max(_buttonHeight, _height);
      focused = !Dimmed;
      controlID = GetFocusControlId();

      if (controlID == -1)
      {
        controlID = _defaultcontrol;
      }
      if ((x >= posX) && (x <= posX + width) && (y >= posY) && (y <= posY + height))
      {
        return true;
      }
      return false;
    }
Ejemplo n.º 5
0
 public override void OnDeInit()
 {
   base.OnDeInit();
   _buttonState = NextButtonStates.Activation;
 }
Ejemplo n.º 6
0
 public override void OnInit()
 {
   base.OnInit();
   // ensure that we are always the last entry in the GUIWindow.Children 
   // -> HitTest always starts from the last entry
   _parentWin = GUIWindowManager.GetWindow(_windowId);
   if (_parentWin != null)
   {
     _parentWin.Children.Remove(this);
     _parentWin.Children.Add(this);
     _isWinOverlayAllowed = _parentWin.IsOverlayAllowed;
   }
   SetDefaultControl();
   _buttonState = NextButtonStates.Activation;
 }