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

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/iwidgets/spinner.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/spinner.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  Spinner < Tk::Iwidgets::Labeledwidget
 
12
    end
 
13
  end
 
14
end
 
15
 
 
16
class Tk::Iwidgets::Spinner
 
17
  TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
 
18
  WidgetClassName = 'Spinner'.freeze
 
19
  WidgetClassNames[WidgetClassName] = self
 
20
 
 
21
  ####################################
 
22
 
 
23
  include Tk::ValidateConfigure
 
24
 
 
25
  class EntryfieldValidate < TkValidateCommand
 
26
    #class CalCmdArgs < TkUtil::CallbackSubst
 
27
    class ValidateArgs < TkUtil::CallbackSubst
 
28
      KEY_TBL  = [ 
 
29
        [ ?c, ?s, :char ], 
 
30
        [ ?P, ?s, :post ], 
 
31
        [ ?S, ?s, :current ], 
 
32
        [ ?W, ?w, :widget ], 
 
33
        nil
 
34
      ]
 
35
      PROC_TBL = [ 
 
36
        [ ?s, TkComm.method(:string) ], 
 
37
        [ ?w, TkComm.method(:window) ], 
 
38
        nil
 
39
      ]
 
40
      _setup_subst_table(KEY_TBL, PROC_TBL);
 
41
    end
 
42
 
 
43
    def self._config_keys
 
44
      ['validate', 'invalid']
 
45
    end
 
46
  end
 
47
 
 
48
  def __validation_class_list
 
49
    super() << EntryfieldValidate
 
50
  end
 
51
 
 
52
  Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
 
53
 
 
54
  ####################################
 
55
 
 
56
  def up
 
57
    tk_call_without_enc(@path, 'up')
 
58
    self
 
59
  end
 
60
 
 
61
  def down
 
62
    tk_call_without_enc(@path, 'down')
 
63
    self
 
64
  end
 
65
 
 
66
  def clear
 
67
    tk_call_without_enc(@path, 'clear')
 
68
    self
 
69
  end
 
70
 
 
71
  def delete(first, last=None)
 
72
    tk_send_without_enc('delete', first, last)
 
73
    self
 
74
  end
 
75
 
 
76
  def value
 
77
    _fromUTF8(tk_send_without_enc('get'))
 
78
  end
 
79
  def value= (val)
 
80
    tk_send_without_enc('delete', 0, 'end')
 
81
    tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
 
82
    val
 
83
  end
 
84
  alias get value
 
85
  alias set value=
 
86
 
 
87
  def cursor=(index)
 
88
    tk_send_without_enc('icursor', index)
 
89
    #self
 
90
    index
 
91
  end
 
92
  alias icursor cursor=
 
93
 
 
94
  def index(idx)
 
95
    number(tk_send_without_enc('index', idx))
 
96
  end
 
97
 
 
98
  def insert(pos,text)
 
99
    tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
 
100
    self
 
101
  end
 
102
 
 
103
  def mark(pos)
 
104
    tk_send_without_enc('scan', 'mark', pos)
 
105
    self
 
106
  end
 
107
  def dragto(pos)
 
108
    tk_send_without_enc('scan', 'dragto', pos)
 
109
    self
 
110
  end
 
111
  def selection_adjust(index)
 
112
    tk_send_without_enc('selection', 'adjust', index)
 
113
    self
 
114
  end
 
115
  def selection_clear
 
116
    tk_send_without_enc('selection', 'clear')
 
117
    self
 
118
  end
 
119
  def selection_from(index)
 
120
    tk_send_without_enc('selection', 'from', index)
 
121
    self
 
122
  end
 
123
  def selection_present()
 
124
    bool(tk_send_without_enc('selection', 'present'))
 
125
  end
 
126
  def selection_range(s, e)
 
127
    tk_send_without_enc('selection', 'range', s, e)
 
128
    self
 
129
  end
 
130
  def selection_to(index)
 
131
    tk_send_without_enc('selection', 'to', index)
 
132
    self
 
133
  end
 
134
 
 
135
  # based on tk/scrollable.rb
 
136
  def xview(*index)
 
137
    if index.size == 0
 
138
      list(tk_send_without_enc('xview'))
 
139
    else
 
140
      tk_send_without_enc('xview', *index)
 
141
      self
 
142
    end
 
143
  end
 
144
  def xview_moveto(*index)
 
145
    xview('moveto', *index)
 
146
  end
 
147
  def xview_scroll(*index)
 
148
    xview('scroll', *index)
 
149
  end
 
150
end