HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next

setStringPainted Manual

determines whether the progress bar should render a progress string

by by Laurent Laville
mailto:pear@laurent-laville.org
November 2003, Laurent Laville
(HTML_Progress 1.0+)

Synopsis

void setStringPainted( $paint )

Attributes

Name Type Default
paint  boolean   false | [ true ]  

Description

The setStringPainted() method is used to decide whether the progress bar should paint its string or not. The default value is false: the progress bar displays the value returned by HTML_Progress::getPercentComplete() method formatted as a percent such as 33%.

Example

Example below will produced a progress bar with a custom string. It's a dynamic example, the progress bar will run.

  1. <?php 
  2. require_once ('HTML/Progress.php');
  3.  
  4. $bar = new HTML_Progress();
  5. $bar->setAnimSpeed(100);
  6. $bar->setIncrement(5);
  7. $bar->setStringPainted(true);          // get space for the string
  8. $bar->setString('');                   // but don't paint it
  9.  
  10. $ui =$bar->getUI();
  11. $ui->setStringAttributes('width=350 align=left');
  12.  
  13. ?>
  14. <!DOCTYPE html
  15.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  16.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  17.  
  18. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  19. <head>
  20. <title>Horizontal String ProgressBar example</title>
  21. <style type="text/css">
  22. <!--
  23. <?php echo $bar->getStyle()?>
  24. // -->
  25. </style>
  26. <script type="text/javascript">
  27. <!--
  28. <?php echo $bar->getScript()?>
  29. //-->
  30. </script>
  31. </head>
  32. <body>
  33.  
  34. <?php 
  35. echo $bar->toHtml()
  36.  
  37. $pkg = array('PEAR''Archive_Tar''Config'
  38.     'HTML_QuickForm''HTML_CSS''HTML_Page''HTML_Template_Sigma'
  39.     'Log''MDB''PHPUnit');
  40.  
  41. do {
  42.     $val $bar->getValue();
  43.     $i floor($val / 10);
  44.     $msg ($val == 100'' : "&nbsp; installing package ($val %) ... : ".$pkg[$i];
  45.     $bar->setString($msg);
  46.  
  47.     $bar->display();
  48.     if ($bar->getPercentComplete(== 1{
  49.         break;   // the progress bar has reached 100%
  50.     }
  51.     $bar->incValue();
  52. while(1);
  53. ?>
  54.  
  55. </body>
  56. </html>

See Also

Take care that setStringPainted() method is not enough to display a custom string. You should also set the value of this custom string. To do it see setString Manual.

Prev   Next
setScript Manual setBorderPainted Manual

Documentation generated on Mon, 11 Mar 2019 10:15:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.