1#
2#  tkextlib/iwidgets/selectiondialog.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 Selectiondialog < Tk::Iwidgets::Dialog
12    end
13  end
14end
15
16class Tk::Iwidgets::Selectiondialog
17  TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze
18  WidgetClassName = 'Selectiondialog'.freeze
19  WidgetClassNames[WidgetClassName] ||= self
20
21  def child_site
22    window(tk_call(@path, 'childsite'))
23  end
24
25  def clear_items
26    tk_call(@path, 'clear', 'items')
27    self
28  end
29
30  def clear_selection
31    tk_call(@path, 'clear', 'selection')
32    self
33  end
34
35  def get
36    tk_call(@path, 'get')
37  end
38
39  def insert_items(idx, *args)
40    tk_call(@path, 'insert', 'items', idx, *args)
41  end
42
43  def insert_selection(pos, text)
44    tk_call(@path, 'insert', 'selection', pos, text)
45  end
46
47  def select_item
48    tk_call(@path, 'selectitem')
49    self
50  end
51
52  # based on Tk::Listbox ( and TkTextWin )
53  def curselection
54    list(tk_send_without_enc('curselection'))
55  end
56  def delete(first, last=None)
57    tk_send_without_enc('delete', first, last)
58    self
59  end
60  def index(idx)
61    tk_send_without_enc('index', idx).to_i
62  end
63  def nearest(y)
64    tk_send_without_enc('nearest', y).to_i
65  end
66  def scan_mark(x, y)
67    tk_send_without_enc('scan', 'mark', x, y)
68    self
69  end
70  def scan_dragto(x, y)
71    tk_send_without_enc('scan', 'dragto', x, y)
72    self
73  end
74  def selection_anchor(index)
75    tk_send_without_enc('selection', 'anchor', index)
76    self
77  end
78  def selection_clear(first, last=None)
79    tk_send_without_enc('selection', 'clear', first, last)
80    self
81  end
82  def selection_includes(index)
83    bool(tk_send_without_enc('selection', 'includes', index))
84  end
85  def selection_set(first, last=None)
86    tk_send_without_enc('selection', 'set', first, last)
87    self
88  end
89  def size
90    tk_send_without_enc('size').to_i
91  end
92end
93