1#
2#  tkextlib/tcllib/datefield.rb
3#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4#
5#   * Part of tcllib extension
6#   * Tk datefield widget
7#
8# (The following is the original description of the library.)
9#
10# The datefield package provides the datefield widget which is an enhanced
11# text entry widget for the purpose of date entry. Only valid dates of the
12# form MM/DD/YYYY can be entered.
13#
14# The datefield widget is, in fact, just an entry widget with specialized
15# bindings. This means all the command and options for an entry widget apply
16# equally here.
17
18require 'tk'
19require 'tk/entry'
20require 'tkextlib/tcllib.rb'
21
22# TkPackage.require('datefield', '0.1')
23TkPackage.require('datefield')
24
25module Tk
26  module Tcllib
27    class Datefield < Tk::Entry
28      PACKAGE_NAME = 'datefield'.freeze
29      def self.package_name
30        PACKAGE_NAME
31      end
32
33      def self.package_version
34        begin
35          TkPackage.require('datefield')
36        rescue
37          ''
38        end
39      end
40    end
41    DateField = Datefield
42  end
43end
44
45class Tk::Tcllib::Datefield
46  TkCommandNames = ['::datefield::datefield'.freeze].freeze
47
48  def create_self(keys)
49    if keys and keys != None
50      tk_call_without_enc(self.class::TkCommandNames[0], @path,
51                          *hash_kv(keys, true))
52    else
53      tk_call_without_enc(self.class::TkCommandNames[0], @path)
54    end
55  end
56  private :create_self
57end
58