$Date: 2004/04/18 13:25:43 $
IntroductionThis example will run a horizontal ProgressBar, with limits (min = 0, max = 60) and increment set to 5 in the mathematical model TimerProgress.
The custom string is center aligned at bottom side of the progress bar.
Cells have default size and colors.
[Top]
PHP scriptBuild the progress bar
require_once 'HTML/Progress.php';
class TimerProgress extends HTML_Progress_DM
{
function TimerProgress()
{
$this->HTML_Progress_DM(0,60,5);
}
}
$timer = new TimerProgress();
$bar = new HTML_Progress($timer);
$bar->setAnimSpeed(100);
$bar->setStringPainted(true); // get space for the string
$bar->setString(''); // but don't paint it
$ui =& $bar->getUI();
$ui->setStringAttributes('width=170 height=20 valign=bottom align=center');
Loop to run the progress
do {
$bar->display();
if ($bar->getPercentComplete() == 1) {
$bar->setString('All done!');
$bar->display();
break; // the progress bar has reached 100%
}
if ($bar->getPercentComplete() == 0.25) {
$bar->setString('Fourth part way done!');
}
if ($bar->getPercentComplete() == 0.5) {
$bar->setString('Half way done!');
}
if ($bar->getPercentComplete() == 0.75) {
$bar->setString('Three quarters way done!');
}
$bar->incValue();
} while(1);
[Top]
Render options width = 170 height = 20 valign = bottom align = center
[Top]
Output
[Top]
Play full exampleRun the script below :
<?php
require_once 'HTML/Progress.php';
class TimerProgress extends HTML_Progress_DM
{
function TimerProgress()
{
$this->HTML_Progress_DM(0,60,5);
}
}
$timer = new TimerProgress();
$bar = new HTML_Progress($timer);
$bar->setAnimSpeed(100);
$bar->setStringPainted(true); // get space for the string
$bar->setString(''); // but don't paint it
$ui =& $bar->getUI();
$ui->setStringAttributes('width=170 height=20 valign=bottom align=center');
?>
<html>
<head>
<title>ProgressBar model example</title>
<style type="text/css">
<!--
<?php echo $bar->getStyle(); ?>
// -->
</style>
<script type="text/javascript">
<!--
<?php echo $bar->getScript(); ?>
//-->
</script>
</head>
<body>
<?php
echo $bar->toHtml();
do {
$bar->display();
if ($bar->getPercentComplete() == 1) {
$bar->setString('All done!');
$bar->display();
break; // the progress bar has reached 100%
}
if ($bar->getPercentComplete() == 0.25) {
$bar->setString('Fourth part way done!');
}
if ($bar->getPercentComplete() == 0.5) {
$bar->setString('Half way done!');
}
if ($bar->getPercentComplete() == 0.75) {
$bar->setString('Three quarters way done!');
}
$bar->incValue();
} while(1);
?>
</body>
</html>
[Top]