Class: MyRendererCalendar

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

Returns a new instance of MyRendererCalendar.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 7

def initialize(pc)
	@pc=pc
	super()
	set_show_details(true) if respond_to?("set_show_details")
	set_show_week_numbers(true)
	show_day_names=true
	signal_connect("next-year"){|me|
		run_events(item['id'],'form_item-Action')
		pc.changed
		pc.notify_observers(self)
	}
	signal_connect("prev-year"){|me|
		run_events(item['id'],'form_item-Action')
		pc.changed
		pc.notify_observers(self)
	}

	signal_connect("month-changed"){|me|
		run_events(item['id'],'form_item-Action')
		pc.changed
		pc.notify_observers(self)
	}

	signal_connect("day-selected"){|me|
		check_limits
		run_events(item['id'],'form_item-Action')
		pc.changed
		pc.notify_observers(self)
	}
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



37
38
39
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 37

def pc
  @pc
end

Instance Method Details

#check_limitsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 43

def check_limits
	@last_text=item["default"] if @last_text.nil?
	if pc.get_min and pc.get_min > text
		tell_exception("min:#{pc.get_min}")
		set_text(@last_text)
		return false
	end
	if pc.get_max and pc.get_max < text
		tell_exception("max:#{pc.get_max}")
		set_text(@last_text)
		return false
	end
	@last_text=text
	return true
end

#itemObject



39
40
41
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 39

def item
	pc.item
end

#parentMObject



97
98
99
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 97

def parentM
	pc.parentM
end

#parentselectedObject



93
94
95
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 93

def parentselected
	pc.parentselected
end

#set_text(t) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 64

def set_text(t)
	if t != nil
		tt=t.split(" ")
		if tt[0] != nil
			f=tt[0].split('-')
			if f[0].nil? or f[0].to_i==0
				f[0]=Time.now.year
				f[1]=Time.now.month
				f[2]=Time.now.day
			end

			set_year(f[0].to_i) if f[0]
			set_month(f[1].to_i-1) if f[1]
			if f[2]
				set_day(f[2].to_i)
				mark_day(f[2].to_i)
			end
		end
	end
end

#textObject



59
60
61
62
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 59

def text
	d=self.date
	return lzero(d[0],4).to_s+"-"+lzero(d[1],2).to_s+"-"+lzero(d[2],2).to_s
end

#update(new_value = ) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/FormHolder/Form/InputHolder/Calendar.rb', line 85

def update(new_value=item['default'])
	item['default']=new_value
	run_events(item['id'],'form_item-BeforeUpdate')
	pc.run_query
	set_text(item['default']) if item['default']
	run_events(item['id'],'form_item-AfterUpdate')
end