Source for file Title.php
Documentation is available at Title.php
* Description: Underlying Title characteristics
* @copyright (c) 1995-2010 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
private static $TITLEFOOTDISTANCE = 5;
private $adjustFrame = true;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function Title($c) {
parent::TextShapePosition($c);
* Resizes Header and Footer frames to full Chart dimensions when true.<br>
* When false it resizes to the Title text width. It only has effect when
* Chart.Header or Chart.Footer.Visible is true.<br>
return $this->adjustFrame;
* Resizes Header and Footer frames to full Chart dimensions when true.<br>
* When false it resizes to the Title text width. It only has effect when
* Chart.Header or Chart.Footer.Visible is true.<br>
* Determines how tChart Header and Footer text will be aligned within the
* The Header or Footer can optionally be surrounded by a Frame. <br>
* @return StringAlignment
* Sets how tChart Header and Footer text will be aligned within the
* The Header or Footer can optionally be surrounded by a Frame. <br>
* @param value StringAlignment
if ($this->alignment != $value) {
$this->alignment = $value;
$this->alignment= Array($value);
/* draw a title text line */
private function drawTitleLine($aIndex, $gd) {
$aPos = ($aIndex+ 1) * $this->fontH + $this->tmpFrameWidth / 2;
$aPos = $this->getShapeBounds()->getBottom() - ($this->fontH + $aPos);
MathUtils::round($gd->textWidth($st)) -
($gd->textWidth($st) / 2));
$oldAlign= $gd->getTextAlign();
$gd->textOut($this->tmpXPosTitle, $aPos, 0, $st);
$gd->setTextAlign($oldAlign);
* Returns if mouse cursor is inside TChartTitle bound rectangle.<br><br>
* The Title.Visible property must be true. <br>
* The Title rectangle size depends on Title.Pen.Visible and
* Returns if mouse cursor is inside TChartTitle bound rectangle.<br><br>
* The Title.Visible property must be true. <br>
* The Title rectangle size depends on Title.Pen.Visible and
function doDraw($gd, $rect, $customOnly) {
return $this->draw($gd, $rect);
protected function draw($gd, $rect) {
TChart::$controlName .= 'Title_';
if ($this->visible && ($linesCount > 0)) {
// calculate title shape margin
$tmpFrameVisible = $this->getPen()->getVisible();
$this->tmpFrameWidth = $this->getPen()->getWidth();
$this->tmpFrameWidth = 0;
if ($this->getBevel()->getInner() != BevelStyle::$NONE) {
$this->tmpFrameWidth += $this->getBevel()->getWidth();
$gd->setTextAlign(StringAlignment::$NEAR);
$oldAlign= $gd->getTextAlign();
$this->fontH = $gd->getFontHeight();
// autosize title height on number of text lines
$this->shapeBounds->height = $linesCount * $this->fontH + $this->tmpFrameWidth;
$this->shapeBounds->height= $linesCount * $this->fontH + $this->tmpFrameWidth;
$this->tmpMargin = MathUtils::round($gd->textWidth("W"));
// resize Title to maximum Chart width
if ($this->adjustFrame) {
for ($t = 0; $t < $linesCount; $t++ ) {
if ($tmp > $tmpMaxWidth) {
$tmpMaxWidth += $this->tmpMargin + $this->tmpFrameWidth;
$this->tmpXPosTitle = $this->getShapeBounds()->getLeft() + ($this->tmpMargin / 2);
// draw all Title text lines
for ($t = 0; $t < $linesCount; $t++ ) {
$this->drawTitleLine($t, $gd);
$gd->setTextAlign($oldAlign);
// calculate Chart positions after drawing the titles / footers
$tmp = self::$TITLEFOOTDISTANCE + $this->tmpFrameWidth;
$rect->height -= ($rect->y - $tmpY);
$rect->height -= ($tmp + $linesCount * $this->fontH);
return $this->chart->recalcWidthHeight($rect); // DB
|