__s32 boot_ui_progressbar_upgrate(__hdle p, int rate) { progressbar_t *progress = (progressbar_t *)p; int base_color, progresscolor; int pixel; int x1, y1; int x2, y2; if((rate < 0) || (rate > 100)) { __inf("boot ui progressbar: invalid progressbar rate\n"); return -1; } if(!p) { __inf("boot ui progressbar: invalid progressbar pointer\n"); return -1; } pixel = (rate * (progress->width - progress->thick*2)/100); if(rate == progress->progress_ratio) { return 0; } else { x1 = progress->pr_x; x2 = progress->st_x + pixel; progresscolor = (rate > progress->progress_ratio)?(progress->progress_color):(UI_BOOT_GUI_BLACK); progress->pr_x = x2; progress->progress_ratio = rate; } base_color = boot_ui_get_color(); boot_ui_set_color(progresscolor); y1 = progress->y1 + progress->thick; y2 = progress->y2 - progress->thick; boot_ui_draw_solidrectangle(x1, y1, x2, y2); boot_ui_set_color(base_color); wlibc_FlushDCacheRegion(ui_source.screen_buf,ui_source.screen_width*ui_source.screen_height*4); return 0; }
__s32 boot_ui_progressbar_destroy(__hdle p) { progressbar_t *progress = (progressbar_t *)p; int base_color; if(!p) { return -1; } base_color = boot_ui_get_color(); boot_ui_set_color(UI_BOOT_GUI_BLACK); boot_ui_draw_solidrectangle(progress->x1, progress->y1, progress->x2, progress->y2); boot_ui_set_color(base_color); wBoot_free(progress); return 0; }
__s32 boot_ui_progressbar_active(__hdle p) { int base_color; int i; progressbar_t *progress = (progressbar_t *)p; if(!p) { return -1; } base_color = boot_ui_get_color(); boot_ui_set_color(progress->frame_color); for(i=0; i<progress->thick; i++) { boot_ui_draw_hollowrectangle(progress->x1+i, progress->y1+i, progress->x2-i, progress->y2-i); } boot_ui_set_color(base_color); wlibc_FlushDCacheRegion(ui_source.screen_buf,ui_source.screen_width*ui_source.screen_height*4); return 0; }
void boot_ui_printf( const char * str, ...) { int base_color; char string[32]; char *p; __s32 hex_flag ; va_list argp; va_start( argp, str ); base_color = boot_ui_get_color(); base_color &= 0xffffff; boot_ui_set_color(base_color); if(change_line == 1) { if(uichar_change_newline()) { __inf("boot ui char: unable to change to one new line\n"); goto boot_ui_print_err; } wBoot_timer_delay(10); change_line = 0; } while( *str ) { if( *str == '%' ) { ++str; p = string; hex_flag = 'X'; switch( *str ) { case 'u': case 'd': { int_to_string_dec( va_arg( argp, __s32 ), string ); if(uichar_putstr( p, 32 )) { goto boot_ui_print_err; } ++str; break; } case 'x': hex_flag = 'x'; // jump to " case 'X' " case 'p': case 'X': { int_to_string_hex( va_arg( argp, __s32 ), string, hex_flag ); if(uichar_putstr( p , 32)) { goto boot_ui_print_err; } ++str; break; } case 'c': { if(uichar_putchar( va_arg( argp, __s32 ) )) { goto boot_ui_print_err; } ++str; break; } case 's': { if(uichar_putstr( va_arg( argp, char * ), 32 )) { goto boot_ui_print_err; } ++str; break; } default : { if(uichar_putchar( '%' )) // if current character is not Conversion Specifiers 'dxpXucs', { goto boot_ui_print_err; } if(uichar_putchar( *str )) // output directly '%' and current character, and then { goto boot_ui_print_err; } ++str; // let 'str' point to next character. } } } else { if( *str == '\n' ) // if current character is '\n', insert and output '\r'