TrackManiaControl/libs/FML/Elements/Format.php

216 lines
4.5 KiB
PHP
Raw Normal View History

<?php
namespace FML\Elements;
2017-03-25 18:40:15 +01:00
use FML\Types\BackgroundColorable;
2014-01-12 00:51:46 +01:00
use FML\Types\Renderable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
/**
2014-01-12 00:51:46 +01:00
* Format Element
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2017-03-25 18:40:15 +01:00
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
2014-05-18 19:45:50 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
2017-03-25 18:40:15 +01:00
class Format implements BackgroundColorable, Renderable, Styleable, TextFormatable
{
/**
* @var string $backgroundColor Background color
*/
protected $backgroundColor = null;
/**
* @var string $style Style
*/
protected $style = null;
/**
* @var int $textSize Text size
*/
protected $textSize = null;
/**
* @var string $textFont Text font
*/
protected $textFont = null;
/**
* @var string $textColor Text color
*/
protected $textColor = null;
/**
* @var string $areaColor Area color
*/
protected $areaColor = null;
/**
* @var string $focusAreaColor Focus area color
*/
protected $focusAreaColor = null;
/**
* Create a new Format
*
* @api
* @return static
*/
public static function create()
{
return new static();
}
/**
* @see BgColorable::getBackgroundColor()
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @see BgColorable::setBackgroundColor()
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = (string)$backgroundColor;
return $this;
}
/**
* @see Styleable::getStyle()
*/
public function getStyle()
{
return $this->style;
}
/**
* @see Styleable::setStyle()
*/
public function setStyle($style)
{
$this->style = (string)$style;
return $this;
}
/**
* @see TextFormatable::getTextSize()
*/
public function getTextSize()
{
return $this->textSize;
}
/**
* @see TextFormatable::setTextSize()
*/
public function setTextSize($textSize)
{
$this->textSize = (int)$textSize;
return $this;
}
/**
* @see TextFormatable::getTextFont()
*/
public function getTextFont()
{
return $this->textFont;
}
/**
* @see TextFormatable::setTextFont()
*/
public function setTextFont($textFont)
{
$this->textFont = (string)$textFont;
return $this;
}
/**
* @see TextFormatable::getTextColor()
*/
public function getTextColor()
{
return $this->textColor;
}
/**
* @see TextFormatable::setTextColor()
*/
public function setTextColor($textColor)
{
$this->textColor = (string)$textColor;
return $this;
}
/**
* @see TextFormatable::getAreaColor()
*/
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @see TextFormatable::setAreaColor()
*/
public function setAreaColor($areaColor)
{
$this->areaColor = (string)$areaColor;
return $this;
}
/**
* @see TextFormatable::getAreaFocusColor()
*/
public function getAreaFocusColor()
{
return $this->focusAreaColor;
}
/**
* @see TextFormatable::setAreaFocusColor()
*/
public function setAreaFocusColor($areaFocusColor)
{
$this->focusAreaColor = (string)$areaFocusColor;
return $this;
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("format");
if ($this->backgroundColor) {
$domElement->setAttribute("bgcolor", $this->backgroundColor);
}
if ($this->style) {
$domElement->setAttribute("style", $this->style);
}
if ($this->textSize) {
$domElement->setAttribute("textsize", $this->textSize);
}
if ($this->textFont) {
$domElement->setAttribute("textfont", $this->textFont);
}
if ($this->textColor) {
$domElement->setAttribute("textcolor", $this->textColor);
}
if ($this->areaColor) {
$domElement->setAttribute("focusareacolor1", $this->areaColor);
}
if ($this->focusAreaColor) {
$domElement->setAttribute("focusareacolor2", $this->focusAreaColor);
}
return $domElement;
}
}