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

« back to all changes in this revision

Viewing changes to ext/tk/lib/tk/radiobutton.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
# tk/radiobutton.rb : treat radiobutton widget
 
3
#
 
4
require 'tk'
 
5
require 'tk/button'
 
6
 
 
7
class TkRadioButton<TkButton
 
8
  TkCommandNames = ['radiobutton'.freeze].freeze
 
9
  WidgetClassName = 'Radiobutton'.freeze
 
10
  WidgetClassNames[WidgetClassName] = self
 
11
  #def create_self(keys)
 
12
  #  if keys and keys != None
 
13
  #    tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
 
14
  #  else
 
15
  #    tk_call_without_enc('radiobutton', @path)
 
16
  #  end
 
17
  #end
 
18
  #private :create_self
 
19
 
 
20
  def __boolval_optkeys
 
21
    super() << 'indicatoron'
 
22
  end
 
23
  private :__boolval_optkeys
 
24
 
 
25
  def __strval_optkeys
 
26
    super() << 'selectcolor'
 
27
  end
 
28
  private :__strval_optkeys
 
29
 
 
30
  def __ruby2val_optkeys  # { key=>proc, ... }
 
31
    {
 
32
      'variable'=>proc{|v| tk_trace_variable(v)}  # for backward compatibility
 
33
    }
 
34
  end
 
35
  private :__ruby2val_optkeys
 
36
 
 
37
 
 
38
  def deselect
 
39
    tk_send_without_enc('deselect')
 
40
    self
 
41
  end
 
42
  def select
 
43
    tk_send_without_enc('select')
 
44
    self
 
45
  end
 
46
 
 
47
  def get_value
 
48
    var = tk_send_without_enc('cget', '-variable')
 
49
    if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS
 
50
      _fromUTF8(INTERP._get_global_var(var))
 
51
    else
 
52
      INTERP._eval(Kernel.format('global %s; set %s', var, var))
 
53
    end
 
54
  end
 
55
 
 
56
  def set_value(val)
 
57
    var = tk_send_without_enc('cget', '-variable')
 
58
    if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS
 
59
      _fromUTF8(INTERP._set_global_var(var, _get_eval_string(val, true)))
 
60
    else
 
61
      s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
 
62
      INTERP._eval(Kernel.format('global %s; set %s %s', var, var, s))
 
63
    end
 
64
  end
 
65
end
 
66
TkRadiobutton = TkRadioButton