Location: PHPKode > scripts > PHP 4 Applications > php-4-applications/p4a_plainbutton.php
<?php
	require_once("p4a_constants.php");
	require_once("p4a_control.php");

	class p4a_PlainButton extends p4a_Control
	{
		var $onClickEvent;
		var $label;
		var $icon;
		var $image;
		var $image_w;

		function p4a_PlainButton( $_l="Control", $_w=0, $_h=0)
		{
			$this->type="plainbutton";
			$this->label=$_l;
			$this->image = "";
			$this->width = 0;
			$this->height = 0;
			if ($_w)
				$this->width = $_w;
			if ($_h)
				$this->height = $_h;
			$this->onClickEvent ="";
		}

		function setLabel( $_l)
		{
			$this->label = $_l;
		}

		function setImage( $_i, $_w=0)
		{
			$this->image = $_i;
			$this->image_w = $_w;
		}

		function onClick( $_en)
		{
			$this->onClickEvent = $_en;
		}

		function flush( $_ev=0)
		{
			if (!$_ev)
				$da="";
			else
				$da="parent.";
				
			$js = "<script language='JavaScript'>\n";
			$js .= $da.$this->id_html.".className='clsPlainButton';\n";
			if ($this->width)
				$js .= $da.$this->id_html.".style.width = '".$this->width."px';\n";
			if ($this->height)
				$js .= $da.$this->id_html.".style.height = '".$this->height."px';\n";
			$js .= $da.$this->id_html.".innerHTML='";
			if (strlen($this->image)>0)
			{
				$js .= "<img src=\"".$this->image."\" ";
				if ($this->image_w)
					$js .= " width=\"".$this->image_w."\">";
				else
					$js .=">";
			}
			$js .= $this->label."';</script>\n";

			if ($this->onClickEvent)
			{
				$js .= "<script for=\"".$da.$this->id_html."\" event=\"onclick\" language=\"JavaScript\">";
				$js .= "p4a_eventFrame.location.href=\"p4a_events.php?event=".$this->onClickEvent."\";";
				$js .= "</script>";
			}

			$js .= "<script for=\"".$da.$this->id_html."\" event=\"onmouseover\" language=\"JavaScript\">";
			$js .= $da.$this->id_html.".className=\"clsPlainButtonOver\";";
			$js .= "</script>";
			$js .= "<script for=\"".$da.$this->id_html."\" event=\"onmouseout\" language=\"JavaScript\">";
			$js .= $da.$this->id_html.".className=\"clsPlainButton\";";
			$js .= "</script>\n";

			return $js;
		}
	}
?>
Return current item: PHP 4 Applications