home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 June / comonline0602.iso / software / cogitum / CoTracker.exe / ToolbarB.___ < prev    next >
Encoding:
Text File  |  2000-09-27  |  6.0 KB  |  279 lines

  1. <PUBLIC:COMPONENT>
  2.  
  3. <PUBLIC:PROPERTY NAME="ct_toolbar_button"    GET="fnIdentify"/>
  4.  
  5. <PUBLIC:PROPERTY NAME="ct_checkbutton" INTERNALNAME="bCheckButton" />
  6. <PUBLIC:PROPERTY NAME="ct_state"       INTERNALNAME="bState"       />
  7.  
  8.  
  9. <PUBLIC:PROPERTY NAME="ct_dropdown"      INTERNALNAME="bDropDown"  />
  10.  
  11. <PUBLIC:PROPERTY NAME="ct_onclick"     INTERNALNAME="szOnClick"    />
  12.  
  13.  
  14. <PUBLIC:METHOD NAME="UpdateButton"/>
  15. <PUBLIC:METHOD NAME="fnDraw"/>
  16.  
  17.  
  18. <PUBLIC:METHOD NAME="ct_mouseover"    INTERNALNAME="fnMouseOverSelf"/>
  19. <PUBLIC:METHOD NAME="ct_mouseout"    INTERNALNAME="fnMouseOutSelf"/>
  20.  
  21.  
  22. <PUBLIC:ATTACH EVENT="onpropertychange" ONEVENT="fnPropertyChange()" FOR="element"/>
  23.  
  24. <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="fnDraw()" FOR=element/>
  25.  
  26. <PUBLIC:ATTACH EVENT="onmousedown" ONEVENT="fnMouseDown()" FOR="element"/>
  27. <PUBLIC:ATTACH EVENT="onmouseup" ONEVENT="fnMouseUp()" FOR="element"/>
  28.  
  29. <PUBLIC:ATTACH EVENT="onclick" ONEVENT="fnMouseClick()" FOR="element"/>
  30.  
  31. <PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="fnMouseOver()" FOR="element"/>
  32. <PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="fnMouseOut()" FOR="element"/>
  33.  
  34. <PUBLIC:ATTACH EVENT="ondragstart" ONEVENT="fnDragStart()" FOR="element"/>
  35.  
  36. <SCRIPT LANGUAGE="JScript">
  37.  
  38. var szOnClick = "";    // script to execute on ONCLICK event
  39.  
  40. var bCheckButton = 0;    // the button is the check button (it fixes in pressed state)
  41. var bDropDown = 0;    // the button is the down arrow that call drop down list to select from
  42.             // ex. Back in Internet Explorer
  43. var bDisabled = 0;    // the button is disabled (does not response to actions)
  44. var bState = 0;        // mouse button is pressed (but not released) on the button
  45. var bActive = 0;    // mouse is over the button
  46. var bPressed = 0;    // the button have been pressed previously
  47.  
  48. function UpdateButton (bDis, bDropD)
  49. {
  50.   bDisabled = bDis;
  51.   bDropDown = bDropD;
  52.   fnDraw();
  53. }
  54.  
  55.  
  56. function fnIdentify()
  57. {
  58. // this used for property ct_toolbar_button which is used to identify this behavior
  59. // always return 1
  60.  
  61.     return 1;
  62. }
  63.  
  64. //
  65. // use "eltSibling" in the code string passed to this function to refer to sibling object
  66. //
  67. function fnExecCodeOnSibling(szCode)
  68. {
  69.     var eltSibling = (bDropDown ? previousSibling : nextSibling);
  70.     //
  71.     if(eltSibling && (eltSibling.ct_toolbar_button == 1))
  72.     {
  73.         if((bDropDown && (bDropDown!=0)) || (eltSibling.ct_dropdown == 1))
  74.             eval(szCode);
  75.     }
  76. }
  77.  
  78. function fnDraw()
  79. {    
  80.  
  81.     if(parseInt(bCheckButton) == 0)
  82.         bState = 0;
  83.     
  84.  
  85.  
  86. //
  87. // it's more correct to leave background setting to toolbar (as it can be image and so on)
  88. //    element.runtimeStyle.backgroundColor = "#C0C0C0";
  89.     
  90.     if(parseInt(bDisabled) == 1)
  91.     {
  92.  
  93.        
  94.        //element.runtimeStyle.filter = "Gray Chroma(color = #C0C0C0) Alpha(Opacity=25)";
  95.        //DropShadow(color=white, offx=1, offy=1)
  96.         if((parseInt(bCheckButton) == 1) && (parseInt(bState) == 1))
  97.         {
  98.             element.runtimeStyle.borderRight = "1px solid white";
  99.             element.runtimeStyle.borderBottom = "1px solid white";
  100.             element.runtimeStyle.borderTop = "1px solid black";
  101.             element.runtimeStyle.borderLeft = "1px solid black";
  102.         }
  103.         else
  104.         {
  105.             element.runtimeStyle.border = "1px solid #C0C0C0";
  106.         }
  107.     }
  108.     else
  109.     {
  110.         if ((parseInt(bState) == 1) || (parseInt(bPressed) == 1))
  111.         {
  112.             element.runtimeStyle.borderRight = "1px solid white";
  113.             element.runtimeStyle.borderBottom = "1px solid white";
  114.             element.runtimeStyle.borderTop = "1px solid black";
  115.             element.runtimeStyle.borderLeft = "1px solid black";
  116.  
  117.              //if(bActive && (bActive != 0))
  118.               //element.runtimeStyle.filter = "";
  119.              //else
  120.               //element.runtimeStyle.filter = "Gray";
  121.  
  122.         }
  123.         else
  124.         {
  125.             if(parseInt(bActive) == 1)
  126.             {               
  127.                //element.runtimeStyle.filter = "";
  128.                element.runtimeStyle.borderRight = "1px solid black";
  129.                element.runtimeStyle.borderBottom = "1px solid black";
  130.                element.runtimeStyle.borderTop = "1px solid white";
  131.                element.runtimeStyle.borderLeft = "1px solid white";
  132.             }
  133.             else
  134.             {               
  135.                //element.runtimeStyle.filter = "Gray Chroma(color = #c0c0c0)";
  136.                element.runtimeStyle.border = "1px solid #c0c0c0";
  137.             }
  138.         }
  139.     }
  140.  
  141. }
  142.  
  143.  
  144. function fnPropertyChange()
  145. {
  146.     switch(window.event.propertyName)
  147.     {
  148.      case "ct_dropdown":
  149.         break;
  150.  
  151.      case "ct_checkbutton":
  152.         break;
  153.  
  154.      case "ct_state":
  155.         break;
  156.  
  157.      default:
  158.         return;
  159.     }
  160.  
  161.     fnDraw();
  162. }
  163.  
  164. function fnMouseDown()
  165. {    
  166.     if(window.event.button & 1)    // pressed left button
  167.     {
  168.         if(parseInt(bDisabled) == 0)
  169.         {
  170.             bPressed = 1;
  171.             fnDraw();
  172.             if(parseInt(bDropDown) == 1)
  173.             {
  174.                 if(szOnClick.length > 0)
  175.                 {
  176.                     window.execScript(szOnClick);
  177.                 }
  178.             }
  179.         }
  180.     }
  181. }
  182.  
  183. function fnMouseUp()
  184. {
  185.     if(window.event.button & 1)    // pressed left button
  186.     {
  187.         if(parseInt(bDisabled) == 0)
  188.         {
  189.             if (parseInt(bPressed) == 1)
  190.             {
  191.                 if(parseInt(bCheckButton) == 1)
  192.                 {
  193.                     if(parseInt(bState) == 1)
  194.                         bState = 0;
  195.                     else
  196.                         bState = 1;
  197.                 }
  198.                 if(parseInt(bDropDown) == 0)
  199.                 {
  200.                     if(szOnClick.length > 0)
  201.                     {
  202.                         window.execScript(szOnClick);
  203.                     }
  204.                 }
  205.                 bPressed = 0;
  206.                 fnDraw();
  207.             }
  208.         }
  209.     }
  210. }
  211.  
  212. //
  213. // called from sibling button if required
  214. //
  215. function fnMouseOverSelf()
  216. {
  217.     if(parseInt(bDisabled) == 0)
  218.     {
  219.         bActive = 1;
  220.         fnDraw();
  221.     }
  222. }
  223.  
  224. function fnMouseOver()
  225. {
  226.     if(parseInt(bDisabled) == 0)
  227.     {
  228.         fnMouseOverSelf();
  229.         fnExecCodeOnSibling("eltSibling.ct_mouseover();")
  230.     }
  231. }
  232.  
  233. //
  234. // called from sibling button if required
  235. //
  236. function fnMouseOutSelf()
  237. {
  238.     if(parseInt(bDisabled) == 0)
  239.     {
  240.         bActive = 0;
  241.         bPressed = 0;
  242.         fnDraw();
  243.     }
  244. }
  245.  
  246. function fnMouseOut()
  247. {
  248.     if(parseInt(bDisabled) == 0)
  249.     {
  250.         fnMouseOutSelf();
  251.         fnExecCodeOnSibling("eltSibling.ct_mouseout();")
  252.     }
  253. }
  254.  
  255. function fnMouseOut()
  256. {
  257.     if(parseInt(bDisabled) == 0)
  258.     {
  259.         bActive = 0;
  260.         bPressed = 0;
  261.         fnDraw();
  262.         //
  263.         fnExecCodeOnSibling("eltSibling.ct_mouseout();")
  264.     }
  265. }
  266.  
  267. function fnMouseClick()
  268. {
  269.  
  270. }
  271.  
  272. function fnDragStart()
  273. {
  274.     window.event.returnValue = false;
  275. }
  276.  
  277. </SCRIPT>
  278. </PUBLIC:COMPONENT>
  279.