summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-02 16:59:02 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-02 16:59:02 +0000
commit7c8d66c3d9e68e1b44e468303b4fcd012f7cce83 (patch)
tree7a226922d0428991ea84929621fb99bd16b909df /ext/tk/lib/tk
parentd8bb4ebcb6c1f80191178538d33e7b85c9dbce4a (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/tk/lib/tk')
-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
3 files changed, 65 insertions, 1 deletions
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