<?php
/*
* (C) Copyright by Christian Möller
* All Rights reserved
*
* This file is part of the WCL (Web Control Library).
*
* WCL is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Foobar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WCL. If not, see <http://www.gnu.org/licenses/>.
*/
// Font Aligns
define ("ALIGN_CENTER", "center");
define ("ALIGN_LEFT", "left");
define ("ALIGN_RIGHT", "right");
define ("VALIGN_TOP", "top");
define ("VALIGN_MIDDLE", "middle");
define ("VALIGN_BOTTOM", "bottom");
// Font Weights
define ("WEIGHT_BOLD", "bold");
define ("WEIGHT_BOLDER", "bolder");
define ("WEIGHT_LIGHTER", "lighter");
define ("WEIGHT_NORMAL", "normal");
// Font Families
define ("FAMILY_SERIF", "serif");
define ("FAMILY_SANS_SERIF", "sans-serif");
define ("FAMILY_CURSIVE", "cursive");
define ("FAMILY_FANTASY", "fantasy");
define ("FAMILY_MONOSPACE", "monospace");
/*
* wuiLabel stellt einen Container bereit, der sich auf
* die Ausgabe von Text spezialisiert. Dabei wird das
* Label von der Abstrakten Panel Komponente abgeleitet,
* um die Verschiedenen Eigenschaften eines Panels zu
* erben. Weiterhin werden verschiedene spezifische
* Funktion zur Manipulation der Darstellung von
* Schriften zur Verfügung gestellt
*/
class wuiLabel extends wuiPanel {
var $text,
$textalign,
$textvalign,
$size,
$family,
$weight,
$queue;
function wuiLabel($name) {
parent::IControl($name);
parent::setBaseTag("div");
}
function setText($text) {
if (!_eventmode()) $this->text = $text;
if (is_object($text) && is_subclass_of($text, "IControl")) {
$text = $text->toString();
}
if (strpos($text, "document.") === false)
_eventmode_add("innerHTML", '"'.$text.'"');
else
_eventmode_add("innerHTML", $text);
}
function setTextAlign($align) {
if (!_eventmode()) $this->textalign = $align;
_eventmode_add("style.textAlign", '"'.$align.'"');
}
function setTextVAlign($valign) {
if (!_eventmode()) $this->textvalign = $valign;
_eventmode_add("style.verticalAlign", '"'.$valign.'"');
}
function setFontSize($size) {
if (!_eventmode()) $this->size = $size;
_eventmode_add("style.fontSize", $size);
}
function setFontFamily($fam) {
if (!_eventmode()) $this->family = $fam;
_eventmode_add("style.fontFamily", '"'.$fam.'"');
}
function setFontWeight($weight) {
if (!_eventmode()) $this->weight = $weight;
_eventmode_add("style.fontWeight", '"'.$weight.'"');
}
function setTextAfterChild() { $this->queue = true; }
function setTextBeforeChild() { $this->queue = false; }
function getText() {
if (!_eventmode()) return $this->text;
else return parent::get_this().".innerHTML";
}
function render_style_underlying() {
return parent::render_style_underlying().
"; text-align: ".$this->textalign.
"; vertical-align: ".$this->textvalign.
"; font-size: ".$this->size.
"; font-family: ".$this->family.
"; font-weight: ".$this->weight;
}
function render() {
$render_out = parent::render_partial_to();
if (!$this->queue)
$render_out .= $this->text;
$render_out .= parent::render_controls();
if ($this->queue)
$render_out .= $this->text;
$render_out .= parent::render_partial_tc();
return $render_out;
}
}
?>