home *** CD-ROM | disk | FTP | other *** search
- <public:component id="checkbox" tagName="checkbox" lightWeight="false" literalContent="false">
- <public:attach event="oncontentready" onevent="Initialize()" />
- <public:attach event="onclick" onevent="Clicked()" />
- <public:event name="onResultChange" id="rcID" />
- <public:property name="threestate" get="GetThreeState" put="PutThreeState" />
- <public:property name="value" get="GetValue" put="PutValue" />
- <public:property name="checked" get="GetChecked" put="PutChecked" />
- <public:method name="save" />
- <public:method name="load" />
-
- <script language="vbscript">
- ' ------------------------------------------------------------------------------
- ' declare variables and constants
- ' ------------------------------------------------------------------------------
- Dim iState, iSavedState, bThreeState
-
- Const vbUnchecked = 0
- Const vbChecked = 1
- Const vbIntermediate = 2
-
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ' public properties
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ' ------------------------------------------------------------------------------
- ' Property: ThreeState
- ' ------------------------------------------------------------------------------
- ' Purpose: Gets or sets whether the check box will allow three check states rather than two.
- ' ------------------------------------------------------------------------------
- Public Function GetThreeState
- GetThreeState = bThreeState
- End Function
-
- Public Function PutThreeState(bValue)
- bThreeState = bValue
- End Function
-
- ' ------------------------------------------------------------------------------
- ' Property: Value
- ' ------------------------------------------------------------------------------
- ' Purpose: Gets or sets the state of the check box.
- ' ------------------------------------------------------------------------------
- Public Function GetValue
- GetValue = iState
- End Function
-
- Public Function PutValue(iValue)
- iValue=CInt(iValue)
- If (iValue=vbUnchecked) or (iValue=vbChecked) or (iValue=vbIntermediate) Then
- If iValue=vbIntermediate Then PutThreeState(True)
- iState = iValue
- Call Repaint()
- End If
- End Function
-
- ' ------------------------------------------------------------------------------
- ' Property: Checked
- ' ------------------------------------------------------------------------------
- ' Purpose: Included for compatibility with the basic html checkbox control
- ' ------------------------------------------------------------------------------
- Public Function GetChecked
- If iState = vbChecked Then
- GetChecked = True
- Else
- GetChecked = False
- End If
- End Function
-
- Public Function PutChecked(bChecked)
- If bChecked Then
- Call PutValue(vbChecked)
- Else
- Call PutValue(vbUnchecked)
- End If
- End Function
-
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ' private methods
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ' ------------------------------------------------------------------------------
- ' Name: Save
- ' ------------------------------------------------------------------------------
- ' Purpose: Saves the current state of the check box
- ' ------------------------------------------------------------------------------
- Public Sub Save()
- iSavedState = iState
- End Sub
-
- ' ------------------------------------------------------------------------------
- ' Property: Load
- ' ------------------------------------------------------------------------------
- ' Purpose: Retrieves the previously saved state
- ' ------------------------------------------------------------------------------
- Public Sub Load()
- Call PutValue(iSavedState)
-
- End Sub
-
-
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ' private methods
- ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ' ------------------------------------------------------------------------------
- ' Name: Initialize
- ' ------------------------------------------------------------------------------
- ' Purpose: Used internally by the component when it is created.
- ' Declared as private because it must not be called directly.
- ' ------------------------------------------------------------------------------
- Private Sub Initialize()
- iState=0
- Call RePaint()
- End Sub
-
- ' ------------------------------------------------------------------------------
- ' Name: Clicked
- ' ------------------------------------------------------------------------------
- ' Purpose: internal processing of the click event
- ' ------------------------------------------------------------------------------
- Private Sub Clicked()
- Select Case iState
- Case 0
- iState = 1
- Case 1
- If bThreeState Then
- iState = 2
- Else
- iState = 0
- End If
- Case 2
- iState = 0
- End Select
-
- Call Repaint()
- Call FireEvent()
- End Sub
-
- ' ------------------------------------------------------------------------------
- ' Name: RePaint
- ' ------------------------------------------------------------------------------
- ' Purpose: internal repaint method
- ' ------------------------------------------------------------------------------
- Private Sub RePaint()
- element.innerHTML ="<img src=""graphics/chkbox-" & iState & ".gif"" width=""13"" height=""13"">"
- End Sub
- </script>
-
- <script language="JScript">
- function FireEvent() {
- var oEvent
-
- oEvent = createEventObject();
- rcID.fire (oEvent);
- }
- </script>
- </public:component>
-