1 /*
2   progressbar.h
3 
4   For Tux Paint
5   Progress bar functions
6 
7   Copyright (c) 2002-2006 by Bill Kendrick and others
8   bill@newbreedsoftware.com
9   http://www.newbreedsoftware.com/tuxpaint/
10 
11   This program is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15 
16   This program is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   GNU General Public License for more details.
20 
21   You should have received a copy of the GNU General Public License
22   along with this program; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24   (See COPYING.txt)
25 
26   June 14, 2002 - February 18, 2006
27   $Id$
28 */
29 
30 
31 #include "progressbar.h"
32 #include "debug.h"
33 
34 SDL_Surface *img_progress;
35 int progress_bar_disabled, prog_bar_ctr;
36 
37 
38 /**
39  * Draw & animate (as function is called repeatedly) the progress bar.
40  *
41  * @param screen Screen surface
42  */
show_progress_bar(SDL_Surface * screen)43 void show_progress_bar(SDL_Surface * screen)
44 {
45   SDL_Rect dest, src;
46   int x;
47   static Uint32 oldtime;
48   Uint32 newtime;
49 
50   if (progress_bar_disabled)
51     return;
52 
53   newtime = SDL_GetTicks();
54   if (newtime > oldtime + 15)   // trying not to eat some serious CPU time!
55     {
56       for (x = 0; x < screen->w; x = x + 65)
57         {
58           src.x = 65 - (prog_bar_ctr % 65);
59           src.y = 0;
60           src.w = 65;
61           src.h = 24;
62 
63           dest.x = x;
64           dest.y = screen->h - 24;
65 
66           SDL_BlitSurface(img_progress, &src, screen, &dest);
67         }
68 
69       prog_bar_ctr++;
70 
71       SDL_UpdateRect(screen, 0, screen->h - 24, screen->w, 24);
72     }
73   oldtime = newtime;
74 
75 
76   /* FIXME: RESURRECT THIS (bjk 2006.02.18) */
77   //eat_sdl_events();
78 }
79