Class: MyRendererTimeStamp

Inherits:
Gtk::VBox
  • Object
show all
Includes:
ManqodCommon
Defined in:
lib/FormHolder/Form/InputHolder/TimeStamp.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

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ MyRendererTimeStamp

Returns a new instance of MyRendererTimeStamp.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 7

def initialize(pc)
	@pc=pc
	super()
	pack_start(@calendar=Gtk::Calendar.new)
	pack_start(Gtk::HBox.new.
  	pack_start(@hw=Gtk::SpinButton.new(0,23,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0)).
  	pack_start(@mw=Gtk::SpinButton.new(0,59,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0)).
  	pack_start(@sw=Gtk::SpinButton.new(0,59,1).set_has_frame(false).set_numeric(true).set_increments(1,10).set_digits(0)),
	true,false)
		@sw.signal_connect('value_changed'){|me| changed}
		@mw.signal_connect('value_changed'){|me| changed}
		@hw.signal_connect('value_changed'){|me| changed}
	@calendar.signal_connect("next-year"){|me| changed}
	@calendar.signal_connect("prev-year"){|me| changed}
	@calendar.signal_connect("month-changed"){|me| changed}
	@calendar.signal_connect("day-selected"){|me| changed}

	@calendar.set_show_details(true)
	@calendar.set_show_week_numbers(true)
	@calendar.show_day_names=true
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



28
29
30
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 28

def pc
  @pc
end

Instance Method Details

#changedObject



49
50
51
52
53
54
55
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 49

def changed
		edebug("#{self} changed to #{wg_to_time}","form","debug")
		pc.changed
		pc.notify_observers(self)
		edebug("#{self} emiting 'changed' to observers","form","debug")
		run_events(item['id'],'form_item-Action')
end

#itemObject



30
31
32
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 30

def item
	pc.item
end

#parentMObject



78
79
80
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 78

def parentM
	pc.parentM
end

#parentselectedObject



74
75
76
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 74

def parentselected
	pc.parentselected
end

#set_sensitive(sens) ⇒ Object



34
35
36
37
38
39
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 34

def set_sensitive(sens)
	@calendar.set_sensitive(sens)
	@hw.set_sensitive(sens)
	@mw.set_sensitive(sens)
	@sw.set_sensitive(sens)
end

#textObject



56
57
58
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 56

def text
	wg_to_time.to_s
end

#time_to_wg(d) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 66

def time_to_wg(d)
	t=Time.at(d.to_i)
	@hw.set_value(t.hour)
	@mw.set_value(t.min)
	@sw.set_value(t.sec)
	@calendar.set_year(t.year).set_month(t.month-1).set_day(t.day).mark_day(t.day)
end

#update(new_value = item['default']) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 41

def update(new_value=item['default'])
	new_value=Time.new.to_i if new_value == ""
	item['default']=new_value
	run_events(item['id'],'form_item-BeforeUpdate')
	pc.run_query
	time_to_wg(item['default']) if item['default']
	run_events(item['id'],'form_item-AfterUpdate')
end

#wg_to_timeObject



59
60
61
62
63
64
65
# File 'lib/FormHolder/Form/InputHolder/TimeStamp.rb', line 59

def wg_to_time
	begin
		Time.mktime(@calendar.date[0],@calendar.date[1],@calendar.date[2],@hw.value,@mw.value,@sw.value).to_i
	rescue => err
		eerror(err)
	end
end