<?php /** * @copyright mpl by ERB software * All rights reserved * @contact stefan.erb@erb-software.com * * @date 17.02.2010 */ include_once(dirname(__FILE__).'/FontImageCreator.php'); class TextBox extends FontImageCreator{ public $dstX = 0; public $dstY = 0; public $srcX = 0; public $srcY = 0; public $xSize = 0; public $ySize = 0; private $image; private $initialized = false; /** * constructer * @param String text * @param String FontName */ public function __construct($text=NULL, $font=NULL, $fontPath=parent::DEFAULT_FONT_PATH){ try{ parent::__construct($text, $font, $fontPath); $this->initialized = true; $this->recalc(); } catch (Exception $e){ throw $e; } } /** * Neuberechnung des images und der entsprechenden massen * @return $box => array(xSize, ySize) */ public function recalc(){ try{ if($this->initialized == false) return NULL; $box = parent::getImage($this->image); $this->xSize = $box['xSize']; $this->ySize = $box['ySize']; return $box; } catch (Exception $e){ throw $e; } } /** * Das TestImage in das Zielimage kopieren * @param $destImage */ public function copyIntoImage(&$destImage){ try{ imagecopy($destImage, $this->image, $this->dstX, $this->dstY, $this->srcX, $this->srcY , $this->xSize ,$this->ySize); } catch (Exception $e){ throw $e; } } /** * Magic Function __set for all properties * @access public * @param String name * @param String value */ public function __set($name, $value){ try{ parent::__set($name, $value); //nach dem Ändern von Eigenschaften neu berechnen $this->recalc(); } catch (Exception $e){ throw $e; } } /** * destruct */ public function __destruct(){ imagedestroy($this->image); } } ?>