File: tk/entry.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Tk
  class: Entry#10
includes
  X_Scrollable ( Unknown-Module )
  TkValidation   
inherits from
  Label ( Tk )
has properties
constant: TkCommandNames #14
constant: WidgetClassName #15
method: __strval_optkeys #23
method: bbox / 1 #28
method: cursor #31
alias: icursor cursor #34
method: cursor= / 1 #35
alias: icursor= cursor #40
method: index / 1 #41
method: insert / 2 #44
method: delete / 2 #48
method: mark / 1 #52
method: dragto / 1 #56
method: selection_adjust / 1 #60
method: selection_clear #64
method: selection_from / 1 #68
method: selection_present #72
method: selection_range / 2 #75
method: selection_to / 1 #79
method: invoke_validate #84
method: validate / 1 #87
method: value #95
method: value= / 1 #98
alias: get value #103
alias: set value #104
method: [] / 1 #106
method: []= / 1 #109

Class Hierarchy

Object ( Builtin-Module )
TkKernel
TkObject
TkWindow
Label ( Tk )
  Entry    #10

Code

   1  #
   2  #               tk/entry.rb - Tk entry classes
   3  #                       by Yukihiro Matsumoto <matz@caelum.co.jp>
   4 
   5  require 'tk'
   6  require 'tk/label'
   7  require 'tk/scrollable'
   8  require 'tk/validation'
   9 
  10  class Tk::Entry<Tk::Label
  11    include X_Scrollable
  12    include TkValidation
  13 
  14    TkCommandNames = ['entry'.freeze].freeze
  15    WidgetClassName = 'Entry'.freeze
  16    WidgetClassNames[WidgetClassName] = self
  17 
  18    #def create_self(keys)
  19    #  super(__conv_vcmd_on_hash_kv(keys))
  20    #end
  21    #private :create_self
  22 
  23    def __strval_optkeys
  24      super() + ['show', 'disabledbackground', 'readonlybackground']
  25    end
  26    private :__strval_optkeys
  27 
  28    def bbox(index)
  29      list(tk_send_without_enc('bbox', index))
  30    end
  31    def cursor
  32      number(tk_send_without_enc('index', 'insert'))
  33    end
  34    alias icursor cursor
  35    def cursor=(index)
  36      tk_send_without_enc('icursor', index)
  37      #self
  38      index
  39    end
  40    alias icursor= cursor=
  41    def index(idx)
  42      number(tk_send_without_enc('index', idx))
  43    end
  44    def insert(pos,text)
  45      tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
  46      self
  47    end
  48    def delete(first, last=None)
  49      tk_send_without_enc('delete', first, last)
  50      self
  51    end
  52    def mark(pos)
  53      tk_send_without_enc('scan', 'mark', pos)
  54      self
  55    end
  56    def dragto(pos)
  57      tk_send_without_enc('scan', 'dragto', pos)
  58      self
  59    end
  60    def selection_adjust(index)
  61      tk_send_without_enc('selection', 'adjust', index)
  62      self
  63    end
  64    def selection_clear
  65      tk_send_without_enc('selection', 'clear')
  66      self
  67    end
  68    def selection_from(index)
  69      tk_send_without_enc('selection', 'from', index)
  70      self
  71    end
  72    def selection_present()
  73      bool(tk_send_without_enc('selection', 'present'))
  74    end
  75    def selection_range(s, e)
  76      tk_send_without_enc('selection', 'range', s, e)
  77      self
  78    end
  79    def selection_to(index)
  80      tk_send_without_enc('selection', 'to', index)
  81      self
  82    end
  83 
  84    def invoke_validate
  85      bool(tk_send_without_enc('validate'))
  86    end
  87    def validate(mode = nil)
  88      if mode
  89        configure 'validate', mode
  90      else
  91        invoke_validate
  92      end
  93    end
  94 
  95    def value
  96      _fromUTF8(tk_send_without_enc('get'))
  97    end
  98    def value= (val)
  99      tk_send_without_enc('delete', 0, 'end')
 100      tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
 101      val
 102    end
 103    alias get value
 104    alias set value=
 105 
 106    def [](*args)
 107      self.value[*args]
 108    end
 109    def []=(*args)
 110      val = args.pop
 111      str = self.value
 112      str[*args] = val
 113      self.value = str
 114      val
 115    end
 116  end
 117 
 118  #TkEntry = Tk::Entry unless Object.const_defined? :TkEntry
 119  Tk.__set_toplevel_aliases__(:Tk, Tk::Entry, :TkEntry)