Sha256: f6571fd01b7d39e576d743c9cc1469b1e25dd9a8ca041830225fbef01ae65375

Contents?: true

Size: 1.86 KB

Versions: 12

Compression:

Stored size: 1.86 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_page_changed cal, :on_change_page
    @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
  
  def on_change_page(event)
    cur_month = @cal.date.month
    @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

12 entries across 12 versions & 1 rubygems

Version Path
wxruby3-0.9.2 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.1 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.rc.3 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.rc.2 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.rc.1 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.14 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.13 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.11 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.10 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.9 samples/bigdemo/wxCalendarCtrl.rbw
wxruby3-0.9.0.pre.beta.8 samples/bigdemo/wxCalendarCtrl.rbw