📄 bcprogress.c
字号:
#include "bcprogress.h"BC_ProgressBar::BC_ProgressBar(int x_, int y_, int w_, int h_, long length_) : BC_Tool(x_, y_, w_, h_){ length = length_; position = 0; percentage = 0;}BC_ProgressBar::create_tool_objects(){ create_window(x, y, w, h, MEGREY); draw();}BC_ProgressBar::draw(){ static char string[32]; static int real_percentage; draw_3d_big(0, 0, w, h, DKGREY, MEGREY, LTGREY); real_percentage = percentage; if(real_percentage > w - 4) real_percentage = w - 4; if(percentage > 0) draw_3d_big(2, 2, real_percentage, h-4, LTGREEN, GREEN, DKGREEN); set_font(LARGEFONT); set_color(BLACK); // draw decimal percentage sprintf(string, "%d%%", (int)(100 * (float)real_percentage / w)); draw_text(w / 2, 20, string); flash();}BC_ProgressBar::update(long position_){ position = position_; int newpercentage; newpercentage = (int)((float)position / (length ? length : 1) * (w - 4)); if(newpercentage != percentage) { percentage = newpercentage; draw(); }}BC_ProgressBar::update_length(long length){ this->length = length; position = 0; percentage = 0; draw();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -