2 # tkextlib/iwidgets/selectionbox.rb
3 # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7 require 'tkextlib/iwidgets.rb'
11 class Selectionbox < Tk::Itk::Widget
16 class Tk::Iwidgets::Selectionbox
17 TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze
18 WidgetClassName = 'Selectionbox'.freeze
19 WidgetClassNames[WidgetClassName] = self
22 super() << 'itemson' << 'selectionon'
24 private :__boolval_optkeys
27 super() << 'itemslabel' << 'selectionlabel'
29 private :__strval_optkeys
32 window(tk_call(@path, 'childsite'))
36 tk_call(@path, 'clear', 'items')
41 tk_call(@path, 'clear', 'selection')
49 def insert_items(idx, *args)
50 tk_call(@path, 'insert', 'items', idx, *args)
53 def insert_selection(pos, text)
54 tk_call(@path, 'insert', 'selection', pos, text)
58 tk_call(@path, 'selectitem')
62 # based on Tk::Listbox ( and TkTextWin )
64 list(tk_send_without_enc('curselection'))
66 def delete(first, last=None)
67 tk_send_without_enc('delete', first, last)
71 tk_send_without_enc('index', idx).to_i
74 tk_send_without_enc('nearest', y).to_i
77 tk_send_without_enc('scan', 'mark', x, y)
81 tk_send_without_enc('scan', 'dragto', x, y)
84 def selection_anchor(index)
85 tk_send_without_enc('selection', 'anchor', index)
88 def selection_clear(first, last=None)
89 tk_send_without_enc('selection', 'clear', first, last)
92 def selection_includes(index)
93 bool(tk_send_without_enc('selection', 'includes', index))
95 def selection_set(first, last=None)
96 tk_send_without_enc('selection', 'set', first, last)
100 tk_send_without_enc('size').to_i