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.


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/watobo/gui/progress_window.rb', line 70

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


95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/watobo/gui/progress_window.rb', line 95

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


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

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

#job=(new_job) ⇒ Object


54
55
56
57
58
# File 'lib/watobo/gui/progress_window.rb', line 54

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

#task=(new_task) ⇒ Object


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

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

#title=(new_title) ⇒ Object


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

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

#total=(x) ⇒ Object


32
33
34
35
36
# File 'lib/watobo/gui/progress_window.rb', line 32

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

#UNUSED_progress=(x) ⇒ Object


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

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

#update_progress(settings = {}) ⇒ Object


60
61
62
63
64
65
66
67
68
# File 'lib/watobo/gui/progress_window.rb', line 60

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