VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Source for file controls.inc.php

Documentation is available at controls.inc.php

  1. <?php
  2. /**
  3. *  This file is part of the VCL for PHP project
  4. *
  5. *  Copyright (c) 2004-2007 qadram software <support@qadram.com>
  6. *
  7. *  Checkout AUTHORS file for more information on the developers
  8. *
  9. *  This library is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU Lesser General Public
  11. *  License as published by the Free Software Foundation; either
  12. *  version 2.1 of the License, or (at your option) any later version.
  13. *
  14. *  This library is distributed in the hope that it will be useful,
  15. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. *  Lesser General Public License for more details.
  18. *
  19. *  You should have received a copy of the GNU Lesser General Public
  20. *  License along with this library; if not, write to the Free Software
  21. *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  22. *  USA
  23. *
  24. */
  25.  
  26. use_unit("classes.inc.php");
  27. use_unit("graphics.inc.php");
  28.  
  29. define('alNone','alNone');
  30. define('alTop','alTop');
  31. define('alBottom','alBottom');
  32. define('alLeft','alLeft');
  33. define('alRight','alRight');
  34. define('alClient','alClient');
  35. define('alCustom','alCustom');
  36.  
  37. define('agNone','agNone');
  38. define('agLeft','agLeft');
  39. define('agCenter','agCenter');
  40. define('agRight','agRight');
  41.  
  42. define('crPointer','crPointer');
  43. define('crCrossHair','crCrossHair');
  44. define('crText','crText');
  45. define('crWait','crWait');
  46. define('crDefault','crDefault');
  47. define('crHelp','crHelp');
  48. define('crEResize','crE-Resize');
  49. define('crNEResize','crNE-Resize');
  50. define('crNResize','crN-Resize');
  51. define('crNWResize','crNW-Resize');
  52. define('crWResize','crW-Resize');
  53. define('crSWResize','crSW-Resize');
  54. define('crSResize','crS-Resize');
  55. define('crSEResize','crSE-Resize');
  56. define('crAuto','crAuto');
  57.  
  58. /**
  59.  * Control class
  60.  *
  61.  * Base class for all controls
  62.  */
  63. class Control extends Component
  64. {
  65.         protected $_caption="";
  66.         protected $_parent=null;
  67.         protected $_popupmenu=null;
  68.         protected $_controlstyle=array();
  69.         protected $_left=0;
  70.         protected $_visible=1;
  71.         protected $_top=0;
  72.         protected $_width=null;
  73.         protected $_height=null;
  74.         protected $_color="";
  75.         protected $_parentcolor=1;
  76.         protected $_enabled=1;
  77.         protected $_hint="";
  78.         protected $_designcolor="";
  79.         protected $_align=alNone;
  80.         protected $_alignment=agNone;
  81.         protected $_onbeforeshow=null;
  82.         protected $_onaftershow=null;
  83.         protected $_onshow=null;
  84.         protected $_cursor="";
  85.         protected $_showhint=0;
  86.         protected $_parentshowhint=1;
  87.  
  88.         protected $_font=null;
  89.  
  90.         protected $_islayer=0;
  91.         protected $_parentfont=1;
  92.  
  93.         private $_doparentreset true;
  94.  
  95.         protected $_jsonactivate=null;
  96.         protected $_jsondeactivate=null;
  97.         protected $_jsonbeforecopy=null;
  98.         protected $_jsonbeforecut=null;
  99.         protected $_jsonbeforedeactivate=null;
  100.         protected $_jsonbeforeeditfocus=null;
  101.         protected $_jsonbeforepaste=null;
  102.         protected $_jsonblur=null;
  103.         protected $_jsonchange=null;
  104.         protected $_jsonclick=null;
  105.         protected $_jsoncontextmenu=null;
  106.         protected $_jsoncontrolselect=null;
  107.         protected $_jsoncopy=null;
  108.         protected $_jsoncut=null;
  109.         protected $_jsondblclick=null;
  110.         protected $_jsondrag=null;
  111.         protected $_jsondragenter=null;
  112.         protected $_jsondragleave=null;
  113.         protected $_jsondragover=null;
  114.         protected $_jsondragstart=null;
  115.         protected $_jsondrop=null;
  116.         protected $_jsonfilterchange=null;
  117.         protected $_jsonfocus=null;
  118.         protected $_jsonhelp=null;
  119.         protected $_jsonkeydown=null;
  120.         protected $_jsonkeypress=null;
  121.         protected $_jsonkeyup=null;
  122.         protected $_jsonlosecapture=null;
  123.         protected $_jsonmousedown=null;
  124.         protected $_jsonmouseup=null;
  125.         protected $_jsonmouseenter=null;
  126.         protected $_jsonmouseleave=null;
  127.         protected $_jsonmousemove=null;
  128.         protected $_jsonmouseout=null;
  129.         protected $_jsonmouseover=null;
  130.         protected $_jsonpaste=null;
  131.         protected $_jsonpropertychange=null;
  132.         protected $_jsonreadystatechange=null;
  133.         protected $_jsonresize=null;
  134.         protected $_jsonresizeend=null;
  135.         protected $_jsonresizestart=null;
  136.         protected $_jsonselectstart=null;
  137.  
  138.  
  139.         /**
  140.         * Fires when the object is set as the active element.
  141.         */
  142.         protected function readjsOnActivate                (return $this->_jsonactivate}
  143.         /**
  144.         * Fires when the activeElement is changed from the current object to another object in the parent document.
  145.         */
  146.         protected function readjsOnDeactivate              (return $this->_jsondeactivate}
  147.         /**
  148.         * Fires on the source object before the selection is copied to the system clipboard.
  149.         */
  150.         protected function readjsOnBeforeCopy              (return $this->_jsonbeforecopy}
  151.         /**
  152.         * Fires on the source object before the selection is deleted from the document.
  153.         */
  154.         protected function readjsOnBeforeCut               (return $this->_jsonbeforecut}
  155.         /**
  156.         * Fires immediately before the activeElement is changed from the current object to another object in the parent document.
  157.         */
  158.         protected function readjsOnBeforeDeactivate        (return $this->_jsonbeforedeactivate}
  159.         /**
  160.         * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected.
  161.         */
  162.         protected function readjsOnBeforeEditfocus         (return $this->_jsonbeforeeditfocus}
  163.         /**
  164.         * Fires on the target object before the selection is pasted from the system clipboard to the document.
  165.         */
  166.         protected function readjsOnBeforePaste             (return $this->_jsonbeforepaste}
  167.         /**
  168.         * Fires when the object loses the input focus.
  169.         */
  170.         protected function readjsOnBlur                    (return $this->_jsonblur}
  171.         /**
  172.         * Fires when the contents of the object or selection have changed.
  173.         */
  174.         protected function readjsOnChange                  (return $this->_jsonchange}
  175.         /**
  176.         * Fires when the user clicks the left mouse button on the object.
  177.         */
  178.         protected function readjsOnClick                   (return $this->_jsonclick}
  179.         /**
  180.         * Fires when the user clicks the right mouse button in the client area, opening the context menu.
  181.         */
  182.         protected function readjsOnContextMenu             (return $this->_jsoncontextmenu}
  183.         /**
  184.         * Fires when the user is about to make a control selection of the object.
  185.         */
  186.         protected function readjsOnControlSelect           (return $this->_jsoncontrolselect}
  187.         /**
  188.         * Fires on the source element when the user copies the object or selection, adding it to the system clipboard.
  189.         */
  190.         protected function readjsOnCopy                    (return $this->_jsoncopy}
  191.         /**
  192.         * Fires on the source element when the object or selection is removed from the document and added to the system clipboard.
  193.         */
  194.         protected function readjsOnCut                     (return $this->_jsoncut}
  195.         /**
  196.         * Fires when the user double-clicks the object.
  197.         */
  198.         protected function readjsOnDblClick                (return $this->_jsondblclick}
  199.         /**
  200.         * Fires on the source object continuously during a drag operation.
  201.         */
  202.         protected function readjsOnDrag                    (return $this->_jsondrag}
  203.         /**
  204.         * Fires on the target element when the user drags the object to a valid drop target.
  205.         */
  206.         protected function readjsOnDragEnter               (return $this->_jsondragenter}
  207.         /**
  208.         * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation.
  209.         */
  210.         protected function readjsOnDragLeave               (return $this->_jsondragleave}
  211.         /**
  212.         * Fires on the target element continuously while the user drags the object over a valid drop target.
  213.         */
  214.         protected function readjsOnDragOver                (return $this->_jsondragover}
  215.         /**
  216.         * Fires on the source object when the user starts to drag a text selection or selected object.
  217.         */
  218.         protected function readjsOnDragStart               (return $this->_jsondragstart}
  219.         /**
  220.         * Fires on the target object when the mouse button is released during a drag-and-drop operation.
  221.         */
  222.         protected function readjsOnDrop                    (return $this->_jsondrop}
  223.         /**
  224.         * Fires when a visual filter changes state or completes a transition.
  225.         */
  226.         protected function readjsOnFilterChange            (return $this->_jsonfilterchange}
  227.         /**
  228.         * Fires when the object receives focus
  229.         */
  230.         protected function readjsOnFocus                   (return $this->_jsonfocus}
  231.         /**
  232.         * Fires when the user presses the F1 key while the browser is the active window.
  233.         */
  234.         protected function readjsOnHelp                    (return $this->_jsonhelp}
  235.         /**
  236.         * Fires when the user presses a key.
  237.         */
  238.         protected function readjsOnKeyDown                 (return $this->_jsonkeydown}
  239.         /**
  240.         * Fires when the user presses an alphanumeric key.
  241.         */
  242.         protected function readjsOnKeyPress                (return $this->_jsonkeypress}
  243.         /**
  244.         * Fires when the user releases a key.
  245.         */
  246.         protected function readjsOnKeyUp                   (return $this->_jsonkeyup}
  247.         /**
  248.         * Fires when the object loses the mouse capture.
  249.         */
  250.         protected function readjsOnLoseCapture             (return $this->_jsonlosecapture}
  251.         /**
  252.         * Fires when the user clicks the object with either mouse button.
  253.         */
  254.         protected function readjsOnMouseDown               (return $this->_jsonmousedown}
  255.         /**
  256.         * Fires when the user releases a mouse button while the mouse is over the object.
  257.         */
  258.         protected function readjsOnMouseUp                 (return $this->_jsonmouseup}
  259.         /**
  260.         * Fires when the user moves the mouse pointer into the object.
  261.         */
  262.         protected function readjsOnMouseEnter              (return $this->_jsonmouseenter}
  263.         /**
  264.         * Fires when the user moves the mouse pointer outside the boundaries of the object.
  265.         */
  266.         protected function readjsOnMouseLeave              (return $this->_jsonmouseleave}
  267.         /**
  268.         * Fires when the user moves the mouse over the object.
  269.         */
  270.         protected function readjsOnMouseMove               (return $this->_jsonmousemove}
  271.         /**
  272.         * Fires when the user moves the mouse pointer outside the boundaries of the object.
  273.         */
  274.         protected function readjsOnMouseOut                (return $this->_jsonmouseout}
  275.         /**
  276.         * Fires when the user moves the mouse pointer into the object.
  277.         */
  278.         protected function readjsOnMouseOver               (return $this->_jsonmouseover}
  279.         /**
  280.         * Fires on the target object when the user pastes data, transferring the data from the system clipboard to the document.
  281.         */
  282.         protected function readjsOnPaste                   (return $this->_jsonpaste}
  283.         /**
  284.         * Fires when a property changes on the object.
  285.         */
  286.         protected function readjsOnPropertyChange          (return $this->_jsonpropertychange}
  287.         /**
  288.         * Fires when the state of the object has changed.
  289.         */
  290.         protected function readjsOnReadyStateChange        (return $this->_jsonreadystatechange}
  291.         /**
  292.         * Fires when the size of the object is about to change.
  293.         */
  294.         protected function readjsOnResize                  (return $this->_jsonresize}
  295.         /**
  296.         * Fires when the user finishes changing the dimensions of the object in a control selection.
  297.         */
  298.         protected function readjsOnResizeEnd               (return $this->_jsonresizeend}
  299.         /**
  300.         * Fires when the user begins to change the dimensions of the object in a control selection
  301.         */
  302.         protected function readjsOnResizeStart             (return $this->_jsonresizestart}
  303.         /**
  304.         * Fires when the object is being selected
  305.         */
  306.         protected function readjsOnSelectStart             (return $this->_jsonselectstart}
  307.  
  308.         protected function writejsOnActivate($value)                $this->_jsonactivate=$value}
  309.         protected function writejsOnDeactivate($value)              $this->_jsondeactivate=$value}
  310.         protected function writejsOnBeforeCopy($value)              $this->_jsonbeforecopy=$value}
  311.         protected function writejsOnBeforeCut($value)               $this->_jsonbeforecut=$value}
  312.         protected function writejsOnBeforeDeactivate($value)        $this->_jsonbeforedeactivate=$value}
  313.         protected function writejsOnBeforeEditfocus($value)         $this->_jsonbeforeeditfocus=$value}
  314.         protected function writejsOnBeforePaste($value)             $this->_jsonbeforepaste=$value}
  315.         protected function writejsOnBlur($value)                    $this->_jsonblur=$value}
  316.         protected function writejsOnChange($value)                  $this->_jsonchange=$value}
  317.         protected function writejsOnClick($value)                   $this->_jsonclick=$value}
  318.         protected function writejsOnContextMenu($value)             $this->_jsoncontextmenu=$value}
  319.         protected function writejsOnControlSelect($value)           $this->_jsoncontrolselect=$value}
  320.         protected function writejsOnCopy($value)                    $this->_jsoncopy=$value}
  321.         protected function writejsOnCut($value)                     $this->_jsoncut=$value}
  322.         protected function writejsOnDblClick($value)                $this->_jsondblclick=$value}
  323.         protected function writejsOnDrag($value)                    $this->_jsondrag=$value}
  324.         protected function writejsOnDragEnter($value)               $this->_jsondragenter=$value}
  325.         protected function writejsOnDragLeave($value)               $this->_jsondragleave=$value}
  326.         protected function writejsOnDragOver($value)                $this->_jsondragover=$value}
  327.         protected function writejsOnDragStart($value)               $this->_jsondragstart=$value}
  328.         protected function writejsOnDrop($value)                    $this->_jsondrop=$value}
  329.         protected function writejsOnFilterChange($value)            $this->_jsonfilterchange=$value}
  330.         protected function writejsOnFocus($value)                   $this->_jsonfocus=$value}
  331.         protected function writejsOnHelp($value)                    $this->_jsonhelp=$value}
  332.         protected function writejsOnKeyDown($value)                 $this->_jsonkeydown=$value}
  333.         protected function writejsOnKeyPress($value)                $this->_jsonkeypress=$value}
  334.         protected function writejsOnKeyUp($value)                   $this->_jsonkeyup=$value}
  335.         protected function writejsOnLoseCapture($value)             $this->_jsonlosecapture=$value}
  336.         protected function writejsOnMouseDown($value)               $this->_jsonmousedown=$value}
  337.         protected function writejsOnMouseUp($value)                 $this->_jsonmouseup=$value}
  338.         protected function writejsOnMouseEnter($value)              $this->_jsonmouseenter=$value}
  339.         protected function writejsOnMouseLeave($value)              $this->_jsonmouseleave=$value}
  340.         protected function writejsOnMouseMove($value)               $this->_jsonmousemove=$value}
  341.         protected function writejsOnMouseOut($value)                $this->_jsonmouseout=$value}
  342.         protected function writejsOnMouseOver($value)               $this->_jsonmouseover=$value}
  343.         protected function writejsOnPaste($value)                   $this->_jsonpaste=$value}
  344.         protected function writejsOnPropertyChange($value)          $this->_jsonpropertychange=$value}
  345.         protected function writejsOnReadyStateChange($value)        $this->_jsonreadystatechange=$value}
  346.         protected function writejsOnResize($value)                  $this->_jsonresize=$value}
  347.         protected function writejsOnResizeEnd($value)               $this->_jsonresizeend=$value}
  348.         protected function writejsOnResizeStart($value)             $this->_jsonresizestart=$value}
  349.         protected function writejsOnSelectStart($value)             $this->_jsonselectstart=$value}
  350.  
  351.         function defaultjsOnActivate                (return null}
  352.         function defaultjsOnDeactivate              (return null}
  353.         function defaultjsOnBeforeCopy              (return null}
  354.         function defaultjsOnBeforeCut               (return null}
  355.         function defaultjsOnBeforeDeactivate        (return null}
  356.         function defaultjsOnBeforeEditfocus         (return null}
  357.         function defaultjsOnBeforePaste             (return null}
  358.         function defaultjsOnBlur                    (return null}
  359.         function defaultjsOnChange                  (return null}
  360.         function defaultjsOnClick                   (return null}
  361.         function defaultjsOnContextMenu             (return null}
  362.         function defaultjsOnControlSelect           (return null}
  363.         function defaultjsOnCopy                    (return null}
  364.         function defaultjsOnCut                     (return null}
  365.         function defaultjsOnDblClick                (return null}
  366.         function defaultjsOnDrag                    (return null}
  367.         function defaultjsOnDragEnter               (return null}
  368.         function defaultjsOnDragLeave               (return null}
  369.         function defaultjsOnDragOver                (return null}
  370.         function defaultjsOnDragStart               (return null}
  371.         function defaultjsOnDrop                    (return null}
  372.         function defaultjsOnFilterChange            (return null}
  373.         function defaultjsOnFocus                   (return null}
  374.         function defaultjsOnHelp                    (return null}
  375.         function defaultjsOnKeyDown                 (return null}
  376.         function defaultjsOnKeyPress                (return null}
  377.         function defaultjsOnKeyUp                   (return null}
  378.         function defaultjsOnLoseCapture             (return null}
  379.         function defaultjsOnMouseDown               (return null}
  380.         function defaultjsOnMouseUp                 (return null}
  381.         function defaultjsOnMouseEnter              (return null}
  382.         function defaultjsOnMouseLeave              (return null}
  383.         function defaultjsOnMouseMove               (return null}
  384.         function defaultjsOnMouseOut                (return null}
  385.         function defaultjsOnMouseOver               (return null}
  386.         function defaultjsOnPaste                   (return null}
  387.         function defaultjsOnPropertyChange          (return null}
  388.         function defaultjsOnReadyStateChange        (return null}
  389.         function defaultjsOnResize                  (return null}
  390.         function defaultjsOnResizeEnd               (return null}
  391.         function defaultjsOnResizeStart             (return null}
  392.         function defaultjsOnSelectStart             (return null}
  393.  
  394.         protected $_style="";
  395.  
  396.         /**
  397.         * CSS style to be used when rendering the component
  398.         * @return string 
  399.         */
  400.         function readStyle(return $this->_style}
  401.         function writeStyle($value$this->_style=$value}
  402.         function defaultStyle(return ""}
  403.  
  404.         protected $_adjusttolayout="0";
  405.  
  406.         /**
  407.         * If true, the control should adjust to the selected layout
  408.         * @return boolean 
  409.         */
  410.         function readAdjustToLayout(return $this->_adjusttolayout}
  411.         function writeAdjustToLayout($value$this->_adjusttolayout=$value}
  412.         function defaultAdjustToLayout(return "0"}
  413.  
  414.         /**
  415.         * Return the normalized CSS style
  416.         * @return string 
  417.         */
  418.         function readStyleClass()
  419.         {
  420.             if ($this->_style!="")
  421.             {
  422.                 $res=$this->_style;
  423.                 if ($res[0]=='.'$res=substr($res,1);
  424.                 return($res);
  425.             }
  426.             else return("");
  427.         }
  428.  
  429.  
  430.  
  431.         /**
  432.          * Constructor for the class
  433.          *
  434.          * @param $aowner The owner component for this class
  435.          *
  436.          * @return          An instance of this class
  437.          */
  438.         function __construct($aowner=null)
  439.         {
  440.                 $this->_font=new Font();
  441.                 $this->_font->_control=$this;
  442.  
  443.                 //Calls inherited constructor
  444.                 parent::__construct($aowner);
  445.         }
  446.  
  447.         function loaded()
  448.         {
  449.                 parent::loaded();
  450.                 $this->writePopupMenu($this->_popupmenu);
  451.         }
  452.  
  453.         /**
  454.          * Determines whether a control can be shown or not
  455.          *
  456.          *
  457.          * @return          <code>true</code> if the control can be shown
  458.          *                   <code>false</code> otherwise.
  459.          */
  460.         function canShow()
  461.         {
  462.                 if ($this->_parent!=null)
  463.                 {
  464.                         if ($this->_parent->inheritsFrom('CustomPanel'))
  465.                         {
  466.                                 return(($this->_visible&& ($this->_parent->canShow()) && ((string)$this->_layer==(string)$this->_parent->ActiveLayer));
  467.                         }
  468.                         else
  469.                         {
  470.                                 return(($this->_visible&& ($this->_parent->canShow()));
  471.                         }
  472.                 }
  473.                 else return($this->_visible);
  474.         }
  475.  
  476.         /**
  477.          * Return assigned javascript events as attributes for the tag
  478.          *
  479.          * @return string 
  480.          */
  481.         function readJsEvents()
  482.         {
  483.                 $result="";
  484.  
  485.                 if ($this->_jsonactivate!=null)  $event=$this->_jsonactivate;  $result.=" onactivate=\"return $event(event)\" "}
  486.                 if ($this->_jsondeactivate!=null)  $event=$this->_jsondeactivate;  $result.=" ondeactivate=\"return $event(event)\" "}
  487.                 if ($this->_jsonbeforecopy!=null)  $event=$this->_jsonbeforecopy;  $result.=" onbeforecopy=\"return $event(event)\" "}
  488.                 if ($this->_jsonbeforecut!=null)  $event=$this->_jsonbeforecut;  $result.=" onbeforecut=\"return $event(event)\" "}
  489.                 if ($this->_jsonbeforedeactivate!=null)  $event=$this->_jsonbeforedeactivate;  $result.=" onbeforedeactivate=\"return $event(event)\" "}
  490.                 if ($this->_jsonbeforeeditfocus!=null)  $event=$this->_jsonbeforeeditfocus;  $result.=" onbeforeeditfocus=\"return $event(event)\" "}
  491.                 if ($this->_jsonbeforepaste!=null)  $event=$this->_jsonbeforepaste;  $result.=" onbeforepaste=\"return $event(event)\" "}
  492.                 if ($this->_jsonblur!=null)  $event=$this->_jsonblur;  $result.=" onblur=\"return $event(event)\" "}
  493.                 if ($this->_jsonchange!=null)  $event=$this->_jsonchange;  $result.=" onchange=\"return $event(event)\" "}
  494.                 if ($this->_jsonclick!=null)  $event=$this->_jsonclick;  $result.=" onclick=\"return $event(event)\" "}
  495.                 if ($this->_jsoncontextmenu!=null)  $event=$this->_jsoncontextmenu;  $result.=" oncontextmenu=\"return $event(event)\" "}
  496.                 if ($this->_jsoncontrolselect!=null)  $event=$this->_jsoncontrolselect;  $result.=" oncontrolselect=\"return $event(event)\" "}
  497.                 if ($this->_jsoncopy!=null)  $event=$this->_jsoncopy;  $result.=" oncopy=\"return $event(event)\" "}
  498.                 if ($this->_jsoncut!=null)  $event=$this->_jsoncut;  $result.=" oncut=\"return $event(event)\" "}
  499.                 if ($this->_jsondblclick!=null)  $event=$this->_jsondblclick;  $result.=" ondblclick=\"return $event(event)\" "}
  500.                 if ($this->_jsondrag!=null)  $event=$this->_jsondrag;  $result.=" ondrag=\"return $event(event)\" "}
  501.                 if ($this->_jsondragenter!=null)  $event=$this->_jsondragenter;  $result.=" ondragenter=\"return $event(event)\" "}
  502.                 if ($this->_jsondragleave!=null)  $event=$this->_jsondragleave;  $result.=" ondragleave=\"return $event(event)\" "}
  503.                 if ($this->_jsondragover!=null)  $event=$this->_jsondragover;  $result.=" ondragover=\"return $event(event)\" "}
  504.                 if ($this->_jsondragstart!=null)  $event=$this->_jsondragstart;  $result.=" ondragstart=\"return $event(event)\" "}
  505.                 if ($this->_jsondrop!=null)  $event=$this->_jsondrop;  $result.=" ondrop=\"return $event(event)\" "}
  506.                 if ($this->_jsonfilterchange!=null)  $event=$this->_jsonfilterchange;  $result.=" onfilterchange=\"return $event(event)\" "}
  507.                 if ($this->_jsonfocus!=null)  $event=$this->_jsonfocus;  $result.=" onfocus=\"return $event(event)\" "}
  508.                 if ($this->_jsonhelp!=null)  $event=$this->_jsonhelp;  $result.=" onhelp=\"return $event(event)\" "}
  509.                 if ($this->_jsonkeydown!=null)  $event=$this->_jsonkeydown;  $result.=" onkeydown=\"return $event(event)\" "}
  510.                 if ($this->_jsonkeypress!=null)  $event=$this->_jsonkeypress;  $result.=" onkeypress=\"return $event(event)\" "}
  511.                 if ($this->_jsonkeyup!=null)  $event=$this->_jsonkeyup;  $result.=" onkeyup=\"return $event(event)\" "}
  512.                 if ($this->_jsonlosecapture!=null)  $event=$this->_jsonlosecapture;  $result.=" onlosecapture=\"return $event(event)\" "}
  513.                 if ($this->_jsonmousedown!=null)  $event=$this->_jsonmousedown;  $result.=" onmousedown=\"return $event(event)\" "}
  514.                 // add the popup mouse up handler (the real mouseup event is wrapped by this event)
  515.                 if ($this->_enabled == && $this->_popupmenu != null && !$this->inheritsFrom("QWidget"))
  516.                 {
  517.                         $event="{$this->_name}Popup";  $result.=" onmouseup=\"return $event(event)\" ";
  518.                 }
  519.                 else
  520.                 {
  521.                         if ($this->_jsonmouseup!=null)  { $event=$this->_jsonmouseup;  $result.=" onmouseup=\"return $event(event)\" "; }
  522.                 }
  523.                 if ($this->_jsonmouseenter!=null)  { $event=$this->_jsonmouseenter;  $result.=" onmouseenter=\"return $event(event)\" "; }
  524.                 if ($this->_jsonmouseleave!=null)  { $event=$this->_jsonmouseleave;  $result.=" onmouseleave=\"return $event(event)\" "; }
  525.                 if ($this->_jsonmousemove!=null)  { $event=$this->_jsonmousemove;  $result.=" onmousemove=\"return $event(event)\" "; }
  526.                 if ($this->_jsonmouseout!=null)  { $event=$this->_jsonmouseout;  $result.=" onmouseout=\"return $event(event)\" "; }
  527.                 if ($this->_jsonmouseover!=null)  { $event=$this->_jsonmouseover;  $result.=" onmouseover=\"return $event(event)\" "; }
  528.                 if ($this->_jsonpaste!=null)  { $event=$this->_jsonpaste;  $result.=" onpaste=\"return $event(event)\" "; }
  529.                 if ($this->_jsonpropertychange!=null)  { $event=$this->_jsonpropertychange;  $result.=" onpropertychange=\"return $event(event)\" "; }
  530.                 if ($this->_jsonreadystatechange!=null)  { $event=$this->_jsonreadystatechange;  $result.=" onreadystatechange=\"return $event(event)\" "; }
  531.                 if ($this->_jsonresize!=null)  { $event=$this->_jsonresize;  $result.=" onresize=\"return $event(event)\" "; }
  532.                 if ($this->_jsonresizeend!=null)  { $event=$this->_jsonresizeend;  $result.=" onresizeend=\"return $event(event)\" "; }
  533.                 if ($this->_jsonresizestart!=null)  { $event=$this->_jsonresizestart;  $result.=" onresizestart=\"return $event(event)\" "; }
  534.                 if ($this->_jsonselectstart!=null)  { $event=$this->_jsonselectstart;  $result.=" onselectstart=\"return $event(event)\" "; }
  535.  
  536.                 return($result);
  537.         }
  538.  
  539.         /**
  540.          * Dumps a javascript named $event
  541.          *
  542.          * @param string $event
  543.          */
  544.         function dumpJSEvent($event)
  545.         {
  546.                 if ($event!=null)
  547.                 {
  548.                         echo "function $event(event)\n";
  549.                         echo "{\n\n";
  550.                         echo "var event = event || window.event;\n";            //To get the right event object
  551.                         echo "var params=null;\n";                               //For Ajax calls
  552.  
  553.                         if ($this->inheritsFrom('CustomPage'))
  554.                         {
  555.                             $this->$event($thisarray());
  556.                         }
  557.                         else
  558.                         {
  559.                             if ($this->owner!=null$this->owner->$event($thisarray());
  560.                         }
  561.                         echo "\n}\n";
  562.                         echo "\n";
  563.                 }
  564.         }
  565.  
  566.         /**
  567.          * Dump Javascript events
  568.          *
  569.          */
  570.         function dumpJsEvents()
  571.         {
  572.                 $this->dumpJSEvent($this->_jsonactivate);
  573.                 $this->dumpJSEvent($this->_jsondeactivate);
  574.                 $this->dumpJSEvent($this->_jsonbeforecopy);
  575.                 $this->dumpJSEvent($this->_jsonbeforecut);
  576.                 $this->dumpJSEvent($this->_jsonbeforedeactivate);
  577.                 $this->dumpJSEvent($this->_jsonbeforeeditfocus);
  578.                 $this->dumpJSEvent($this->_jsonbeforepaste);
  579.                 $this->dumpJSEvent($this->_jsonblur);
  580.                 $this->dumpJSEvent($this->_jsonchange);
  581.                 $this->dumpJSEvent($this->_jsonclick);
  582.                 $this->dumpJSEvent($this->_jsoncontextmenu);
  583.                 $this->dumpJSEvent($this->_jsoncontrolselect);
  584.                 $this->dumpJSEvent($this->_jsoncopy);
  585.                 $this->dumpJSEvent($this->_jsoncut);
  586.                 $this->dumpJSEvent($this->_jsondblclick);
  587.                 $this->dumpJSEvent($this->_jsondrag);
  588.                 $this->dumpJSEvent($this->_jsondragenter);
  589.                 $this->dumpJSEvent($this->_jsondragleave);
  590.                 $this->dumpJSEvent($this->_jsondragover);
  591.                 $this->dumpJSEvent($this->_jsondragstart);
  592.                 $this->dumpJSEvent($this->_jsondrop);
  593.                 $this->dumpJSEvent($this->_jsonfilterchange);
  594.                 $this->dumpJSEvent($this->_jsonfocus);
  595.                 $this->dumpJSEvent($this->_jsonhelp);
  596.                 $this->dumpJSEvent($this->_jsonkeydown);
  597.                 $this->dumpJSEvent($this->_jsonkeypress);
  598.                 $this->dumpJSEvent($this->_jsonkeyup);
  599.                 $this->dumpJSEvent($this->_jsonlosecapture);
  600.                 $this->dumpJSEvent($this->_jsonmousedown);
  601.                 $this->dumpJSEvent($this->_jsonmouseup);
  602.                 $this->dumpJSEvent($this->_jsonmouseenter);
  603.                 $this->dumpJSEvent($this->_jsonmouseleave);
  604.                 $this->dumpJSEvent($this->_jsonmousemove);
  605.                 $this->dumpJSEvent($this->_jsonmouseout);
  606.                 $this->dumpJSEvent($this->_jsonmouseover);
  607.                 $this->dumpJSEvent($this->_jsonpaste);
  608.                 $this->dumpJSEvent($this->_jsonpropertychange);
  609.                 $this->dumpJSEvent($this->_jsonreadystatechange);
  610.                 $this->dumpJSEvent($this->_jsonresize);
  611.                 $this->dumpJSEvent($this->_jsonresizeend);
  612.                 $this->dumpJSEvent($this->_jsonresizestart);
  613.                 $this->dumpJSEvent($this->_jsonselectstart);
  614.         }
  615.  
  616.         /**
  617.          * Dump Javascript code required for this component to work
  618.          *
  619.          */
  620.         function dumpJavascript()
  621.         {
  622.                 $this->dumpJsEvents();
  623.  
  624.                 if ($this->_enabled == && $this->_popupmenu != null && !$this->inheritsFrom("QWidget"))
  625.                 {
  626.                         echo "function {$this->_name}Popup(event)\n";
  627.                         echo "{\n";
  628.                         // add wrapper so the mouseup event still gets called
  629.                         if ($this->_jsonmouseup != null)
  630.                         {
  631.                                 // just to be sure it really exists...
  632.                                 echo "  if (typeof($this->_jsonmouseup) == 'function') $this->_jsonmouseup(event);\n";
  633.                         }
  634.                         echo "  var rightclick;\n";
  635.                         echo "  if (!event) var event = window.event;\n";
  636.                         echo "  if (event.which) rightclick = (event.which == 3);\n";
  637.                         echo "  else if (event.button) rightclick = (event.button == 2);\n";
  638.  
  639.                         echo "  if (rightclick)\n";
  640.                         echo "  {\n";
  641.                         echo "     Show{$this->_popupmenu->Name}(event, 0);\n";
  642.                         echo "  }\n";
  643.  
  644.                         // allow the event be handled by others
  645.                         echo "  return true;\n";
  646.                         echo "}\n";
  647.                 }
  648.         }
  649.  
  650.         function dumpHeaderCode()
  651.         {
  652.                 parent::dumpHeaderCode();
  653.  
  654.                 // only dump the style sheet at design-time and if the style sheet is used by the sub-classed control
  655.                 if (($this->ControlState csDesigning== csDesigning && isset($this->_controlstyle['csRenderAlso']&& $this->_controlstyle['csRenderAlso'== 'StyleSheet')
  656.                 {
  657.                         if ($this->owner!=null)
  658.                         {
  659.                                 $components=$this->owner->components->items;
  660.                                 reset($components);
  661.                                 while (list($k,$v)=each($components))
  662.                                 {
  663.                                         if ($v->inheritsFrom('StyleSheet'))
  664.                                         {
  665.                                             $v->dumpHeaderCode();
  666.                                         }
  667.                                 }
  668.                         }
  669.                 }
  670.         }
  671.  
  672.         /**
  673.         * This function returns the attribute for the hint that can be included
  674.         * in any tag. The attribute's name is "title".
  675.         *
  676.         * @return string If the hint is defined and can be shown a string with
  677.         *                the attribute, otherwise an empty string.
  678.         */
  679.         protected function getHintAttribute()
  680.         {
  681.                 $hint = "";
  682.                 if ($this->_hint != "")
  683.                 {
  684.                         $hintspecial = htmlspecialchars($this->_hintENT_QUOTES);
  685.                         if ($this->_showhint)
  686.                         {
  687.                                 $hint = "title=\"$hintspecial\"";
  688.                         }
  689.                 }
  690.                 return $hint;
  691.         }
  692.  
  693.  
  694.         /**
  695.          * Show control contents
  696.          *
  697.          * @param boolean $return_contents return contents as string or dump to output
  698.          * @return string
  699.          */
  700.         function show($return_contents=false)
  701.         {
  702.                 global $output_enabled;
  703.  
  704.                 if ($output_enabled)
  705.                 {
  706.                         $this->callEvent('onbeforeshow',array());
  707.                         //A call to show, will dump out control code
  708.                         if ($return_contentsob_start();
  709.                         $this->dumpContents();
  710.                         if ($return_contents)
  711.                         {
  712.                                 $contents=ob_get_contents();
  713.                                 ob_end_clean();
  714.                         }
  715.                         $this->callEvent('onaftershow',array());
  716.  
  717.                         if ($return_contents)
  718.                         {
  719.                                 return($contents);
  720.                         }
  721.                 }
  722.         }
  723.  
  724.         /**
  725.          * Dump all children components
  726.          *
  727.          */
  728.         function dumpChildren()
  729.         {
  730.  
  731.         }
  732.  
  733.         /**
  734.          * Dump the control contents, inherit and fill this method with the code
  735.          * your control must generate
  736.          *
  737.          */
  738.         function dumpContents()
  739.         {
  740.                 //Inherit and fill this method to show up your control
  741.         }
  742.  
  743.  
  744.         /**
  745.         * Add or replace the JS event attribute with the wrapper.
  746.         * The wrapper is used to notify the PHP script that a event occured. The
  747.         * script then may fire an event itself (for example OnClick of a button).
  748.         *
  749.         * @param string $events A string that is empty or contains already
  750.         *                       existing JS event-handlers. This string passed
  751.         *                       by reference.
  752.         * @param string $event String representation of the event (ex. $this->_onclick;)
  753.         * @param string $jsEvent String representation of the JS event (ex. $this->_jsonclick;)
  754.         * @param string $jsEventAttr Name of attribute for the JS event (ex. "onclick")
  755.         */
  756.         protected function addJSWrapperToEvents(&$events, $event, $jsEvent, $jsEventAttr)
  757.         {
  758.                 if ($event != null)
  759.                 {
  760.                         $wrapperEvent = $this->getJSWrapperFunctionName($event);
  761.                         $submitEventValue $this->getJSWrapperSubmitEventValue($event);
  762.                         $hiddenfield $this->getJSWrapperHiddenFieldName();
  763.                         $hiddenfield ($this->owner != null"document.forms[0].$hiddenfield" : "null";
  764.                         if ($jsEvent != null)
  765.                         {
  766.                                 $events = str_replace("$jsEventAttr=\"return $jsEvent(event)\"",
  767.                                                       "$jsEventAttr=\"return $wrapperEvent(event$hiddenfield, '$submitEventValue', $jsEvent)\"",
  768.                                                       $events);
  769.                         }
  770.                         else
  771.                         {
  772.                                 $events .= " $jsEventAttr=\"return $wrapperEvent(event$hiddenfield, '$submitEventValue')\" ";
  773.                         }
  774.                 }
  775.         }
  776.  
  777.         /**
  778.         * Get the function name of a JS event wrapper.
  779.         *
  780.         * @param string $event String representation of the event (ex. $this->_onclick;)
  781.         * @return string Name of the function
  782.         */
  783.         protected function getJSWrapperFunctionName($event)
  784.         {
  785.                 $res = ($event != null) ? $event."Wrapper" : "";
  786.                 return $res;
  787.         }
  788.  
  789.         /**
  790.         * JS wrapper function that forwards a JS event to the PHP script by
  791.         * submitting the HTML form.
  792.         * It is the responsiblity of the component to add this function to the
  793.         * <javascript> section in the HTML header. Usually this is done in the
  794.         * dumpJavascript() function of the component.
  795.         *
  796.         * @param string $event String representation of the event (ex. $this->_onclick;)
  797.         * @return string Returns the whole JS wrapper function for the $event.
  798.         */
  799.         protected function getJSWrapperFunction($event)
  800.         {
  801.                 $res = "";
  802.                 if ($event != null)
  803.                 {
  804.                         $funcName = $this->getJSWrapperFunctionName($event);
  805.  
  806.                         $res .= "function $funcName(eventhiddenfieldsubmitvaluewrappedfunc)\n";
  807.                         $res .= "{\n\n";
  808.                         $res .= "var event = event || window.event;\n";
  809.  
  810.                         $res .= "submit1=true;\n";
  811.                         $res .= "submit2=true;\n";
  812.  
  813.                         // call the user defined JS function first, if it exists
  814.                         $res .= "if (typeof(wrappedfunc) == 'function') submit1=wrappedfunc(event);\n";
  815.  
  816.                         // set the hidden field value so we later know which event was fired
  817.                         $res .= "hiddenfield.value = submitvalue;\n";
  818.  
  819.                         // submit the form
  820.                         $res .= "if ((hiddenfield.form.onsubmit) && (typeof(hiddenfield.form.onsubmit) == 'function')) submit2=hiddenfield.form.onsubmit();\n";
  821.                         $res .= "if ((submit1) && (submit2)) hiddenfield.form.submit();\n";
  822.  
  823.                         // make sure the event handler of element does not handle
  824.                         // the JS event again (this might happen with a submit button)
  825.                         $res .= "return false;\n";
  826.  
  827.                         $res .= "\n}\n";
  828.                         $res .= "\n";
  829.                 }
  830.                 return $res;
  831.         }
  832.  
  833.         /**
  834.         * Get the name of the hidden field used to submit the value which event
  835.         * was fired.
  836.         * There is should one hidden field for each component that can forward
  837.         * JS event to the PHP script. It is the responsiblity of the component to
  838.         * add this field.
  839.         *
  840.         * @return string Name of the hidden field
  841.         */
  842.         protected function getJSWrapperHiddenFieldName()
  843.         {
  844.                 return "{$this->_name}SubmitEvent";
  845.         }
  846.  
  847.         /**
  848.         * Value set to the hidden field when the specific JS event was fired and
  849.         * the wrapper function was called.
  850.         * Have a look at getJSWrapperFunction(), that is where the value gets set
  851.         * to the hidden field.
  852.         * It is also used in the component to check if the defined $event has been
  853.         * fired on the page. This should be done in the init() function of the
  854.         * component.
  855.         *
  856.         * @param string $event String representation of the event (ex. $this->_onclick;)
  857.         * @return string The value that will be set in the hidden input.
  858.         */
  859.         protected function getJSWrapperSubmitEventValue($event)
  860.         {
  861.                 return "{$this->_name}_$event";
  862.         }
  863.  
  864.         //Protected properties
  865.  
  866.         /*
  867.         function setName($value)
  868.         {
  869.                 $oldname=$this->_name;
  870.                 parent::setName($value);
  871.                 //Sets the caption if not already changed
  872.                 if (!$this->_caption==$oldname)
  873.                 {
  874.                         $this->_caption=$this->_name;
  875.                 }
  876.         }
  877.         */
  878.  
  879.         /**
  880.         * Performs a parent reset if true
  881.         * @return boolean
  882.         */
  883.         function readDoParentReset() { return $this->_doparentreset}
  884.  
  885.         /**
  886.          * Returns the caption property
  887.          * @return string
  888.          */
  889.         protected function readCaption() { return $this->_caption}
  890.         protected function writeCaption($value) { $this->_caption=$value}
  891.         function defaultCaption() { return ""; }
  892.  
  893.         /**
  894.          * Returns the color property
  895.          * @return string
  896.          */
  897.         protected function readColor() { return $this->_color;     }
  898.         protected function writeColor($value)
  899.         {
  900.                 if ($this->_color!=$value)
  901.                 {
  902.                         $this->_color=$value;
  903.  
  904.                         if (($this->ControlState csLoading!= csLoading)
  905.                         {
  906.                                 // update the children
  907.                                 if ($this->methodExists("updateChildrenColors"))
  908.                                 {
  909.                                         $this->updateChildrenColors();
  910.                                 }
  911.  
  912.                                 // check if the ParentColor property cn be reset
  913.                                 if ($this->_doparentreset)
  914.                                 {
  915.                                         $this->_parentcolor=0;
  916.                                 }
  917.                         }
  918.                 }
  919.         }
  920.         function defaultColor() { return "";     }
  921.  
  922.         /**
  923.         * Determines if the controls is enabled or not
  924.         * @return boolean
  925.         */
  926.         protected function readEnabled() { return $this->_enabled}
  927.         protected function writeEnabled($value) { $this->_enabled=$value}
  928.         function defaultEnabled() { return 1; }
  929.  
  930.         /**
  931.         * Specifies the PopupMenu component to show when right clicking the control
  932.         * @return PopupMenu
  933.         */
  934.         protected function readPopupMenu() { return $this->_popupmenu}
  935.         protected function writePopupMenu($value) { $this->_popupmenu$this->fixupProperty($value)}
  936.         function defaultPopupmenu() { return null; }
  937.  
  938.         /**
  939.         * Determines where a control looks for its color information.
  940.         *
  941.         * To have a control use the same color as its parent control,
  942.         * set ParentColor to true. If ParentColor is false,
  943.         * the control uses its own Color property.
  944.         *
  945.         * @return true
  946.         */
  947.         protected function readParentColor() { return $this->_parentcolor}
  948.         protected function writeParentColor($value)
  949.         {
  950.                 if ($this->_parentcolor!=$value && $this->_doparentreset)
  951.                 {
  952.                         $this->_parentcolor=$value;
  953.                         // only change the color if parentcolor is set to true;
  954.                         // otherwise leave it as it is
  955.                         if ($this->_parentcolor == 1)
  956.                         {
  957.                                 if ($this->_parent!=null)
  958.                                 {
  959.                                         // set the color through writeColor() so child controls are updated too
  960.                                         $this->writeColor($this->_parent->_color);
  961.                                 }
  962.                                 else
  963.                                 {
  964.                                         $this->_color="";
  965.                                 }
  966.                         }
  967.                 }
  968.         }
  969.         function defaultParentColor() { return true;     }
  970.  
  971.         /**
  972.         * Determines the Font to be used when generating this control
  973.         *
  974.         * @return Font
  975.         */
  976.         protected function readFont() { return $this->_font;       }
  977.         protected function writeFont($value)
  978.         {
  979.                 if (is_object($value))
  980.                 {
  981.                         $this->_font=$value;
  982.  
  983.                         if (($this->ControlState csLoading!= csLoading)
  984.                         {
  985.                                 // update the children
  986.                                 if ($this->methodExists("updateChildrenFonts"))
  987.                                 {
  988.                                         $this->updateChildrenFonts();
  989.                                 }
  990.  
  991.                                 // check if the ParentFont property cn be reset
  992.                                 if ($this->_doparentreset)
  993.                                 {
  994.                                         $this->_parentfont=0;
  995.                                 }
  996.                         }
  997.                 }
  998.         }
  999.  
  1000.         /**
  1001.         * Specifies if this control is a Layer instead be integrated into the document
  1002.         *
  1003.         * @return boolean
  1004.         */
  1005.         protected function readIsLayer() { return $this->_islayer}
  1006.         protected function writeIsLayer($value) { $this->_islayer=$value}
  1007.         function defaultIsLayer() { return 0; }
  1008.  
  1009.         /**
  1010.         * Determines where a control looks for its font information.
  1011.         *
  1012.         * To have a control use the same font as its parent control,
  1013.         * set ParentFont to true. If ParentFont is false,
  1014.         * the control uses its own Font property.
  1015.         *
  1016.         * @return boolean
  1017.         */
  1018.         protected function readParentFont() { return $this->_parentfont}
  1019.         protected function writeParentFont($value)
  1020.         {
  1021.                 if ($this->_parentfont!=$value && $this->_doparentreset)
  1022.                 {
  1023.                         $this->_parentfont=$value;
  1024.  
  1025.                         // only change the font if parentfont is set to true;
  1026.                         // otherwise leave it as it is
  1027.                         if ($this->_parentfont == 1)
  1028.                         {
  1029.                                 if ($this->_parent!=null)
  1030.                                 {
  1031.                                         // do not allow to update ParentFont while assigning
  1032.                                         // the parent font to this control, otherwise the
  1033.                                         // Font::modified() function will try to set $this->ParentFont to false
  1034.                                         // because the font has changed.
  1035.                                         $this->_doparentreset false;
  1036.  
  1037.                                         $this->Parent->Font->assignTo($this->Font);
  1038.  
  1039.                                         $this->_parentfont = 1;
  1040.                                         $this->_doparentreset true;
  1041.                                 }
  1042.                                 else
  1043.                                 {
  1044.                                         $this->_font=null;
  1045.                                 }
  1046.                         }
  1047.                 }
  1048.         }
  1049.         function defaultParentFont() { return 1; }
  1050.  
  1051.  
  1052.  
  1053.         //Public properties
  1054.  
  1055.         protected $_layer=0;
  1056.  
  1057.         /**
  1058.         * Determines the layer this control is going to be rendered
  1059.         */
  1060.         function getLayer() { return $this->_layer}
  1061.         function setLayer($value) { $this->_layer=$value}
  1062.         function defaultLayer() { return 0; }
  1063.  
  1064.         /**
  1065.         * Specifies the Align for this control
  1066.         *
  1067.         * @return enum
  1068.         */
  1069.         function readAlign() { return $this->_align;     }
  1070.         function writeAlign($value) { $this->_align=$value}
  1071.         function defaultAlign() { return alNone;     }
  1072.  
  1073.         //TODO: Check if alignment,color and designcolor must be here or not
  1074.         /**
  1075.         * Specifies the alignment to be used by the control
  1076.         *
  1077.         * @return enum
  1078.         */
  1079.         function readAlignment() { return $this->_alignment;     }
  1080.         function writeAlignment($value) { $this->_alignment=$value}
  1081.         function defaultAlignment() { return agNone;     }
  1082.  
  1083.  
  1084.         /**
  1085.         * Specifies a color can be used by the control in design time
  1086.         *
  1087.         * @return string
  1088.         */
  1089.         function readDesignColor() { return $this->_designcolor;     }
  1090.         function writeDesignColor($value) { $this->_designcolor=$value}
  1091.         function defaultDesignColor() { return "";     }
  1092.  
  1093.         /**
  1094.         * Determines whether the control displays a Help Hint
  1095.         * when the mouse pointer rests momentarily on the control.
  1096.         *
  1097.         * @return boolean
  1098.         */
  1099.         function readShowHint() { return $this->_showhint;     }
  1100.         function writeShowHint($value)
  1101.         {
  1102.                 if ($value!=$this->_showhint)
  1103.                 {
  1104.                         $this->_showhint=$value;
  1105.  
  1106.                         if (($this->ControlState csLoading!= csLoading)
  1107.                         {
  1108.                                 // update the children
  1109.                                 if ($this->methodExists("updateChildrenShowHints"))
  1110.                                 {
  1111.                                         $this->updateChildrenShowHints();
  1112.                                 }
  1113.  
  1114.                                 if ($this->_doparentreset)
  1115.                                 {
  1116.                                         $this->_parentshowhint=0;
  1117.                                 }
  1118.                         }
  1119.                 }
  1120.  
  1121.         }
  1122.         function defaultShowHint() { return 0;     }
  1123.  
  1124.         /**
  1125.         * Determines where a control looks to find out if its Help Hint
  1126.         * should be shown.
  1127.         *
  1128.         * Use ParentShowHint to ensure that all the controls on a form
  1129.         * either uniformly show their Help Hints or uniformly do not show them.
  1130.         *
  1131.         * If ParentShowHint is true, the control uses the ShowHint property
  1132.         * value of its parent. If ParentShowHint is false, the control uses
  1133.         * the value of its own ShowHint property.
  1134.         *
  1135.         * To provide Help Hints for only selected controls on a form,
  1136.         * set the ShowHint property for those controls that should have
  1137.         * Help Hints to true, and ParentShowHint becomes false automatically.
  1138.         *
  1139.         * Note:   Enable or disable all Help Hints for the entire application
  1140.         *         using the ShowHint property of the application object.
  1141.         *
  1142.         * @return boolean
  1143.         */
  1144.         function readParentShowHint() { return $this->_parentshowhint;     }
  1145.         function writeParentShowHint($value)
  1146.         {
  1147.                 if ($this->_parentshowhint!=$value && $this->_doparentreset)
  1148.                 {
  1149.                         $this->_parentshowhint=$value;
  1150.                         // only change the showhint if parentshowhint is set to true;
  1151.                         // otherwise leave it as it is
  1152.                         if ($this->_parentshowhint == 1)
  1153.                         {
  1154.                                 if ($this->_parent!=null)
  1155.                                 {
  1156.                                         //$this->_showhint=$this->_parent->_showhint;
  1157.                                         $this->writeShowHint($this->_parent->_showhint);
  1158.                                 }
  1159.                                 else
  1160.                                 {
  1161.                                         $this->_showhint=0;
  1162.                                 }
  1163.                         }
  1164.                 }
  1165.         }
  1166.         function defaultParentShowHint() { return 1; }
  1167.  
  1168.         /**
  1169.         * Updates all properties that use the parent property as source.
  1170.         * These include ShowHint, Color and Font.
  1171.         */
  1172.         function updateParentProperties()
  1173.         {
  1174.                 $this->updateParentFont();
  1175.                 $this->updateParentColor();
  1176.                 $this->updateParentShowHint();
  1177.         }
  1178.  
  1179.         /**
  1180.         * If ParentFont == true the parent's font is assigned to this control.
  1181.         */
  1182.         function updateParentFont()
  1183.         {
  1184.                 if ($this->_parent!=null)
  1185.                 {
  1186.                         if (is_object($this->_parent))
  1187.                         {
  1188.                                 $this->_doparentreset false;
  1189.                                 if ($this->_parentfont)
  1190.                                 {
  1191.                                     $this->_parent->_font->assignTo($this->Font);
  1192.                                 }
  1193.                                 $this->_doparentreset true;
  1194.                         }
  1195.                 }
  1196.         }
  1197.  
  1198.         /**
  1199.         * If ParentColor == true the parent's color is assigned to this control.
  1200.         */
  1201.         function updateParentColor()
  1202.         {
  1203.                 if ($this->_parent!=null)
  1204.                 {
  1205.                         if (is_object($this->_parent))
  1206.                         {
  1207.                                 $this->_doparentreset false;
  1208.                                 if ($this->_parentcolor)    $this->writeColor($this->_parent->_color);
  1209.                                 $this->_doparentreset true;
  1210.                         }
  1211.                 }
  1212.         }
  1213.  
  1214.         /**
  1215.         * If ParentShowHint == true the parent's showhint is assigned to this control.
  1216.         */
  1217.         function updateParentShowHint()
  1218.         {
  1219.                 if ($this->_parent!=null)
  1220.                 {
  1221.                         if (is_object($this->_parent))
  1222.                         {
  1223.                                 $this->_doparentreset false;
  1224.                                 if ($this->_parentshowhint$this->writeShowHint($this->_parent->_showhint);
  1225.                                 $this->_doparentreset true;
  1226.                         }
  1227.                 }
  1228.         }
  1229.  
  1230.  
  1231.         /**
  1232.         * Determines if the controls is visible in run-time or not
  1233.         *
  1234.         * @return boolean
  1235.         */
  1236.         function readVisible() { return $this->_visible}
  1237.         function writeVisible($value) { $this->_visible=$value}
  1238.         function defaultVisible() { return 1; }
  1239.  
  1240.         /**
  1241.         * Determines the parent control which holds this control
  1242.         *
  1243.         * @return object
  1244.         */
  1245.         function readParent() { return $this->_parent}
  1246.         function writeParent($value)
  1247.         {
  1248.                 //Remove component from the previous parent, if any
  1249.                 if (is_object($this->_parent)) $this->_parent->controls->remove($this);
  1250.  
  1251.                 //Store
  1252.                 $this->_parent=$value;
  1253.  
  1254.                 //Adds this component to the parent's control list
  1255.                 if (is_object($this->_parent))
  1256.                 {
  1257.                         $this->_parent->controls->add($this);
  1258.                 }
  1259.         }
  1260.  
  1261.         /**
  1262.         * An array which holds the control style, with settings for the IDE
  1263.         *
  1264.         * @return array
  1265.         */
  1266.         function readControlStyle() { return($this->_controlstyle)}
  1267.         function writeControlStyle($value)
  1268.         {
  1269.                 $pieces=split("=",$value);
  1270.                 $this->_controlstyle[$pieces[0]]=$pieces[1];
  1271.         }
  1272.  
  1273.         function writeControlState($value)
  1274.         {
  1275.                 $oldstate = $this->_controlstate;
  1276.                 parent::writeControlState($value);
  1277.  
  1278.                 // Detect when the state changes after loading has finished
  1279.                 // ($oldvalue has csLoading, $value does not have it)
  1280.                 if (($oldstate csLoading== csLoading && ($value csLoading!= csLoading)
  1281.                 {
  1282.                         // Update the parent properties after the loading to ensure all properties
  1283.                         // were read from the stream and set.
  1284.                         // At the moment of writeParent() the control does not have
  1285.                         // the properties initialized because it's the first property set.
  1286.  
  1287.                         // Update all controls that accept controls inside itself, but do not update the
  1288.                         // root (usually Page) control.
  1289.                         if ((isset($this->_controlstyle["csAcceptsControls"])) && ($this->_controlstyle["csAcceptsControls"== "1" && $this->_parent != null))
  1290.                         {
  1291.                                 // check if the parent control will not update this container;
  1292.                                 // if $this->_parentcolor == 1 then it will be updated by the parent
  1293.                                 // (and also all children of this control)
  1294.                                 if ($this->_parentcolor == 0)
  1295.                                 {
  1296.                                         if ($this->methodExists("updateChildrenColors"))
  1297.                                         {
  1298.                                                 // check if there are any children that have $this->_parentcolor == 1
  1299.                                                 // if there are, update them
  1300.                                                 $this->updateChildrenColors();
  1301.                                         }
  1302.                                 }
  1303.                                 // same comment as $this->_parentcolor
  1304.                                 if ($this->_parentfont == 0)
  1305.                                 {
  1306.                                         if ($this->methodExists("updateChildrenFonts"))
  1307.                                         {
  1308.                                                 $this->updateChildrenFonts();
  1309.                                         }
  1310.                                 }
  1311.                                 // same comment as $this->_parentcolor
  1312.                                 if ($this->_parentshowhint == 0)
  1313.                                 {
  1314.                                         if ($this->methodExists("updateChildrenShowHints"))
  1315.                                         {
  1316.                                                 $this->updateChildrenShowHints();
  1317.                                         }
  1318.                                 }
  1319.                         }
  1320.                         // put the Page (parent == null) to the end of the if-statement because it's called only once
  1321.                         else if ($this->_parent == null && $this->methodExists("updateChildrenParentProperties"))
  1322.                         {
  1323.                                 $this->updateChildrenParentProperties();
  1324.                         }
  1325.                 }
  1326.         }
  1327.  
  1328.  
  1329.         //Published
  1330.  
  1331.         /**
  1332.         * Left coordinate
  1333.         */
  1334.         function getLeft() { return $this->_left}
  1335.         function setLeft($value) { $this->_left=$value}
  1336.         function defaultLeft() { return 0; }
  1337.  
  1338.         /**
  1339.         * Top coordinate
  1340.         */
  1341.         function getTop() { return $this->_top}
  1342.         function setTop($value) { $this->_top=$value}
  1343.         function defaultTop() { return 0; }
  1344.  
  1345.         /**
  1346.         * Control width
  1347.         */
  1348.         function getWidth() { return $this->_width}
  1349.         function setWidth($value) { $this->_width=$value}
  1350.         function defaultWidth() { return 0; }
  1351.  
  1352.         /*
  1353.         * Control height
  1354.         */
  1355.         function getHeight() { return $this->_height}
  1356.         function setHeight($value) { $this->_height=$value}
  1357.         function defaultHeight() { return 0; }
  1358.  
  1359.         /**
  1360.         * Cursor to show when the mouse is over the control
  1361.         */
  1362.         function getCursor() { return $this->_cursor}
  1363.         function setCursor($value) { $this->_cursor=$value}
  1364.         function defaultCursor() { return ""; }
  1365.  
  1366.         /**
  1367.         * Text to show in a tooltip when the mouse is over the control for some time
  1368.         */
  1369.         function getHint() { return $this->_hint}
  1370.         function setHint($value) { $this->_hint=$value}
  1371.         function defaultHint() { return ""; }
  1372.  
  1373.  
  1374.         //Events
  1375.  
  1376.         /**
  1377.         * Event fired before show the control
  1378.         */
  1379.         function getOnBeforeShow() { return $this->_onbeforeshow}
  1380.         function setOnBeforeShow($value) { $this->_onbeforeshow=$value}
  1381.         function defaultOnBeforeShow() { return null; }
  1382.  
  1383.         /**
  1384.         * Event fired after show the control
  1385.         */
  1386.         function getOnAfterShow() { return $this->_onaftershow}
  1387.         function setOnAfterShow($value) { $this->_onaftershow=$value}
  1388.         function defaultOnAfterShow() { return null; }
  1389.  
  1390.         /**
  1391.         * Event fired at the same moment the control is show, some controls can
  1392.         * prevent the control to be shown when this event is attached
  1393.         */
  1394.         function getOnShow() { return $this->_onshow}
  1395.         function setOnShow($value) { $this->_onshow=$value}
  1396.         function defaultOnShow() { return null; }
  1397. }
  1398.  
  1399. /**
  1400.  * FocusControl class
  1401.  *
  1402.  * Base class for controls with input focus
  1403.  */
  1404. class FocusControl extends Control
  1405. {
  1406.         protected $_layout=null;
  1407.  
  1408.         public    $controls;
  1409.  
  1410.         /**
  1411.         * If this control has any children that have ParentFont==true then
  1412.         * this function will assign the Font property to all children Font properties.
  1413.         * Note: This must be in FocusControl, not in Control, as it's here where the controls property is defined
  1414.         */
  1415.         function updateChildrenFonts()
  1416.         {
  1417.                 //Iterates through all child controls and assign the new font
  1418.                 //to all that have ParentFont=true
  1419.                 reset($this->controls->items);
  1420.                 while (list($k,$veach($this->controls->items))
  1421.                 {
  1422.                         if ($v->ParentFont)
  1423.                         {
  1424.                                 $v->updateParentFont();
  1425.                         }
  1426.                 }
  1427.         }
  1428.  
  1429.         /**
  1430.         * Update the colors for all the children if parentcolor is set
  1431.         */
  1432.         function updateChildrenColors()
  1433.         {
  1434.                 //Iterates through all child controls and assign the new color
  1435.                 //to all that have ParentColor=true
  1436.                 reset($this->controls->items);
  1437.                 while (list($k,$veach($this->controls->items))
  1438.                 {
  1439.                         if ($v->ParentColor)
  1440.                         {
  1441.                                 $v->updateParentColor();
  1442.                         }
  1443.                 }
  1444.         }
  1445.  
  1446.         /**
  1447.         * Update the ShowHints properties for all children controlss
  1448.         */
  1449.         function updateChildrenShowHints()
  1450.         {
  1451.                 //Iterates through all child controls and assign the new showhint
  1452.                 //to all that have ParentShowHint=true
  1453.                 reset($this->controls->items);
  1454.                 while (list($k,$veach($this->controls->items))
  1455.                 {
  1456.                         if ($v->ParentShowHint)
  1457.                         {
  1458.                                 $v->updateParentShowHint();
  1459.                         }
  1460.                 }
  1461.         }
  1462.  
  1463.         /**
  1464.         * If this control has any children that use a property's value from the parent then
  1465.         * this function will update all necessary properties.
  1466.         * Note: This must be in FocusControl, not in Control, as it's here where the controls property is defined
  1467.         */
  1468.         function updateChildrenParentProperties()
  1469.         {
  1470.                 //Iterates through all child controls and assign the new font
  1471.                 //to all that have ParentFont=true
  1472.                 reset($this->controls->items);
  1473.                 while (list($k,$veach($this->controls->items))
  1474.                 {
  1475.                         // first check if it is really necessary to update the parent properties
  1476.                         if ($v->ParentColor || $v->ParentFont || $v->ParentShowHint)
  1477.                         {
  1478.                                 $v->updateParentProperties();
  1479.                         }
  1480.                 }
  1481.         }
  1482.  
  1483.  
  1484.         function __construct($aowner=null)
  1485.         {
  1486.                 //Creates the controls list
  1487.                 $this->controls=new Collection();
  1488.  
  1489.                 //Calls inherited constructor
  1490.                 parent::__construct($aowner);
  1491.  
  1492.                 $this->_layout=new Layout();
  1493.                 $this->_layout->_control=$this;
  1494.         }
  1495.  
  1496.         /**
  1497.         * Return the number of controls for which this control is the Parent
  1498.         * @return integer
  1499.         */
  1500.         function readControlCount() { return $this->controls->count()}
  1501.  
  1502.         /**
  1503.         * Specifies the Layout this control lives in @see ActiveLayout
  1504.         *
  1505.         * @return mixed
  1506.         */
  1507.         function readLayout() { return $this->_layout}
  1508.         function writeLayout($value) { if (is_object($value)) $this->_layout=$value}
  1509.  
  1510.  
  1511.         /**
  1512.         * Dump all children
  1513.         */
  1514.         function dumpChildren()
  1515.         {
  1516.                 //Iterates through controls calling show for all of them
  1517.                 reset($this->controls->items);
  1518.                 while (list($k,$v)=each($this->controls->items))
  1519.                 {
  1520.                         $v->show();
  1521.                 }
  1522.  
  1523.         }
  1524. }
  1525.  
  1526. /**
  1527.  * CustomControl class
  1528.  *
  1529.  * Base class for custom control
  1530.  */
  1531. class CustomControl extends FocusControl
  1532. {
  1533. }
  1534.  
  1535. /**
  1536.  * GraphicControl class
  1537.  *
  1538.  * Base class for controls with graphic capabilities
  1539.  */
  1540. class GraphicControl extends CustomControl
  1541. {
  1542. }
  1543.  
  1544. /**
  1545. * CustomListControl
  1546. *
  1547. * CustomListControl is the base class for controls that display a list of items.
  1548. */
  1549. abstract class CustomListControl extends FocusControl
  1550. {
  1551.         protected $_itemindex = -1;
  1552.  
  1553.         /**
  1554.         * Returns the number of items in the list.
  1555.         * @return integer Number of items in the list.
  1556.         */
  1557.         abstract function readCount();
  1558.  
  1559.         /**
  1560.         * Returns the value of the ItemIndex property.
  1561.         * @return mixed Return the ItemIndex of the list.
  1562.         */
  1563.         abstract function readItemIndex();
  1564.  
  1565.         /**
  1566.         * Set new ItemIndex value.
  1567.         * @param mixed $value Value of the new ItemIndex.
  1568.         */
  1569.         abstract function writeItemIndex($value);
  1570.  
  1571.         /**
  1572.         * Return default ItemIndex.
  1573.         * @return mixed Returns default ItemIndex.
  1574.         */
  1575.         abstract function defaultItemIndex();
  1576.  
  1577.         /**
  1578.         * Adds an item to the list control.
  1579.         * @param mixed $item Value of item to add.
  1580.         * @param mixed $object Object to assign to the $item. is_object() is used to
  1581.         *                      test if $object is an object.
  1582.         * @param mixed $itemkey Key of the item in the array. Default key is used if null.
  1583.         * @return integer Return the number of items in the list.
  1584.         */
  1585.         abstract function AddItem($item, $object = null, $itemkey = null);
  1586.  
  1587.         /**
  1588.         * Deletes all of the items from the list control.
  1589.         */
  1590.         abstract function Clear();
  1591.  
  1592.         /**
  1593.         * Removes the selection, leaving all items unselected.
  1594.         */
  1595.         abstract function ClearSelection();
  1596.         //abstract function CopySelection($destination);
  1597.         //abstract function DeleteSelection();
  1598.         //abstract function MoveSelection($destination);
  1599.  
  1600.         /**
  1601.         * Selects all items or all text in the selected item.
  1602.         */
  1603.         abstract function SelectAll();
  1604. }
  1605.  
  1606. abstract class CustomMultiSelectListControl extends CustomListControl
  1607. {
  1608.         protected $_multiselect = 0;
  1609.  
  1610.         /**
  1611.         * Returns how many items are selected in the list.
  1612.         * @return integer Returns how many items are selected in the list.
  1613.         */
  1614.         abstract function readSelCount();
  1615.  
  1616.         /**
  1617.         * Reads the value of the MultiSelect property.
  1618.         * @return bool Returns if the list is MultiSelect or not.
  1619.         */
  1620.         abstract function readMultiSelect();
  1621.  
  1622.         /**
  1623.         * Sets the value of the MultiSelect property.
  1624.         * @param bool $value Set MultiSelect to true or false.
  1625.         */
  1626.         abstract function writeMultiSelect($value);
  1627.  
  1628.         /**
  1629.         * Return default MultiSelect value.
  1630.         * @return bool Returns default MultiSelect value.
  1631.         */
  1632.         abstract function defaultMultiSelect();
  1633. }
  1634.  

Documentation generated on Tue, 27 Mar 2007 13:34:00 +0200 by phpDocumentor 1.3.1