Type=Class Version=5.9 ModulesStructureVersion=1 B4J=true @EndOfDesignText@ 'Custom View class #Event: ItemClick (Item As String) #DesignerProperty: Key: MaxValue, DisplayName: Max Value, FieldType: Float, DefaultValue: 1, MinRange: 0, MaxRange: 10, Description: The maximum number of choices that the group can have. #DesignerProperty: Key: MinValue, DisplayName: Min Value, FieldType: Float, DefaultValue: 0, MinRange: 0, MaxRange: 10, Description: The minimum number of choices that the group can have. #DesignerProperty: Key: TickUnit, DisplayName: Tick Unit, FieldType: Float, DefaultValue: 1, MinRange: 0, MaxRange: 10, Description: The jumps between choices. #DesignerProperty: Key: Value, DisplayName: Value, FieldType: Float, DefaultValue: 0, MinRange: 0, MaxRange: 10, Description: The current value that is selected. Sub Class_Globals Private fx As JFX Private mEventName As String 'ignore Private mCallBack As Object 'ignore Private mBase As Pane Private items As List Private masterRB As RadioButton Public MaxValue As Float = 1 Public MinValue As Float = 0 Public TickUnit As Float = 1 Public Value As Float = 0 Private eachW As Int = 60 Private DefaultLabel As Label End Sub 'Initialize the RG control Public Sub Initialize (Callback As Object, EventName As String) 'this executes first mEventName = EventName mCallBack = Callback masterRB.Initialize("masterRB") End Sub Public Sub DesignerCreateView (Base As Pane, Lbl As Label, Props As Map) 'this executes second MaxValue = Props.GetDefault("MaxValue", MaxValue) MinValue = Props.GetDefault("MinValue", MinValue) TickUnit = Props.GetDefault("TickUnit", TickUnit) Value = Props.GetDefault("Value", Value) mBase = Base masterRB.Style = Lbl.Style DefaultLabel = Lbl 'Base.Style = "-fx-border-style: none;" Refresh(MinValue,MaxValue,TickUnit,Value) Base_Resize(mBase.Width, mBase.Height) End Sub 'Select the specified RadioButton with Text Sub SelectValue(uValue As String) If uValue = "" Then Return For Each rb As RadioButton In items rb.Selected = False If rb.Text = uValue Then rb.Selected = True Next End Sub 'Reset the slider Sub Reset Refresh(MinValue,MaxValue,TickUnit,Value) End Sub 'Refresh the configuration of the RadioGroup Sub Refresh(uMinValue As Float, uMaxValue As Float, uTick As Float, uValue As Float) MaxValue = uMaxValue MinValue = uMinValue TickUnit = uTick Value = uValue items.Initialize mBase.RemoveAllNodes Dim rgItems As Float Dim leftPos As Int For rgItems = MinValue To MaxValue Step TickUnit Dim rbi As RadioButton rbi.Initialize("masterRB") rbi.Text = rgItems rbi.TextColor = DefaultLabel.TextColor rbi.Visible = True rbi.Selected = False rbi.Font = DefaultLabel.Font rbi.TextSize = DefaultLabel.TextSize If rgItems = Value Then rbi.Selected = True rbi.MouseCursor = fx.Cursors.HAND leftPos = items.size * eachW If leftPos = 0 Then leftPos = 5 rbi.Left = leftPos mBase.AddNode(rbi,leftPos, 5, eachW, DefaultLabel.height) items.add(rbi) Next masterRB.GroupRadioButtons(items) End Sub Private Sub Base_Resize (Width As Double, Height As Double) End Sub Public Sub GetBase As Pane Return mBase End Sub 'a radio button has been selected, trap true event and raise ItemClick in calling parent. Sub masterRB_SelectedChange(Selected As Boolean) Dim rb As RadioButton rb = Sender If rb.Selected Then If SubExists(mCallBack, mEventName & "_ItemClick") Then CallSub2(mCallBack, mEventName & "_ItemClick", rb.Text) End If End If End Sub 'set visibility Sub setVisible(bVisible As Boolean) mBase.Visible = bVisible End Sub 'set visibility Sub setEnable(bEnabled As Boolean) mBase.Enabled = bEnabled End Sub 'set tag Sub setTag(obj As Object) mBase.Tag = obj End Sub 'get tag Sub getTag() As Object Return mBase.tag End Sub