2
# tkextlib/iwidgets/spinner.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7
require 'tkextlib/iwidgets.rb'
11
class Spinner < Tk::Iwidgets::Labeledwidget
16
class Tk::Iwidgets::Spinner
17
TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
18
WidgetClassName = 'Spinner'.freeze
19
WidgetClassNames[WidgetClassName] = self
21
####################################
23
include Tk::ValidateConfigure
25
class EntryfieldValidate < TkValidateCommand
26
#class CalCmdArgs < TkUtil::CallbackSubst
27
class ValidateArgs < TkUtil::CallbackSubst
36
[ ?s, TkComm.method(:string) ],
37
[ ?w, TkComm.method(:window) ],
40
_setup_subst_table(KEY_TBL, PROC_TBL);
44
['validate', 'invalid']
48
def __validation_class_list
49
super() << EntryfieldValidate
52
Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
54
####################################
57
tk_call_without_enc(@path, 'up')
62
tk_call_without_enc(@path, 'down')
67
tk_call_without_enc(@path, 'clear')
71
def delete(first, last=None)
72
tk_send_without_enc('delete', first, last)
77
_fromUTF8(tk_send_without_enc('get'))
80
tk_send_without_enc('delete', 0, 'end')
81
tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
88
tk_send_without_enc('icursor', index)
95
number(tk_send_without_enc('index', idx))
99
tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
104
tk_send_without_enc('scan', 'mark', pos)
108
tk_send_without_enc('scan', 'dragto', pos)
111
def selection_adjust(index)
112
tk_send_without_enc('selection', 'adjust', index)
116
tk_send_without_enc('selection', 'clear')
119
def selection_from(index)
120
tk_send_without_enc('selection', 'from', index)
123
def selection_present()
124
bool(tk_send_without_enc('selection', 'present'))
126
def selection_range(s, e)
127
tk_send_without_enc('selection', 'range', s, e)
130
def selection_to(index)
131
tk_send_without_enc('selection', 'to', index)
135
# based on tk/scrollable.rb
138
list(tk_send_without_enc('xview'))
140
tk_send_without_enc('xview', *index)
144
def xview_moveto(*index)
145
xview('moveto', *index)
147
def xview_scroll(*index)
148
xview('scroll', *index)