2 #include "bcdisplayinfo.h"
3 #include "bcprogress.h"
4 #include "bcprogressbox.h"
5 #include "bcresources.h"
10 BC_ProgressBox::BC_ProgressBox(int x, int y, char *text, int64_t length)
15 // Calculate default x, y
18 BC_DisplayInfo display_info;
19 x = display_info.get_abs_cursor_x();
20 y = display_info.get_abs_cursor_y();
23 pwindow = new BC_ProgressWindow(x, y);
24 pwindow->create_objects(text, length);
28 BC_ProgressBox::~BC_ProgressBox()
33 void BC_ProgressBox::run()
35 int result = pwindow->run_window();
36 if(result) cancelled = 1;
39 int BC_ProgressBox::update(int64_t position, int lock_it)
43 if(lock_it) pwindow->lock_window("BC_ProgressBox::update");
44 pwindow->bar->update(position);
45 if(lock_it) pwindow->unlock_window();
50 int BC_ProgressBox::update_title(char *title, int lock_it)
52 if(lock_it) pwindow->lock_window("BC_ProgressBox::update_title");
53 pwindow->caption->update(title);
54 if(lock_it) pwindow->unlock_window();
58 int BC_ProgressBox::update_length(int64_t length, int lock_it)
60 if(lock_it) pwindow->lock_window("BC_ProgressBox::update_length");
61 pwindow->bar->update_length(length);
62 if(lock_it) pwindow->unlock_window();
67 int BC_ProgressBox::is_cancelled()
72 int BC_ProgressBox::stop_progress()
79 void BC_ProgressBox::lock_window()
81 pwindow->lock_window("BC_ProgressBox::lock_window");
84 void BC_ProgressBox::unlock_window()
86 pwindow->unlock_window();
91 BC_ProgressWindow::BC_ProgressWindow(int x, int y)
92 : BC_Window("Progress",
96 100 + get_resources()->ok_images[0]->get_h(),
103 BC_ProgressWindow::~BC_ProgressWindow()
107 int BC_ProgressWindow::create_objects(char *text, int64_t length)
111 // Recalculate width based on text
114 int text_w = get_text_width(MEDIUMFONT, text);
115 int new_w = text_w + x + 10;
117 if(new_w > get_root_w()) new_w = get_root_w();
120 resize_window(new_w, get_h());
125 add_tool(caption = new BC_Title(x, y, text));
126 y += caption->get_h() + 20;
127 add_tool(bar = new BC_ProgressBar(x, y, get_w() - 20, length));
128 add_tool(new BC_CancelButton(this));