tk 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/MANUAL_tcltklib.eng +0 -2
  4. data/MANUAL_tcltklib.ja +0 -2
  5. data/README.ActiveTcl +1 -1
  6. data/README.md +43 -0
  7. data/ext/tk/extconf.rb +4 -2
  8. data/ext/tk/old-extconf.rb +0 -1
  9. data/ext/tk/tcltklib.c +46 -148
  10. data/ext/tk/tkutil/extconf.rb +0 -2
  11. data/ext/tk/tkutil/tkutil.c +6 -9
  12. data/lib/multi-tk.rb +95 -315
  13. data/lib/remote-tk.rb +6 -23
  14. data/lib/tk.rb +41 -122
  15. data/lib/tk/bgerror.rb +2 -2
  16. data/lib/tk/bindtag.rb +1 -1
  17. data/lib/tk/canvas.rb +6 -14
  18. data/lib/tk/canvastag.rb +8 -16
  19. data/lib/tk/font.rb +1 -1
  20. data/lib/tk/fontchooser.rb +1 -1
  21. data/lib/tk/image.rb +1 -1
  22. data/lib/tk/menu.rb +4 -4
  23. data/lib/tk/msgcat.rb +5 -5
  24. data/lib/tk/namespace.rb +12 -32
  25. data/lib/tk/optiondb.rb +3 -73
  26. data/lib/tk/scale.rb +2 -2
  27. data/lib/tk/scrollable.rb +4 -2
  28. data/lib/tk/selection.rb +5 -4
  29. data/lib/tk/text.rb +8 -16
  30. data/lib/tk/textmark.rb +1 -1
  31. data/lib/tk/texttag.rb +7 -15
  32. data/lib/tk/timer.rb +2 -2
  33. data/lib/tk/tk_mac.rb +18 -18
  34. data/lib/tk/validation.rb +4 -35
  35. data/lib/tk/variable.rb +7 -5
  36. data/lib/tk/virtevent.rb +1 -1
  37. data/lib/tkextlib/blt/barchart.rb +0 -17
  38. data/lib/tkextlib/blt/bitmap.rb +1 -1
  39. data/lib/tkextlib/blt/component.rb +34 -34
  40. data/lib/tkextlib/blt/dragdrop.rb +6 -6
  41. data/lib/tkextlib/blt/graph.rb +0 -17
  42. data/lib/tkextlib/blt/stripchart.rb +0 -17
  43. data/lib/tkextlib/blt/tabset.rb +16 -31
  44. data/lib/tkextlib/blt/tree.rb +5 -5
  45. data/lib/tkextlib/blt/treeview.rb +14 -14
  46. data/lib/tkextlib/blt/watch.rb +1 -1
  47. data/lib/tkextlib/bwidget/labelentry.rb +6 -14
  48. data/lib/tkextlib/bwidget/listbox.rb +13 -29
  49. data/lib/tkextlib/bwidget/notebook.rb +6 -14
  50. data/lib/tkextlib/bwidget/spinbox.rb +6 -14
  51. data/lib/tkextlib/bwidget/tree.rb +19 -35
  52. data/lib/tkextlib/itcl/incr_tcl.rb +2 -2
  53. data/lib/tkextlib/itk/incr_tk.rb +7 -29
  54. data/lib/tkextlib/iwidgets/calendar.rb +0 -15
  55. data/lib/tkextlib/iwidgets/entryfield.rb +0 -21
  56. data/lib/tkextlib/iwidgets/notebook.rb +2 -2
  57. data/lib/tkextlib/iwidgets/scrolledcanvas.rb +6 -14
  58. data/lib/tkextlib/iwidgets/tabnotebook.rb +2 -2
  59. data/lib/tkextlib/tcllib/ctext.rb +2 -2
  60. data/lib/tkextlib/tcllib/plotchart.rb +5 -5
  61. data/lib/tkextlib/tcllib/validator.rb +6 -6
  62. data/lib/tkextlib/tile.rb +1 -1
  63. data/lib/tkextlib/tile/style.rb +1 -1
  64. data/lib/tkextlib/tile/treeview.rb +13 -20
  65. data/lib/tkextlib/tkDND/tkdnd.rb +6 -22
  66. data/lib/tkextlib/tkHTML/htmlwidget.rb +1 -1
  67. data/lib/tkextlib/tktable/tktable.rb +1 -1
  68. data/lib/tkextlib/treectrl/tktreectrl.rb +12 -20
  69. data/lib/tkextlib/vu/pie.rb +1 -1
  70. data/sample/binding_sample.rb +2 -2
  71. data/sample/cmd_res_test.rb +1 -1
  72. data/sample/demos-en/widget +21 -21
  73. data/sample/demos-jp/widget +4 -4
  74. data/sample/multi-ip_sample.rb +0 -3
  75. data/sample/multi-ip_sample2.rb +1 -1
  76. data/sample/resource.en +3 -3
  77. data/sample/resource.ja +3 -3
  78. data/sample/tcltklib/sample1.rb +2 -2
  79. data/sample/tkballoonhelp.rb +2 -2
  80. data/sample/tkextlib/tkHTML/ss.rb +0 -6
  81. data/sample/tkmulticolumnlist.rb +2 -2
  82. data/sample/tkmultilistframe.rb +2 -2
  83. data/sample/tkoptdb.rb +14 -16
  84. data/tk.gemspec +4 -4
  85. metadata +6 -13
  86. data/ChangeLog.tkextlib +0 -949
  87. data/old-README.tcltklib.ja +0 -159
  88. data/sample/binstr_usage.rb +0 -46
  89. data/sample/remote-ip_sample2.rb +0 -57
  90. data/sample/safe-tk.rb +0 -132
  91. data/sample/tkoptdb-safeTk.rb +0 -74
  92. data/sample/tktree.rb +0 -104
  93. data/sample/tktree.tcl +0 -305
@@ -41,12 +41,12 @@ module Tk
41
41
  class ItclObject < TkObject
42
42
  ITCL_CLASSNAME = ''.freeze
43
43
 
44
- (ITCL_OBJ_ID = ['itclobj'.freeze, TkUtil.untrust('00000')]).instance_eval{
44
+ (ITCL_OBJ_ID = ['itclobj'.freeze, '00000']).instance_eval{
45
45
  @mutex = Mutex.new
46
46
  def mutex; @mutex; end
47
47
  freeze
48
48
  }
49
- ITCL_OBJ_TBL = TkUtil.untrust({})
49
+ ITCL_OBJ_TBL = {}
50
50
 
51
51
  def initialize(*args)
52
52
  if (@klass = self.class::ITCL_CLASSNAME).empty?
@@ -147,7 +147,7 @@ module Tk
147
147
 
148
148
  ComponentID_TBL = TkCore::INTERP.create_table
149
149
 
150
- (Itk_Component_ID = ['itk:component'.freeze, TkUtil.untrust('00000')]).instance_eval{
150
+ (Itk_Component_ID = ['itk:component'.freeze, '00000']).instance_eval{
151
151
  @mutex = Mutex.new
152
152
  def mutex; @mutex; end
153
153
  freeze
@@ -360,18 +360,7 @@ module Tk
360
360
  end
361
361
  end
362
362
 
363
- #def bind(*args)
364
- # unless @widget
365
- # begin
366
- # @widget = window(tk_call(@master, 'component', @component))
367
- # @path = @widget.path
368
- # rescue
369
- # fail RuntimeError, 'component is not assigned to a widget'
370
- # end
371
- # end
372
- # @widget.bind(*args)
373
- #end
374
- def bind(context, *args)
363
+ def bind(context, *args, &block)
375
364
  unless @widget
376
365
  begin
377
366
  @widget = window(tk_call(@master, 'component', @component))
@@ -381,26 +370,15 @@ module Tk
381
370
  end
382
371
  end
383
372
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
384
- if TkComm._callback_entry?(args[0]) || !block_given?
373
+ if TkComm._callback_entry?(args[0]) || !block
385
374
  cmd = args.shift
386
375
  else
387
- cmd = Proc.new
376
+ cmd = block
388
377
  end
389
378
  @widget.bind(context, cmd, *args)
390
379
  end
391
380
 
392
- #def bind_append(*args)
393
- # unless @widget
394
- # begin
395
- # @widget = window(tk_call(@master, 'component', @component))
396
- # @path = @widget.path
397
- # rescue
398
- # fail RuntimeError, 'component is not assigned to a widget'
399
- # end
400
- # end
401
- # @widget.bind_append(*args)
402
- #end
403
- def bind_append(context, *args)
381
+ def bind_append(context, *args, &block)
404
382
  unless @widget
405
383
  begin
406
384
  @widget = window(tk_call(@master, 'component', @component))
@@ -410,10 +388,10 @@ module Tk
410
388
  end
411
389
  end
412
390
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
413
- if TkComm._callback_entry?(args[0]) || !block_given?
391
+ if TkComm._callback_entry?(args[0]) || !block
414
392
  cmd = args.shift
415
393
  else
416
- cmd = Proc.new
394
+ cmd = block
417
395
  end
418
396
  @widget.bind_append(context, cmd, *args)
419
397
  end
@@ -76,10 +76,6 @@ class Tk::Iwidgets::Calendar
76
76
  # array of config-option key (string or symbol)
77
77
  ['command']
78
78
  end
79
-
80
- #def initialize(cmd = Proc.new, *args)
81
- # _initialize_for_cb_class(CalCmdArgs, cmd, *args)
82
- #end
83
79
  end
84
80
 
85
81
  def __validation_class_list
@@ -87,17 +83,6 @@ class Tk::Iwidgets::Calendar
87
83
  end
88
84
 
89
85
  Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand)
90
- =begin
91
- def command(cmd = Proc.new, args = nil)
92
- if cmd.kind_of?(CalendarCommand)
93
- configure('command', cmd)
94
- elsif args
95
- configure('command', [cmd, args])
96
- else
97
- configure('command', cmd)
98
- end
99
- end
100
- =end
101
86
 
102
87
  ####################################
103
88
 
@@ -75,27 +75,6 @@ class Tk::Iwidgets::Entryfield
75
75
  end
76
76
 
77
77
  Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
78
- =begin
79
- def validate(cmd = Proc.new, args = nil)
80
- if cmd.kind_of?(ValidateCmd)
81
- configure('validate', cmd)
82
- elsif args
83
- configure('validate', [cmd, args])
84
- else
85
- configure('validate', cmd)
86
- end
87
- end
88
-
89
- def invalid(cmd = Proc.new, args = nil)
90
- if cmd.kind_of?(ValidateCmd)
91
- configure('invalid', cmd)
92
- elsif args
93
- configure('invalid', [cmd, args])
94
- else
95
- configure('invalid', cmd)
96
- end
97
- end
98
- =end
99
78
 
100
79
  ####################################
101
80
 
@@ -118,8 +118,8 @@ class Tk::Iwidgets::Notebook
118
118
  self
119
119
  end
120
120
 
121
- def scrollcommand(cmd=Proc.new)
122
- configure_cmd 'scrollcommand', cmd
121
+ def scrollcommand(cmd=nil, &block)
122
+ configure_cmd('scrollcommand', cmd || block)
123
123
  self
124
124
  end
125
125
  alias xscrollcommand scrollcommand
@@ -108,31 +108,23 @@ class Tk::Iwidgets::Scrolledcanvas
108
108
  *tags.collect{|t| tagid(t)}))
109
109
  end
110
110
 
111
- #def itembind(tag, context, cmd=Proc.new, *args)
112
- # _bind([path, "bind", tagid(tag)], context, cmd, *args)
113
- # self
114
- #end
115
- def itembind(tag, context, *args)
111
+ def itembind(tag, context, *args, &block)
116
112
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
117
- if TkComm._callback_entry?(args[0]) || !block_given?
113
+ if TkComm._callback_entry?(args[0]) || !block
118
114
  cmd = args.shift
119
115
  else
120
- cmd = Proc.new
116
+ cmd = block
121
117
  end
122
118
  _bind([path, "bind", tagid(tag)], context, cmd, *args)
123
119
  self
124
120
  end
125
121
 
126
- #def itembind_append(tag, context, cmd=Proc.new, *args)
127
- # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
128
- # self
129
- #end
130
- def itembind_append(tag, context, *args)
122
+ def itembind_append(tag, context, *args, &block)
131
123
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
132
- if TkComm._callback_entry?(args[0]) || !block_given?
124
+ if TkComm._callback_entry?(args[0]) || !block
133
125
  cmd = args.shift
134
126
  else
135
- cmd = Proc.new
127
+ cmd = block
136
128
  end
137
129
  _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
138
130
  self
@@ -124,8 +124,8 @@ class Tk::Iwidgets::Tabnotebook
124
124
  self
125
125
  end
126
126
 
127
- def scrollcommand(cmd=Proc.new)
128
- configure_cmd 'scrollcommand', cmd
127
+ def scrollcommand(cmd=nil, &block)
128
+ configure_cmd('scrollcommand', cmd || block)
129
129
  self
130
130
  end
131
131
  alias xscrollcommand scrollcommand
@@ -150,8 +150,8 @@ class Tk::Tcllib::CText
150
150
  tk_call('ctext::findPreviousSpace', @path, idx)
151
151
  end
152
152
 
153
- def set_update_proc(cmd=Proc.new)
154
- tk_call('proc', 'ctext::update', '', cmd)
153
+ def set_update_proc(cmd=nil, &block)
154
+ tk_call('proc', 'ctext::update', '', cmd || block)
155
155
  self
156
156
  end
157
157
 
@@ -709,15 +709,15 @@ module Tk::Tcllib::Plotchart
709
709
  end
710
710
  private :_create_chart
711
711
 
712
- def plot_function(cmd=Proc.new)
713
- Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
712
+ def plot_function(cmd=nil, &block)
713
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd || block)} $x $y}")
714
714
  tk_call_without_enc(@chart, 'plotfunc', "#{@path}_#{@chart}")
715
715
  self
716
716
  end
717
717
 
718
- def plot_funcont(conts, cmd=Proc.new)
718
+ def plot_funcont(conts, cmd=nil, &block)
719
719
  conts = array2tk_list(conts) if conts.kind_of?(Array)
720
- Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
720
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd || block)} $x $y}")
721
721
  tk_call_without_enc(@chart, 'plotfuncont', "#{@path}_#{@chart}", conts)
722
722
  self
723
723
  end
@@ -1360,7 +1360,7 @@ module Tk::Tcllib::Plotchart
1360
1360
  class PlotSeries < TkObject
1361
1361
  SeriesID_TBL = TkCore::INTERP.create_table
1362
1362
 
1363
- (Series_ID = ['series'.freeze, TkUtil.untrust('00000')]).instance_eval{
1363
+ (Series_ID = ['series'.freeze, '00000']).instance_eval{
1364
1364
  @mutex = Mutex.new
1365
1365
  def mutex; @mutex; end
1366
1366
  freeze
@@ -33,8 +33,8 @@ end
33
33
  module Tk::Tcllib::Validator
34
34
  extend TkCore
35
35
 
36
- def self.attach(widget, color, cmd=Proc.new)
37
- tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd)
36
+ def self.attach(widget, color, cmd=nil, &block)
37
+ tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd || block)
38
38
  nil
39
39
  end
40
40
 
@@ -48,17 +48,17 @@ module Tk::Tcllib::Validator
48
48
  nil
49
49
  end
50
50
 
51
- def attach_validator(color, cmd=Proc.new)
52
- tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd)
51
+ def attach_validator(color, cmd=nil, &block)
52
+ tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd || block)
53
53
  self
54
54
  end
55
55
 
56
- def detach_validator(color, cmd=Proc.new)
56
+ def detach_validator(color, cmd=nil)
57
57
  tk_call_without_enc('::widget::validator', 'detach', @path)
58
58
  self
59
59
  end
60
60
 
61
- def invoke_validator(color, cmd=Proc.new)
61
+ def invoke_validator(color, cmd=nil)
62
62
  tk_call_without_enc('::widget::validator', 'validate', @path)
63
63
  self
64
64
  end
@@ -338,7 +338,7 @@ module Tk
338
338
  if script
339
339
  tk_send('instate', state, script)
340
340
  elsif b
341
- tk_send('instate', state, Proc.new(&b))
341
+ tk_send('instate', state, b)
342
342
  else
343
343
  bool(tk_send('instate', state))
344
344
  end
@@ -320,7 +320,7 @@ class << Tk::Tile::Style
320
320
 
321
321
  def theme_settings(name, cmd=nil, &b)
322
322
  name = name.to_s
323
- cmd = Proc.new(&b) if !cmd && b
323
+ cmd = b if !cmd && b
324
324
  tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
325
325
  name
326
326
  end
@@ -939,7 +939,7 @@ class Tk::Tile::Treeview::Tag < TkObject
939
939
 
940
940
  TagID_TBL = TkCore::INTERP.create_table
941
941
 
942
- (Tag_ID = ['tile_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
942
+ (Tag_ID = ['tile_treeview_tag'.freeze, '00000']).instance_eval{
943
943
  @mutex = Mutex.new
944
944
  def mutex; @mutex; end
945
945
  freeze
@@ -999,21 +999,21 @@ class Tk::Tile::Treeview::Tag < TkObject
999
999
  @t.tag_remove(@id, *items)
1000
1000
  end
1001
1001
 
1002
- def bind(seq, *args)
1003
- if TkComm._callback_entry?(args[0]) || !block_given?
1002
+ def bind(seq, *args, &block)
1003
+ if TkComm._callback_entry?(args[0]) || !block
1004
1004
  cmd = args.shift
1005
1005
  else
1006
- cmd = Proc.new
1006
+ cmd = block
1007
1007
  end
1008
1008
  @t.tag_bind(@id, seq, cmd, *args)
1009
1009
  self
1010
1010
  end
1011
1011
 
1012
- def bind_append(seq, *args)
1013
- if TkComm._callback_entry?(args[0]) || !block_given?
1012
+ def bind_append(seq, *args, &block)
1013
+ if TkComm._callback_entry?(args[0]) || !block
1014
1014
  cmd = args.shift
1015
1015
  else
1016
- cmd = Proc.new
1016
+ cmd = block
1017
1017
  end
1018
1018
  @t.tag_bind_append(@id, seq, cmd, *args)
1019
1019
  self
@@ -1191,13 +1191,6 @@ class Tk::Tile::Treeview < TkWindow
1191
1191
  Tk::Tile::Treeview::Item.new(self, parent, idx, keys)
1192
1192
  end
1193
1193
 
1194
- # def instate(spec, cmd=Proc.new)
1195
- # tk_send('instate', spec, cmd)
1196
- # end
1197
- # def state(spec=None)
1198
- # tk_send('state', spec)
1199
- # end
1200
-
1201
1194
  def move(item, parent, idx)
1202
1195
  tk_send('move', item, parent, idx)
1203
1196
  self
@@ -1280,22 +1273,22 @@ class Tk::Tile::Treeview < TkWindow
1280
1273
  }
1281
1274
  end
1282
1275
 
1283
- def tag_bind(tag, seq, *args)
1284
- if TkComm._callback_entry?(args[0]) || !block_given?
1276
+ def tag_bind(tag, seq, *args, &block)
1277
+ if TkComm._callback_entry?(args[0]) || !block
1285
1278
  cmd = args.shift
1286
1279
  else
1287
- cmd = Proc.new
1280
+ cmd = block
1288
1281
  end
1289
1282
  _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
1290
1283
  self
1291
1284
  end
1292
1285
  alias tagbind tag_bind
1293
1286
 
1294
- def tag_bind_append(tag, seq, *args)
1295
- if TkComm._callback_entry?(args[0]) || !block_given?
1287
+ def tag_bind_append(tag, seq, *args, &block)
1288
+ if TkComm._callback_entry?(args[0]) || !block
1296
1289
  cmd = args.shift
1297
1290
  else
1298
- cmd = Proc.new
1291
+ cmd = block
1299
1292
  end
1300
1293
  _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
1301
1294
  self
@@ -146,19 +146,7 @@ module Tk
146
146
  end
147
147
  end
148
148
 
149
- #def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
150
- # event = tk_event_sequence(event)
151
- # if prior.kind_of?(Numeric)
152
- # tk_call('dnd', 'bindtarget', @path, type, event,
153
- # install_bind_for_event_class(DND_Subst, cmd, *args),
154
- # prior)
155
- # else
156
- # tk_call('dnd', 'bindtarget', @path, type, event,
157
- # install_bind_for_event_class(DND_Subst, cmd, prior, *args))
158
- # end
159
- # self
160
- #end
161
- def dnd_bindtarget(type, event, *args)
149
+ def dnd_bindtarget(type, event, *args, &block)
162
150
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
163
151
  klass = case type
164
152
  when 'text/plain'
@@ -168,10 +156,10 @@ module Tk
168
156
  else
169
157
  DND_Subst
170
158
  end
171
- if TkComm._callback_entry?(args[0]) || !block_given?
159
+ if TkComm._callback_entry?(args[0]) || !block
172
160
  cmd = args.shift
173
161
  else
174
- cmd = Proc.new
162
+ cmd = block
175
163
  end
176
164
 
177
165
  prior = 50
@@ -202,16 +190,12 @@ module Tk
202
190
  end
203
191
  end
204
192
 
205
- #def dnd_bindsource(type, cmd=Proc.new, prior=None)
206
- # tk_call('dnd', 'bindsource', @path, type, cmd, prior)
207
- # self
208
- #end
209
- def dnd_bindsource(type, *args)
193
+ def dnd_bindsource(type, *args, &block)
210
194
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
211
- if TkComm._callback_entry?(args[0]) || !block_given?
195
+ if TkComm._callback_entry?(args[0]) || !block
212
196
  cmd = args.shift
213
197
  else
214
- cmd = Proc.new
198
+ cmd = block
215
199
  end
216
200
 
217
201
  args = [TkComm::None] if args.empty?
@@ -391,7 +391,7 @@ class Tk::HTML_Widget
391
391
  end
392
392
 
393
393
  def token_handler(tag, cmd=nil, &b)
394
- cmd = Proc.new(&b) if !cmd && b
394
+ cmd = b if !cmd && b
395
395
  if cmd
396
396
  tk_send('token', 'handler', tag, cmd)
397
397
  return self
@@ -132,7 +132,7 @@ class Tk::TkTable::CellTag
132
132
 
133
133
  CellTagID_TBL = TkCore::INTERP.create_table
134
134
 
135
- (CellTag_ID = ['tktbl:celltag'.freeze, TkUtil.untrust('00000')]).instance_eval{
135
+ (CellTag_ID = ['tktbl:celltag'.freeze, '00000']).instance_eval{
136
136
  @mutex = Mutex.new
137
137
  def mutex; @mutex; end
138
138
  freeze