summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--ext/tk/lib/tk.rb2
-rw-r--r--ext/tk/lib/tk/font.rb3
-rw-r--r--ext/tk/lib/tk/radiobutton.rb19
-rw-r--r--ext/tk/lib/tk/spinbox.rb44
-rw-r--r--ext/tk/sample/demos-en/widget4
-rw-r--r--ext/tk/sample/demos-jp/widget4
7 files changed, 89 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5913e77cba..9d01c54535 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * 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
+ TkRadiobutton#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.
+
Thu Dec 2 16:41:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_protect): prevent continuations created inside from being
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. / " +