TrackManiaControl/application/core/FML/Controls/Entry.php

179 lines
3.8 KiB
PHP
Raw Normal View History

<?php
namespace FML\Controls;
use FML\Types\NewLineable;
use FML\Types\Scriptable;
use FML\Types\Styleable;
use FML\Types\TextFormatable;
/**
2014-01-19 19:30:21 +01:00
* Entry Control
2014-01-12 00:51:46 +01:00
* (CMlEntry)
*
* @author steeffeen
*/
class Entry extends Control implements NewLineable, Scriptable, Styleable, TextFormatable {
2014-01-21 20:30:40 +01:00
/*
2013-12-31 02:55:19 +01:00
* Protected Properties
*/
protected $name = '';
protected $default = null;
protected $autoNewLine = 0;
protected $scriptEvents = 0;
protected $style = '';
protected $textColor = '';
protected $textSize = -1;
2014-01-19 19:30:21 +01:00
protected $focusAreaColor1 = '';
protected $focusAreaColor2 = '';
/**
* Create a new Entry Control
*
* @param string $id (optional) Control Id
* @return \FML\Controls\Entry
*/
public static function create($id = null) {
$entry = new Entry($id);
return $entry;
}
/**
2013-12-31 02:55:19 +01:00
* Construct a new Entry Control
*
2014-01-12 00:51:46 +01:00
* @param string $id (optional) Control Id
*/
public function __construct($id = null) {
parent::__construct($id);
$this->tagName = 'entry';
}
/**
2013-12-31 02:55:19 +01:00
* Set Entry Name
*
2014-01-12 00:51:46 +01:00
* @param string $name Entry Name
* @return \FML\Controls\Entry
*/
public function setName($name) {
2014-01-12 00:51:46 +01:00
$this->name = (string) $name;
return $this;
}
/**
2013-12-31 02:55:19 +01:00
* Set Default Value
*
2014-01-12 00:51:46 +01:00
* @param string $default Default Value
* @return \FML\Controls\Entry
*/
public function setDefault($default) {
$this->default = $default;
return $this;
}
/**
*
* @see \FML\Types\NewLineable::setAutoNewLine()
* @return \FML\Controls\Entry
*/
public function setAutoNewLine($autoNewLine) {
$this->autoNewLine = ($autoNewLine ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Scriptable::setScriptEvents()
* @return \FML\Controls\Entry
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/**
*
* @see \FML\Types\Styleable::setStyle()
* @return \FML\Controls\Entry
*/
public function setStyle($style) {
2014-01-12 00:51:46 +01:00
$this->style = (string) $style;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextColor()
* @return \FML\Controls\Entry
*/
public function setTextColor($textColor) {
2014-01-12 00:51:46 +01:00
$this->textColor = (string) $textColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setTextSize()
* @return \FML\Controls\Entry
*/
public function setTextSize($textSize) {
2014-01-12 00:51:46 +01:00
$this->textSize = (int) $textSize;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaColor()
* @return \FML\Controls\Entry
*/
public function setAreaColor($areaColor) {
2014-01-19 19:30:21 +01:00
$this->focusAreaColor1 = (string) $areaColor;
return $this;
}
/**
*
* @see \FML\Types\TextFormatable::setAreaFocusColor()
* @return \FML\Controls\Entry
*/
public function setAreaFocusColor($areaFocusColor) {
2014-01-19 19:30:21 +01:00
$this->focusAreaColor2 = (string) $areaFocusColor;
return $this;
}
/**
*
* @see \FML\Control::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = parent::render($domDocument);
if ($this->name) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('name', $this->name);
}
if ($this->default !== null) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('default', $this->default);
}
if ($this->autoNewLine) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('autonewline', $this->autoNewLine);
}
if ($this->scriptEvents) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
if ($this->style) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('style', $this->style);
}
if ($this->textColor) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('textcolor', $this->textColor);
}
if ($this->textSize >= 0.) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('textsize', $this->textSize);
}
2014-01-19 19:30:21 +01:00
if ($this->focusAreaColor1) {
$xmlElement->setAttribute('focusareacolor1', $this->focusAreaColor1);
}
2014-01-19 19:30:21 +01:00
if ($this->focusAreaColor2) {
$xmlElement->setAttribute('focusareacolor2', $this->focusAreaColor2);
}
2014-01-12 00:51:46 +01:00
return $xmlElement;
}
}