int BC_ProgressBar::draw(int force, int flush) { char string[32]; int new_pixel; new_pixel = (int)(((float)position / length) * get_w()); if(new_pixel != pixel || force) { pixel = new_pixel; // Clear background draw_top_background(parent_window, 0, 0, get_w(), get_h()); draw_3segmenth(0, 0, pixel, 0, get_w(), images[PROGRESS_HI]); draw_3segmenth(pixel, 0, get_w() - pixel, 0, get_w(), images[PROGRESS_UP]); if(do_text) { set_font(MEDIUMFONT); set_color(get_resources()->progress_text); // draw decimal percentage sprintf(string, "%d%%", (int)(100 * (float)position / length + 0.5 / w)); draw_center_text(w / 2, h / 2 + get_text_ascent(MEDIUMFONT) / 2, string); } flash(flush); } return 0; }
int BC_Title::draw(int flush) { int i, j, x, y; // Fix background for block fonts. // This should eventually be included in a BC_WindowBase::is_blocked_font() if(font == MEDIUM_7SEGMENT) { //leave it up to the theme to decide if we need a background or not. if (top_level->get_resources()->draw_clock_background) { BC_WindowBase::set_color(get_bg_color()); draw_box(0, 0, w, h); } } else draw_top_background(parent_window, 0, 0, w, h); set_font(font); BC_WindowBase::set_color(color); int text_len = strlen(text); j = 0; x = 0; y = get_text_ascent(font); for(i = 0; i <= text_len; i++) { if(text[i] == '\n' || text[i] == 0) { if(centered) { draw_center_text(get_w() / 2, y, &text[j], i - j); j = i + 1; } else { draw_text(x, y, &text[j], i - j); j = i + 1; } y += get_text_height(font); } } set_font(MEDIUMFONT); // reset flash(flush); return 0; }