PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

User Interface related

setCellCount()

Sets the number of cell in the progress bar

This method accept now zero as minimum value for smooth progress meter. That means that a progress bar with zero cell, will render a full bar as HTML_Progress2_Lite do.

setLabelAttributes(), addLabel()

With HTML_Progress 1.x you might only defines one custom text label. Now with new multiple label system you can do it at infinite. There is no label number limit (except memory).

[Important] Important
You have to define first each label you will put around the progress meter by the addLabel() method, before to set its attributes.

While with HTML_Progress 1.x, you could have a script like this:

  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. ?>

which prepare to render a custom string on right side of the progress bar.

Now with HTML_Progress2, you will have a modified script like:

  1. <?php
  2. require_once 'HTML/Progress2.php';
  3.  
  4. $bar = new HTML_Progress2();
  5. $bar->setAnimSpeed(100);
  6. $bar->setIncrement(5);
  7. $bar->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Simple static text');
  8. $bar->setLabelAttributes('txt1', array(
  9.     'valign' => 'top',
  10.     'left' => 0
  11. ));
  12. // ...
  13. ?>

The percent info will be render alone at right side of the progress bar (default) and we have added a static text label on top side of the same progress bar.

HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007