1 | <?php |
||
15 | class Button extends AbstractUiElement implements ScriptFeatureable, Container |
||
16 | { |
||
17 | const TYPE_DECORATED = "decorated"; |
||
18 | const TYPE_DEFAULT = "default"; |
||
19 | const COLOR_DEFAULT = "777"; |
||
20 | const COLOR_SUCCESS = "0d0"; |
||
21 | const COLOR_WARNING = "d00"; |
||
22 | const COLOR_PRIMARY = "3af"; |
||
23 | const COLOR_SECONDARY = "000"; |
||
24 | |||
25 | /** @var Label */ |
||
26 | protected $buttonLabel; |
||
27 | protected $type; |
||
28 | protected $textColor = "fff"; |
||
29 | protected $backColor = self::COLOR_DEFAULT; |
||
30 | protected $focusColor = "aaa"; |
||
31 | protected $borderColor = "fff"; |
||
32 | protected $translate = true; |
||
33 | |||
34 | protected $action = null; |
||
35 | protected $text = "button"; |
||
36 | protected $scale = 1.; |
||
37 | |||
38 | public function __construct($text = "button", $type = self::TYPE_DEFAULT) |
||
54 | |||
55 | |||
56 | /** |
||
57 | * Render the XML element |
||
58 | * |
||
59 | * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered |
||
60 | * @return \DOMElement |
||
61 | * |
||
62 | * <frame pos="64 -35" class="uiContainer UiButton"> |
||
63 | * <label size="26 9" data-color="fff" text="Cancel" class="button noAnim" textprefix=" " opacity="1" halign="center" valign="center" focusareacolor1="0000" focusareacolor2="d00" scriptevents="1" translate="0" textsize="2"/> |
||
64 | * <quad size="26 9" style="Bgs1" colorize="d00" substyle="BgColorContour" class="button" halign="center" valign="center" pos="0 0"/> |
||
65 | * </frame> |
||
66 | */ |
||
67 | public function render(\DOMDocument $domDocument) |
||
112 | |||
113 | /** |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getText() |
||
120 | |||
121 | /** |
||
122 | * @param string $text |
||
123 | * @return Button |
||
124 | */ |
||
125 | public function setText($text) |
||
136 | |||
137 | /** |
||
138 | * Get the Script Features |
||
139 | * |
||
140 | * @return ScriptFeature[] |
||
141 | */ |
||
142 | public function getScriptFeatures() |
||
146 | |||
147 | /** |
||
148 | * Prepare the given Script for rendering by adding the needed Labels, etc. |
||
149 | * |
||
150 | * @param Script $script Script to prepar |
||
151 | * @return void |
||
152 | */ |
||
153 | public function prepare(Script $script) |
||
171 | |||
172 | protected function getScriptMouseClick() |
||
181 | |||
182 | protected function getScriptFunction() |
||
204 | |||
205 | |||
206 | /** |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getType() |
||
213 | |||
214 | /** |
||
215 | * @param string $type |
||
216 | * @return Button |
||
217 | */ |
||
218 | public function setType($type) |
||
224 | |||
225 | /** |
||
226 | * @return string |
||
227 | */ |
||
228 | public function getTextColor() |
||
232 | |||
233 | /** |
||
234 | * @param string $textColor |
||
235 | * @return Button |
||
236 | */ |
||
237 | public function setTextColor($textColor) |
||
243 | |||
244 | /** |
||
245 | * @return string |
||
246 | */ |
||
247 | public function getBackgroundColor() |
||
251 | |||
252 | /** |
||
253 | * @param string $backColor |
||
254 | * @return Button |
||
255 | */ |
||
256 | public function setBackgroundColor($backColor) |
||
262 | |||
263 | /** |
||
264 | * @return string |
||
265 | */ |
||
266 | public function getBorderColor() |
||
270 | |||
271 | /** |
||
272 | * @param string $borderColor |
||
273 | * @return Button |
||
274 | */ |
||
275 | public function setBorderColor($borderColor) |
||
281 | |||
282 | /** |
||
283 | * @return null |
||
284 | */ |
||
285 | public function getAction() |
||
289 | |||
290 | /** |
||
291 | * @param null $action |
||
292 | * @return Button |
||
293 | */ |
||
294 | public function setAction($action) |
||
300 | |||
301 | /** |
||
302 | * @return string |
||
303 | */ |
||
304 | public function getFocusColor() |
||
308 | |||
309 | /** |
||
310 | * @param string $focusColor |
||
311 | * @return Button |
||
312 | */ |
||
313 | public function setFocusColor($focusColor) |
||
319 | |||
320 | /** |
||
321 | * @return float |
||
322 | */ |
||
323 | public function getScale() |
||
327 | |||
328 | /** |
||
329 | * @param float $scale |
||
330 | * @return Button |
||
331 | */ |
||
332 | public function setScale($scale) |
||
338 | |||
339 | /** |
||
340 | * @return bool |
||
341 | */ |
||
342 | public function getTranslate() |
||
347 | |||
348 | /** |
||
349 | * @param bool $translate |
||
350 | * @return Button |
||
351 | */ |
||
352 | public function setTranslate($translate = true) |
||
359 | |||
360 | /** |
||
361 | * Get the children |
||
362 | * |
||
363 | * @api |
||
364 | * @return Renderable[] |
||
365 | */ |
||
366 | public function getChildren() |
||
370 | |||
371 | /** |
||
372 | * Add a new child |
||
373 | * |
||
374 | * @api |
||
375 | * @param Renderable $child Child Control to add |
||
376 | * @deprecated |
||
377 | * @return void |
||
378 | */ |
||
379 | public function addChild(Renderable $child) |
||
383 | |||
384 | /** |
||
385 | * Add a new child |
||
386 | * |
||
387 | * @api |
||
388 | * @param Renderable $child Child Control to add |
||
389 | * @return void |
||
390 | * @deprecated Use addChild() |
||
391 | * @see Container::addChild() |
||
392 | */ |
||
393 | public function add(Renderable $child) |
||
397 | |||
398 | /** |
||
399 | * Add new children |
||
400 | * |
||
401 | * @api |
||
402 | * @param Renderable[] $children Child Controls to add |
||
403 | * @return void |
||
404 | */ |
||
405 | public function addChildren(array $children) |
||
409 | |||
410 | /** |
||
411 | * Remove all children |
||
412 | * |
||
413 | * @api |
||
414 | * @return void |
||
415 | */ |
||
416 | public function removeAllChildren() |
||
420 | |||
421 | /** |
||
422 | * Remove all children |
||
423 | * |
||
424 | * @api |
||
425 | * @return void |
||
426 | * @deprecated Use removeAllChildren() |
||
427 | * @see Container::removeAllChildren() |
||
428 | */ |
||
429 | public function removeChildren() |
||
433 | |||
434 | /** |
||
435 | * Get the Format |
||
436 | * |
||
437 | * @api |
||
438 | * @param bool $createIfEmpty If the format should be created if it doesn't exist yet |
||
439 | * @return void |
||
440 | * @deprecated Use Style |
||
441 | * @see Style |
||
442 | */ |
||
443 | public function getFormat($createIfEmpty = true) |
||
447 | |||
448 | /** |
||
449 | * Set the Format |
||
450 | * |
||
451 | * @api |
||
452 | * @param Format $format New Format |
||
453 | * @return void |
||
454 | * @deprecated Use Style |
||
455 | * @see Style |
||
456 | */ |
||
457 | public function setFormat(Format $format = null) |
||
461 | |||
462 | /** |
||
463 | * @return string|null |
||
464 | */ |
||
465 | public function getId() |
||
469 | |||
470 | /** |
||
471 | * @param null $id |
||
472 | * @return Button |
||
473 | */ |
||
474 | public function setId($id) |
||
480 | } |
||
481 |