diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-02 16:59:02 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-02 16:59:02 +0000 |
commit | 7c8d66c3d9e68e1b44e468303b4fcd012f7cce83 (patch) | |
tree | 7a226922d0428991ea84929621fb99bd16b909df /ext | |
parent | d8bb4ebcb6c1f80191178538d33e7b85c9dbce4a (diff) |
* ext/tk/lib/tk.rb: widget configuration by TkWindow#method_missing
returns proper object. "widget.option = val" returns val, and
"widget.option(val)" returns self.
* ext/tk/lib/tk/font.rb: TkFont#replace accepts only one font argument.
* ext/tk/lib/tk/radiobutton.rb: add TkRadiobutton#value and value=(val).
* ext/tk/lib/tk/spinbox.rb: callback substitution support on command option.
* ext/tk/sample/demos-en/widget: bug fix (wrong image height)
* ext/tk/sample/demos-jp/widget: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/tk/lib/tk.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tk/font.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tk/radiobutton.rb | 19 | ||||
-rw-r--r-- | ext/tk/lib/tk/spinbox.rb | 44 | ||||
-rw-r--r-- | ext/tk/sample/demos-en/widget | 4 | ||||
-rw-r--r-- | ext/tk/sample/demos-jp/widget | 4 |
6 files changed, 71 insertions, 5 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 0abab4b3ec..9081eb9939 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -3186,8 +3186,10 @@ class TkObject<TkKernel when 1 if name[-1] == ?= configure name[0..-2], args[0] + args[0] else configure name, args[0] + self end when 0 begin diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 02e09c6066..2ebe6612bd 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -1362,7 +1362,8 @@ class TkFont end end - def replace(ltn, knj) + def replace(ltn, knj=None) + knj = ltn if knj == None latin_replace(ltn) kanji_replace(knj) self diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb index 697c021283..8ee67bde68 100644 --- a/ext/tk/lib/tk/radiobutton.rb +++ b/ext/tk/lib/tk/radiobutton.rb @@ -28,5 +28,24 @@ class TkRadioButton<TkButton def variable(v) configure 'variable', tk_trace_variable(v) end + + def value + var = tk_send_without_enc('cget', '-variable') + if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS + _fromUTF8(INTERP._get_global_var(var)) + else + INTERP._eval(Kernel.format('global %s; set %s', var, var)) + end + end + + def value=(val) + var = tk_send_without_enc('cget', '-variable') + if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS + _fromUTF8(INTERP._set_global_var(var, _get_eval_string(val, true))) + else + s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"' + INTERP._eval(Kernel.format('global %s; set %s %s', var, var, s)) + end + end end TkRadiobutton = TkRadioButton diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index f4febb05b1..fe50d85e43 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -11,6 +11,50 @@ class TkSpinbox<TkEntry WidgetClassName = 'Spinbox'.freeze WidgetClassNames[WidgetClassName] = self + class SpinCommand < TkValidateCommand + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ + [ ?d, ?s, :direction ], + [ ?s, ?e, :current ], + [ ?W, ?w, :widget ], + nil + ] + + PROC_TBL = [ + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + + [ ?e, proc{|val| + enc = Tk.encoding + if enc + Tk.fromUTF8(TkComm::string(val), enc) + else + TkComm::string(val) + end + } + ], + + nil + ] + + _setup_subst_table(KEY_TBL, PROC_TBL); + + def self.ret_val(val) + (val)? '1': '0' + end + end + + def self._config_keys + ['command'] + end + end + + def __validation_class_list + super << SpinCommand + end + + Tk::ValidateConfigure.__def_validcmd(binding, SpinCommand) + #def create_self(keys) # tk_call_without_enc('spinbox', @path) # if keys and keys != None diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index 133d151d46..9d970435ae 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -72,7 +72,7 @@ EOD end if $tk_major_ver >= 8 -$image['print'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) +$image['print'] = TkPhotoImage.new(:height=>19, :format=>'GIF', :data=><<EOD) R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM @@ -780,7 +780,7 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk widget demonstration Ver.1.4.3-en\n\n" + + 'message'=>"Ruby/Tk widget demonstration Ver.1.4.4-en\n\n" + "based on demos of Tk8.1 -- 8.5 " + "( Copyright:: " + "(c) 1996-1997 Sun Microsystems, Inc. / " + diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index e8196aec8f..6eaaece4c4 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -86,7 +86,7 @@ EOD end if $tk_major_ver >= 8 -$image['print'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) +$image['print'] = TkPhotoImage.new(:height=>19, :format=>'GIF', :data=><<EOD) R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM @@ -807,7 +807,7 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.4.3-jp\n\n" + + 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.4.4-jp\n\n" + "based on demos of Tk8.1 -- 8.5 " + "( Copyright:: " + "(c) 1996-1997 Sun Microsystems, Inc. / " + |