home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / guicast / bcprogressbox.C < prev    next >
C/C++ Source or Header  |  2000-11-29  |  2KB  |  93 lines

  1. #include "bcbutton.h"
  2. #include "bcprogress.h"
  3. #include "bcprogressbox.h"
  4. #include "bctitle.h"
  5. #include "bcwindow.h"
  6.  
  7. BC_ProgressBox::BC_ProgressBox(int x, int y, char *text, long length)
  8.  : Thread()
  9. {
  10.     Thread::synchronous = 1;
  11.     pwindow = new BC_ProgressWindow(x, y);
  12.     pwindow->create_objects(text, length);
  13.     cancelled = 0;
  14. }
  15.  
  16. BC_ProgressBox::~BC_ProgressBox()
  17. {
  18.     delete pwindow;
  19. }
  20.  
  21. void BC_ProgressBox::run()
  22. {
  23.     pwindow->run_window();
  24. }
  25.  
  26. int BC_ProgressBox::update(long position)
  27. {
  28.     if(!cancelled)
  29.     {
  30.         pwindow->lock_window();
  31.         pwindow->bar->update(position);
  32.         pwindow->unlock_window();
  33.     }
  34.     return cancelled;
  35. }
  36.  
  37. int BC_ProgressBox::update_title(char *title)
  38. {
  39.     pwindow->caption->update(title);
  40.     return cancelled;
  41. }
  42.  
  43. int BC_ProgressBox::update_length(long length)
  44. {
  45.     pwindow->bar->update_length(length);
  46.     return cancelled;
  47. }
  48.  
  49.  
  50. int BC_ProgressBox::is_cancelled()
  51. {
  52.     return cancelled;
  53. }
  54.  
  55. int BC_ProgressBox::stop_progress()
  56. {
  57.     pwindow->set_done(0);
  58.     Thread::join();
  59.     return 0;
  60. }
  61.  
  62. void BC_ProgressBox::lock_window()
  63. {
  64.     pwindow->lock_window();
  65. }
  66.  
  67. void BC_ProgressBox::unlock_window()
  68. {
  69.     pwindow->unlock_window();
  70. }
  71.  
  72.  
  73.  
  74. BC_ProgressWindow::BC_ProgressWindow(int x, int y)
  75.  : BC_Window("Progress", x, y, 340, 120, 0, 0, 0)
  76. {
  77. }
  78.  
  79. BC_ProgressWindow::~BC_ProgressWindow()
  80. {
  81. }
  82.  
  83. int BC_ProgressWindow::create_objects(char *text, long length)
  84. {
  85.     int x = 10, y = 10;
  86.     this->text = text;
  87.     add_tool(caption = new BC_Title(x, y, text));
  88.     y += caption->get_h() + 10;
  89.     add_tool(bar = new BC_ProgressBar(x, y, get_w() - 20, length));
  90.     add_tool(new BC_CancelButton(x, y));
  91.     return 0;
  92. }
  93.