Skip to content

Repository files navigation

pbSwitch

Simple Switch control for Xojo. It's an alternative for DesktopCheckBox Control. The class is standalone, you just need to include it in a project, for example by copying it from the demo project included in the repository.

Main features

  • Set the colors for the left, right, borders, and ball separately;
  • set the left and right text, style, and colors. The color can also be automatically adjusted (black or white) depending on the background.
  • finally, an event allows you to modify the graphics once the control has been rendered.

Appearance properties

For the ball

  • BallAnimation, to animate the ball when clicked
  • BallBorderVisible, BallBorderColor, to set the border of the ball
  • BallLeftColor, BallRightColor, to set the ball color according to the control value
  • BallMargin, to adjust the distance between the ball and the edge of the control. If the margin is negative, you get a ruler appearance.
  • BallShawdowIntesity, to define the shadow under the ball

For the control

Note : The color intensity of the background changes when the control is hovered over or if it receives focus. The color of the border too.

  • BorderColor, BorderVisible, to set the border of the control
  • OffBackClor, OnBackColor, to set the background color based on the control value

For the text

  • OffText, OnText, to set the text on each side
  • FontName, FonSize, Bold, Italic, Underline
  • OffTextColor, OnTextColor, to set the textcolor on each side
  • AutoOffTextColor/AutoOnTextColor, to automatically set the text color (black or white) depending on the background color.
  • TextAlignements, to define whether the text will be aligned to the edge opposite the ball or to the middle of the space between the ball and the opposite side.
  • DeltaTextY, to adjust the top of the both right and left texts.
  • OffDeltaX, OnDeltaX, to adjust the left of each text

General properties

  • Enabled
  • Value
  • Tag

Events

ValueChanged(NewValue as boolean, ByCode as Boolean = True) The ByCode parameter is true if you set the value by code (not by clicking)

AfterDrawingSwitch(g as Graphics, areas() as Rect, Pressed as Boolean, Hover as Boolean) It allows you to draw on the control after it has changed appearance. The settings let you know if it is pressed (MouseDown) or if it is hovered over.

About

Simple Switch control for Xojo

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages