home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileInclude002 < prev    next >
Encoding:
Text File  |  2005-09-02  |  5.7 KB  |  158 lines

  1.     <public:component id="checkbox" tagName="checkbox" lightWeight="false" literalContent="false">
  2.     <public:attach        event="oncontentready"    onevent="Initialize()" />
  3.     <public:attach        event="onclick"            onevent="Clicked()"  />
  4.     <public:event        name="onResultChange"    id="rcID" />
  5.     <public:property    name="threestate"        get="GetThreeState"    put="PutThreeState"    />
  6.     <public:property    name="value"            get="GetValue"        put="PutValue"        />
  7.     <public:property    name="checked"            get="GetChecked"    put="PutChecked"    />
  8.     <public:method        name="save"                />
  9.     <public:method        name="load"                />
  10.  
  11.     <script language="vbscript">
  12.         ' ------------------------------------------------------------------------------
  13.         ' declare variables and constants
  14.         ' ------------------------------------------------------------------------------
  15.         Dim iState, iSavedState, bThreeState
  16.  
  17.         Const vbUnchecked        = 0
  18.         Const vbChecked            = 1
  19.         Const vbIntermediate    = 2
  20.  
  21.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22.         ' public properties
  23.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  24.  
  25.         ' ------------------------------------------------------------------------------
  26.         ' Property:    ThreeState
  27.         ' ------------------------------------------------------------------------------
  28.         ' Purpose:    Gets or sets whether the check box will allow three check states rather than two.
  29.         ' ------------------------------------------------------------------------------
  30.         Public Function GetThreeState
  31.             GetThreeState = bThreeState
  32.         End Function
  33.  
  34.         Public Function PutThreeState(bValue)
  35.             bThreeState = bValue
  36.         End Function
  37.  
  38.         ' ------------------------------------------------------------------------------
  39.         ' Property:    Value
  40.         ' ------------------------------------------------------------------------------
  41.         ' Purpose:    Gets or sets the state of the check box.
  42.         ' ------------------------------------------------------------------------------
  43.         Public Function GetValue
  44.             GetValue = iState
  45.         End Function
  46.  
  47.         Public Function PutValue(iValue)
  48.             iValue=CInt(iValue)
  49.             If (iValue=vbUnchecked) or (iValue=vbChecked) or (iValue=vbIntermediate) Then
  50.                 If iValue=vbIntermediate Then PutThreeState(True)
  51.                 iState = iValue
  52.                 Call Repaint()
  53.             End If
  54.         End Function
  55.  
  56.         ' ------------------------------------------------------------------------------
  57.         ' Property:    Checked
  58.         ' ------------------------------------------------------------------------------
  59.         ' Purpose:    Included for compatibility with the basic html checkbox control
  60.         ' ------------------------------------------------------------------------------
  61.         Public Function GetChecked
  62.             If iState = vbChecked Then
  63.                 GetChecked = True
  64.             Else
  65.                 GetChecked = False
  66.             End If
  67.         End Function
  68.  
  69.         Public Function PutChecked(bChecked)
  70.             If bChecked Then
  71.                 Call PutValue(vbChecked)
  72.             Else
  73.                 Call PutValue(vbUnchecked)
  74.             End If
  75.         End Function
  76.  
  77.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  78.         ' private methods
  79.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  80.  
  81.         ' ------------------------------------------------------------------------------
  82.         ' Name:        Save
  83.         ' ------------------------------------------------------------------------------
  84.         ' Purpose:    Saves the current state of the check box
  85.         ' ------------------------------------------------------------------------------
  86.         Public Sub Save()
  87.             iSavedState = iState
  88.         End Sub
  89.         
  90.         ' ------------------------------------------------------------------------------
  91.         ' Property:    Load
  92.         ' ------------------------------------------------------------------------------
  93.         ' Purpose:    Retrieves the previously saved state
  94.         ' ------------------------------------------------------------------------------
  95.         Public Sub Load()
  96.             Call PutValue(iSavedState)
  97.  
  98.         End Sub
  99.  
  100.  
  101.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  102.         ' private methods
  103.         ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  104.  
  105.         ' ------------------------------------------------------------------------------
  106.         ' Name:        Initialize
  107.         ' ------------------------------------------------------------------------------
  108.         ' Purpose:    Used internally by the component when it is created.
  109.         '            Declared as private because it must not be called directly.
  110.         ' ------------------------------------------------------------------------------
  111.         Private Sub Initialize()
  112.             iState=0
  113.             Call RePaint()
  114.         End Sub
  115.         
  116.         ' ------------------------------------------------------------------------------
  117.         ' Name:        Clicked
  118.         ' ------------------------------------------------------------------------------
  119.         ' Purpose:    internal processing of the click event
  120.         ' ------------------------------------------------------------------------------
  121.         Private Sub Clicked()    
  122.             Select Case iState
  123.                 Case 0
  124.                     iState = 1
  125.                 Case 1
  126.                     If bThreeState Then
  127.                         iState = 2
  128.                     Else
  129.                         iState = 0
  130.                     End If
  131.                 Case 2
  132.                     iState = 0
  133.             End Select
  134.  
  135.             Call Repaint()
  136.             Call FireEvent()
  137.         End Sub
  138.  
  139.         ' ------------------------------------------------------------------------------
  140.         ' Name:        RePaint
  141.         ' ------------------------------------------------------------------------------
  142.         ' Purpose:    internal repaint method
  143.         ' ------------------------------------------------------------------------------
  144.         Private Sub RePaint()
  145.             element.innerHTML ="<img src=""graphics/chkbox-" & iState & ".gif"" width=""13"" height=""13"">"
  146.         End Sub
  147.     </script>
  148.  
  149.     <script language="JScript">
  150.         function FireEvent() {
  151.         var oEvent
  152.  
  153.         oEvent = createEventObject();
  154.         rcID.fire (oEvent);
  155.         }
  156.     </script>
  157. </public:component>
  158.