home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 February / PCWorld_2001-02_cd.bin / Software / Topware / winmedpl / mpbonus_full.exe / wmpskin.cab / DigitalDJ.wmz / checkbox.js < prev    next >
Encoding:
JavaScript  |  2000-07-13  |  2.9 KB  |  102 lines

  1. //<script>
  2. //****************************************************************
  3. //  ⌐2000 Microsoft Corporation. All rights reserved.
  4. //****************************************************************
  5. //
  6. // JScript Checkbox Object
  7. //
  8. // This object allows for a windows media player skin to "simulate"
  9. // a checkbox using text controls
  10. //****************************************************************
  11.  
  12.  
  13.  
  14. //****************************************************************
  15. //****************************************************************
  16. //
  17. // checkbox object
  18. //
  19. //****************************************************************
  20. //****************************************************************
  21.  
  22. function checkbox(  check_text, check_label_text,
  23.                     onValueChange,
  24.                     fInitialValue )
  25. {
  26.     // Controls
  27.     
  28.     this.check_text             = check_text;
  29.     this.check_label_text       = check_label_text;
  30.  
  31.     // Public data
  32.     
  33.     this.fChecked               = fInitialValue;
  34.  
  35.     // Public methods
  36.  
  37.     this.onMouseDownCB          = onMouseDownCB;
  38.     this.onKeyPressCB           = onKeyPressCB;
  39.     this.setCheckedCB           = setCheckedCB;
  40.     
  41.     // Public Events
  42.     
  43.     this.onValueChange          = onValueChange;
  44.     
  45.     // Initialization Code
  46.     
  47.     this.check_text.fontFace        = "wingdings";
  48.     this.check_text.value           = String.fromCharCode( this.fChecked ? 0x00FE : 0x00A8 )
  49.     this.check_text.fontSize        = this.check_label_text.fontSize + 1;
  50.     this.check_text.left            = this.check_label_text.left - this.check_text.textWidth - 4;
  51.     this.check_text.top             = this.check_label_text.top;
  52.     this.check_text.fontStyle       = "bold";
  53.     this.check_text.cursor          = "hand";
  54.     this.check_text.foregroundColor = this.check_label_text.foregroundColor;
  55.     this.check_label_text.cursor    = "hand";
  56. }
  57.  
  58.  
  59.  
  60.  
  61. //****************************************************************
  62. // XML Callbacks
  63. //****************************************************************
  64.  
  65. //****************************************************************
  66. // This function is called when the mouse goes down over either
  67. // text control
  68.  
  69. function onMouseDownCB()
  70. {
  71.     if (event.button == 1)
  72.     {
  73.         this.setCheckedCB( !this.fChecked );
  74.     }
  75. }
  76.  
  77. //****************************************************************
  78.  
  79. function onKeyPressCB()
  80. {
  81.     if (event.keyCode == 32)
  82.     {
  83.         this.setCheckedCB( !this.fChecked );
  84.     }
  85. }
  86.  
  87. //****************************************************************
  88.  
  89. function setCheckedCB( checked )
  90. {
  91.     if (this.fChecked != checked)
  92.     {
  93.         this.fChecked = checked;
  94.         this.check_text.value           = String.fromCharCode( this.fChecked ? 0x00FE : 0x00A8 )
  95.             
  96.         if (this.onValueChange)
  97.         {
  98.             this.onValueChange();        
  99.         }
  100.     }
  101. }
  102.