Class CheckBox
A box that is ticked or unticked, with a label beside it. Clicking it, or pressing Space while it has focus, toggles it.
public class CheckBox : InteractiveControl, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>, IDisposable
- Inheritance
-
CheckBox
- Implements
- Derived
- Inherited Members
Constructors
CheckBox(ILogger, View, string)
Creates a check box in view.
public CheckBox(ILogger logger, View view, string id = null)
Parameters
Properties
BoxSize
The side of the box, in pixels, for a box drawn in flat colours. Zero uses the font size. Ignored when a state supplies a texture, whose size is used instead.
public float BoxSize { get; set; }
Property Value
CheckMarkColor
Color of the check mark drawn inside the box when checked.
public Color? CheckMarkColor { get; set; }
Property Value
Remarks
Only used by a flat-themed checkbox; a textured one carries its checked state in the art. Drawn as two lines rather than a glyph so it doesn't depend on the font having a tick, and so it scales with BoxSize. Falls back to the checked state's border color, which is what a theme has already said "checked" looks like.
Checked
Whether the box is ticked. Setting it changes the box's look and raises CheckChanged.
public bool Checked { get; set; }
Property Value
CheckedRegion
The name of the picture region drawn for a ticked box. RadioButton overrides it.
protected virtual string CheckedRegion { get; }
Property Value
Font
The font the label is drawn in. Set by LoadContent().
public IFont Font { get; }
Property Value
FontFile
The font to draw the label in: a font file, or the name of a built-in font. Null for the built-in default.
public string FontFile { get; set; }
Property Value
FontSize
The size of the label's text, in pixels.
public float FontSize { get; set; }
Property Value
RequiresRawKeyboard
Whether the box takes keys directly, so that Space reaches it when it has focus.
public override bool RequiresRawKeyboard { get; }
Property Value
Text
The label beside the box.
public string Text { get; set; }
Property Value
Texture
The texture drawn for the box in its current state.
public ITexture Texture { get; set; }
Property Value
UncheckedRegion
The name of the picture region drawn for an unticked box. RadioButton overrides it.
protected virtual string UncheckedRegion { get; }
Property Value
Methods
Dispose()
Unsubscribes the click handler, then disposes the control.
public override void Dispose()
Draw(IGameTime)
Draws the box and its label, while the box is visible.
public override void Draw(IGameTime gameTime)
Parameters
gameTimeIGameTime
~CheckBox()
Unsubscribes the click handler.
protected ~CheckBox()
LoadContent()
Loads the font, and the built-in box pictures for each state that sets neither a texture nor a fill or border.
public override void LoadContent()
OnClicked()
Called when the box is clicked, or Space is pressed while it has focus. Toggles Checked.
protected virtual void OnClicked()
Events
CheckChanged
Raised when Checked changes, with the new value.
public event EventHandler<bool> CheckChanged