class MyRendererCalendarButton
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/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
Public Instance Methods
calendar_text()
click to toggle source
# 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_limits()
click to toggle source
# 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
inspect()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 110 def inspect "CalendarButton(#{item['description']})" end
item()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 107 def item pc.item end
parentM()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 100 def parentM pc.parentM end
set_text(t)
click to toggle source
# 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
target()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 104 def target item['to_call'] end
text()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 53 def text label end
to_s()
click to toggle source
# File lib/FormHolder/Form/InputHolder/CalendarButton.rb, line 113 def to_s inspect end
update(new_value=item['default'])
click to toggle source
# 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