Examples TOCexamples TOC

Square Back

$Date: 2004/04/18 13:25:44 $

 Table of contents

Introduction

This example will run a polygonal (square 4x4) ProgressBar filled in reverse way.

Cell coordinates are pre-computed but free x-y-grid coordinates are also possible. Percent text info is centered on a white background area of 50 pixels width, at left side of polygonal shape.

[Top]

 PHP script

Build the progress bar

require_once 'HTML/Progress.php';

$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(10);

$ui =& $bar->getUI();
$ui->setStringAttributes('valign=left align=center');
$ui->setFillWay('reverse');
$ui->setOrientation(HTML_PROGRESS_POLYGONAL);
$ui->setCellAttributes('width=10 height=10');
$ui->setCellCoordinates(4,4);          // square 4x4

Loop to run the progress


do {
    $bar->display();
    if ($bar->getPercentComplete() == 1) {
        break;   // the progress bar has reached 100%
    }
    // your user-process should be put HERE !
    $bar->incValue();
} while(1);


[Top]

 Render options

Here are options to build this progress bar string (percent text info):
valign = left
align  = center
HTML_Progress_UI::setStringAttributes()
Here are options to build the progress bar cells :
width  = 10
height = 10
HTML_Progress_UI::setCellAttributes()

[Top]

 Output

Screenshot

[Top]

 Play full example

Run the script below :


<?php 
require_once 'HTML/Progress.php';

$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(10);

$ui =& $bar->getUI();
$ui->setStringAttributes('valign=left align=center');
$ui->setFillWay('reverse');
$ui->setOrientation(HTML_PROGRESS_POLYGONAL);
$ui->setCellAttributes('width=10 height=10');
$ui->setCellCoordinates(4,4);          // square 4x4
?>
<html>
<head>
<title>Reverse Square Progress example</title>
<style type="text/css">
<!--
<?php echo $bar->getStyle(); ?>
// -->
</style>
<script type="text/javascript">
<!--
<?php echo $ui->getScript(); ?>
//-->
</script>
</head>
<body>

<?php 
echo $bar->toHtml(); 

do {
    $bar->display();
    if ($bar->getPercentComplete() == 1) {
        break;   // the progress bar has reached 100%
    }
    $bar->incValue();
} while(1);

?>

</body>
</html>
href:  ./squareback.php

[Top]