Model Railroad System  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CTCPanel::Toggle Class Reference

Toggle switch object type. More...

Public Member Functions

 Toggle (name, _ctcpanel, _canvas,...)
 Construct a toggle switch object. More...
 
 ~Toggle ()
 Clean up all data objects and free up all resources. More...
 
 getv ()
 Method to get our value (lever position). More...
 
 setv (state)
 Method to set out value (level position). More...
 
 geti (ind)
 Method to get the state of one of our indicators (none). More...
 
 seti (ind, value)
 Method to set an indicator's state (none). More...
 
 invoke ()
 Method to invoke the toggle switch. More...
 

Private Member Functions

 _VerifyOrientationHV (option, value)
 Method to validate an orientation option of horizontal or vertical. More...
 
 _configureLeftLabel (option, value)
 Method to update the leftlabel option. More...
 
 _configureRightLabel (option, value)
 Method to update the rightlabel option. More...
 
 _configureCenterLabel (option, value)
 Method to update the centerlabel option. More...
 
 _AddTLever (pos)
 Method to add (draw) a toggle switch lever. More...
 
 _MoveTLever (mx, my)
 Method to move an object's lever. More...
 

Private Attributes

 ctcpanel
 The CTC Panel component (parent widget). More...
 
 canvas
 The canvas component (parent widget component). More...
 
 lever
 

Detailed Description

Toggle switch object type.

These are on the control panel and represent simple toggle switches.

Parameters
_ctcpanelThe CTCPanel megawidget.
_canvasThe control panel canvas to draw the switch plate on.
...Options:
  • -x The x coordinate of the object (readonly, default 0).
  • -y The y coordinate of the object (readonly, default 0).
  • -controlpoint The name of the control point this switch is part of (readonly, default CP1).
  • -orientation The orientation of the switch, either horizontal or vertical (readonly, default horizontal).
  • -leftlabel The label of the left or upper position (default "on").
  • -rightlabel The label of the right or lower position (default "off").
  • -centerlabel The label of the center position (default "off").
  • -hascenter Flag indicating if there is a center position or not (readonly, default no).
  • -leftcommand Script to run when the switch is in its left or upper position (default {}).
  • -rightcommand Script to run when the switch is in its right or lower position (default {}).
  • -centercommand Script to run when the switch is in its center position (default {}).
Defined coords terminals:
  • xy The base position of the object.
Defined values (states):
  • Left Left position.
  • Center Center position.
  • Right Right position.
Defined indicators: none.
Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ Toggle()

CTCPanel::Toggle::Toggle ( name  ,
_ctcpanel  ,
_canvas  ,
  ... 
)

Construct a toggle switch object.

Parameters
_ctcpanelThe CTCPanel megawidget.
_canvasThe control panel canvas to draw the Code Button on.
...Option list.

◆ ~Toggle()

CTCPanel::Toggle::~Toggle ( )

Clean up all data objects and free up all resources.

Member Function Documentation

◆ _AddTLever()

CTCPanel::Toggle::_AddTLever ( pos  )
private

Method to add (draw) a toggle switch lever.

Parameters
posThe lever's position (Left, Right, or Center).

◆ _configureCenterLabel()

CTCPanel::Toggle::_configureCenterLabel ( option  ,
value   
)
private

Method to update the centerlabel option.

◆ _configureLeftLabel()

CTCPanel::Toggle::_configureLeftLabel ( option  ,
value   
)
private

Method to update the leftlabel option.

◆ _configureRightLabel()

CTCPanel::Toggle::_configureRightLabel ( option  ,
value   
)
private

Method to update the rightlabel option.

◆ _MoveTLever()

CTCPanel::Toggle::_MoveTLever ( mx  ,
my   
)
private

Method to move an object's lever.

Parameters
mxMouse X coordinate. The lever is moved to be near the mouse pointer.
myMouse Y coordinate. The lever is moved to be near the mouse pointer.

◆ _VerifyOrientationHV()

CTCPanel::Toggle::_VerifyOrientationHV ( option  ,
value   
)
private

Method to validate an orientation option of horizontal or vertical.

◆ geti()

CTCPanel::Toggle::geti ( ind  )

Method to get the state of one of our indicators (none).

◆ getv()

CTCPanel::Toggle::getv ( )

Method to get our value (lever position).

◆ invoke()

CTCPanel::Toggle::invoke ( )

Method to invoke the toggle switch.

One of the command scripts is executed depending on the lever position.

◆ seti()

CTCPanel::Toggle::seti ( ind  ,
value   
)

Method to set an indicator's state (none).

◆ setv()

CTCPanel::Toggle::setv ( state  )

Method to set out value (level position).

Parameters
stateThe new state to set.

Member Data Documentation

◆ canvas

CTCPanel::Toggle::canvas
private

The canvas component (parent widget component).

◆ ctcpanel

CTCPanel::Toggle::ctcpanel
private

The CTC Panel component (parent widget).

◆ lever

CTCPanel::Toggle::lever
private