2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
2013-11-28 01:12:52 +01:00
|
|
|
use FML\Types\Styleable;
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
* Class representing CMlGauge
|
|
|
|
*
|
|
|
|
* @author steeffeen
|
|
|
|
*/
|
|
|
|
class Gauge extends Control implements Styleable {
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Protected Properties
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
protected $ratio = 1.;
|
|
|
|
protected $grading = 1.;
|
2013-11-28 01:12:52 +01:00
|
|
|
protected $color = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
protected $rotation = 0.;
|
|
|
|
protected $centered = 0;
|
|
|
|
protected $clan = 0;
|
|
|
|
protected $drawBg = 1;
|
|
|
|
protected $drawBlockBg = 1;
|
2013-11-28 01:12:52 +01:00
|
|
|
protected $style = '';
|
2013-11-25 00:02:07 +01:00
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Construct a new Gauge Control
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param string $id
|
|
|
|
* Control Id
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function __construct($id = null) {
|
|
|
|
parent::__construct($id);
|
2013-11-28 01:12:52 +01:00
|
|
|
$this->tagName = 'gauge';
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Ratio
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param float $ratio
|
|
|
|
* Ratio Value
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setRatio($ratio) {
|
|
|
|
$this->ratio = $ratio;
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Grading
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param float $grading
|
|
|
|
* Grading Value
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setGrading($grading) {
|
|
|
|
$this->grading = $grading;
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Color
|
2013-11-28 01:12:52 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param string $color
|
|
|
|
* Gauge Color
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
|
|
|
*/
|
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Rotation
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param float $rotation
|
|
|
|
* Gauge Rotation
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setRotation($rotation) {
|
|
|
|
$this->rotation = $rotation;
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Centered
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param bool $centered
|
|
|
|
* If Gauge is centered
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setCentered($centered) {
|
|
|
|
$this->centered = ($centered ? 1 : 0);
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Clan
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param int $clan
|
|
|
|
* Clan number
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setClan($clan) {
|
|
|
|
$this->clan = $clan;
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Draw Background
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param bool $drawBg
|
|
|
|
* If Gauge Background should be drawn
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setDrawBg($drawBg) {
|
|
|
|
$this->drawBg = ($drawBg ? 1 : 0);
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Set Draw Block Background
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2013-12-31 02:55:19 +01:00
|
|
|
* @param bool $drawBlockBg
|
|
|
|
* If Gauge Block Background should be drawn
|
2013-11-28 01:12:52 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function setDrawBlockBg($drawBlockBg) {
|
|
|
|
$this->drawBlockBg = ($drawBlockBg ? 1 : 0);
|
2013-11-28 01:12:52 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Styleable::setStyle()
|
2013-12-31 02:55:19 +01:00
|
|
|
* @return \FML\Controls\Gauge
|
2013-11-28 01:12:52 +01:00
|
|
|
*/
|
|
|
|
public function setStyle($style) {
|
|
|
|
$this->style = $style;
|
|
|
|
return $this;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Control::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument) {
|
|
|
|
$xml = parent::render($domDocument);
|
|
|
|
$xml->setAttribute('ratio', $this->ratio);
|
|
|
|
$xml->setAttribute('grading', $this->grading);
|
2013-11-28 01:12:52 +01:00
|
|
|
if ($this->color) {
|
|
|
|
$xml->setAttribute('color', $this->color);
|
|
|
|
}
|
|
|
|
if ($this->rotation) {
|
|
|
|
$xml->setAttribute('rotation', $this->rotation);
|
|
|
|
}
|
|
|
|
if ($this->centered) {
|
|
|
|
$xml->setAttribute('centered', $this->centered);
|
|
|
|
}
|
|
|
|
if ($this->clan) {
|
|
|
|
$xml->setAttribute('clan', $this->clan);
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
$xml->setAttribute('drawbg', $this->drawBg);
|
|
|
|
$xml->setAttribute('drawblockbg', $this->drawBlockBg);
|
2013-11-28 01:12:52 +01:00
|
|
|
if ($this->style) {
|
|
|
|
$xml->setAttribute('style', $this->style);
|
|
|
|
}
|
2013-11-25 00:02:07 +01:00
|
|
|
return $xml;
|
|
|
|
}
|
|
|
|
}
|