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

Source for file extctrls.inc.php

Documentation is available at extctrls.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("controls.inc.php");
  28. use_unit("stdctrls.inc.php");
  29. use_unit("graphics.inc.php");
  30. use_unit("imglist.inc.php");
  31.  
  32.  
  33. /**
  34.  * Shape.ShapeType
  35.  */
  36. define('stRectangle''stRectangle');
  37. define('stSquare''stSquare');
  38. define('stRoundRect''stRoundRect');
  39. define('stRoundSquare''stRoundSquare');
  40. define('stEllipse''stEllipse');
  41. define('stCircle''stCircle');
  42.  
  43. /**
  44.  * Bevel.Shape
  45.  */
  46. define('bsBox''bsBox');
  47. define('bsFrame''bsFrame');
  48. define('bsTopLine''bsTopLine');
  49. define('bsBottomLine''bsBottomLine');
  50. define('bsLeftLine''bsLeftLine');
  51. define('bsRightLine''bsRightLine');
  52. define('bsSpacer''bsSpacer');
  53.  
  54. /**
  55.  * Bevel.Style
  56.  */
  57. define('bsLowered''bsLowered');
  58. define('bsRaised''bsRaised');
  59.  
  60. /**
  61.  * Image class
  62.  *
  63.  * A class to encapsulate and display an image.
  64.  *
  65.  */
  66. class Image extends GraphicControl
  67. {
  68.         protected $_onclick = null;
  69.         protected $_oncustomize = null;
  70.  
  71.         protected $_autosize=0;
  72.         protected $_border=0;
  73.         protected $_bordercolor="";
  74.         protected $_center=0;
  75.         protected $_datafield="";
  76.         protected $_datasource=null;
  77.         protected $_imagesource;
  78.         protected $_link;
  79.         protected $_linktarget;
  80.         protected $_proportional=0;
  81.  
  82.  
  83.         function __construct($aowner=null)
  84.         {
  85.                 //Calls inherited constructor
  86.                 parent::__construct($aowner);
  87.  
  88.                 $this->Width=105;
  89.                 $this->Height=105;
  90.  
  91.                 //For mapshapes
  92.                 $this->ControlStyle="csAcceptsControls=1";
  93.  
  94.                 $this->ControlStyle="csRenderOwner=1";
  95.                 $this->ControlStyle="csRenderAlso=StyleSheet";
  96.         }
  97.  
  98.  
  99.         /**
  100.         * Returns the absolute image path.
  101.         * @return string 
  102.         */
  103.         private function getImageSourcePath()
  104.         {
  105.                 // check if relative
  106.                 if (substr($this->_imagesource02== ".." || $this->_imagesource{0== ".")
  107.                 {
  108.                         return dirname($_SERVER['SCRIPT_FILENAME']).'/'.$this->_imagesource;
  109.                 }
  110.                 else
  111.                 {
  112.                         return $this->_imagesource;
  113.                 }
  114.         }
  115.  
  116.         function loaded()
  117.         {
  118.                 parent::loaded();
  119.  
  120.                 $this->setDataSource($this->_datasource);
  121.  
  122.                 if ($this->_autosize)
  123.                 {
  124.                         if ($this->_imagesource!="")
  125.                         {
  126.                                 $result getimagesize($this->getImageSourcePath());
  127.  
  128.                                 if (is_array($result))
  129.                                 {
  130.                                         $bordersize ($this->_border == 12*0;
  131.  
  132.                                         list($width$height$type$attr$result;
  133.                                         $this->Width = $width $bordersize;
  134.                                         $this->Height = $height $bordersize;
  135.                                 }
  136.                         }
  137.                 }
  138.  
  139.         }
  140.  
  141.         function init()
  142.         {
  143.                 parent::init();
  144.  
  145.                 $submitEventValue $this->input->{$this->getJSWrapperHiddenFieldName()};
  146.  
  147.                 if (is_object($submitEventValue))
  148.                 {
  149.                         // check if the a click event has been fired
  150.                         if ($this->_onclick != null && $submitEventValue->asString(== $this->getJSWrapperSubmitEventValue($this->_onclick))
  151.                         {
  152.                                 $this->callEvent('onclick'array());
  153.                         }
  154.                 }
  155.         }
  156.  
  157.         function dumpContents()
  158.         {
  159.                 if ($this->_onshow!=null)
  160.                 {
  161.                         $this->callEvent('onshow',array());
  162.                 }
  163.                 else
  164.                 {
  165.                         $map="";
  166.                         if ($this->controls->count()>0)
  167.                         {
  168.                                 $map "usemap=\"#map$this->_name\"";
  169.                         }
  170.  
  171.                         $events $this->readJsEvents();
  172.                         // add or replace the JS events with the wrappers if necessary
  173.                         $this->addJSWrapperToEvents($events$this->_onclick,    $this->_jsonclick,    "onclick");
  174.  
  175.                         $imgwidth $this->Width;
  176.                         $imgheight $this->Height;
  177.                         // first let's get the image size
  178.                         if ($this->_imagesource != "")
  179.                         {
  180.                                 $result getimagesize($this->getImageSourcePath());
  181.  
  182.                                 if (is_array($result))
  183.                                 {
  184.                                         list($imgwidth$imgheight$type$attr$result;
  185.                                 }
  186.                         }
  187.  
  188.                         $attr "";
  189.                         $divstyle "";
  190.                         $imgstyle "";
  191.  
  192.                         $divstyle .= " width$this->_width";
  193.                         $divstyle .= " height$this->_height";
  194.                         if (($this->ControlState csDesigning== csDesigning)
  195.                         {
  196.                                 $divstyle .= "border:1px dashed gray;";
  197.                         }
  198.  
  199.                         // add the cursor to the style
  200.                         if ($this->_cursor != "" && $this->Style=="")
  201.                         {
  202.                                 $cr strtolower(substr($this->_cursor2));
  203.                                 $divstyle .= "cursor$cr;";
  204.                         }
  205.  
  206.                         $w $imgwidth;
  207.                         $h $imgheight;
  208.                         $bordersize ($this->_border == 12*0;
  209.  
  210.                         if ($this->_proportional == 1)
  211.                         {
  212.                                 // actual image is smaller than the area where it should be displayed
  213.                                 if (intval($this->_width$imgwidth && intval($this->_height$imgheight)
  214.                                 {
  215.                                         // no resizing necessary
  216.                                         $attr .= " width=\"$imgwidth\" ";
  217.                                         $attr .= " height=\"$imgheight\" ";
  218.                                 }
  219.                                 else
  220.                                 {
  221.                                         // only height of image is bigger
  222.                                         if (intval($this->_width$imgwidth && intval($this->_height$imgheight)
  223.                                         {
  224.                                                 $h intval($this->_height$bordersize;
  225.                                                 $w floor(($imgwidth $h$imgheight);
  226.                                         }
  227.                                         // only width of image is bigger
  228.                                         else if (intval($this->_width$imgwidth && intval($this->_height$imgheight)
  229.                                         {
  230.                                                 $w intval($this->_width$bordersize;
  231.                                                 $h floor(($imgheight $w$imgwidth);
  232.                                         }
  233.                                         // both sides of the image are bigger
  234.                                         else
  235.                                         {
  236.                                                 // Check which side is bigger
  237.                                                 if (intval($this->_widthintval($this->_height))
  238.                                                 {
  239.                                                         $h intval($this->_height$bordersize;
  240.                                                         $w floor(($imgwidth $h$imgheight);
  241.                                                 }
  242.                                                 else
  243.                                                 {
  244.                                                         $w intval($this->_width$bordersize;
  245.                                                         $h floor(($imgheight $w$imgwidth);
  246.                                                 }
  247.                                         }
  248.                                         $attr .= " width=\"$w\" ";
  249.                                         $attr .= " height=\"$h\" ";
  250.                                 }
  251.                         }
  252.                         else
  253.                         {
  254.                                 $divstyle .= "overflow: hidden;";
  255.  
  256.                                 $attr .= " width=\"$imgwidth\" ";
  257.                                 $attr .= " height=\"$imgheight\" ";
  258.                         }
  259.  
  260.                         if ($this->_center == 1)
  261.                         {
  262.                                 $divstyle .= "text-align: center;";
  263.                                 $margin floor(($this->_height $h2);
  264.                                 $imgstyle .= "margin-top$margin;";
  265.                         }
  266.  
  267.                         $hint $this->getHintAttribute();
  268.                         $hint .= ($hint != """ alt=\"".(htmlspecialchars($this->_hintENT_QUOTES))."\"" "";
  269.  
  270.                         if ($this->Style=="")
  271.                         {
  272.                                 $attr .= " border=\"$this->_border\" ";
  273.  
  274.                                 if ($this->_bordercolor!=""$attr .= " style=\" border-color$this->_bordercolor \" ";
  275.                         }
  276.  
  277.                         $class ($this->Style != """class=\"$this->StyleClass\""";
  278.  
  279.  
  280.                         echo "<div id=\"{$this->_name}_container\" style=\"$divstyle\" $class>";
  281.  
  282.                         if ($this->_link != "")
  283.                         {
  284.                                 echo "<A HREF=\"".$this->_link."\" $hint ";
  285.                                 if ($this->_linktarget!=""echo " target=\"".$this->_linktarget."\"";
  286.                                 echo ">";
  287.                         }
  288.  
  289.                         if ($imgstyle != ""$imgstyle "style=\"$imgstyle\"";
  290.  
  291.                         if (($this->ControlState csDesigning!= csDesigning)
  292.                         {
  293.                                 if ($this->hasValidDataField())
  294.                                 {
  295.                                         $this->_imagesource $this->readDataFieldValue();
  296.                                         // no hidden field to dump since it's a read-only control
  297.                                 }
  298.                         }
  299.  
  300.                         $this->callEvent('oncustomize'array());
  301.  
  302.                         echo "<img id=\"$this->_name\" src=\"$this->_imagesource\" $attr $imgstyle $class $hint $map $events />";
  303.  
  304.                         // add a hidden field so we can determine which event for the label was fired
  305.                         if ($this->_onclick != null)
  306.                         {
  307.                                 $hiddenwrapperfield $this->getJSWrapperHiddenFieldName();
  308.                                 echo "<input type=\"hidden\" id=\"$hiddenwrapperfield\" name=\"$hiddenwrapperfield\" value=\"\" />";
  309.                         }
  310.  
  311.                         if ($this->_link != ""echo "</A>";
  312.                         echo "</div>";
  313.  
  314.                         if ($this->controls->count()>0)
  315.                         {
  316.                                 echo "<map name=\"map$this->_name\">\n";
  317.                                 reset($this->controls->items);
  318.                                 while (list($k,$v)=each($this->controls->items))
  319.                                 {
  320.                                         if ($v->Visible)
  321.                                         {
  322.                                                 $v->show();
  323.                                         }
  324.                                 }
  325.                                 echo "</map>";
  326.                         }
  327.                 }
  328.         }
  329.  
  330.         /**
  331.         * Write the Javascript section to the header
  332.         */
  333.         function dumpJavascript()
  334.         {
  335.                 parent::dumpJavascript();
  336.  
  337.                 if ($this->_onclick != null && !defined($this->_onclick))
  338.                 {
  339.                         // only output the same function once;
  340.                         // otherwise if for example two buttons use the same
  341.                         // OnClick event handler it would be outputted twice.
  342.                         $def=$this->_onclick;
  343.                         define($def,1);
  344.  
  345.                         // output the wrapper function
  346.                         echo $this->getJSWrapperFunction($this->_onclick);
  347.                 }
  348.         }
  349.  
  350.  
  351.         /*
  352.         * Publish the events for the component
  353.         */
  354.  
  355.         /**
  356.         * Occurs when the user clicks the control.
  357.         * @return mixed Returns the event handler or null if no handler is set.
  358.         */
  359.         function getOnClick                     (return $this->_onclick}
  360.         /**
  361.         * Occurs when the user clicks the control.
  362.         * @param mixed $value Event handler or null to unset.
  363.         */
  364.         function setOnClick                     ($value$this->_onclick=$value}
  365.         function defaultOnClick                 (return null}
  366.  
  367.         /**
  368.         * Occurs before the image tag is written to the stream sent to the client.
  369.         * Use this event to modifiy the image source.
  370.         * @return mixed Event handler or null to unset.
  371.         */
  372.         function getOnCustomize                 (return $this->_oncustomize}
  373.         /**
  374.         * Occurs before the image tag is written to the stream sent to the client.
  375.         * Use this event to modifiy the image source.
  376.         * @param mixed $value Event handler or null to unset.
  377.         */
  378.         function setOnCustomize                 ($value$this->_oncustomize=$value}
  379.         function defaultOnCustomize             (return null}
  380.  
  381.  
  382.         /*
  383.         * Publish the JS events for the component
  384.         */
  385.         function getjsOnClick                   (return $this->readjsOnClick()}
  386.         function setjsOnClick                   ($value$this->writejsOnClick($value)}
  387.  
  388.         function getjsOnDblClick                (return $this->readjsOnDblClick()}
  389.         function setjsOnDblClick                ($value$this->writejsOnDblClick($value)}
  390.  
  391.         function getjsOnMouseDown               (return $this->readjsOnMouseDown()}
  392.         function setjsOnMouseDown               ($value$this->writejsOnMouseDown($value)}
  393.  
  394.         function getjsOnMouseUp                 (return $this->readjsOnMouseUp()}
  395.         function setjsOnMouseUp                 ($value$this->writejsOnMouseUp($value)}
  396.  
  397.         function getjsOnMouseOver               (return $this->readjsOnMouseOver()}
  398.         function setjsOnMouseOver               ($value$this->writejsOnMouseOver($value)}
  399.  
  400.         function getjsOnMouseMove               (return $this->readjsOnMouseMove()}
  401.         function setjsOnMouseMove               ($value$this->writejsOnMouseMove($value)}
  402.  
  403.         function getjsOnMouseOut                (return $this->readjsOnMouseOut()}
  404.         function setjsOnMouseOut                ($value$this->writejsOnMouseOut($value)}
  405.  
  406.         function getjsOnKeyPress                (return $this->readjsOnKeyPress()}
  407.         function setjsOnKeyPress                ($value$this->writejsOnKeyPress($value)}
  408.  
  409.         function getjsOnKeyDown                 (return $this->readjsOnKeyDown()}
  410.         function setjsOnKeyDown                 ($value$this->writejsOnKeyDown($value)}
  411.  
  412.         function getjsOnKeyUp                   (return $this->readjsOnKeyUp()}
  413.         function setjsOnKeyUp                   ($value$this->writejsOnKeyUp($value)}
  414.  
  415.  
  416.         /*
  417.         * Publish the properties for the component
  418.         */
  419.  
  420.         /**
  421.         * If Autosize is true the control takes over the size of the image.
  422.         * This way the image is displayed 100%.
  423.         * @return bool 
  424.         */
  425.         function getAutosize(return $this->_autosize}
  426.         /**
  427.         * If Autosize is true the control takes over the size of the image.
  428.         * This way the image is displayed 100%.
  429.         * @param bool $value 
  430.         */
  431.         function setAutosize($value)  $this->_autosize=$value}
  432.  
  433.         /**
  434.         * Adds a border around the image if true.
  435.         * @return bool 
  436.         */
  437.         function getBorder(return $this->_border}
  438.         /**
  439.         * Adds a border around the image if true.
  440.         * @param bool $value 
  441.         */
  442.         function setBorder($value$this->_border=$value}
  443.  
  444.         /**
  445.         * Color of the border, only has an affect if Border is set to true.
  446.         * Use the HTML hex color format. e.g. #FF0000 for red.
  447.         * @return string 
  448.         */
  449.         function getBorderColor(return $this->_bordercolor}
  450.         /**
  451.         * Color of the border, only has an affect if Border is set to true.
  452.         * Use the HTML hex color format. e.g. #FF0000 for red.
  453.         * @param string $value 
  454.         */
  455.         function setBorderColor($value$this->_bordercolor=$value}
  456.         function defaultBorderColor(return ""}
  457.  
  458.         /**
  459.         * Indicates whether the image is centered in the image control.
  460.         * When the image does not fit perfectly within the image control,
  461.         * use Center to specify how the image is positioned.
  462.         * When Center is true, the image is centered in the control.
  463.         * When Center is false, the upper left corner of the image is positioned
  464.         * at the upper left corner of the control.
  465.         *
  466.         * Note: Center has no effect if the AutoSize property is true.
  467.         *
  468.         * @return bool 
  469.         */
  470.         function getCenter(return $this->_center}
  471.         /**
  472.         * Indicates whether the image is centered in the image control.
  473.         * When the image does not fit perfectly within the image control,
  474.         * use Center to specify how the image is positioned.
  475.         * When Center is true, the image is centered in the control.
  476.         * When Center is false, the upper left corner of the image is positioned
  477.         * at the upper left corner of the control.
  478.         *
  479.         * Note: Center has no effect if the AutoSize property is true.
  480.         *
  481.         * @return bool 
  482.         */
  483.         function setCenter($value$this->_center=$value}
  484.         function defaultCenter(return 0}
  485.  
  486.         /**
  487.         * Fieldname this control is attached to
  488.         * @return string 
  489.         */
  490.         function getDataField(return $this->_datafield}
  491.         function setDataField($value$this->_datafield=$value}
  492.         function defaultDataField(return ""}
  493.  
  494.         /**
  495.         * Datasource this control is attached to
  496.         * @return DataSource 
  497.         */
  498.         function getDataSource(return $this->_datasource}
  499.         function setDataSource($value$this->_datasource=$this->fixupProperty($value)}
  500.         function defaultDataSource(return ""}
  501.  
  502.         /**
  503.         * Source of the image denotes a path where the image is located.
  504.         * This path can be relative to the script or absolute.
  505.         * @return string 
  506.         */
  507.         function getImageSource(return $this->_imagesource}
  508.         /**
  509.         * Source of the image denotes a path where the image is located.
  510.         * This path can be relative to the script or absolute.
  511.         * @param string $value 
  512.         */
  513.         function setImageSource($value$this->_imagesource=$value}
  514.  
  515.         /**
  516.         * If Link is set the Caption is rendered as a link.
  517.         * @return string Link, if empty string the link is not used.
  518.         */
  519.         function getLink(return $this->_link}
  520.         /**
  521.         * If Link is set the Caption is rendered as a link.
  522.         * @value string $value Link, if empty string the link is not used.
  523.         */
  524.         function setLink($value$this->_link=$value}
  525.  
  526.         /**
  527.         * Target attribute when the label acts as a link.
  528.         * @link http://www.w3.org/TR/html4/present/frames.html#adef-target
  529.         * @return string The link target as defined by the HTML specs.
  530.         */
  531.         function getLinkTarget(return $this->_linktarget}
  532.         /**
  533.         * Target attribute when the label acts as a link.
  534.         * @link http://www.w3.org/TR/html4/present/frames.html#adef-target
  535.         * @param string $value The link target as defined by the HTML specs.
  536.         */
  537.         function setLinkTarget($value$this->_linktarget=$value}
  538.  
  539.         function getParentShowHint(return $this->readParentShowHint()}
  540.         function setParentShowHint($value$this->writeParentShowHint($value)}
  541.  
  542.         function getPopupMenu(return $this->readPopupMenu()}
  543.         function setPopupMenu($value$this->writePopupMenu($value)}
  544.  
  545.         /**
  546.         * Indicates whether the image should be changed, without distortion,
  547.         * so that it fits the bounds of the image control.
  548.         *
  549.         * Set Proportional to true to ensure that the image can be fully displayed
  550.         * in the image control without any distortion. When Proportional is true,
  551.         * images that are too large to fit in the image control are scaled down
  552.         * (while maintaining the same aspect ratio) until they fit in the image control.
  553.         * Images that are too small are displayed normally. That is,
  554.         * Proportional can reduce the magnification of the image, but does not increase it.
  555.         *
  556.         * Note: The filesize is equal even the image is scaled down.
  557.         *
  558.         * @return bool 
  559.         */
  560.         function getProportional(return $this->_proportional}
  561.         /**
  562.         * Indicates whether the image should be changed, without distortion,
  563.         * so that it fits the bounds of the image control.
  564.         *
  565.         * Set Proportional to true to ensure that the image can be fully displayed
  566.         * in the image control without any distortion. When Proportional is true,
  567.         * images that are too large to fit in the image control are scaled down
  568.         * (while maintaining the same aspect ratio) until they fit in the image control.
  569.         * Images that are too small are displayed normally. That is,
  570.         * Proportional can reduce the magnification of the image, but does not increase it.
  571.         *
  572.         * Note: The filesize is equal even the image is scaled down.
  573.         *
  574.         * @param bool $value 
  575.         */
  576.         function setProportional($value$this->_proportional=$value}
  577.         function defaultProportional(return 0}
  578.  
  579.         function getShowHint(return $this->readShowHint()}
  580.         function setShowHint($value$this->writeShowHint($value)}
  581.  
  582.         function getStyle()             return $this->readstyle()}
  583.         function setStyle($value)       $this->writestyle($value)}
  584.  
  585.         function getVisible(return $this->readVisible()}
  586.         function setVisible($value$this->writeVisible($value)}
  587. }
  588.  
  589. /**
  590.  * FlashObject class
  591.  *
  592.  * A class to encapsulate a FlashObject.
  593.  * This control may be use to include a flash animation into a page.
  594.  *
  595.  */
  596. class FlashObject extends GraphicControl
  597. {
  598.         protected $_swffile;
  599.  
  600.         function __construct($aowner=null)
  601.         {
  602.                 //Calls inherited constructor
  603.                 parent::__construct($aowner);
  604.  
  605.                 $this->Width=105;
  606.                 $this->Height=105;
  607.  
  608.         }
  609.  
  610.  
  611.         function getVisible(return $this->readVisible()}
  612.         function setVisible($value$this->writeVisible($value)}
  613.  
  614.         /**
  615.         * Location of the Flash file (*.swf).
  616.         * Path can be relative to the script or absolute.
  617.         * @return string 
  618.         */
  619.         function getSwfFile(return $this->_swffile}
  620.         /**
  621.         * Location of the Flash file (*.swf).
  622.         * Path can be relative to the script or absolute.
  623.         * @param string $value 
  624.         */
  625.         function setSwfFile($value$this->_swffile=$value}
  626.  
  627.         function dumpContents()
  628.         {
  629.                 if (($this->ControlState csDesigning)==csDesigning)
  630.                 {
  631.                         $attr="";
  632.                         if ($this->_width!=""$attr.=" width=\"$this->_width\" ";
  633.                         if ($this->_height!=""$attr.=" height=\"$this->_height\" ";
  634.  
  635.                         $font ($this->_parent != null$this->_parent->Font->FontString "";
  636.  
  637.                         $bstyle=" style=\"border: 1px dotted #000000; text-aligncenter$font\" ";
  638.                         echo "<table $attr $bstyle><tr><td>".basename($this->_swffile)."</td></tr></table>\n";
  639.                 }
  640.                 else
  641.                 {
  642.                         $this->callEvent('onshow',array());
  643.  
  644.                         echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" id=\"$this->_name\" width=\"$this->_width\" height=\"$this->_height\">\n";
  645.                         echo "<param name=\"movie\" value=\"$this->_swffile\" />\n";
  646.                         echo "<param name=\"quality\" value=\"high\" />\n";
  647.                         echo "<embed src=\"$this->_swffile\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"$this->_width\" height=\"$this->_height\"></embed>\n";
  648.                         echo "</object>\n";
  649.                 }
  650.  
  651.         }
  652. }
  653.  
  654. /*
  655. class ImageMap extends GraphicControl
  656. {
  657.         function __construct($aowner=null)
  658.         {
  659.                 //Calls inherited constructor
  660.                 parent::__construct($aowner);
  661.                 $this->ControlStyle="csAcceptsControls=1";
  662.         }
  663.  
  664.         function dumpContents()
  665.         {
  666.  
  667.                 if (($this->ControlState & csDesigning)==csDesigning)
  668.                 {
  669.                         $attr="";
  670.                         if ($this->_width!="") $attr.=" width=\"$this->_width\" ";
  671.                         if ($this->_height!="") $attr.=" height=\"$this->_height\" ";
  672.  
  673.                         $bstyle=" style=\"border: 1px dotted #000000\" ";
  674.                         echo "<table $attr $bstyle><tr><td>\n";
  675.                 }
  676.  
  677.                 echo "<map name=\"$this->_name\">\n";
  678.                 echo "</map>\n";
  679.  
  680.                 if (($this->ControlState & csDesigning)==csDesigning)
  681.                 {
  682.                         echo "</table>\n";
  683.                 }
  684.         }
  685. }
  686. */
  687.  
  688. /**
  689.  * Encapsulates a shape for images
  690.  *
  691.  */
  692. class MapShape extends Control
  693. {
  694.         function getjsOnMouseOut(return $this->readjsOnMouseOut()}
  695.         function setjsOnMouseOut($value$this->writejsOnMouseOut($value)}
  696.  
  697.         function getjsOnMouseOver(return $this->readjsOnMouseOver()}
  698.         function setjsOnMouseOver($value$this->writejsOnMouseOver($value)}
  699.  
  700.  
  701.         function __construct($aowner=null)
  702.         {
  703.                 //Calls inherited constructor
  704.                 parent::__construct($aowner);
  705.  
  706.                 $this->Width=20;
  707.                 $this->Height=20;
  708.  
  709.         }
  710.  
  711.         function dumpContents()
  712.         {
  713.  
  714.                 if (($this->ControlState csDesigning)==csDesigning)
  715.                 {
  716.                         $attr="";
  717.                         if ($this->_width!=""$attr.=" width=\"$this->_width\" ";
  718.                         if ($this->_height!=""$attr.=" height=\"$this->_height\" ";
  719.  
  720.                         $bstyle=" style=\"border: 1px dotted #000000\" ";
  721.                         echo "<table $attr $bstyle><tr><td>\n";
  722.                 }
  723.  
  724.                 $l=$this->_left;
  725.                 $t=$this->_top;
  726.                 $w=$this->_left+$this->_width;
  727.                 $h=$this->_top+$this->_height;
  728.  
  729.                 $events=$this->readJsEvents();
  730.  
  731.                 echo "<area id=\"$this->_name\" shape=\"rect\" coords=\"$l,$t,$w,$h\" href=\"#\" $events />\n";
  732.  
  733.                 if (($this->ControlState csDesigning)==csDesigning)
  734.                 {
  735.                         echo "</table>\n";
  736.                 }
  737.         }
  738. }
  739.  
  740. /**
  741.  * ImageFade, to encapsulate an Image with transitions
  742.  *
  743.  */
  744.  //Removed due licensing issues
  745. /*
  746. class ImageFade extends Image
  747. {
  748.         protected $_delay=3000;
  749.         protected $_fadedegree=10;
  750.  
  751.         function getDelay() { return $this->_delay; }
  752.         function setDelay($value) { $this->_delay=$value; }
  753.         function defaultDelay() { return 3000; }
  754.  
  755.         function getFadeDegree() { return $this->_fadedegree; }
  756.         function setFadeDegree($value) { $this->_fadedegree=$value; }
  757.         function defaultFadeDegree() { return 10; }
  758.  
  759.  
  760.         function dumpHeaderCode()
  761.         {
  762.                 echo "<script type=\"text/javascript\" src=\"".VCL_HTTP_PATH."/fadeimage/fadeimage.js\"></script>\n";
  763.         }
  764.  
  765.  
  766.         protected $_images=null;
  767.  
  768.         function getImages() { return $this->_images;   }
  769.         function setImages($value) { $this->_images=$this->fixupProperty($value); }
  770.         function defaultImages() { return "";   }
  771.  
  772.         function loaded()
  773.         {
  774.                 parent::loaded();
  775.                 $this->setImages($this->_images);
  776.         }
  777.  
  778.         function dumpContents()
  779.         {
  780.                 if (($this->ControlState & csDesigning)==csDesigning)
  781.                 {
  782.                         $attr="";
  783.                         if ($this->_width!="") $attr.=" width=\"$this->_width\" ";
  784.                         if ($this->_height!="") $attr.=" height=\"$this->_height\" ";
  785.  
  786.                         $bstyle=" style=\"border: 1px dotted #000000\" ";
  787.                         echo "<table $attr $bstyle><tr><td>&nbsp</td></tr></table>\n";
  788.                 }
  789.                 else if ($this->_images!=null)
  790.                 {
  791. ?>
  792. <script type="text/javascript">
  793.  
  794. var fadeimages=new Array()
  795.         <?php
  796.                 $images=$this->_images->Images;
  797.                 reset($images);
  798.                 $c=0;
  799.                 while (list($k,$v)=each($images))
  800.                 {
  801.                         echo "fadeimages[$c]=[\"$v\", \"\", \"\"]\n";
  802.                         $c++;
  803.                 }
  804.         ?>
  805.  
  806. var fadebgcolor="white"
  807.  
  808. new fadeshow(fadeimages, <?php echo $this->_width; ?>, <?php echo $this->_height; ?>, <?php echo $this->_border; ?>, <?php echo $this->_delay; ?>, 0, "R",<?php echo $this->_fadedegree; ?>)
  809.  
  810. </script>
  811. <?php
  812.                 }
  813.         }
  814. }
  815. */
  816.  
  817.  
  818.  
  819. /**
  820.  * CustomPanel class
  821.  *
  822.  * Base class for panels
  823.  *
  824.  */
  825. class CustomPanel extends CustomControl
  826. {
  827. //        protected $_layout=XY_LAYOUT;
  828.  
  829.         
  830.  
  831.         protected $_include="";
  832.         protected $_dynamic=false;
  833.  
  834.         protected $_background="";
  835.         protected $_borderwidth=0;
  836.         protected $_bordercolor="";
  837.         protected $_backgroundrepeat="";
  838.         protected $_backgroundposition="";
  839.  
  840.         function __construct($aowner=null)
  841.         {
  842.                 //Calls inherited constructor
  843.                 parent::__construct($aowner);
  844.                 $this->ControlStyle="csAcceptsControls=1";
  845.  
  846.                 $this->ControlStyle="csRenderOwner=1";
  847.                 $this->ControlStyle="csRenderAlso=StyleSheet";
  848.         }
  849.  
  850.         protected $_activelayer=0;
  851.  
  852.         /**
  853.         * Specifies the Layer this panel has active, only controls with their Layer property set to ActiveLayer, are shown
  854.         * @return string 
  855.         */
  856.         function getActiveLayer(return $this->_activelayer}
  857.         function setActiveLayer($value$this->_activelayer=$value}
  858.         function defaultActiveLayer(return 0}
  859.  
  860.         /**
  861.         * Specifies the Background property for this panel
  862.         * @return string 
  863.         */
  864.         function readBackground(return $this->_background}
  865.         function writeBackground($value$this->_background=$value}
  866.         function defaultBackground(return ""}
  867.  
  868.         /**
  869.         * Specifies the way the brackground is repeated
  870.         * @return string 
  871.         */
  872.         function readBackgroundRepeat(return $this->_backgroundrepeat}
  873.         function writeBackgroundRepeat($value$this->_backgroundrepeat=$value}
  874.         function defaultBackgroundRepeat(return ""}
  875.  
  876.         /**
  877.         * Specifies the position for the background
  878.         * @return string 
  879.         */
  880.         function readBackgroundPosition(return $this->_backgroundposition}
  881.         function writeBackgroundPosition($value$this->_backgroundposition=$value}
  882.         function defaultBackgroundPosition(return ""}
  883.  
  884.         /**
  885.         * Specifies the width for the border
  886.         * @return string 
  887.         */
  888.         function readBorderWidth(return $this->_borderwidth}
  889.         function writeBorderWidth($value$this->_borderwidth=$value}
  890.         function defaultBorderWidth(return 0}
  891.  
  892.         /**
  893.         * Fieldname the color for the border
  894.         * @return string 
  895.         */
  896.         function readBorderColor(return $this->_bordercolor}
  897.         function writeBorderColor($value$this->_bordercolor=$value}
  898.         function defaultBorderColor(return ""}
  899.  
  900.         /**
  901.         * Specifies anything you want to include inside the panel, can be anything valid to include
  902.         * on PHP, usually another .php file. Contents will be shown on design time
  903.         * @return string 
  904.         */
  905.         function readInclude(return $this->_include}
  906.         function writeInclude($value$this->_include=$value}
  907.         function defaultInclude(return ""}
  908.  
  909.         //IsLayer property
  910.         /*
  911.         function readIsLayer() { return $this->readIsLayer(); }
  912.         function writeIsLayer($value) { $this->writeIsLayer($value); }
  913.         function defaultIsLayer() { return 0; }
  914.         */
  915.  
  916.         /**
  917.         * Deprecated, not used
  918.         * @return boolean 
  919.         */
  920.         function readDynamic(return $this->_dynamic}
  921.         function writeDynamic($value$this->_dynamic=$value}
  922.         function defaultDynamic(return 0}
  923.  
  924.         function dumpContents()
  925.         {
  926.                 if (($this->ControlState csDesigning)!=csDesigning)
  927.                 {
  928.                     //if (!$this->Visible) return;
  929.                 }
  930.                 $alignment="";
  931.                 $background="";
  932.                 $width="";
  933.                 $height="";
  934.                 $color="";
  935.                 $style="";
  936.  
  937.                 switch ($this->_alignment)
  938.                 {
  939.                         case agNone$alignment=""break;
  940.                         case agLeft$alignment=" align=\"Left\" "break;
  941.                         case agCenter$alignment=" align=\"Center\" "break;
  942.                         case agRight$alignment=" align=\"Right\" "break;
  943.  
  944.                 }
  945.  
  946.                 if ($this->Style=="")
  947.                 {
  948.                         if ($this->Color!=""$color=" bgcolor=\"$this->Color\" ";
  949.                         if ($this->Background!=""$background=" background=\"$this->Background\" ";
  950.  
  951.                         $style.=" border: ".$this->_borderwidth."px solid $this->_bordercolor";
  952.  
  953.                         if ($this->BackgroundRepeat!=""$style.=" background-repeat$this->BackgroundRepeat";
  954.                         if ($this->BackgroundPosition!=""$style.=" background-position$this->BackgroundPosition";
  955.                 }
  956.  
  957.                 if ($style!=''$style=" style=\"$style\" ";
  958.  
  959.                 $class ($this->Style != """class=\"$this->StyleClass\""";
  960.  
  961.                 if ($this->Width!=""$width=" width=\"$this->Width\" ";
  962.                 if ($this->Height!=""$height=" height=\"$this->Height\" ";
  963.  
  964.                 $bstyle="";
  965.  
  966.                 if (($this->ControlState csDesigning)==csDesigning)
  967.                 {
  968.                         if (count($this->controls->items==0))
  969.                         {
  970.                                 if ($this->_include=='')
  971.                                 {
  972.                                         if (($this->_borderwidth!=""&& ($this->_borderwidth!="0px"&& ($this->_bordercolor!=""))
  973.                                         {
  974.                                         }
  975.                                         else
  976.                                         {
  977.                                                 $bstyle=" style=\"border: 1px dotted #000000\" ";
  978.                                         }
  979.                                 }
  980.                         }
  981.                 }
  982.  
  983.                 $hint $this->getHintAttribute();
  984.  
  985.                 if ($this->_islayer)
  986.                 {
  987.                         echo "<div id=\"$this->_name\" style=\"top".$this->_top."px; left: ".$this->_left."px; position: absolute; width: ".$this->_width."px; height: ".$this->_height."pxvisibilityhidden\" $hint >\n";
  988.                 }
  989.  
  990.                 if ($this->_adjusttolayout)
  991.                 {
  992.                     $width=" width=\"100%\" ";
  993.                     $height=" height=\"100%\" ";
  994.                 }
  995.                 if ($this->_include!="")
  996.                 {
  997.                     include($this->_include);
  998.                 }
  999.                 else
  1000.                 {
  1001.                     echo "<table id=\"{$this->_name}_table\" $width $height border=\"0\" $bstyle cellpadding=\"0\" cellspacing=\"0\" $alignment $color $background $style $class $hint>\n";
  1002.                 echo "<tr>\n";
  1003.                 if ((($this->ControlState csDesigning)==csDesigning|| ($this->controls->count()==0))
  1004.                 {
  1005.                         $spanstyle = ($this->Style=="""style=\"".$this->Font->FontString."\"" "class=\"$this->StyleClass\"";
  1006.                         echo "<td align=\"center\"><span $spanstyle>$this->Caption</span>\n";
  1007.                 }
  1008.                 else
  1009.                 {
  1010.                 echo "<td valign=\"top\">\n";
  1011.                 }
  1012.                 if (($this->ControlState csDesigning!= csDesigning)
  1013.                 {
  1014.                         $this->callEvent('onshow',array());
  1015.                         $this->Layout->dumpLayoutContents();
  1016.                 }
  1017.                 echo "</td>\n";
  1018.                 echo "</tr>\n";
  1019.                 echo "</table>\n";
  1020.                 }
  1021.  
  1022.         }
  1023.  
  1024.  
  1025. }
  1026.  
  1027.  
  1028. /**
  1029.  * Panel class
  1030.  *
  1031.  * A component to group another controls
  1032.  *
  1033.  */
  1034. class Panel extends CustomPanel
  1035. {
  1036.         function __construct($aowner=null)
  1037.         {
  1038.                 //Calls inherited constructor
  1039.                 parent::__construct($aowner);
  1040.         }
  1041.  
  1042.         function getFont() { return $this->readFont()}
  1043.         function setFont($value) { $this->writeFont($value)}
  1044.  
  1045.         function getParentFont() { return $this->readParentFont()}
  1046.         function setParentFont($value) { $this->writeParentFont($value)}
  1047.         
  1048.         function getParentColor() { return $this->readParentColor()}
  1049.         function setParentColor($value) { $this->writeParentColor($value)}
  1050.  
  1051.         function getParentShowHint() { return $this->readParentShowHint()}
  1052.         function setParentShowHint($value) { $this->writeParentShowHint($value)}
  1053.  
  1054.         function getShowHint() { return $this->readShowHint()}
  1055.         function setShowHint($value) { $this->writeShowHint($value)}
  1056.         
  1057.  
  1058.         function getAlignment() { return $this->readAlignment()}
  1059.         function setAlignment($value) { $this->writeAlignment($value)}
  1060.  
  1061.         function getCaption() { return $this->readCaption()}
  1062.         function setCaption($value) { $this->writeCaption($value)}
  1063.  
  1064.         function getColor() { return $this->readColor()}
  1065.         function setColor($value) { $this->writeColor($value)}
  1066.  
  1067.         function getVisible() { return $this->readVisible()}
  1068.         function setVisible($value) { $this->writeVisible($value)}
  1069.  
  1070.         function getBackground() { return $this->readBackground()}
  1071.         function setBackground($value) { $this->writeBackground($value)}
  1072.  
  1073.         function getBackgroundRepeat() { return $this->readBackgroundRepeat()}
  1074.         function setBackgroundRepeat($value) { $this->writeBackgroundRepeat($value)}
  1075.  
  1076.         function getBackgroundPosition() { return $this->readBackgroundPosition()}
  1077.         function setBackgroundPosition($value) { $this->writeBackgroundPosition($value)}
  1078.  
  1079.         function getBorderWidth() { return $this->readBorderWidth()}
  1080.         function setBorderWidth($value) { $this->writeBorderWidth($value)}
  1081.  
  1082.         function getBorderColor() { return $this->readBorderColor()}
  1083.         function setBorderColor($value) { $this->writeBorderColor($value)}
  1084.  
  1085.         function getLayout() { return $this->readLayout()}
  1086.         function setLayout($value) { $this->writeLayout($value)}
  1087.  
  1088.         function getInclude() { return $this->readInclude()}
  1089.         function setInclude($value) { $this->writeInclude($value)}
  1090.  
  1091.         function getIsLayer() { return $this->readIsLayer()}
  1092.         function setIsLayer($value) { $this->writeIsLayer($value)}
  1093.  
  1094.         function getDynamic() { return $this->readDynamic()}
  1095.         function setDynamic($value) { $this->writeDynamic($value)}
  1096.  
  1097.         function getStyle()             { return $this->readstyle()}
  1098.         function setStyle($value)       { $this->writestyle($value)}
  1099.  
  1100. }
  1101.  
  1102. /**
  1103.  * Control to group another controls inside a frame
  1104.  *
  1105.  */
  1106. class GroupBox extends QWidget
  1107. {
  1108.         function dumpContents()
  1109.         {
  1110.                 $this->dumpCommonContentsTop();
  1111.                 echo "        var ".$this->Name."    = new qx.ui.groupbox.GroupBox(\"$this->Caption\");\n";
  1112.                 echo "        $this->Name.setLeft(0);\n";
  1113.                 echo "        $this->Name.setTop(0);\n";
  1114.                 echo "        $this->Name.setWidth($this->Width);\n";
  1115.                 echo "        $this->Name.setHeight($this->Height);\n";
  1116.                 if ($this->Color != "")
  1117.                 {
  1118.                         echo "        $this->Name.setBackgroundColor(new qx.renderer.color.Color(\"$this->Color\"));\n";
  1119.                         // set background color the the groupbox caption  
  1120.                         echo "        var obj = $this->Name.getLegendObject();\n";
  1121.                         echo "        if (objobj.setBackgroundColor(new qx.renderer.color.Color(\"$this->Color\"));\n";
  1122.                 }
  1123.                 $this->dumpChildrenControls();
  1124.                 $this->dumpCommonContentsBottom();
  1125.  
  1126.         }
  1127.  
  1128.         //Publish some properties
  1129.         function getFont() { return $this->readFont()}
  1130.         function setFont($value) { $this->writeFont($value)}
  1131.  
  1132.         function getParentFont() { return $this->readParentFont()}
  1133.         function setParentFont($value) { $this->writeParentFont($value)}
  1134.  
  1135.         function getParentColor() { return $this->readParentColor()}
  1136.         function setParentColor($value) { $this->writeParentColor($value)}
  1137.  
  1138.         function getParentShowHint() { return $this->readParentShowHint()}
  1139.         function setParentShowHint($value) { $this->writeParentShowHint($value)}
  1140.  
  1141.         function getShowHint() { return $this->readShowHint()}
  1142.         function setShowHint($value) { $this->writeShowHint($value)}
  1143.  
  1144.         function getAlignment() { return $this->readAlignment()}
  1145.         function setAlignment($value) { $this->writeAlignment($value)}
  1146.  
  1147.         function getCaption() { return $this->readCaption()}
  1148.         function setCaption($value) { $this->writeCaption($value)}
  1149.  
  1150.         function getColor() { return $this->readColor()}
  1151.         function setColor($value) { $this->writeColor($value)}
  1152.  
  1153.         function getVisible() { return $this->readVisible()}
  1154.         function setVisible($value) { $this->writeVisible($value)}
  1155.  
  1156.         function __construct($aowner=null)
  1157.         {
  1158.                 //Calls inherited constructor
  1159.                 parent::__construct($aowner);
  1160.  
  1161.                 $this->Width=200;
  1162.                 $this->Height=200;
  1163.  
  1164.                 //This control can hold another controls
  1165.                 $this->ControlStyle="csAcceptsControls=1";
  1166.         }
  1167.  
  1168. }
  1169.  
  1170. define("btTop","btTop");
  1171. define("btRight","btRight");
  1172. define("btBottom","btBottom");
  1173. define("btLeft","btLeft");
  1174.  
  1175. /**
  1176.  * The typical apple-like tabview-replacements which could also be found
  1177.  * in more modern versions of the settings dialog in Mozilla Firefox.
  1178.  *
  1179.  */
  1180. class CustomButtonView extends QWidget
  1181. {
  1182.         protected $_position=btLeft;
  1183.         protected $_items=array();
  1184.         protected $_images = null;
  1185.  
  1186.         function loaded()
  1187.         {
  1188.                 parent::loaded();
  1189.                 $this->writeImageList($this->_images);
  1190.         }
  1191.  
  1192.         private function dumpButtons($name, $items)
  1193.         {
  1194.                 $event=$this->jsOnClick;
  1195.                 if ($event!=''$event="$event";
  1196.                 else $event=", function dummy(){}";
  1197.  
  1198.                 if (($this->ControlState csDesigning== csDesigning$event=", function dummy(){}";
  1199.  
  1200.                 reset($items);
  1201.                 if (isset($items))
  1202.                 {
  1203.                         echo "\n";
  1204.                         echo "  <!-- Define Buttons - Start -->\n";
  1205.                 }
  1206.                 while(list($index, $item) = each($items))
  1207.                 {
  1208.                         $caption=$item['Caption'];
  1209.  
  1210.                         $imageindex=$item['ImageIndex'];
  1211.                         if (($this->_images != null&& (is_object($this->_images)))
  1212.                         {
  1213.                                 $image = $this->_images->readImageByID($imageindex1);
  1214.                         }
  1215.                         else
  1216.                         {
  1217.                                 $image = "null";
  1218.                         }
  1219.  
  1220.                         $tag = $item['Tag'];
  1221.                         if ($tag == '') $tag=0;
  1222.  
  1223.                         $itemname = $name . "_" . $index;
  1224.  
  1225.                         if ($image === "null")
  1226.                         {
  1227.                                 echo "    var $itemname = new qx.ui.pageview.buttonview.Button(\"$caption\");\n";
  1228.                         }
  1229.                         else
  1230.                         {
  1231.                                 echo "    var $itemname = new qx.ui.pageview.buttonview.Button(\"$caption\", $image);\n";
  1232.                         }
  1233.                         __QLibrary_SetCursor($itemname, $this->Cursor);
  1234. //                        echo "    $itemname.addEventListener(\"execute\", " . $this->Name . "_clickwrapper);\n";
  1235.                         echo "    $itemname.tag=$tag;\n";
  1236.                         echo "    $itemname.addEventListener(\"click\"$event);\n";
  1237.  
  1238.                         $elements[] = $itemname;
  1239.                 }
  1240.  
  1241.                 if (isset($elements))
  1242.                 {
  1243.                         echo "  <!-- Define Buttons - Start -->\n";
  1244.                         echo "\n";
  1245.                         echo "  $name.getBar().add(" . implode(",", $elements) . ");\n";
  1246.                         unset($elements);
  1247.  
  1248.                         echo "  $name" . "_0.setChecked(true);\n";
  1249.                 }
  1250.         }
  1251.  
  1252.         function dumpHeaderCode()
  1253.         {
  1254.                 parent::dumpHeaderCode();
  1255.                 //This function is used as a common click processor for all item clicks
  1256. //                echo '<script type="text/javascript">';
  1257. //                echo "function $this->Name"."_clickwrapper(e)\n";
  1258. //                echo "{\n";
  1259. //                echo "  submit=true; \n";
  1260. //                if (($this->ControlState & csDesigning) != csDesigning)
  1261. //                {
  1262. //                        if ($this->JsOnClick!=null)
  1263. //                        {
  1264. //                                echo "  submit=".$this->JsOnClick."(e);\n";
  1265. //                        }
  1266. //                }
  1267. //                echo "  var tag=e.getTarget().tag;\n";
  1268. //                echo "  if ((tag!=0) && (submit))\n";
  1269. //                echo "  {\n";
  1270. //                echo "    var hid=findObj('$this->Name"."_state');\n";
  1271. //                echo "    if (hid) hid.value=tag;\n";
  1272. //                if (($this->ControlState & csDesigning) != csDesigning)
  1273. //                {
  1274. //                        $form = "document.".$this->owner->Name;
  1275. //                        echo "    if (($form.onsubmit) && (typeof($form.onsubmit) == 'function')) { $form.onsubmit(); }\n";
  1276. //                        echo "    $form.submit();\n";
  1277. //                }
  1278.   //              echo "    }\n";
  1279. //                echo "}\n";
  1280. //                echo '</script>';
  1281.         }
  1282.  
  1283.         function dumpContents()
  1284.         {
  1285.                 $this->dumpCommonContentsTop();
  1286.  
  1287.                 $position "top";
  1288.                 switch ($this->_position)
  1289.                 {
  1290.                         case btRight:  $position = "right"; break;
  1291.                         case btBottom$position = "bottom"; break;
  1292.                         case btLeft:   $position = "left"; break;
  1293.                 }
  1294.  
  1295.                 echo "  var i = new qx.ui.basic.Inline(\"$this->Name\");\n";
  1296.                 echo "  i.setHeight(\"auto\");\n";
  1297.                 echo "  i.setWidth(\"auto\");\n";
  1298.                 echo "  var $this->Name = new qx.ui.pageview.buttonview.ButtonView;\n";
  1299.  
  1300.                 echo "  $this->Name.setLeft(0);\n";
  1301.                 echo "  $this->Name.setTop(0);\n";
  1302.                 echo "  $this->Name.setWidth($this->Width);\n";
  1303.                 echo "  $this->Name.setHeight($this->Height);\n";
  1304.  
  1305.                 echo "  $this->Name.setBarPosition(\"$position\");\n";
  1306.  
  1307.               $this->dumpButtons($this->Name$this->_items);
  1308.  
  1309.                 $this->dumpCommonContentsBottom();
  1310.           }
  1311.  
  1312.         function __construct($aowner=null)
  1313.         {
  1314.                 //Calls inherited constructor
  1315.                 parent::__construct($aowner);
  1316.  
  1317.                 $this->Width=63;
  1318.                 $this->Height=335;
  1319.  
  1320.                 $this->ControlStyle="csSlowRedraw=1";
  1321.         }
  1322.  
  1323.         /**
  1324.          * Lists the images that can appear beside individual menu items.
  1325.          *
  1326.          * @return ImageList
  1327.          */
  1328.         protected function readImageList()      { return $this->_images}
  1329.         protected function writeImageList($value) { $this->_images=$this->fixupProperty($value)}
  1330.         function defaultImageList()             { return ""; }
  1331.         /**
  1332.          * Describes the buttons.
  1333.          * Use Items to access information about the elements in the menu.
  1334.          * Item contain information about Caption, associated image and Tag.
  1335.          *
  1336.          * @return item collection
  1337.          */
  1338.         protected function readItems()          { return $this->_items}
  1339.         protected function writeItems($value)   { $this->_items=$value}
  1340.         /**
  1341.          * Defines a position/orientation of the ButtonView
  1342.          *
  1343.          * @return enum (btTop, btBottom, btLeft, btRight)
  1344.          */
  1345.         function readPosition()                 { return $this->_position}
  1346.         function writePosition($value)
  1347.         {
  1348.             if ($this->_position!=$value)
  1349.             {
  1350.                 /*
  1351.                 $w=$this->Width;
  1352.                 $h=$this->Height;
  1353.                 switch ($value)
  1354.                 {
  1355.                         case btTop:
  1356.                         case btBottom:
  1357.                                 if (($this->_position = btLeft) || ($this->_position = btRight))
  1358.                                 {
  1359.                                     $this->Height=$w; $this->Width=$h;
  1360.                                 }
  1361.                                 break;
  1362.                         case btLeft:
  1363.                         case btRight:
  1364.                                 if (($this->_position = btTop) || ($this->_position = btBottom))
  1365.                                 {
  1366.                                     $this->Height=$w; $this->Width=$h;
  1367.                                 }
  1368.                                 break;
  1369.                 }
  1370.                 */
  1371.                 $this->_position=$value;
  1372.             }
  1373.         }
  1374.         function defaultPosition()              { return btLeft; }
  1375. }
  1376.  
  1377. class ButtonView extends CustomButtonView
  1378. {
  1379.         //Publish common properties
  1380.         function getFont()              { return $this->readFont()}
  1381.         function setFont($value)        { $this->writeFont($value)}
  1382.  
  1383.         function getParentFont()        { return $this->readParentFont()}
  1384.         function setParentFont($value)  { $this->writeParentFont($value)}
  1385.  
  1386.         function getAlignment()         { return $this->readAlignment()}
  1387.         function setAlignment($value)   { $this->writeAlignment($value)}
  1388.  
  1389.         function getCaption()           { return $this->readCaption()}
  1390.         function setCaption($value)     { $this->writeCaption($value)}
  1391.  
  1392.         function getColor()             { return $this->readColor()}
  1393.         function setColor($value)       { $this->writeColor($value)}
  1394.  
  1395.         function getVisible()           { return $this->readVisible()}
  1396.         function setVisible($value)     { $this->writeVisible($value)}
  1397.  
  1398.         // Common events
  1399.         function getjsOnClick()                 { return $this->readjsOnClick()}
  1400.         function setjsOnClick($value)           { $this->writejsOnClick($value)}
  1401.  
  1402.         //Publish properties
  1403.         function getImageList()         { return $this->readImageList()}
  1404.         function setImageList($value)   { $this->writeImageList($value)}
  1405.  
  1406.         function getItems()             { return $this->readItems()}
  1407.         function setItems($value)       { $this->writeItems($value)}
  1408.  
  1409.         function getPosition()          { return $this->readPosition()}
  1410.         function setPosition($value)    { $this->writePosition($value)}
  1411. }
  1412.  
  1413. define('orHorizontal', 'orHorizontal');
  1414. define('orVertical', 'orVertical');
  1415.  
  1416. /**
  1417. * CustomRadioGroup is the base class for radio-group components.
  1418. * When the user checks a radio button, all other radio buttons in its group become unchecked.
  1419. *
  1420. */
  1421. class CustomRadioGroup extends FocusControl
  1422. {
  1423.         protected $_onclick = null;
  1424.         protected $_onsubmit = null;
  1425.  
  1426.         protected $_datasource = null;
  1427.         protected $_datafield = "";
  1428.         protected $_itemindex = -1;
  1429.         protected $_items = array();
  1430.         protected $_orientation = orVertical;
  1431.         protected $_taborder=0;
  1432.         protected $_tabstop=1;
  1433.  
  1434.         function __construct($aowner = null)
  1435.         {
  1436.                 //Calls inherited constructor
  1437.                 parent::__construct($aowner);
  1438.  
  1439.                 $this->Clear();
  1440.  
  1441.                 $this->Width 185;
  1442.                 $this->Height 89;
  1443.  
  1444.                 $this->ControlStyle="csRenderOwner=1";
  1445.                 $this->ControlStyle="csRenderAlso=StyleSheet";
  1446.         }
  1447.  
  1448.         function loaded()
  1449.         {
  1450.                 parent::loaded();
  1451.                 $this->writeDataSource($this->_datasource);
  1452.         }
  1453.  
  1454.         function preinit()
  1455.         {
  1456.                 $submitted = $this->input->{$this->Name};
  1457.  
  1458.                 if (is_object($submitted))
  1459.                 {
  1460.                         $changed = ($this->_itemindex != $submitted->asString());
  1461.                         // the ItemIndex might be an integer or a string,
  1462.                         // so let's get a string
  1463.                         $this->_itemindex $submitted->asString();
  1464.  
  1465.                         // only update the data field if the item index was changed
  1466.                         if ($changed)
  1467.                         {
  1468.                                 // following somehow does not work here:
  1469.                                 //   if (array_key_exists($this->_itemindex, $this->_items)) { $this->updateDataField($this->_items[$this->_itemindex]); }
  1470.                                 // so let's do it like this...
  1471.                                 foreach ($this->_items as $key => $item)
  1472.                                 {
  1473.                                         if ($key == $this->_itemindex)
  1474.                                         {
  1475.                                                 //If there is any valid DataField attached, update it
  1476.                                                 $this->updateDataField($item);
  1477.                                         }
  1478.                                 }
  1479.                         }
  1480.                 }
  1481.         }
  1482.  
  1483.         function init()
  1484.         {
  1485.                 parent::init();
  1486.  
  1487.                 $submitted = $this->input->{$this->Name};
  1488.  
  1489.                 if (is_object($submitted))
  1490.                 {
  1491.                         // Allow the OnSubmit event to be fired because it is not
  1492.                         // a mouse or keyboard event.
  1493.                         if ($this->_onsubmit != null)
  1494.                         {
  1495.                                 $this->callEvent('onsubmit'array());
  1496.                         }
  1497.                 }
  1498.  
  1499.                 $submitEvent = $this->input->{$this->getJSWrapperHiddenFieldName()};
  1500.  
  1501.                 if (is_object($submitEvent) && $this->_enabled == 1)
  1502.                 {
  1503.                         // check if the a click event has been fired
  1504.                         if ($this->_onclick != null && $submitEvent->asString(== $this->getJSWrapperSubmitEventValue($this->_onclick))
  1505.                         {
  1506.                                 $this->callEvent('onclick'array());
  1507.                         }
  1508.                 }
  1509.         }
  1510.  
  1511.  
  1512.         function dumpContents()
  1513.         {
  1514.                 $events = "";
  1515.                 if ($this->_enabled == 1)
  1516.                 {
  1517.                         // get the string for the JS Events
  1518.                         $events = $this->readJsEvents();
  1519.  
  1520.                         // add or replace the JS events with the wrappers if necessary
  1521.                         $this->addJSWrapperToEvents($events$this->_onclick,    $this->_jsonclick,    "onclick");
  1522.                 }
  1523.  
  1524.                 $style="";
  1525.                 if ($this->Style=="")
  1526.                 {
  1527.                         // get the Font attributes
  1528.                         $style .= $this->Font->FontString;
  1529.  
  1530.                         if ($this->Color != "")
  1531.                         {
  1532.                                 $style  .= "background-color: " . $this->Color ";";
  1533.                         }
  1534.  
  1535.                         // add the cursor to the style
  1536.                         if ($this->_cursor != "")
  1537.                         {
  1538.                                 $cr = strtolower(substr($this->_cursor2));
  1539.                                 $style .= "cursor$cr;";
  1540.                         }
  1541.                 }
  1542.  
  1543.                 $spanstyle = $style;
  1544.  
  1545.                 $h = $this->Height 2;
  1546.                 $w $this->Width;
  1547.  
  1548.                 $style .= "height:" $h "px;width:" $w "px;";
  1549.  
  1550.                 // set enabled/disabled status
  1551.                 $enabled (!$this->_enabled"disabled=\"disabled\"" "";
  1552.  
  1553.                 // set tab order if tab stop set to true
  1554.                 $taborder ($this->_tabstop == 1"tabindex=\"$this->_taborder\"" : "";
  1555.  
  1556.                 // get the hint attribute; returns: title="[HintText]"
  1557.                 $hint = $this->getHintAttribute();
  1558.  
  1559.                 if ($style  != "")  $style  "style=\"$style\"";
  1560.                 if ($style  != "")  $spanstyle  = "style=\"$spanstyle\"";
  1561.  
  1562.                 // get the alignment of the Items
  1563.                 $alignment = "";
  1564.                 switch ($this->_alignment)
  1565.                 {
  1566.                         case agNone :
  1567.                                 $alignment = "";
  1568.                                 break;
  1569.                         case agLeft :
  1570.                                 $alignment = "align=\"Left\"";
  1571.                                 break;
  1572.                         case agCenter :
  1573.                                 $alignment = "align=\"Center\"";
  1574.                                 break;
  1575.                         case agRight :
  1576.                                 $alignment = "align=\"Right\"";
  1577.                                 break;
  1578.                 }
  1579.  
  1580.                 if (($this->ControlState csDesigning!= csDesigning)
  1581.                 {
  1582.                         if ($this->hasValidDataField())
  1583.                         {
  1584.                                 //check if the value of the current data-field is in the itmes array as value
  1585.                                 $val = $this->readDataFieldValue();
  1586. /*
  1587.                                 $ds = $this->_datasource->DataSet;
  1588.                                 $df = $this->_datafield;
  1589.  
  1590.                                 //TODO: Save the position of the current record so we can reset it after the loop
  1591.                                 //$ds->memorizeCurrentRecord();
  1592.  
  1593.                                 $ds->first();
  1594.                                 // iterate through all records and add them
  1595.                                 while (!$ds->EOF)
  1596. */
  1597.                                 // get the corresponding key to the value read from the data source
  1598.                                 if (($key array_search($val$this->_items)) !== FALSE)
  1599.                                 {
  1600.                                         // if an item was found the overwrite the itemindex
  1601.                                         $this->_itemindex $key;
  1602.                                 }
  1603.  
  1604.                                 //Dumps hidden fields to know which is the record to update
  1605.                                 $this->dumpHiddenKeyFields();
  1606.                         }
  1607.                 }
  1608.  
  1609.                 $class = ($this->Style != """class=\"$this->StyleClass\"" : "";
  1610.  
  1611.                 // call the OnShow event if assigned so the Items property can be changed
  1612.                 if ($this->_onshow != null)
  1613.                 {
  1614.                         $this->callEvent('onshow'array());
  1615.                 }
  1616.  
  1617.  
  1618.                 echo "<table id=\"{$this->_name}_table\" cellpadding=\"0\" cellspacing=\"0\" $style $class>";
  1619.                 if (is_array($this->_items))
  1620.                 {
  1621.                         // if horizontal then only add one row
  1622.                         echo ($this->_orientation == orHorizontal"<tr>" "";
  1623.                         // $index is used to call the JS RadioGroupClick function
  1624.                         $index 0;
  1625.                         foreach ($this->_items as $key => $item)
  1626.                         {
  1627.                                 // add the checked attribut if the itemindex is the current item
  1628.                                 $checked = ($this->_itemindex == $key"checked=\"checked\"" "";
  1629.                                 // only allow an OnClick if enabled
  1630.                                 $itemclick ($this->_enabled == && $this->Owner != null"onclick=\"return RadioGroupClick(document.forms[0].$this->_name$index);\"" : "";
  1631.  
  1632.                                 // add a new row for every item
  1633.                                 echo ($this->_orientation == orVertical"<tr>\n" "";
  1634.  
  1635.                                 echo "<td width=\"20\">\n";
  1636.                                 echo "<input type=\"radio\" id=\"{$this->_name}_{$key}\" name=\"$this->_name\" value=\"$key\" $events $checked $enabled $taborder $hint $class />\n";
  1637.                                 echo "</td><td $alignment>\n";
  1638.                                 echo "<span id=\"{$this->_name}_{$key}_caption\" $itemclick $hint $spanstyle $class>$item</span>\n";
  1639.                                 echo "</td>\n";
  1640.  
  1641.                                 echo ($this->_orientation == orVertical"</tr>\n" "";
  1642.                                 $index++;
  1643.                         }
  1644.                         echo ($this->_orientation == orHorizontal"</tr>" "";
  1645.                 }
  1646.                 echo "</table>";
  1647.  
  1648.                 // add a hidden field so we can determine which radiogroup fired the event
  1649.                 if ($this->_onclick != null)
  1650.                 {
  1651.                         $hiddenwrapperfield = $this->getJSWrapperHiddenFieldName();
  1652.                         echo "<input type=\"hidden\" id=\"$hiddenwrapperfield\" name=\"$hiddenwrapperfield\" value=\"\" />";
  1653.                 }
  1654.         }
  1655.  
  1656.         /*
  1657.         * Write the Javascript section to the header
  1658.         */
  1659.         function dumpJavascript()
  1660.         {
  1661.                 parent::dumpJavascript();
  1662.  
  1663.                 if ($this->_enabled == 1)
  1664.                 {
  1665.                         if ($this->_onclick != null && !defined($this->_onclick))
  1666.                         {
  1667.                                 // only output the same function once;
  1668.                                 // otherwise if for example two radio groups use the same
  1669.                                 // OnClick event handler it would be outputted twice.
  1670.                                 $def=$this->_onclick;
  1671.                                 define($def,1);
  1672.  
  1673.                                 // output the wrapper function
  1674.                                 echo $this->getJSWrapperFunction($this->_onclick);
  1675.                         }
  1676.  
  1677.                         // only output the function once
  1678.                         if (!defined('RadioGroupClick'))
  1679.                         {
  1680.                                 define('RadioGroupClick', 1);
  1681.  
  1682.                                 echo "
  1683. function RadioGroupClick(elem, index)
  1684. {
  1685.    if (!elem.disabled) {
  1686.      if (typeof(elem.length) == 'undefined') {
  1687.        elem.checked = true;
  1688.        return (typeof(elem.onclick) == 'function') ? elem.onclick() : false;
  1689.      } else {
  1690.        if (index >= 0 && index < elem.length) {
  1691.          elem[index].checked = true;
  1692.          return (typeof(elem[index].onclick) == 'function') ? elem[index].onclick() : false;
  1693.        }
  1694.      }
  1695.    }
  1696.    return false;
  1697. }
  1698. ";
  1699.                         }
  1700.                 }
  1701.         }
  1702.  
  1703.  
  1704.         /**
  1705.         * Return the number of itmes in the radio group.
  1706.         * @return integer
  1707.         */
  1708.         function readCount()
  1709.         {
  1710.                 return count($this->_items);
  1711.         }
  1712.  
  1713.         /**
  1714.         * Adds an item to the radio group control.
  1715.         * @param mixed $item Value of item to add.
  1716.         * @param mixed $object Object to assign to the $item. is_object() is used to
  1717.         *                      test if $object is an object.
  1718.         * @param mixed $itemkey Key of the item in the array. Default key is used if null.
  1719.         * @return integer Return the number of items in the list.
  1720.         */
  1721.         function AddItem($item, $object = null, $itemkey = null)
  1722.         {
  1723.                 if ($object != null)
  1724.                 {
  1725.                         throw new Exception('Object functionallity for RadioGroup is not yet implemented.');
  1726.                 }
  1727.  
  1728.                 //Set the array to the end
  1729.                 end($this->_items);
  1730.  
  1731.                 //Adds the item as the last one
  1732.                 if ($itemkey != null)
  1733.                 {
  1734.                         $this->_items[$itemkey$item;
  1735.                 }
  1736.                 else
  1737.                 {
  1738.                         $this->_items[$item;
  1739.                 }
  1740.  
  1741.                 return($this->Count);
  1742.         }
  1743.  
  1744.         /**
  1745.         * Deletes all of the items from the list control.
  1746.         */
  1747.         function Clear()
  1748.         {
  1749.                 $this->_items array();
  1750.         }
  1751.  
  1752.  
  1753.  
  1754.         /**
  1755.         * Occurs when the user clicks the control.
  1756.         * @return mixed Returns the event handler or null if no handler is set.
  1757.         */
  1758.         function readOnClick() { return $this->_onclick}
  1759.         /**
  1760.         * Occurs when the user clicks the control.
  1761.         * @param mixed Event handler or null if no handler is set.
  1762.         */
  1763.         function writeOnClick($value) { $this->_onclick $value}
  1764.         function defaultOnClick() { return null; }
  1765.  
  1766.         /**
  1767.         * Occurs when the control was submitted.
  1768.         * @return mixed Returns the event handler or null if no handler is set.
  1769.         */
  1770.         function readOnSubmit() { return $this->_onsubmit}
  1771.         /**
  1772.         * Occurs when the control was submitted.
  1773.         * @param mixed Event handler or null if no handler is set.
  1774.         */
  1775.         function writeOnSubmit($value) { $this->_onsubmit=$value}
  1776.         function defaultOnSubmit() { return null; }
  1777.  
  1778.         /**
  1779.         * Fieldname this control is attached to
  1780.         * @return string
  1781.         */
  1782.         function readDataField() { return $this->_datafield}
  1783.         function writeDataField($value) { $this->_datafield $value}
  1784.         function defaultDataField() { return ""; }
  1785.  
  1786.         /**
  1787.         * Datasource this control is attached to
  1788.         * @return DataSource
  1789.         */
  1790.         function readDataSource() { return $this->_datasource}
  1791.         function writeDataSource($value)
  1792.         {
  1793.                 $this->_datasource $this->fixupProperty($value);
  1794.         }
  1795.         function defaultDataSource() { return null; }
  1796.  
  1797.         /**
  1798.         * Returns the value of the ItemIndex property.
  1799.         * @return mixed Return the ItemIndex of the list.
  1800.         */
  1801.         function readItemIndex() { return $this->_itemindex}
  1802.         /**
  1803.         * Set new ItemIndex value.
  1804.         * @param mixed $value Value of the new ItemIndex.
  1805.         */
  1806.         function writeItemIndex($value) { $this->_itemindex $value}
  1807.         function defaultItemIndex() { return -1; }
  1808.  
  1809.         /**
  1810.         * Contains the strings that appear in the radio group.
  1811.         * @return array
  1812.         */
  1813.         function readItems() { return $this->_items}
  1814.         /**
  1815.         * Contains the strings that appear in the radio group.
  1816.         * @param array $value
  1817.         */
  1818.         function writeItems($value)
  1819.         {
  1820.                 if (is_array($value))
  1821.                 {
  1822.                         $this->_items $value;
  1823.                 }
  1824.                 else
  1825.                 {
  1826.                         $this->_items (empty($value)) array(array($value);
  1827.                 }
  1828.         }
  1829.         function defaultItems() { return array(); }
  1830.  
  1831.         /**
  1832.         * Orientation of the radio button within the group.
  1833.         * @return enum (orHorizontal, orVertical)
  1834.         */
  1835.         function readOrientation() { return $this->_orientation}
  1836.         /**
  1837.         * Orientation of the radio button within the group.
  1838.         * @param enum (orHorizontal, orVertical)
  1839.         */
  1840.         function writeOrientation($value) { $this->_orientation=$value}
  1841.         function defaultOrientation() { return orVertical; }
  1842.  
  1843.         /**
  1844.         * TabOrder indicates in which order controls are access when using
  1845.         * the Tab key.
  1846.         * The value of the TabOrder can be between 0 and 32767.
  1847.         * @return integer
  1848.         */
  1849.         function readTabOrder() { return $this->_taborder}
  1850.         /**
  1851.         * TabOrder indicates in which order controls are access when using
  1852.         * the Tab key.
  1853.         * The value of the TabOrder can be between 0 and 32767.
  1854.         * @param integer $value
  1855.         */
  1856.         function writeTabOrder($value) { $this->_taborder=$value}
  1857.         function defaultTabOrder() { return 0; }
  1858.  
  1859.         /**
  1860.         * Enable or disable the TabOrder property. The browser may still assign
  1861.         * a TabOrder by itself internally. This cannot be controlled by HTML.
  1862.         * @return bool
  1863.         */
  1864.         function readTabStop() { return $this->_tabstop}
  1865.         /**
  1866.         * Enable or disable the TabOrder property. The browser may still assign
  1867.         * a TabOrder by itself internally. This cannot be controlled by HTML.
  1868.         * @param bool $value
  1869.         */
  1870.         function writeTabStop($value) { $this->_tabstop=$value}
  1871.         function defaultTabStop() { return 1; }
  1872. }
  1873.  
  1874. /**
  1875. * RadioGroup represents a group of radio buttons that function together.
  1876. *
  1877. */
  1878. class RadioGroup extends CustomRadioGroup
  1879. {
  1880.         /*
  1881.         * Publish the events for the CheckBox component
  1882.         */
  1883.         function getOnClick                   () { return $this->readOnClick()}
  1884.         function setOnClick($value)           { $this->writeOnClick($value)}
  1885.  
  1886.         function getOnSubmit                  () { return $this->readOnSubmit()}
  1887.         function setOnSubmit                  ($value) { $this->writeOnSubmit($value)}
  1888.  
  1889.         /*
  1890.         * Publish the JS events for the CheckBox component
  1891.         */
  1892.         function getjsOnBlur                    () { return $this->readjsOnBlur()}
  1893.         function setjsOnBlur                    ($value) { $this->writejsOnBlur($value)}
  1894.  
  1895.         function getjsOnChange                  () { return $this->readjsOnChange()}
  1896.         function setjsOnChange                  ($value) { $this->writejsOnChange($value)}
  1897.  
  1898.         function getjsOnClick                   () { return $this->readjsOnClick()}
  1899.         function setjsOnClick                   ($value) { $this->writejsOnClick($value)}
  1900.  
  1901.         function getjsOnDblClick                () { return $this->readjsOnDblClick()}
  1902.         function setjsOnDblClick                ($value) { $this->writejsOnDblClick($value)}
  1903.  
  1904.         function getjsOnFocus                   () { return $this->readjsOnFocus()}
  1905.         function setjsOnFocus                   ($value) { $this->writejsOnFocus($value)}
  1906.  
  1907.         function getjsOnMouseDown               () { return $this->readjsOnMouseDown()}
  1908.         function setjsOnMouseDown               ($value) { $this->writejsOnMouseDown($value)}
  1909.  
  1910.         function getjsOnMouseUp                 () { return $this->readjsOnMouseUp()}
  1911.         function setjsOnMouseUp                 ($value) { $this->writejsOnMouseUp($value)}
  1912.  
  1913.         function getjsOnMouseOver               () { return $this->readjsOnMouseOver()}
  1914.         function setjsOnMouseOver               ($value) { $this->writejsOnMouseOver($value)}
  1915.  
  1916.         function getjsOnMouseMove               () { return $this->readjsOnMouseMove()}
  1917.         function setjsOnMouseMove               ($value) { $this->writejsOnMouseMove($value)}
  1918.  
  1919.         function getjsOnMouseOut                () { return $this->readjsOnMouseOut()}
  1920.         function setjsOnMouseOut                ($value) { $this->writejsOnMouseOut($value)}
  1921.  
  1922.         function getjsOnKeyPress                () { return $this->readjsOnKeyPress()}
  1923.         function setjsOnKeyPress                ($value) { $this->writejsOnKeyPress($value)}
  1924.  
  1925.         function getjsOnKeyDown                 () { return $this->readjsOnKeyDown()}
  1926.         function setjsOnKeyDown                 ($value) { $this->writejsOnKeyDown($value)}
  1927.  
  1928.         function getjsOnKeyUp                   () { return $this->readjsOnKeyUp()}
  1929.         function setjsOnKeyUp                   ($value) { $this->writejsOnKeyUp($value)}
  1930.  
  1931.  
  1932.         /*
  1933.         * Publish the properties for the CheckBox component
  1934.         */
  1935.  
  1936.         function getAlignment()
  1937.         {
  1938.                 return $this->readAlignment();
  1939.         }
  1940.         function setAlignment($value)
  1941.         {
  1942.                 $this->writeAlignment($value);
  1943.         }
  1944.  
  1945.         function getColor()
  1946.         {
  1947.                 return $this->readColor();
  1948.         }
  1949.         function setColor($value)
  1950.         {
  1951.                 $this->writeColor($value);
  1952.         }
  1953.  
  1954.         function getDataField()
  1955.         {
  1956.                 return $this->readDataField();
  1957.         }
  1958.         function setDataField($value)
  1959.         {
  1960.                 $this->writeDataField($value);
  1961.         }
  1962.  
  1963.         function getDataSource()
  1964.         {
  1965.                 return $this->readDataSource();
  1966.         }
  1967.         function setDataSource($value)
  1968.         {
  1969.                 $this->writeDataSource($value);
  1970.         }
  1971.  
  1972.         function getEnabled()
  1973.         {
  1974.                 return $this->readEnabled();
  1975.         }
  1976.         function setEnabled($value)
  1977.         {
  1978.                 $this->writeEnabled($value);
  1979.         }
  1980.  
  1981.         function getFont()
  1982.         {
  1983.                 return $this->readFont();
  1984.         }
  1985.         function setFont($value)
  1986.         {
  1987.                 $this->writeFont($value);
  1988.         }
  1989.  
  1990.  
  1991.         function getItemIndex()
  1992.         {
  1993.                 return $this->readItemIndex();
  1994.         }
  1995.         function setItemIndex($value)
  1996.         {
  1997.                 $this->writeItemIndex($value);
  1998.         }
  1999.  
  2000.         function getItems()
  2001.         {
  2002.                 return $this->readItems();
  2003.         }
  2004.         function setItems($value)
  2005.         {
  2006.                 $this->writeItems($value);
  2007.         }
  2008.  
  2009.         function getParentColor()
  2010.         {
  2011.                 return $this->readParentColor();
  2012.         }
  2013.         function setParentColor($value)
  2014.         {
  2015.                 $this->writeParentColor($value);
  2016.         }
  2017.  
  2018.         function getParentFont()
  2019.         {
  2020.                 return $this->readParentFont();
  2021.         }
  2022.         function setParentFont($value)
  2023.         {
  2024.                 $this->writeParentFont($value);
  2025.         }
  2026.  
  2027.         function getParentShowHint()
  2028.         {
  2029.                 return $this->readParentShowHint();
  2030.         }
  2031.         function setParentShowHint($value)
  2032.         {
  2033.                 $this->writeParentShowHint($value);
  2034.         }
  2035.  
  2036.         function getPopupMenu()
  2037.         {
  2038.                 return $this->readPopupMenu();
  2039.         }
  2040.         function setPopupMenu($value)
  2041.         {
  2042.                 $this->writePopupMenu($value);
  2043.         }
  2044.  
  2045.         function getOrientation()
  2046.         {
  2047.                 return $this->readOrientation();
  2048.         }
  2049.         function setOrientation($value)
  2050.         {
  2051.                 $this->writeOrientation($value);
  2052.         }
  2053.  
  2054.         function getShowHint()
  2055.         {
  2056.                 return $this->readShowHint();
  2057.         }
  2058.         function setShowHint($value)
  2059.         {
  2060.                 $this->writeShowHint($value);
  2061.         }
  2062.  
  2063.         function getStyle()             { return $this->readstyle()}
  2064.         function setStyle($value)       { $this->writestyle($value)}
  2065.  
  2066.         function getTabOrder()
  2067.         {
  2068.                 return $this->readTabOrder();
  2069.         }
  2070.         function setTabOrder($value)
  2071.         {
  2072.                 $this->writeTabOrder($value);
  2073.         }
  2074.  
  2075.         function getTabStop()
  2076.         {
  2077.                 return $this->readTabStop();
  2078.         }
  2079.         function setTabStop($value)
  2080.         {
  2081.                 $this->writeTabStop($value);
  2082.         }
  2083.  
  2084.         function getVisible()
  2085.         {
  2086.                 return $this->readVisible();
  2087.         }
  2088.         function setVisible($value)
  2089.         {
  2090.                 $this->writeVisible($value);
  2091.         }
  2092. }
  2093.  
  2094. /**
  2095.  * Shape Class
  2096.  *
  2097.  * A component to show simple shapes
  2098.  *
  2099.  */
  2100. class Shape extends Control
  2101. {
  2102.         protected $_shape=stRectangle;
  2103.         protected $_pen=null;
  2104.         protected $_brush=null;
  2105.         protected $_canvas=null;
  2106.  
  2107.         function dumpHeaderCode()
  2108.         {
  2109.                 $this->_canvas->InitLibrary();
  2110.                 if (( $this->ControlState csDesigning == csDesigning )
  2111.                 {
  2112.                         echo "<div id=\"" . $this->Name "_outer\" style=\"Z-INDEX: 2; WIDTH: "
  2113.                             . $this->Width "px; HEIGHT: " $this->Height "px\">";
  2114.                 }
  2115.         }
  2116.  
  2117.         function dumpContents()
  2118.         {
  2119.                 $this->_canvas->BeginDraw();
  2120.  
  2121.                 $penwidth max($this->Pen->Width1);
  2122.                 switch ($this->_shape)
  2123.                 {
  2124.                         case stCircle:
  2125.                         case stSquare:
  2126.                         case stRoundSquare:
  2127.                                 // need to center the shape
  2128.                                 $size = min($this->Width$this->Height$penwidth 4;
  2129.                                 $xc$this->Width 2;
  2130.                                 $yc$this->Height 2;
  2131.                                 $x1 $xc $size;
  2132.                                 $y1 $yc $size;
  2133.                                 $x2$xc $size;
  2134.                                 $y2$yc $size;
  2135.                                 break;
  2136.                         default:
  2137.                                 $x1=$penwidth;
  2138.                                 $y1=$penwidth;
  2139.                                 $x2=max($this->Width2$penwidth 2;
  2140.                                 $y2=max($this->Height2$penwidth 2;
  2141.                                 $size=max($x2$y2);
  2142.                                 break;
  2143.                 };
  2144.  
  2145.                 $w = max($this->Width1);
  2146.                 $h max($this->Height1);
  2147.  
  2148.                 $this->_canvas->Pen->Color $this->Pen->Color;
  2149. //                $this->_canvas->Pen->Style = $this->Pen->Style;
  2150.                 $this->_canvas->Pen->Width $this->Pen->Width;
  2151.                 $this->_canvas->Brush->Color $this->Brush->Color;
  2152.  
  2153.                 switch ($this->_shape)
  2154.                 {
  2155.                         case stRectangle:
  2156.                         case stSquare:
  2157.                                 $this->_canvas->FillRect($x1$y1$x2$y2);
  2158.                                 $this->_canvas->Rectangle($x1$y1$x2$y2);
  2159.                                 break;
  2160.                         case stRoundRect:
  2161.                         case stRoundSquare:
  2162.                                 if ($w $h$s $w;
  2163.                                 else $s $h;
  2164.                                 $this->_canvas->RoundRect($x1$y1$x2$y2$s 4$s 4);
  2165.                                 break;
  2166.                         case stCircle:
  2167.                                 $this->_canvas->Ellipse($x1$y1$x2 1$y2 1);
  2168.                                 break;
  2169.                         case stEllipse:
  2170.                                 $this->_canvas->Ellipse($x1$y1$x2$y2);
  2171.                                 break;
  2172.                 }
  2173.  
  2174.                 $this->_canvas->EndDraw();
  2175.         }
  2176.  
  2177.         function __construct($aowner=null)
  2178.         {
  2179.                 //Calls inherited constructor
  2180.                 parent::__construct($aowner);
  2181.  
  2182.                 $this->Width=65;
  2183.                 $this->Height=65;
  2184.                 $this->_pen=new Pen();
  2185.                 $this->_brush=new Brush();
  2186.                 $this->_canvas new Canvas($this);
  2187.         }
  2188.  
  2189.         /**
  2190.          * Specifies the shape of the control.
  2191.          *
  2192.          * @return enum (stRectangle, stSquare, stRoundRect, stRoundSquare, stEllipse, stCircle)
  2193.          */
  2194.         function readShape()                    { return $this->_shape}
  2195.         function writeShape($value)             { $this->_shape=$value}
  2196.         function defaultShape()                 { return stRectangle; }
  2197.         /**
  2198.          * Specifies the pen used to outline the shape control.
  2199.          *
  2200.          * @return Pen object
  2201.          */
  2202.         protected function readPen()            { return $this->_pen;       }
  2203.         protected function writePen($value)     { if (is_object($value)) $this->_pen=$value}
  2204.         /**
  2205.          * Specifies the color and pattern used for filling the shape control.
  2206.          *
  2207.          * @return Brush object
  2208.          */
  2209.         protected function readBrush()          { return $this->_brush;       }
  2210.         protected function writeBrush($value)   { if (is_object($value)) $this->_brush=$value}
  2211.  
  2212.         // Published common properties
  2213.         function getHint()              { return $this->_hint}
  2214.         function setHint($value)        { $this->_hint=$value}
  2215.  
  2216.         function getVisible()           { return $this->readVisible()}
  2217.         function setVisible($value)     { $this->writeVisible($value)}
  2218.  
  2219.         // Published properties
  2220.         function getShape()             { return $this->readShape()}
  2221.         function setShape($value)       { $this->writeShape($value)}
  2222.  
  2223.         function getPen()               { return $this->readPen()}
  2224.         function setPen($value)         { $this->writePen($value)}
  2225.  
  2226.         function getBrush()             { return $this->readBrush()}
  2227.         function setBrush($value)       { $this->writeBrush($value)}
  2228. }
  2229.  
  2230. /**
  2231.  * Bevel Class
  2232.  *
  2233.  * A component to show beveled graphics
  2234.  *
  2235.  */
  2236. class Bevel extends GraphicControl
  2237. {
  2238.         protected $_shape=bsBox;
  2239.         protected $_bevelstyle=bsLowered;
  2240.         protected $_canvas=null;
  2241.  
  2242.         function dumpHeaderCode()
  2243.         {
  2244.                 $this->_canvas->InitLibrary();
  2245.                 if (( $this->ControlState csDesigning == csDesigning )
  2246.                 {
  2247.                         echo "<div id=\"" . $this->Name "_outer\" style=\"Z-INDEX: 2; WIDTH: "
  2248.                             . $this->Width "px; HEIGHT: " $this->Height "px\">";
  2249.                 }
  2250.         }
  2251.  
  2252.         function dumpContents()
  2253.         {
  2254.                 $this->_canvas->BeginDraw();
  2255.                 $w max($this->Width1);
  2256.                 $h max($this->Height1);
  2257.  
  2258.                 if (( $this->ControlState csDesigning == csDesigning )
  2259.                 {
  2260.                         $this->_canvas->Pen->Color "#000000";
  2261.                         if ($this->_shape == bsSpacer)
  2262.                         {
  2263. //                                $this->_canvas->Pen->Style = psDot;
  2264.                                 $this->_canvas->Rectangle(00$w$h);
  2265.                         }
  2266.                         else
  2267.                         {
  2268. //                                $this->_canvas->Pen->Style = psSolid;
  2269.                         }
  2270.                 }
  2271.  
  2272.                 if ($this->_bevelstyle == bsLowered)
  2273.                 {
  2274.                         $color1 = "#000000";
  2275.                         $color2 = "#EEEEEE";
  2276.                 }
  2277.                 else
  2278.                 {
  2279.                         $color1 = "#EEEEEE";
  2280.                         $color2 = "#000000";
  2281.                 };
  2282.  
  2283.                 switch ($this->_shape)
  2284.                 {
  2285.                         case bsFrame:
  2286.                                 $temp = $color1;
  2287.                                 $color1 = $color2;
  2288.                                 $this->_canvas->BevelRect(11$w 1$h 1$color1$color2);
  2289.                                 $color2 $temp;
  2290.                                 $color1 $temp;
  2291.                                 $this->_canvas->BevelRect(00$w 2$h 2$color1$color2);
  2292.                                 break;
  2293.                         case bsTopLine:
  2294.                                 $this->_canvas->BevelLine($color100$w0);
  2295.                                 $this->_canvas->BevelLine($color201$w1);
  2296.                                 break;
  2297.                         case bsBottomLine:
  2298.                                 $this->_canvas->BevelLine($color10$h 2$w$h 2);
  2299.                                 $this->_canvas->BevelLine($color20$h 1$w$h 1);
  2300.                                 break;
  2301.                         case bsLeftLine:
  2302.                                 $this->_canvas->BevelLine($color1000$h);
  2303.                                 $this->_canvas->BevelLine($color2101$h);
  2304.                                 break;
  2305.                         case bsRightLine:
  2306.                                 $this->_canvas->BevelLine($color1$w 20$w 2$h);
  2307.                                 $this->_canvas->BevelLine($color2$w 10$w 1$h);
  2308.                                 break;
  2309.                         case bsSpacer:
  2310.                                 break;
  2311.                         default:        // bsBox
  2312.                                 $this->_canvas->BevelRect(00$w 1$h 1$color1$color2);
  2313.                                 break;
  2314.                 }
  2315.                 $this->_canvas->EndDraw();
  2316.         }
  2317.  
  2318.         function __construct($aowner=null)
  2319.         {
  2320.                 //Calls inherited constructor
  2321.                 parent::__construct($aowner);
  2322.                 $this->_canvas new Canvas($this);
  2323.         }
  2324.  
  2325.         /**
  2326.         * Specifies the shape type
  2327.         * @return enum
  2328.         */
  2329.         function readShape()            { return $this->_shape}
  2330.         function writeShape($value)     { $this->_shape=$value}
  2331.         function defaultShape()         { return bsBox; }
  2332.  
  2333.         /**
  2334.         * Specifies the style used to draw the bevel
  2335.         * @return enum
  2336.         */
  2337.         function readBevelStyle()       { return $this->_bevelstyle}
  2338.         function writeBevelStyle($value){ $this->_bevelstyle=$value}
  2339.         function defaultBevelStyle()    { return bsLowered; }
  2340.  
  2341.         function getHint()              { return $this->_hint}
  2342.         function setHint($value)        { $this->_hint=$value}
  2343.  
  2344.         function getVisible()           { return $this->readVisible()}
  2345.         function setVisible($value)     { $this->writeVisible($value)}
  2346.  
  2347.         function getShape()             { return $this->readShape()}
  2348.         function setShape($value)       { $this->writeShape($value)}
  2349.  
  2350.         function getBevelStyle()        { return $this->readBevelStyle()}
  2351.         function setBevelStyle($value)  { $this->writeBevelStyle($value)}
  2352. }
  2353.  
  2354. /**
  2355.  * Timer Class
  2356.  *
  2357.  * A component to generate events at specified intervals
  2358.  *
  2359.  */
  2360. class Timer extends Component
  2361. {
  2362.         protected $_interval = 1000;
  2363.         protected $_enabled = true;
  2364.         //protected $_ontimer = null;
  2365.         protected $_jsontimer = null;
  2366.  
  2367.         function dumpJSEvent($event)
  2368.         {
  2369.                 if ($event!=null)
  2370.                 {
  2371.                         echo "function $event(event)\n";
  2372.                         echo "{\n\n";
  2373.                         echo "var event = event || window.event;\n";
  2374. //                        echo "if (!event) var event = window.event;\n";
  2375.                         if ($this->owner!=null$this->owner->$event($thisarray());
  2376.                         echo "\n}\n";
  2377.                         echo "\n";
  2378.                 }
  2379.         }
  2380.  
  2381.         function dumpJavascript()
  2382.         {
  2383.                 parent::dumpJavascript();
  2384.  
  2385.                 if (($this->ControlState csDesigning== csDesigningBreak;
  2386.  
  2387.                 if (($this->_enabled&& ($this->_jsontimer != null))
  2388.                 {
  2389.                         $this->dumpJSEvent($this->_jsontimer);
  2390.  
  2391.                         echo "  var " $this->Name "_TimerID = null;\n";
  2392.                         echo "  var " $this->Name "_OnLoad = null;\n";
  2393.                         echo "\n\n";
  2394.  
  2395.                         echo "  function addEvent(obj, evType, fn)\n";
  2396.                         echo "  { if (obj.addEventListener)\n";
  2397.                         echo "    { obj.addEventListener(evType, fn, false);\n";
  2398.                         echo "      return true;\n";
  2399.                         echo "    }\n";
  2400.                         echo "    else if (obj.attachEvent)\n";
  2401.                         echo "    { var r = obj.attachEvent(\"on\"+evType, fn);\n";
  2402.                         echo "      return r;\n";
  2403.                         echo "    } else {\n";
  2404.                         echo "      return false;\n";
  2405.                         echo "    }\n";
  2406.                         echo "  }\n\n";
  2407.  
  2408.                         echo "  function " $this->Name "_InitTimer()\n";
  2409.                         echo "  {  if (" $this->Name "_OnLoad != null) " $this->Name "_OnLoad();\n";
  2410.                         echo "     " $this->Name "_DisableTimer();\n";
  2411.                         echo "     " $this->Name "_EnableTimer();\n";
  2412.                         echo "  }\n\n";
  2413.  
  2414.                         echo "  function " $this->Name "_DisableTimer()\n";
  2415.                         echo "  {  if (" $this->Name "_TimerID)\n";
  2416.                         echo "     { clearTimeout(" $this->Name "_TimerID); \n";
  2417.                         echo "       " $this->Name "_TimerID  = null;\n";
  2418.                         echo "     }\n";
  2419.                         echo "  }\n\n";
  2420.  
  2421.                         echo "  function " $this->Name "_Event()\n";
  2422.                         echo "  { \n";
  2423.                         echo "  var event = event || window.event; \n";
  2424.                         echo "  if (" $this->Name "_TimerID)\n";
  2425.                         echo "    {  " $this->Name "_DisableTimer();\n";
  2426.                         echo "       " $this->_jsontimer "(event);\n";
  2427.                         echo "       " $this->Name "_EnableTimer();\n";
  2428.                         echo "    }\n";
  2429.                         echo "  }\n\n";
  2430.  
  2431.                         echo "  function " $this->Name "_EnableTimer()\n";
  2432.                         echo "  { " $this->Name "_TimerID = self.setTimeout(\"" $this->Name "_Event()\", $this->_interval);\n";
  2433.                         echo "  }\n\n";
  2434.  
  2435.                         echo "  if (window.onload) " . $this->Name "_OnLoad=window.onload;\n";
  2436.                         echo "  addEvent(window, 'load', " $this->Name "_InitTimer);\n";
  2437.                 }
  2438.         }
  2439.  
  2440.         /**
  2441.          * Controls whether the timer generates OnTimer events periodically.
  2442.          *
  2443.          * @return boolean
  2444.          */
  2445.         protected function readEnabled()        { return $this->_enabled}
  2446.         protected function writeEnabled($value) { $this->_enabled=$value}
  2447.         protected function defaultEnabled()     { return true; }
  2448.         /**
  2449.          * Determines the amount of time, in milliseconds, that passes before
  2450.          * the timer component initiates another OnTimer event.
  2451.          *
  2452.          * @return integer
  2453.          */
  2454.         protected function readInterval()       { return $this->_interval}
  2455.         protected function writeInterval($value) { $this->_interval=$value}
  2456.         protected function defaultInterval()    { return 1000; }
  2457.         //protected function readOnTimer()        { return $this->_ontimer; }
  2458.         //protected function writeOnTimer($value) { $this->_ontimer=$value; }
  2459.         //protected function defaultOnTimer()     { return null; }
  2460.         /**
  2461.          * Occurs when a specified amount of time, determined by the Interval
  2462.          * property, has passed. (JS event)
  2463.          */
  2464.         protected function readjsOnTimer()      { return $this->_jsontimer}
  2465.         protected function writejsOnTimer($value) { $this->_jsontimer=$value}
  2466.         protected function defaultjsOnTimer()   { return null; }
  2467.  
  2468.         // publish properties
  2469.         function getEnabled()                   { return $this->readEnabled()}
  2470.         function setEnabled($value)             { $this->writeEnabled($value)}
  2471.  
  2472.         function getInterval()                   { return $this->readInterval()}
  2473.         function setInterval($value)             { $this->writeInterval($value)}
  2474.  
  2475.         //function getOnTimer()                   { return $this->readOnTimer(); }
  2476.         //function setOnTimer($value)             { $this->writeOnTimer($value); }
  2477.  
  2478.         function getjsOnTimer()                 { return $this->readjsOnTimer()}
  2479.         function setjsOnTimer($value)           { $this->writejsOnTimer($value)}
  2480. }
  2481.  
  2482. /**
  2483.  * PaintBox Class
  2484.  *
  2485.  * A component to paint
  2486.  */
  2487. class PaintBox extends Control
  2488. {
  2489.         protected $_canvas = null;
  2490.         protected $_onpaint = null;
  2491.  
  2492.         function dumpHeaderCode()
  2493.         {
  2494.                 if (($this->ControlState csDesigning)!==csDesigning)
  2495.                 {
  2496.                         $this->_canvas->InitLibrary();
  2497.                 }
  2498.         }
  2499.  
  2500.         function dumpContents()
  2501.         {
  2502.                 if (($this->ControlState csDesigning)==csDesigning)
  2503.                 {
  2504.                         echo "<table width=\"$this->Width\" height=\"$this->Height\" border=\"0\" style=\"border: 1px dotted #000000\" cellpadding=\"0\" cellspacing=\"0\">\n";
  2505.                         echo "<tr>\n";
  2506.                         echo "<td align=\"center\">$this->Name</td>\n";
  2507.                         echo "</tr>\n";
  2508.                         echo "</table>\n";
  2509.                 }
  2510.                 else
  2511.                 {
  2512.                         if (($this->ControlState csDesigning!= csDesigning)
  2513.                         {
  2514.                                 $style="";
  2515.  
  2516.                                 // set height and width to the style attribute
  2517.                                 if (!$this->_adjusttolayout)
  2518.                                 {
  2519.                                     $style .= "height:" . $this->Height "px;width:" $this->Width "px;";
  2520.                                 }
  2521.                                 else
  2522.                                 {
  2523.                                     $style .= "height:100%;width:100%;";
  2524.                                 }
  2525.                                 $events = $this->readJsEvents();
  2526.                                 echo "<div id=\"$this->_name\" style=\"$style\" $events >";
  2527.                                 $this->_canvas->BeginDraw();
  2528.                                 $this->callEvent('onpaint'$this->_canvas);
  2529.                                 $this->_canvas->EndDraw();
  2530.                                 echo "</div>";
  2531.                         }
  2532.                 }
  2533.         }
  2534.  
  2535.         function __construct($aowner=null)
  2536.         {
  2537.                 //Calls inherited constructor
  2538.                 parent::__construct($aowner);
  2539.                 $this->_canvas new Canvas($this);
  2540.                 $this->Width 100;
  2541.                 $this->Height 100;
  2542.         }
  2543.  
  2544.         function getPopupMenu() { return $this->readPopupMenu()}
  2545.         function setPopupMenu($value) { $this->writePopupMenu($value)}
  2546.  
  2547.         /**
  2548.         * Fired when the control requires you to paint its contents
  2549.         */
  2550.         protected function readOnPaint()        { return $this->_onpaint}
  2551.         protected function writeOnPaint($value) { $this->_onpaint=$value}
  2552.  
  2553.         function getOnPaint()                   { return $this->readOnPaint()}
  2554.         function setOnPaint($value)             { $this->writeOnPaint($value)}
  2555. }
  2556.  

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