class MyRendererDuration
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
pc[RW]
Public Class Methods
new(pc)
click to toggle source
Calls superclass method
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 7 def initialize(pc) @pc=pc super(4,2) attach_defaults(Gtk::Label.new("day"),0,1,0,1) attach_defaults(Gtk::Label.new("hour"),1,2,0,1) attach_defaults(Gtk::Label.new("min"),2,3,0,1) attach_defaults(Gtk::Label.new("sec"),3,4,0,1) attach_defaults(@dw=Gtk::SpinButton.new(0,5*365,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0),0,1,1,2) attach_defaults(@hw=Gtk::SpinButton.new(0,23,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0),1,2,1,2) attach_defaults(@mw=Gtk::SpinButton.new(0,59,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0),2,3,1,2) attach_defaults(@sw=Gtk::SpinButton.new(0,59,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0),3,4,1,2) @sw.signal_connect('value_changed'){|me| changed} @mw.signal_connect('value_changed'){|me| changed} @hw.signal_connect('value_changed'){|me| changed} @dw.signal_connect('value_changed'){|me| changed} end
Public Instance Methods
changed()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 63 def changed edebug("#{self} changed to #{wg_to_duration}","form","debug") pc.changed pc.notify_observers(self) edebug("#{self} emiting 'changed' to observers","form","debug") run_events(item['id'],'form_item-Action') end
duration_to_wg(d)
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 42 def duration_to_wg(d) d,r=(d.to_f).divmod(24*3600) h,r=(r).divmod(3600) m,s=(r).divmod(60) @dw.set_value(d) @hw.set_value(h) @mw.set_value(m) @sw.set_value(s.round) end
item()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 26 def item @pc.item end
parentM()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 60 def parentM @pc.parentM end
parentselected()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 56 def parentselected @pc.parentselected end
text()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 52 def text wg_to_duration.to_s end
to_s()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 70 def to_s;"Duration(#{item["description"]})";end
update(new_value=item['default'])
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 30 def update(new_value=item['default']) item['default']=new_value.to_f run_events(item['id'],'form_item-BeforeUpdate') pc.run_query duration_to_wg(item['default'].to_f) if item['default'] # set_sensitive(item['editable']=="true") run_events(item['id'],'form_item-AfterUpdate') end
wg_to_duration()
click to toggle source
# File lib/FormHolder/Form/InputHolder/Duration.rb, line 39 def wg_to_duration (@dw.value*24*3600+@hw.value*3600+@mw.value*60+@sw.value).round end