2
# tkextlib/iwidgets/entryfield.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7
require 'tkextlib/iwidgets.rb'
11
class Entryfield < Tk::Iwidgets::Labeledwidget
16
class Tk::Iwidgets::Entryfield
17
TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze
18
WidgetClassName = 'Entryfield'.freeze
19
WidgetClassNames[WidgetClassName] = self
24
private :__font_optkeys
26
####################################
28
include Tk::ValidateConfigure
30
class EntryfieldValidate < TkValidateCommand
31
#class CalCmdArgs < TkUtil::CallbackSubst
32
class ValidateArgs < TkUtil::CallbackSubst
41
[ ?s, TkComm.method(:string) ],
42
[ ?w, TkComm.method(:window) ],
45
_setup_subst_table(KEY_TBL, PROC_TBL);
49
['validate', 'invalid']
53
def __validation_class_list
54
super() << EntryfieldValidate
57
Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
59
def validate(cmd = Proc.new, args = nil)
60
if cmd.kind_of?(ValidateCmd)
61
configure('validate', cmd)
63
configure('validate', [cmd, args])
65
configure('validate', cmd)
69
def invalid(cmd = Proc.new, args = nil)
70
if cmd.kind_of?(ValidateCmd)
71
configure('invalid', cmd)
73
configure('invalid', [cmd, args])
75
configure('invalid', cmd)
80
####################################
83
tk_call(@path, 'clear')
87
def delete(first, last=None)
88
tk_send_without_enc('delete', first, last)
93
_fromUTF8(tk_send_without_enc('get'))
96
tk_send_without_enc('delete', 0, 'end')
97
tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
104
tk_send_without_enc('icursor', index)
108
alias icursor cursor=
111
number(tk_send_without_enc('index', index))
115
tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
120
tk_send_without_enc('scan', 'mark', pos)
124
tk_send_without_enc('scan', 'dragto', pos)
127
def selection_adjust(index)
128
tk_send_without_enc('selection', 'adjust', index)
132
tk_send_without_enc('selection', 'clear')
135
def selection_from(index)
136
tk_send_without_enc('selection', 'from', index)
139
def selection_present()
140
bool(tk_send_without_enc('selection', 'present'))
142
def selection_range(s, e)
143
tk_send_without_enc('selection', 'range', s, e)
146
def selection_to(index)
147
tk_send_without_enc('selection', 'to', index)
151
# based on tk/scrollable.rb
154
list(tk_send_without_enc('xview'))
156
tk_send_without_enc('xview', *index)
160
def xview_moveto(*index)
161
xview('moveto', *index)
163
def xview_scroll(*index)
164
xview('scroll', *index)