#ifdef __KERNEL__ #include #include #else #include #endif #include "progbar.h" void DrawProgress( tGC *pGC, tRect *barrect, int percent, const char *addtext ) { int thick = 2; tRect rect = { {0,0},{0,0} }; tRect rect2= { {0,0},{0,0} }; tRect textrect = { {0,0},{0,0} }; char text[256]; const char *p; #if 1 tColor tcol = SetColorRGB(0xa8,0xa8,0xa8); tColor fg = SetColorRGB(0x1a,0x1a,0x4b); //tColor fg = SetColorRGB(0x9d,0x83,0x3c); //9d833c tColor bg = SetColorRGB(0x30,0x57,0x84); #else tColor tcol = SetColorRGB(239,239,239); tColor fg = SetColorRGB(200,200, 16); tColor bg = SetColorRGB( 16, 16, 16); #endif if( percent<0 ) percent= 0; if( percent>100 ) percent=100; p = addtext; if( !p ) { sprintf( text, "%d%%",percent); p = text; } GSetFont( pGC,1 ); GTextRect( pGC, &textrect, p ); ExtendRect( &rect, barrect, 0 ); CenterRect( &textrect, &rect ); do { GSetFGColor( pGC, tcol ); GDrawRect(pGC,&rect); ExtendRect( &rect, &rect, -1 ); } while(thick--); thick=4; do { GSetFGColor( pGC, bg ); GDrawRect(pGC,&rect); ExtendRect( &rect, &rect, -1 ); } while(thick--); GRasterMode(pGC,0); /* remember rect */ ExtendRect( &rect2, &rect, 0 ); thick = rect.BottomRight.x - rect.UpperLeft.x; thick = thick * percent / 100; rect.BottomRight.x = rect.UpperLeft.x + thick; rect2.UpperLeft.x = rect.BottomRight.x+1; /* percent rectangle (left) */ GSetBGColor(pGC,fg); GSetFGColor(pGC,fg); GFillRect(pGC,&rect); /* rest rectangle (right) */ if( rect2.UpperLeft.x <= rect2.BottomRight.x) { GSetBGColor(pGC,bg); GSetFGColor(pGC,fg); GFillRect(pGC,&rect2); } GRasterMode(pGC,GC_ROP_XOR); GSetFGColor(pGC,tcol); GDrawText(pGC,&textrect,p); }