00001 <?php
00002
00013 class TKIconButton extends TKAbstractButton {
00014 const TEXT_NONE = 0;
00015 const TEXT_SIDE = 1;
00016 const TEXT_UNDER = 2;
00017
00025 public function __construct($caption, $iconPath, $textPos = self::TEXT_SIDE) {
00026 parent::__construct($caption);
00027
00028 $this->addProperty('icon_path', self::PROP_STRING);
00029 $this->addProperty('icon_class', self::PROP_CLASS);
00030 $this->addProperty('text_pos', self::PROP_NUMERIC);
00031
00032 $this->set('icon_path', $iconPath);
00033 $this->set('text_pos', $textPos);
00034 }
00035
00037 protected function renderComponent($class, $style, $events, $id) {
00038 if($this->get('disabled') == true)
00039 $disabled = ' disabled="disabled"';
00040 else
00041 $disabled = "";
00042
00043 $collect = "<div $id$class[0]$style[0]$events$disabled>";
00044 if($class['icon'] != "")
00045 $collect .= "<div $class[icon]></div>";
00046 else
00047 $collect .= "<div style=\"float:left;width:16px;height:16px;background:url('" . $this->get('icon_path') . "');\"></div>";
00048
00049 switch($this->get('text_pos')) {
00050 case self::TEXT_NONE:
00051 break;
00052 case self::TEXT_SIDE:
00053 $collect .= $this->getCaption();
00054 break;
00055 case self::TEXT_UNDER:
00056 $collect .= "<br />" . $this->getCaption();
00057 break;
00058 }
00059
00060 $collect .= "</div>";
00061
00062 return $collect;
00063 }
00064
00066 public static function createFromXML($attrs, $contents, $node) {
00067 $obj = new TKIconButton("$contents", "");
00068 self::convertStdAttributes($obj, $attrs);
00069 self::convertStdEvents($obj, $node);
00070 return $obj;
00071 }
00072 }
00073
00074 ?>