<?php
/******************************************************************
* @version 1.0
* @author : José Augusto Ferreira Franco <hide@address.com>
* @Webname : Webmaster Guto Ferreira
* @link : http://guto.awardspace.com
* @email : hide@address.com
* @notes : free to use this class since it isn´t 4 commercial endings
* email me if you are using this in way to still doing it :)
********************************************************************/
/*
*@ (pt) Definição da classe
*@ (en) class defenition
**/
class ProgressBar{
/*
*@ (pt) método constructor
*@ (en) constructor method
**/
function ProgressBar($annex_on,$hor_pos,$vert_pos,$progress=0,$num_blocks=NULL)
{
return $this->make_bar($annex_on,$hor_pos,$vert_pos,$progress=0,$num_blocks);
}
/*
*@ (pt) constroi a barra de progresso
*@ (en) builds progress bar
**/
function make_bar ($annex,$horiz,$vert,$progress=0,$blocks){
$this->adjust = new GtkAdjustment(0, 0, 100, 1, 0, 0);
$this->bar = new GtkProgressBar($this->adjust);
switch($progress){
case '0':
$this->bar->set_bar_style(0);
break;
case '1':
$this->bar->set_bar_style(1);
$this->bar->set_discrete_blocks($blocks);
break;
default:
return;
}
$this->bar->set_discrete_blocks(10);
$annex->put($this->bar,$horiz,$vert);
Gtk::timeout_add(0, array(&$this,'UpdateBar'));
}
/*
*@ (pt) Actualiza a barra de progresso
*@ (en) Updates progress bar
**/
function UpdateBar(){
global $value;
$value++;
$this->bar->set_value($value);
Gtk::timeout_add(100, array(&$this,'UpdateBar'));
}
/*
*@ (pt) Cria a contagem percentua da progressão
*@ (en) Creates the percentage counting for progression
**/
function Progress($annex_on,$hor,$vert)
{
$this->label = $this->bold_text($annex_on,"0 % Complete",$hor,$vert);
Gtk::timeout_add(0, array(&$this,'UpdateProgress'));
}
/*
*@ (pt) Actualiza a countagem percentual
*@ (en) Updates the percentage
**/
function UpdateProgress()
{
global $percent;
while($percent<100)
{
$percent++;
break;
}
$this->label->set_text($percent." % Complete");
Gtk::timeout_add(100, array(&$this,'UpdateProgress'));
}
/*
*@ (pt) Estiliza o texto na contagem
*@ (en) Adds some style to the text on counting
**/
function bold_text($annex_on,$text,$hor_pos,$ver_pos)
{
$label = &new GTKLabel($text);
$style = &new GTKStyle();
$style->font = gdk::font_load ("-*-arial-bold-r-*-*-*-105-*-*-*-*-*-*");
$label->set_style($style);
$annex_on->put($label,$hor_pos,$ver_pos);
return $label;
}
}
?>