File: tk/spinbox.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Tk
  class: Spinbox#8
inherits from
  Entry ( Tk )
has properties
constant: TkCommandNames #9
constant: WidgetClassName #10
method: __validation_class_list #70
method: __boolval_optkeys #84
method: __strval_optkeys #89
method: __listval_optkeys #94
method: identify / 2 #99
method: spinup #103
method: spindown #108
method: set / 1 #113
  class: SpinCommand#13
inherits from
  TkValidateCommand   
has properties
class method: _config_keys #65
  class: ValidateArgs#14
inherits from
  CallbackSubst ( TkUtil )
has properties
constant: KEY_TBL #15
constant: PROC_TBL #22
class method: ret_val / 1 #60

Class Hierarchy

Object ( Builtin-Module )
TkKernel
TkObject
TkWindow
Label ( Tk )
Entry ( Tk )
  Spinbox    #8
CallbackSubst ( TkUtil )
TkValidateCommand
  SpinCommand ( Tk::Spinbox ) #13

Code

   1  #
   2  #               tk/spinbox.rb - Tk spinbox classes
   3  #                       by Yukihiro Matsumoto <matz@caelum.co.jp>
   4  #
   5  require 'tk'
   6  require 'tk/entry'
   7 
   8  class Tk::Spinbox<Tk::Entry
   9    TkCommandNames = ['spinbox'.freeze].freeze
  10    WidgetClassName = 'Spinbox'.freeze
  11    WidgetClassNames[WidgetClassName] = self
  12 
  13    class SpinCommand < TkValidateCommand
  14      class ValidateArgs < TkUtil::CallbackSubst
  15        KEY_TBL = [
  16          [ ?d, ?s, :direction ], 
  17          [ ?s, ?e, :current ], 
  18          [ ?W, ?w, :widget ], 
  19          nil
  20        ]
  21 
  22        PROC_TBL = [
  23          [ ?s, TkComm.method(:string) ], 
  24          [ ?w, TkComm.method(:window) ], 
  25 
  26          [ ?e, proc{|val|
  27              #enc = Tk.encoding
  28              enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
  29              if enc
  30                Tk.fromUTF8(TkComm::string(val), enc)
  31              else
  32                TkComm::string(val)
  33              end
  34            }
  35          ], 
  36 
  37          nil
  38        ]
  39 
  40  =begin
  41        # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
  42        KEY_TBL.map!{|inf|
  43          if inf.kind_of?(Array)
  44            inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
  45            inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
  46          end
  47          inf
  48        }
  49 
  50        PROC_TBL.map!{|inf|
  51          if inf.kind_of?(Array)
  52            inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
  53          end
  54          inf
  55        }
  56  =end
  57 
  58        _setup_subst_table(KEY_TBL, PROC_TBL);
  59 
  60        def self.ret_val(val)
  61          (val)? '1': '0'
  62        end
  63      end
  64 
  65      def self._config_keys
  66        ['command']
  67      end
  68    end
  69 
  70    def __validation_class_list
  71      super() << SpinCommand
  72    end
  73 
  74    Tk::ValidateConfigure.__def_validcmd(binding, SpinCommand)
  75 
  76    #def create_self(keys)
  77    #  tk_call_without_enc('spinbox', @path)
  78    #  if keys and keys != None
  79    #    configure(keys)
  80    #  end
  81    #end
  82    #private :create_self
  83 
  84    def __boolval_optkeys
  85      super() << 'wrap'
  86    end
  87    private :__boolval_optkeys
  88 
  89    def __strval_optkeys
  90      super() << 'buttonbackground' << 'format'
  91    end
  92    private :__strval_optkeys
  93 
  94    def __listval_optkeys
  95      super() << 'values'
  96    end
  97    private :__listval_optkeys
  98 
  99    def identify(x, y)
 100      tk_send_without_enc('identify', x, y)
 101    end
 102 
 103    def spinup
 104      tk_send_without_enc('invoke', 'spinup')
 105      self
 106    end
 107 
 108    def spindown
 109      tk_send_without_enc('invoke', 'spindown')
 110      self
 111    end
 112 
 113    def set(str)
 114      _fromUTF8(tk_send_without_enc('set', _get_eval_enc_str(str)))
 115    end
 116  end
 117 
 118  #TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox
 119  Tk.__set_toplevel_aliases__(:Tk, Tk::Spinbox, :TkSpinbox)