private void UpdateUpDownControls() { for (int i = 0; i < _itemsPerPage; ++i) { GUIUpDownButton btn = (GUIUpDownButton)_listButtons[i]; if (i == _cursorX) { switch (currentSelection) { case Selection.Button: btn.UpDownControl.Focus = false; break; case Selection.Down: btn.UpDownControl.Focus = true; btn.UpDownControl.SelectedButton = GUISpinControl.SpinSelect.SPIN_BUTTON_DOWN; break; case Selection.Up: btn.UpDownControl.Focus = true; btn.UpDownControl.SelectedButton = GUISpinControl.SpinSelect.SPIN_BUTTON_UP; break; case Selection.PageCounter: btn.UpDownControl.Focus = false; break; } } else { btn.UpDownControl.Focus = false; } } }
protected override void AllocButtons() { currentSelection = Selection.Button; for (int i = 0; i < _itemsPerPage; ++i) { GUIUpDownButton cntl = new GUIUpDownButton(_controlId, 0, _spinControlPositionX, _spinControlPositionY, _width, _itemHeight, _buttonFocusName, _buttonNonFocusName, _spinControlWidth, _spinControlHeight, _upTextureName, _downTextureName, _upTextureNameFocus, _downTextureNameFocus, _spinControlColor, _spinControlPositionX, _spinControlPositionY, _shadowAngle, _shadowDistance, _shadowColor); cntl.ParentControl = this; cntl.AllocResources(); _listButtons.Add(cntl); } }
public override bool HitTest(int x, int y, out int controlID, out bool focused) { controlID = GetID; focused = Focus; int id; bool focus; if (_verticalScrollbar.HitTest(x, y, out id, out focus)) { return(true); } if (_upDownControl.HitTest(x, y, out id, out focus)) { if (_upDownControl.GetMaximum() > 1) { _listType = ListType.CONTROL_UPDOWN; _upDownControl.Focus = true; if (!_upDownControl.Focus) { _listType = ListType.CONTROL_LIST; } return(true); } return(true); } if (!base.HitTest(x, y, out id, out focus)) { return(false); } _listType = ListType.CONTROL_LIST; int posy = y - (int)_positionY; _cursorX = (posy / (_itemHeight + _spaceBetweenItems)); while (_offset + _cursorX >= _listItems.Count) { _cursorX--; } if (_cursorX >= _itemsPerPage) { _cursorX = _itemsPerPage - 1; } OnSelectionChanged(); _refresh = true; if (_listButtons != null) { int cntlId; bool gotFocus; for (int i = 0; i < _itemsPerPage; ++i) { GUIUpDownButton btn = (GUIUpDownButton)_listButtons[i]; btn.HitTest(x, y, out cntlId, out gotFocus); if (i == _cursorX) { currentSelection = Selection.Button; if (btn.UpDownControl.Focus) { if (btn.UpDownControl.SelectedButton == GUISpinControl.SpinSelect.SPIN_BUTTON_DOWN) { currentSelection = Selection.Down; } if (btn.UpDownControl.SelectedButton == GUISpinControl.SpinSelect.SPIN_BUTTON_UP) { currentSelection = Selection.Up; } } } } } return(true); }