Class: MyRendererCalendarButton

Inherits:
Gtk::Button
  • Object
show all
Includes:
Conf, ManqodCommon, MyExec
Defined in:
lib/FormHolder/Form/InputHolder/CalendarButton.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 MyExec

#myexec

Methods included from Conf

#get_conf, #load_conf, #save_conf, #set_conf

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

Returns a new instance of MyRendererCalendarButton.



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
37
38
39
40
41
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 9

def initialize(pc)
@pc=pc
super(item['description'])
@calendar_win=Gtk::Window.new(Gtk::Window::POPUP)
@calendar_win.set_modal(true).set_has_frame(false).add(@calendar=Gtk::Calendar.new).set_transient_for(@pc.caller.get_ancestor(Gtk::Window))

@calendar.set_show_details(true) if @calendar.respond_to?("set_show_details")
@calendar.show_day_names=true
@calendar.signal_connect("month-changed"){|me|
	@month_changed=true
}

@calendar.signal_connect("day-selected"){|me|
	run_events(item['id'],'form_item-Action')
	set_label(calendar_text)
	if @month_changed
		@month_changed=false
		else
		@calendar_win.hide
	end
	pc.changed
	pc.notify_observers(self)
}
@calendar.signal_connect("key-release-event"){|me,ev| @calendar_win.hide if ev.keyval == Gdk::Keyval::GDK_KEY_Escape}

signal_connect('clicked'){|me|
	edebug("#{item['default']} clicked","gtk_button")
	x,y=@pc.caller.get_ancestor(Gtk::Window).position
	xd,yd=translate_coordinates(@pc.caller.get_ancestor(Gtk::Window),x,y+allocation.height+allocation.y)
	@calendar_win.move(xd,yd)
	@calendar_win.show_all
}
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



42
43
44
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 42

def pc
  @pc
end

Instance Method Details

#calendar_textObject



57
58
59
60
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 57

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

#check_limitsObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 84

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

#inspectObject



110
111
112
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 110

def inspect
	"CalendarButton(#{item['description']})"
end

#itemObject



107
108
109
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 107

def item
pc.item
end

#parentMObject



100
101
102
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 100

def parentM
pc.parentM
end

#set_text(t) ⇒ Object



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

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

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

#targetObject



104
105
106
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 104

def target
item['to_call']
end

#textObject



53
54
55
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 53

def text
label
end

#to_sObject



113
114
115
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 113

def to_s
	inspect
end

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



44
45
46
47
48
49
50
51
# File 'lib/FormHolder/Form/InputHolder/CalendarButton.rb', line 44

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