Class: Watobo::Gui::ProgressWindow

Inherits:
FXTopWindow
  • Object
show all
Defined in:
lib/watobo/gui/progress_window.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, opts = {}) ⇒ ProgressWindow

Returns a new instance of ProgressWindow.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/watobo/gui/progress_window.rb', line 58

def initialize(owner, opts={})
  super( owner, 'Progress Bar', nil, nil, DECOR_BORDER, 0, 0, 300, 100, 0, 0, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
  @update_lock = Mutex.new

  @title_lbl = FXLabel.new(frame, "title")
  @title_lbl.setFont(FXFont.new(getApp(), "helvetica", 12, FONTWEIGHT_BOLD, FONTSLANT_ITALIC, FONTENCODING_DEFAULT))

  @task_lbl = FXLabel.new(frame, "task")

  @pbar = FXProgressBar.new(frame, nil, 0, LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK|PROGRESSBAR_HORIZONTAL)

  @job_lbl = FXLabel.new(frame, "job")

  @pbar.progress = 0
  @pbar.total = 100
  @increment = 0
  @total = 100
  @title = "-"
  @job = "-"
  @task = "-"

  add_update_timer(50)
end

Instance Method Details

#add_update_timer(ms) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/watobo/gui/progress_window.rb', line 83

def add_update_timer(ms)
  @update_timer = FXApp.instance.addTimeout( ms, :repeat => true) {
    @update_lock.synchronize do
      @title_lbl.text = @title
      @task_lbl.text = @task
      @job_lbl.text = @job

      @pbar.increment(@increment)
      @increment = 0
      @pbar.total = @total
    # @pbar.progress = settings[:progress] unless settings[:progress].nil?
    end
  }
end

#increment(x) ⇒ Object



14
15
16
17
18
# File 'lib/watobo/gui/progress_window.rb', line 14

def increment(x)
  @update_lock.synchronize do
    @increment += x
  end
end

#job=(new_job) ⇒ Object



42
43
44
45
46
# File 'lib/watobo/gui/progress_window.rb', line 42

def job=(new_job)
  @update_lock.synchronize do
    @job = new_job
  end
end

#task=(new_task) ⇒ Object



36
37
38
39
40
# File 'lib/watobo/gui/progress_window.rb', line 36

def task=(new_task)
  @update_lock.synchronize do
    @task = new_task
  end
end

#title=(new_title) ⇒ Object



30
31
32
33
34
# File 'lib/watobo/gui/progress_window.rb', line 30

def title=(new_title)
  @update_lock.synchronize do
    @title = new_title
  end
end

#total=(x) ⇒ Object



20
21
22
23
24
# File 'lib/watobo/gui/progress_window.rb', line 20

def total=(x)
  @update_lock.synchronize do
    @total = x
  end
end

#UNUSED_progress=(x) ⇒ Object



26
27
28
# File 'lib/watobo/gui/progress_window.rb', line 26

def UNUSED_progress=(x)
  @pbar.progress = x
end

#update_progress(settings = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/watobo/gui/progress_window.rb', line 48

def update_progress(settings={})
  @update_lock.synchronize do
    @total = settings[:total] unless settings[:total].nil?
    @title = settings[:title] unless settings[:title].nil?
    @task = settings[:task] unless settings[:task].nil?
    @job = settings[:job] unless settings[:job].nil?
    @increment += settings[:increment] unless settings[:increment].nil?
  end
end