class MyRendererCalendar

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/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

Public Instance Methods

check_limits() click to toggle source
# 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
item() click to toggle source
# File lib/FormHolder/Form/InputHolder/Calendar.rb, line 39
def item
      pc.item
end
parentM() click to toggle source
# File lib/FormHolder/Form/InputHolder/Calendar.rb, line 97
def parentM
        pc.parentM
end
parentselected() click to toggle source
# File lib/FormHolder/Form/InputHolder/Calendar.rb, line 93
def parentselected
        pc.parentselected
end
set_text(t) click to toggle source
# 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
text() click to toggle source
# 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=item['default']) click to toggle source
# 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