2
/***************************************************************************
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
***************************************************************************/
11
#include "autoprogressbar.h"
13
#include <pgapplication.h>
14
#include "../events.h"
16
#include "../basestrm.h"
18
void AutoProgressBar :: tick()
21
newTickTimes.push_back ( ticker - starttime );
23
// limit to 25 Hz to reduce graphic updates
24
if ( lastdisplaytime + 4 < ticker ) {
26
// double p = double(ticker - starttime) * 100 / time;
27
if ( counter < prevTickTimes.size() && time ) {
28
int a = prevTickTimes[counter];
37
lastdisplaytime = ticker;
43
lastticktime = ticker;
46
AutoProgressBar :: AutoProgressBar( SigC::Signal0<void>& tickSignal, PG_Widget *parent, const PG_Rect &r, const std::string &style ) : PG_ProgressBar( parent, r, style ), lastticktime(-1), counter(0)
48
lastdisplaytime = starttime = ticker;
50
tickSignal.connect( SigC::slot( *this, &AutoProgressBar::tick ));
53
tnfilestream stream ( "progress.dat", tnstream::reading );
54
stream.readInt(); // version
55
time = stream.readInt( );
56
readClassContainer( prevTickTimes, stream );
63
void AutoProgressBar :: close( )
66
tnfilestream stream ( "progress.dat", tnstream::writing );
68
stream.writeInt( lastticktime - starttime );
69
writeClassContainer( newTickTimes, stream );