Source for file AHTMLElement.php

Documentation is available at AHTMLElement.php

  1. <?php
  2. /**
  3.  * AHTMLElement
  4.  *
  5.  * @author Jordan CM Wambaugh <jordan@wambaugh.org>
  6.  * @package Alia
  7.  * @subpackage Widgets
  8.  */
  9.  
  10.  
  11.  
  12. /**
  13.  * Abstract class for all HTML Element widgets
  14.  * defines attributes and signals common to most elements
  15.  *
  16.  * @author Jordan CM Wambaugh <jordan@wambaugh.org>
  17.  * @package Alia
  18.  * @subpackage Widgets
  19.  * @signal clicked() Emitted when the widget is clicked
  20.  * @signal mouseOver() Emitted when the mouse hovers over the widget
  21.  * @signal mouseOut() Emitted when the mouse leaves the widget
  22.  * @signal mouseDown() Emitted when the mouse button is pressed down on the widget
  23.  * @signal mouseUP() Emitted when the mouse button is released from the wwidget
  24.  * @signal dblClicked() Emitted when the widget is double-clicked
  25.  * @signal focus() Emitted when the widget gets keyboard focus
  26.  * @signal keyPressed() Emitted when a key is pressed within the widget
  27.  * @signal keyUp() Emitted when a key is released
  28.  * @signal mouseMove() Emitted when the mouse moves over the widget
  29.  */
  30. abstract class AHTMLElement extends AWidget
  31. {
  32.     /**
  33.      * The inner html (if any)
  34.      *
  35.      * @var unknown_type 
  36.      */
  37.     private $innerHTML;
  38.     
  39.     /**
  40.      * The name of the html tag
  41.      *
  42.      * @var unknown_type 
  43.      */
  44.     private $tagName;
  45.     
  46.     /**
  47.      * 
  48.      *
  49.      */
  50.     public function __construct(){
  51.         parent::__construct();
  52.         
  53.         $this->addAttribute('style');
  54.         $this->addAttribute('title');
  55.         $this->addAttribute('class');
  56.         $this->addAttribute('style');
  57.         $this->addAttribute('lang');        
  58.         
  59.         //define the signals for this object
  60.         $this->defineSignal("clicked",0);
  61.         $this->defineSignal("mouseOver",0);
  62.         $this->defineSignal("mouseOut",0);
  63.         $this->defineSignal("mouseDown",0);
  64.         $this->defineSignal("mouseUp",0);
  65.         $this->defineSignal("dblClicked",0);
  66.         $this->defineSignal("focus",0);
  67.         $this->defineSignal("keyPressed",0);
  68.         $this->defineSignal("keyUp",0);
  69.         $this->defineSignal("mouseMove",0);
  70.     }
  71.  
  72.     /**
  73.      * set the event attributes, but only if we have a connection (save page weight)
  74.      *
  75.      * @return string 
  76.      */
  77.     public function render(){
  78.         
  79.         
  80.         //generate emitions, but only if we have a connection to the slot.
  81.         
  82.         if($this->hasConnection('clicked')){
  83.             $this->addAttribute('onclick')->setAttribute('onclick',AJScript::emit('clicked',$this));
  84.         }
  85.         
  86.         if($this->hasConnection('mouseOver')){
  87.             $this->addAttribute('onmouseover')->setAttribute('onmouseover',AJScript::emit('mouseOver',$this));
  88.         }
  89.         
  90.         if($this->hasConnection('mouseOut')){
  91.             $this->addAttribute('onmouseout')->setAttribute('onmouseout',AJScript::emit('mouseOut',$this));
  92.         }
  93.         
  94.         if($this->hasConnection('mouseDown')){
  95.             $this->addAttribute('mouseDown')->setAttribute('mouseDown',AJScript::emit('mouseDown',$this));
  96.         }
  97.         
  98.         
  99.         if($this->hasConnection('mouseUp')){
  100.             $this->addAttribute('mouseUp')->setAttribute('mouseUp',AJScript::emit('mouseUp',$this));
  101.         }
  102.         
  103.         if($this->hasConnection('dblClicked')){
  104.             $this->addAttribute('dblClicked')->setAttribute('mouseDown',AJScript::emit('dblClicked',$this));
  105.         }
  106.         
  107.         if($this->hasConnection('mouseOut')){
  108.             $this->addAttribute('mouseOut')->setAttribute('mouseOut',AJScript::emit('mouseOut',$this));
  109.         }
  110.         
  111.         if($this->hasConnection('focus')){
  112.             $this->addAttribute('focus')->setAttribute('focus',AJScript::emit('focus',$this));
  113.         }
  114.         
  115.         
  116.         if($this->hasConnection('keyPressed')){
  117.             $this->addAttribute('keyPressed')->setAttribute('keyPressed',AJScript::emit('keyPressed',$this));
  118.         }
  119.         
  120.         if($this->hasConnection('keyUp')){
  121.             $this->addAttribute('keyUp')->setAttribute('keyUp',AJScript::emit('keyUp',$this));
  122.         }
  123.         
  124.         if($this->hasConnection('mouseMove')){
  125.             $this->addAttribute('mouseMove')->setAttribute('mouseMove',AJScript::emit('mouseMove',$this));
  126.         }
  127.         
  128.         $buffer parent::render();
  129.         return $buffer;
  130.     }
  131.     
  132.     /**
  133.      * Sets the name of the tag
  134.      *
  135.      * @param string $name 
  136.      */
  137.     public function setTagName($name){
  138.         $this->tagName=$name;
  139.     }
  140.     
  141.     
  142.     /**
  143.      * returns the name of the tag
  144.      *
  145.      * @return string 
  146.      */
  147.     public function getTagName(){
  148.         return $this->tagName;
  149.     }
  150.     
  151.     /**
  152.      * sets the inner HTML
  153.      *
  154.      * @param string $html 
  155.      */
  156.     public function setInnerHTML($html){
  157.         $this->innerHTML=$html;
  158.     }
  159.     
  160.     /**
  161.      * returns the inner HTML
  162.      *
  163.      * @return string 
  164.      */
  165.     public function getInnerHTML(){
  166.         return $this->innerHTML;
  167.     }
  168.     
  169.     
  170.  
  171. // end of AHTMLElement
  172. ?>

Documentation generated on Fri, 11 Jul 2008 13:28:40 -0400 by phpDocumentor 1.4.2