9 #include "bcprogress.h"
11 #include "bcresources.h"
13 BC_ProgressBar::BC_ProgressBar(int x, int y, int w, int64_t length, int do_text)
14 : BC_SubWindow(x, y, w, 0, -1)
16 this->length = length;
17 this->do_text = do_text;
20 for(int i = 0; i < 2; i++) images[i] = 0;
24 BC_ProgressBar::~BC_ProgressBar()
26 for(int i = 0; i < 2; i++)
27 if (images[i]) delete images[i];
30 int BC_ProgressBar::initialize()
33 h = images[PROGRESS_UP]->get_h();
35 BC_SubWindow::initialize();
40 int BC_ProgressBar::reposition_window(int x, int y, int w, int h)
42 if(w < 0) w = get_w();
43 if(h < 0) h = get_h();
44 BC_WindowBase::reposition_window(x, y, w, h);
48 void BC_ProgressBar::set_do_text(int value)
50 this->do_text = value;
53 int BC_ProgressBar::set_images()
55 for(int i = 0; i < 2; i++)
56 if(images[i]) delete images[i];
58 for(int i = 0; i < 2; i++)
60 images[i] = new BC_Pixmap(parent_window,
61 get_resources()->progress_images[i],
68 int BC_ProgressBar::draw(int force)
73 new_pixel = (int)(((float)position / length) * get_w());
75 if(new_pixel != pixel || force)
79 draw_top_background(parent_window, 0, 0, get_w(), get_h());
80 draw_3segmenth(0, 0, pixel, 0, get_w(), images[PROGRESS_HI]);
81 draw_3segmenth(pixel, 0, get_w() - pixel, 0, get_w(), images[PROGRESS_UP]);
87 set_color(get_resources()->progress_text); // draw decimal percentage
88 sprintf(string, "%d%%", (int)(100 * (float)position / length + 0.5 / w));
89 draw_center_text(w / 2, h / 2 + get_text_ascent(MEDIUMFONT) / 2, string);
96 int BC_ProgressBar::update(int64_t position)
98 this->position = position;
103 int BC_ProgressBar::update_length(int64_t length)
105 this->length = length;
115 // c-file-style: "linux"