~ubuntu-branches/ubuntu/intrepid/ruby1.8/intrepid-updates

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/iwidgets/combobox.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  tkextlib/iwidgets/combobox.rb
 
3
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
 
4
#
 
5
 
 
6
require 'tk'
 
7
require 'tkextlib/iwidgets.rb'
 
8
 
 
9
module Tk
 
10
  module Iwidgets
 
11
    class Combobox < Tk::Iwidgets::Entryfield
 
12
    end
 
13
  end
 
14
end
 
15
 
 
16
class Tk::Iwidgets::Combobox
 
17
  TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
 
18
  WidgetClassName = 'Combobox'.freeze
 
19
  WidgetClassNames[WidgetClassName] = self
 
20
 
 
21
  def __boolval_optkeys
 
22
    super() << 'completion' << 'dropdown' << 'editable' << 'unique'
 
23
  end
 
24
  private :__boolval_optkeys
 
25
 
 
26
  def clear(component=None)
 
27
    tk_call(@path, 'clear', component)
 
28
    self
 
29
  end
 
30
 
 
31
  def delete_list(first, last=None)
 
32
    tk_call(@path, 'delete', 'list', first, last)
 
33
    self
 
34
  end
 
35
 
 
36
  def delete_entry(first, last=None)
 
37
    tk_call(@path, 'delete', 'entry', first, last)
 
38
    self
 
39
  end
 
40
 
 
41
  def get_list_contents(index)
 
42
    tk_call(@path, 'get', index)
 
43
  end
 
44
 
 
45
  def insert_list(idx, *elems)
 
46
    tk_call(@path, 'insert', 'list', idx, *elems)
 
47
    self
 
48
  end
 
49
 
 
50
  def insert_entry(idx, *elems)
 
51
    tk_call(@path, 'insert', 'entry', idx, *elems)
 
52
    self
 
53
  end
 
54
 
 
55
  # listbox methods
 
56
  def size
 
57
    tk_send_without_enc('size').to_i
 
58
  end
 
59
  def see(index)
 
60
    tk_send_without_enc('see', index)
 
61
    self
 
62
  end
 
63
  def selection_anchor(index)
 
64
    tk_send_without_enc('selection', 'anchor', index)
 
65
    self
 
66
  end
 
67
  def selection_clear(first, last=None)
 
68
    tk_send_without_enc('selection', 'clear', first, last)
 
69
    self
 
70
  end
 
71
  def selection_includes(index)
 
72
    bool(tk_send_without_enc('selection', 'includes', index))
 
73
  end
 
74
  def selection_set(first, last=None)
 
75
    tk_send_without_enc('selection', 'set', first, last)
 
76
    self
 
77
  end
 
78
 
 
79
  # scrolledlistbox methods
 
80
  def get_curselection
 
81
    tk_call(@path, 'getcurselection')
 
82
  end
 
83
  def justify(dir)
 
84
    tk_call(@path, 'justify', dir)
 
85
    self
 
86
  end
 
87
  def sort(*params, &b)
 
88
    # see 'lsort' man page about params
 
89
    if b
 
90
      tk_call(@path, 'sort', '-command', proc(&b), *params)
 
91
    else
 
92
      tk_call(@path, 'sort', *params)
 
93
    end
 
94
    self
 
95
  end
 
96
  def sort_ascending
 
97
    tk_call(@path, 'sort', 'ascending')
 
98
    self
 
99
  end
 
100
  def sort_descending
 
101
    tk_call(@path, 'sort', 'descending')
 
102
    self
 
103
  end
 
104
end