diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-19 16:14:43 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-19 16:14:43 +0000 |
commit | 068bc7e43a7e88d9d48aa627a846ef5f22660694 (patch) | |
tree | bd3f9c1e0fa20f4c864b4f7ae911d26c96c858d1 /ext/tk/lib | |
parent | 13e15cecf3f3bec0514ce9b2b4576135fe3f944c (diff) | |
download | ruby-068bc7e43a7e88d9d48aa627a846ef5f22660694.tar.gz |
tcltklib.c :
* lib_do_one_event() : change default value of the argument
* lib_do_one_event() : returns true/false
* add TclTkLib::EventFlag::NONE ( == 0 )
* add set_no_event_wait() and get_no_event_wait()
* modify MANUAL.euc and README.euc
tk.rb :
* change default value of TkCore.do_one_event argument
* add TkCore.set_no_event_wait(wait) and TkCore.get_no_event_wait
* add Tk.exit ( == destroy root widget )
tkafter.rb :
* rename TkAfter => TkTimer ( TkAfter is an alias name now. )
* set_callback returns self
* continue() raises an exception, if already running or no procedure.
* skip() raises an exception, if not running.
sample/tktimer2.rb
* new sample for TkTimer class.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib')
-rw-r--r-- | ext/tk/lib/tk.rb | 14 | ||||
-rw-r--r-- | ext/tk/lib/tkafter.rb | 18 |
2 files changed, 23 insertions, 9 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 35b9e7ce97..464f7f179e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -765,7 +765,7 @@ module TkCore TclTkLib.mainloop_watchdog(check_root) end - def do_one_event(flag = 0) + def do_one_event(flag = TclTkLib::EventFlag::ALL) TclTkLib.do_one_event(flag) end @@ -777,6 +777,14 @@ module TkCore TclTkLib.get_eventloop_tick end + def set_no_event_wait(wait) + TclTkLib.set_no_even_wait(wait) + end + + def get_no_event_wait() + TclTkLib.get_no_eventloop_wait + end + def set_eventloop_weight(loop_max, no_event_tick) TclTkLib.set_eventloop_weight(loop_max, no_event_tick) end @@ -972,6 +980,10 @@ module Tk tk_call('destroy', *wins) end + def Tk.exit + tk_call('destroy', '.') + end + def Tk.current_grabs tk_split_list(tk_call('grab', 'current')) end diff --git a/ext/tk/lib/tkafter.rb b/ext/tk/lib/tkafter.rb index 5176db3e35..a75ad5a237 100644 --- a/ext/tk/lib/tkafter.rb +++ b/ext/tk/lib/tkafter.rb @@ -5,7 +5,7 @@ # require 'tk' -class TkAfter +class TkTimer include TkCore extend TkCore @@ -20,19 +20,19 @@ class TkAfter end INTERP._invoke("proc", "rb_after", "id", - "ruby [format \"TkAfter.callback %%Q!%s!\" $id]") + "ruby [format \"#{self.name}.callback %%Q!%s!\" $id]") ############################### # class methods ############################### - def TkAfter.callback(obj_id) + def self.callback(obj_id) @after_id = nil ex_obj = Tk_CBTBL[obj_id] return nil if ex_obj == nil; # canceled _get_eval_string(ex_obj.do_callback) end - def TkAfter.info + def self.info tk_call('after', 'info').split(' ').collect!{|id| ret = Tk_CBTBL.find{|key,val| val.after_id == id} (ret == nil)? id: ret[1] @@ -68,6 +68,7 @@ class TkAfter @after_id = tk_call('after', sleep, @after_script) @current_args = args @current_script = [sleep, @after_script] + self end def set_next_callback(args) @@ -286,11 +287,12 @@ class TkAfter alias stop cancel def continue(wait=nil) + fail RuntimeError, "is already running" if @running sleep, cmd = @current_script - return nil if cmd == nil || @running == true + fail RuntimeError, "no procedure to continue" unless cmd if wait if not wait.kind_of? Integer - fail format("%s need to be Integer", wait.inspect) + fail RuntimeError, format("%s need to be Integer", wait.inspect) end sleep = wait end @@ -301,7 +303,7 @@ class TkAfter end def skip - return nil if @running == false + fail RuntimeError, "is not running now" unless @running cancel Tk_CBTBL[@id] = self @running = true @@ -319,4 +321,4 @@ class TkAfter end end -TkTimer = TkAfter +TkAfter = TkTimer |