1: <?php
2: /**
3: * ManiaLib - Lightweight PHP framework for Manialinks
4: *
5: * @see http://code.google.com/p/manialib/
6: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
7: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
8: * @version $Revision: 619 $:
9: * @author $Author: maximeraoust $:
10: * @date $Date: 2012-01-09 12:44:21 +0100 (lun., 09 janv. 2012) $:
11: */
12:
13: namespace ManiaLib\Gui\Elements;
14:
15: class Label extends \ManiaLib\Gui\Elements\Format
16: {
17:
18: protected $xmlTagName = 'label';
19: protected $style = self::TextStaticSmall;
20: protected $posX = 0;
21: protected $posY = 0;
22: protected $posZ = 0;
23: protected $text;
24: protected $textid;
25: protected $autonewline;
26: protected $maxline;
27: protected $focusAreaColor1;
28: protected $focusAreaColor2;
29:
30: function __construct($sizeX = 20, $sizeY = 7)
31: {
32: $this->sizeX = $sizeX;
33: $this->sizeY = $sizeY;
34: }
35:
36: /**
37: * Sets the text
38: * @param string
39: */
40: function setText($text)
41: {
42: $this->text = $text;
43: }
44:
45: /**
46: * Sets the text Id for use with Manialink dictionaries
47: */
48: function setTextid($textid)
49: {
50: $this->textid = $textid;
51: }
52:
53: /**
54: * Sets the maximum number of lines to display
55: * @param int
56: */
57: function setMaxline($maxline)
58: {
59: $this->maxline = $maxline;
60: }
61:
62: /**
63: * Enables wraping the text into several lines if the line is too short
64: */
65: function enableAutonewline()
66: {
67: $this->autonewline = 1;
68: }
69:
70: /**
71: * Set the default background color of the label (if it has one)
72: * @param string $focusareacolor1 4-digit RGBA hexadecimal value
73: */
74: function setFocusAreaColor1($focusareacolor1)
75: {
76: $this->focusAreaColor1 = $focusareacolor1;
77: }
78:
79: /**
80: * Set the background color of the label when mouse is over (if it has one)
81: * @param string $focusareacolor1 4-digit RGBA hexadecimal value
82: */
83: function setFocusAreaColor2($focusareacolor2)
84: {
85: $this->focusAreaColor2 = $focusareacolor2;
86: }
87:
88: /**
89: * Returns the text
90: * @return string
91: */
92: function getText()
93: {
94: return $this->text;
95: }
96:
97: /**
98: * Returns the text Id
99: * @return string
100: */
101: function getTextid()
102: {
103: return $this->textid;
104: }
105:
106: /**
107: * Returns the maximum number of lines to display
108: * @return int
109: */
110: function getMaxline()
111: {
112: return $this->maxline;
113: }
114:
115: /**
116: * Returns whether word wrapping is enabled
117: * @return boolean
118: */
119: function getAutonewline()
120: {
121: return $this->autonewline;
122: }
123:
124: /**
125: * Return the default background color
126: * @return string
127: */
128: function getFocusAreaColor1()
129: {
130: return $this->focusAreaColor1;
131: }
132:
133: /**
134: * Return the background color when mouse is over
135: * @return string
136: */
137: function getFocusAreaColor2()
138: {
139: return $this->focusAreaColor2;
140: }
141:
142: protected function postFilter()
143: {
144: parent::postFilter();
145: if($this->text !== null)
146: {
147: if(\ManiaLib\Gui\Manialink::$linksEnabled)
148: $this->xml->setAttribute('text', $this->text);
149: else
150: $this->xml->setAttribute('text',
151: \ManiaLib\Utils\Formatting::stripLinks($this->text));
152: }
153: if($this->textid !== null)
154: {
155: if(\ManiaLib\Gui\Manialink::$linksEnabled)
156: $this->xml->setAttribute('textid', $this->textid);
157: else
158: $this->xml->setAttribute('textid',
159: \ManiaLib\Utils\Formatting::stripLinks($this->textid));
160: }
161: if($this->autonewline !== null)
162: $this->xml->setAttribute('autonewline', $this->autonewline);
163: if($this->maxline !== null)
164: $this->xml->setAttribute('maxline', $this->maxline);
165: if($this->focusAreaColor1 !== null)
166: $this->xml->setAttribute('focusareacolor1', $this->focusAreaColor1);
167: if($this->focusAreaColor2 !== null)
168: $this->xml->setAttribute('focusareacolor2', $this->focusAreaColor2);
169: }
170:
171: }
172:
173: ?>