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

setStringAttributes Manual

defines look and feel of the progress bar string

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

Synopsis

void setStringAttributes( $attributes )

Attributes

Name Type Default
attributes  array  
  • id => installationProgress   
  • width => 50   
  • font-family => Verdana, Arial, Helvetica, sans-serif   
  • font-size => 12   
  • color => #000000   
  • background-color => #FFFFFF   
  • align => right ( left, center )   
  • for horizontal bar:   
    • valign => right (left, top, bottom)   
  • for vertical bar:   
    • valign => bottom (top, left, right)   

$attributes is an associative array or string of HTML tag attributes.

Description

The setStringAttributes() method is used to give a look and feel, such as alignment, size and color, to the progress bar string.

You may also used an existing StyleSheet and a CSS id with pre-defined style. For example:

  1. <?php
  2. require_once ('HTML/Progress.php');
  3.  
  4. $bar = new HTML_Progress();
  5. // specify a user-ident (instead of the auto-generated value)
  6. $bar->setIdent('myPB');
  7. $bar->setStringPainted(true);
  8.  
  9. $ui =$bar->getUI();
  10. $ui->setStringAttributes('id="myPBstring"');
  11. ...
  12. ?>
<!-- custom stylesheet -->
...
.myPB .myPBstring { width: 100px; background-color: lightyellow; color: black; }
...
   

Example

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

  1. <?php
  2. require_once ('HTML/Progress.php');
  3.  
  4. $bar = new HTML_Progress();
  5. $bar->setValue(50);
  6. $bar->setBorderPainted(true);
  7.  
  8. $ui =$bar->getUI();
  9. $ui->setFillWay('reverse');
  10. $ui->setCellCount(5);
  11. $ui->setCellAttributes('active-color=#970038 inactive-color=#FFDDAA width=20');
  12. $ui->setBorderAttributes('width=1 color=#000000');
  13. $ui->setStringAttributes('font-size=14 color=#FF0000 align=left valign=bottom');
  14.  
  15. ?>
  16. <!DOCTYPE html
  17.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  18.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  19.  
  20. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  21. <head>
  22. <title>Progress example</title>
  23. <style type="text/css">
  24. <!--
  25. <?php echo $bar->getStyle()?>
  26. // -->
  27. </style>
  28. <script type="text/javascript">
  29. <!--
  30. <?php echo $ui->getScript()?>
  31. //-->
  32. </script>
  33. </head>
  34. <body>
  35.  
  36. <?php 
  37. echo $bar->toHtml()
  38. $bar->display();
  39. ?>
  40.  
  41. </body>
  42. </html>

See Also

To display the progress bar string, take care that method in setStringPainted Manual was also invoked.

Prev   Next
setFillWay Manual setString Manual

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