Class: MyRendererDuration
- Inherits:
-
Gtk::Table
- Object
- Gtk::Table
- MyRendererDuration
- Includes:
- ManqodCommon
- Defined in:
- lib/FormHolder/Form/InputHolder/Duration.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Constant Summary
Constants included from ManqodCommon
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included from Eprint
Instance Attribute Summary collapse
-
#pc ⇒ Object
Returns the value of attribute pc.
Instance Method Summary collapse
- #changed ⇒ Object
- #duration_to_wg(d) ⇒ Object
-
#initialize(pc) ⇒ MyRendererDuration
constructor
A new instance of MyRendererDuration.
- #item ⇒ Object
- #parentM ⇒ Object
- #parentselected ⇒ Object
- #text ⇒ Object
- #to_s ⇒ Object
- #update(new_value = item['default']) ⇒ Object
- #wg_to_duration ⇒ Object
Methods included from ManqodCommon
#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick
Methods included from Eprint
#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception
Constructor Details
#initialize(pc) ⇒ MyRendererDuration
Returns a new instance of MyRendererDuration.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 |
Instance Attribute Details
#pc ⇒ Object
Returns the value of attribute pc.
24 25 26 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 24 def pc @pc end |
Instance Method Details
#changed ⇒ Object
63 64 65 66 67 68 69 |
# 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) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
26 27 28 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 26 def item @pc.item end |
#parentM ⇒ Object
60 61 62 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 60 def parentM @pc.parentM end |
#parentselected ⇒ Object
56 57 58 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 56 def parentselected @pc.parentselected end |
#text ⇒ Object
52 53 54 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 52 def text wg_to_duration.to_s end |
#to_s ⇒ Object
70 |
# File 'lib/FormHolder/Form/InputHolder/Duration.rb', line 70 def to_s;"Duration(#{item["description"]})";end |
#update(new_value = item['default']) ⇒ Object
30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
39 40 41 |
# 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 |