/// <summary> /// Checks if a GUICheckButton control is selected (checked) /// This is also safe if control is not implemented by skin in which case the default value is returned /// </summary> /// <param name="self">the control to check</param> /// <returns>true if selected/checked</returns> public static bool IsSelected(this GUICheckButton self, bool defaultValue = false) { // check if skin implements control if (self == null) { return(defaultValue); } return(self.Selected); }
protected override void RenderButton(float timePassed, int buttonNr, int x, int y, bool gotFocus) { if (buttonNr + _offset >= 0 && buttonNr + _offset < _listItems.Count) { GUIListItem item = (GUIListItem)_listItems[buttonNr + _offset]; GUICheckButton cntl = (GUICheckButton)_listButtons[buttonNr]; cntl.Selected = item.Selected; } base.RenderButton(timePassed, buttonNr, x, y, gotFocus); }
/// <summary> /// Sets a GUICheckButton to selected or not selected /// </summary> /// <param name="self">the control to set</param> /// <param name="state">checked or unchecked</param> public static void Select(this GUICheckButton self, bool state) { // check if skin implements control if (self == null) { return; } self.Selected = state; return; }
/// <summary> /// Creates the element and retrieves all information from the control /// </summary> /// <param name="control">GUIControl</param> public CheckButtonElement(GUIControl control) : base(control) { _button = control as GUICheckButton; if (_button != null) { _font = getFont(_button.FontName); _focusBitmap = loadBitmap(_button.TexutureFocusName); _noFocusBitmap = loadBitmap(_button.TexutureNoFocusName); _textColor = GetColor(_button.TextColor); _disabledColor = GetColor(_button.DisabledColor); _focus = _button.Focus; _selected = _button.Selected; _label = _button.Label; } }
protected override void AllocButtons() { for (int i = 0; i < _itemsPerPage; ++i) { GUICheckButton cntl = new GUICheckButton(_controlId, 0, _spinControlPositionX, _spinControlPositionY, _width, _itemHeight, _buttonFocusName, _buttonNonFocusName, _checkMarkFocusTextureName, _checkMarkNoFocusTextureName, _checkMarkWidth, _checkMarkHeight, _shadowAngle, _shadowDistance, _shadowColor); cntl.ParentControl = this; cntl.AllocResources(); cntl.CheckOffsetX = markOffsetX; cntl.CheckOffsetY = markOffsetY; cntl.DimColor = DimColor; _listButtons.Add(cntl); } }
protected override void AllocButtons() { for (int i = 0; i < _itemsPerPage; ++i) { GUICheckButton cntl = new GUICheckButton(_controlId, 0, _spinControlPositionX, _spinControlPositionY, _width, _itemHeight, _buttonFocusName, _buttonNonFocusName, _checkMarkFocusTextureName, _checkMarkNoFocusTextureName, _checkMarkWidth, _checkMarkHeight, _shadowAngle, _shadowDistance, _shadowColor); cntl.ParentControl = this; cntl.AllocResources(); cntl.CheckOffsetX = markOffsetX; cntl.CheckOffsetY = markOffsetY; cntl.DimColor = DimColor; _listButtons.Add(cntl); } }