Sha256: 36d11a01cc50c671abe988c13402b2c7448df621e302a628937415268d407b73

Contents?: true

Size: 1.93 KB

Versions: 30

Compression:

Stored size: 1.93 KB

Contents

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
begin
  require 'rubygems' 
rescue LoadError
end
require 'wx'
require 'date'

class TestPanel < Wx::Panel
  attr_reader :cal

  def initialize(parent, id, log)
    super(parent, id)
    @log = log
    
    date = DateTime.now
    @cal = Wx::CalendarCtrl.new(self, :date => date, :pos => [ 25, 50 ], 
                                :style => Wx::CAL_SHOW_HOLIDAYS| 
                                          Wx::CAL_SUNDAY_FIRST| 
                                          Wx::CAL_SEQUENTIAL_MONTH_SELECTION)
    
    evt_calendar cal, :on_cal_selected
    # Set up control to display a set of holidays:
    evt_calendar_month cal, :on_change_month
    @holidays = [ [1,1], [10,31], [12,25] ] #(these don't move around)
  end
  def on_cal_selected(event)
    @log.write_text( "on_cal_selected: " + event.date.strftime("%F") )
  end
  
  # missing get_current_month() method
  def on_change_month(event)
    #~ cur_month = @cal.get_date().get_current_month() + 1
    #~ @holidays.each do |date|
    #~ if date[0] == cur_month
    #~ @cal.set_holiday(date[1])
    #~ end
    #~ end
    event.skip()
  end
end

module Demo
  def Demo.run(frame, nb, log)
    win = TestPanel.new(nb, -1, log)
    return win
  end

  def Demo.overview
    return "The calendar control allows the user to pick a date interactively. For this, it displays a window containing several parts: the control to pick the month and the year at the top (either or both of them may be disabled) and a month area below them which shows all the days in the month. The user can move the current selection using the keyboard and select the date (generating EVT_CALENDAR event) by pressing <Return> or double clicking it."
  end
end

if __FILE__ == $0
  run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
  load run_solo_lib
  run File.basename($0)
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
wxruby-ruby19-2.0.1-x86-mingw32 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-ruby19-2.0.1-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-ruby19-2.0.1-x86-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-2.0.1-x86-mingw32 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-2.0.1-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-2.0.1-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.10-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.10-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.10-x86_64-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.10-x86-mingw32 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.6-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.6-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.7-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.7-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.8-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.8-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.8-x86_64-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.9-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby-1.9.9-x86-linux samples/bigdemo/wxCalendarCtrl.rbw
wxruby-2.0.0-universal-darwin-9 samples/bigdemo/wxCalendarCtrl.rbw