/home/jonas/tidevel/adt/Advanced Dialogs/source/ProgressBar.c

00001 /*
00002         Advanved Dialogs v1.05
00003         Copyright (C) 2005-2007 Jonas Gehring
00004 
00005         Advanced Dialogs is free software; you can redistribute it and/or modify
00006         it under the terms of the GNU Lesser General Public License as published by
00007         the Free Software Foundation; either version 2 of the License, or
00008         (at your option) any later version.
00009 
00010         Advanced Dialogs is distributed in the hope that it will be useful,
00011         but WITHOUT ANY WARRANTY; without even the implied warranty of
00012         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013         GNU Lesser General Public License for more details.
00014 
00015         You should have received a copy of the GNU Lesser General Public License
00016         along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 // C Source File
00021 // Created 29.08.2005; 22:57:55
00022 
00023 
00024 #include <extgraph.h>                                                   // ExtGraph by TI-Chess Team
00025 
00026 #include "AdvDialogs.h"                                                 // This should be obvious ;)
00027 
00028 
00029 // Progress bar variables
00030 static short progress, psteps;
00031 
00032 
00033 // Progresses the progress bar
00034 void AdvDlgProgressUp(void)
00035 {
00036         if (progress > psteps)
00037         {
00038                 return;
00039         }
00040         
00041         const short CX = (LCD_WIDTH - 160) >> 1;
00042         const short CY = (LCD_HEIGHT - 100) >> 1;
00043 
00044         // On step further
00045         progress++;
00046         
00047         // Draw progress bar
00048         if (36+((90/psteps)*progress)+CX < 125+CX)      
00049                 GrayDrawRect(36+CX, 53+CY, 36+((90/psteps)*progress)+CX, 59+CY, COLOR_BLACK, RECT_FILLED);
00050         else
00051                 GrayDrawRect(36+CX, 53+CY, 125+CX, 59+CY, COLOR_BLACK, RECT_FILLED);
00052 }
00053 
00054 
00055 // Initializes a progress bar
00056 void AdvDlgProgressBar(const char *title, const char *msg, short steps)
00057 {
00058         const short CX = (LCD_WIDTH - 160) >> 1;
00059         const short CY = (LCD_HEIGHT - 100) >> 1;
00060         
00061         // Draw dialog box
00062         GrayDrawRect(30+CX, 37+CY, 130+CX, 70+CY, COLOR_LIGHTGRAY, RECT_FILLED);
00063         GrayDrawRect(30+CX, 30+CY, 130+CX, 37+CY, COLOR_BLACK, RECT_FILLED);
00064         GrayFastDrawLine(31+CX, 71+CY, 131+CX, 71+CY, COLOR_BLACK);
00065         GrayFastDrawLine(131+CX, 31+CY, 131+CX, 71+CY, COLOR_BLACK);
00066 
00067         // Add title
00068         GrayDrawStrExt(0, 31+CY, title, A_XOR | A_CENTERED, F_4x6);
00069         
00070         // Add message
00071         GrayDrawStrExt(TXTSTART+CX, 42+CY, msg, A_NORMAL, F_4x6);
00072         
00073         // Draw progress bar
00074         GrayDrawRect(35+CX, 52+CY, 125+CX, 60+CY, COLOR_BLACK, RECT_EMPTY);
00075         
00076         // Set progress variables
00077         progress = 0;
00078         psteps = steps;
00079 }
00080 
00081 

Generated on Thu Oct 4 19:42:03 2007 for Advanced Dialogs by  doxygen 1.5.1