1# 2# tkextlib/iwidgets/selectionbox.rb 3# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) 4# 5 6require 'tk' 7require 'tkextlib/iwidgets.rb' 8 9module Tk 10 module Iwidgets 11 class Selectionbox < Tk::Itk::Widget 12 end 13 end 14end 15 16class Tk::Iwidgets::Selectionbox 17 TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze 18 WidgetClassName = 'Selectionbox'.freeze 19 WidgetClassNames[WidgetClassName] ||= self 20 21 def __boolval_optkeys 22 super() << 'itemson' << 'selectionon' 23 end 24 private :__boolval_optkeys 25 26 def __strval_optkeys 27 super() << 'itemslabel' << 'selectionlabel' 28 end 29 private :__strval_optkeys 30 31 def child_site 32 window(tk_call(@path, 'childsite')) 33 end 34 35 def clear_items 36 tk_call(@path, 'clear', 'items') 37 self 38 end 39 40 def clear_selection 41 tk_call(@path, 'clear', 'selection') 42 self 43 end 44 45 def get 46 tk_call(@path, 'get') 47 end 48 49 def insert_items(idx, *args) 50 tk_call(@path, 'insert', 'items', idx, *args) 51 end 52 53 def insert_selection(pos, text) 54 tk_call(@path, 'insert', 'selection', pos, text) 55 end 56 57 def select_item 58 tk_call(@path, 'selectitem') 59 self 60 end 61 62 # based on Tk::Listbox ( and TkTextWin ) 63 def curselection 64 list(tk_send_without_enc('curselection')) 65 end 66 def delete(first, last=None) 67 tk_send_without_enc('delete', first, last) 68 self 69 end 70 def index(idx) 71 tk_send_without_enc('index', idx).to_i 72 end 73 def nearest(y) 74 tk_send_without_enc('nearest', y).to_i 75 end 76 def scan_mark(x, y) 77 tk_send_without_enc('scan', 'mark', x, y) 78 self 79 end 80 def scan_dragto(x, y) 81 tk_send_without_enc('scan', 'dragto', x, y) 82 self 83 end 84 def selection_anchor(index) 85 tk_send_without_enc('selection', 'anchor', index) 86 self 87 end 88 def selection_clear(first, last=None) 89 tk_send_without_enc('selection', 'clear', first, last) 90 self 91 end 92 def selection_includes(index) 93 bool(tk_send_without_enc('selection', 'includes', index)) 94 end 95 def selection_set(first, last=None) 96 tk_send_without_enc('selection', 'set', first, last) 97 self 98 end 99 def size 100 tk_send_without_enc('size').to_i 101 end 102end 103