GPS4Palm

Source Code Documentation


progressbar.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * $RCSfile: progressbar_8c-source.html,v $
00004  *
00005  * Draws a progress bar
00006  *
00007  * created: 2002-12-30
00008  *
00009  * This program is Copyright (C) 12/2002 Matthias Prinke
00010  * <matthias.prinke@surfeu.de> and covered by GNU's GPL.
00011  * In particular, this program is free software and comes WITHOUT
00012  * ANY WARRANTY.
00013  *
00014  * Changes for Palm TX are Copyright (C) 07/2007 Frank Saurbier
00015  * <frank.saurbier@surfeu.de> and covered by GNU's GPL.
00016  * In particular, this program is free software and comes WITHOUT
00017  * ANY WARRANTY.
00018  *
00019  * $Author: mp $
00020  *
00021  * $Date: 2007-10-08 20:40:34 $
00022  *
00023  * $Revision: 1.7.2.1 $
00024  *
00025  * $Log: progressbar_8c-source.html,v $
00025  * Revision 1.7.2.1  2007-10-08 20:40:34  mp
00025  * updated for gps4palm V0.9.5 beta
00025  *
00026  * Revision 1.2.2.1  2007-10-05 22:04:21  mp
00027  * added Frank's changes (NOPROGRESSBAR)
00028  *
00029  * Revision 1.3  2007/07/11 16:00:00  fs
00030  * added NOPROGRESSBAR for testing
00031  *
00032  * Revision 1.2  2004/03/10 17:17:53  mp
00033  * added progressbar.h
00034  *
00035  * Revision 1.1.1.1  2003/07/14 18:59:29  mp
00036  * Imported GPS4Palm to CVS revision control.
00037  *
00038  *
00039  ****************************************************************************/
00040 #include <PalmOS.h>
00041 #include <PalmCompatibility.h>
00042 #include "progressbar.h"
00043 
00044 /*
00045  * progressbar: 
00046  *   Draws a progress bar. The width is fixed to 100 pixels.
00047  *
00048  * Note: progressbar() has to be called with val = 0 initially
00049  *         for proper initialization!
00050  * 
00051  * Parameters:
00052  * -----------
00053  *      ypos    vertical position of progress bar
00054  *      val     current value
00055  *      total   final value (progress = 100%)
00056  */
00057 void progressbar(UInt16 ypos, UInt32 val, UInt32 total)
00058 {
00059 #ifndef NOPROGRESSBAR
00060   static UInt32         inc;    /* increment for progress bar update */
00061   static UInt32         w;      /* bar width */
00062   static UInt32         mod;    /* modulo counter */
00063   RectangleType         rect;   /* rectangle structure */
00064   
00065   if (val == 0) {
00066     /* Initialization */
00067     inc = total / 100;
00068     mod = 0;
00069     w = 0;
00070     RctSetRectangle(&rect, 29 /* xpos */, ypos, 102 /* w */, 4 /* h */);
00071     WinEraseRectangle(&rect, 0 /* corner diameter */);
00072     WinDrawRectangleFrame(simpleFrame, &rect);
00073   } else {
00074     if (mod == inc) {
00075       mod = 0;
00076       w++;
00077       RctSetRectangle(&rect, 30 /* xpos */, ypos+1, w, 2 /* h */);
00078       WinDrawRectangle(&rect, 0 /* corner diameter */);
00079     } else {
00080       mod++;
00081     }
00082   }
00083 #endif
00084 }

Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke