mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/tk/tcltklib.c (lib_eventloop_ensure): mis-delete a timer handler
when exit from a recursive called eventloop * ext/tk/lib/tk/timer.rb: new TkRTTimer class, which can works for a realtime operation * ext/tk/sample/tkrttimer.rb: sample of TkRTTimer class * ext/tk/lib/tk/textmark.rb: move TkTextMark#+ and TkTextMark#- to TkText::IndexModMethods * ext/tk/lib/tk/text.rb: improve TkTextMark#+ and TkTextMark#-, and add them to TkText::IndexModMethods module * ext/tk/sample/tktextio.rb: add test part of "seek by text index modifiers" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7935361d36
								
							
						
					
					
						commit
						d2a9e77748
					
				
					 35 changed files with 550 additions and 292 deletions
				
			
		
							
								
								
									
										19
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,22 @@
 | 
			
		|||
Thu Mar 10 19:10:29 2005  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp>
 | 
			
		||||
 | 
			
		||||
	* ext/tk/tcltklib.c (lib_eventloop_ensure): mis-delete a timer handler
 | 
			
		||||
	  when exit from a recursive called eventloop
 | 
			
		||||
 | 
			
		||||
	* ext/tk/lib/tk/timer.rb: new TkRTTimer class, which can works for a
 | 
			
		||||
	  realtime operation
 | 
			
		||||
 | 
			
		||||
	* ext/tk/sample/tkrttimer.rb: sample of TkRTTimer class
 | 
			
		||||
 | 
			
		||||
	* ext/tk/lib/tk/textmark.rb: move  TkTextMark#+ and TkTextMark#- to 
 | 
			
		||||
	  TkText::IndexModMethods
 | 
			
		||||
 | 
			
		||||
	* ext/tk/lib/tk/text.rb: improve TkTextMark#+ and TkTextMark#-, and 
 | 
			
		||||
	  add them to TkText::IndexModMethods module
 | 
			
		||||
 | 
			
		||||
	* ext/tk/sample/tktextio.rb: add test part of "seek by text index
 | 
			
		||||
	  modifiers"
 | 
			
		||||
 | 
			
		||||
Wed Mar  9 23:55:34 2005  Tanaka Akira  <akr@m17n.org>
 | 
			
		||||
 | 
			
		||||
	* lib/pp.rb (PP::PPMethods#guard_inspect_key): support
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1470,14 +1470,14 @@ module TkCore
 | 
			
		|||
    nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def event_generate(window, context, keys=nil)
 | 
			
		||||
    #window = window.path if window.kind_of?(TkObject)
 | 
			
		||||
  def event_generate(win, context, keys=nil)
 | 
			
		||||
    #win = win.path if win.kind_of?(TkObject)
 | 
			
		||||
    if keys
 | 
			
		||||
      tk_call_without_enc('event', 'generate', window, 
 | 
			
		||||
      tk_call_without_enc('event', 'generate', win, 
 | 
			
		||||
                          "<#{tk_event_sequence(context)}>", 
 | 
			
		||||
                          *hash_kv(keys, true))
 | 
			
		||||
    else
 | 
			
		||||
      tk_call_without_enc('event', 'generate', window, 
 | 
			
		||||
      tk_call_without_enc('event', 'generate', win, 
 | 
			
		||||
                          "<#{tk_event_sequence(context)}>")
 | 
			
		||||
    end
 | 
			
		||||
    nil
 | 
			
		||||
| 
						 | 
				
			
			@ -1874,8 +1874,8 @@ module Tk
 | 
			
		|||
    TkManageFocus.prev(win)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def Tk.strictMotif(bool=None)
 | 
			
		||||
    bool(tk_call_without_enc('set', 'tk_strictMotif', bool))
 | 
			
		||||
  def Tk.strictMotif(mode=None)
 | 
			
		||||
    bool(tk_call_without_enc('set', 'tk_strictMotif', mode))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def Tk.show_kinsoku(mode='both')
 | 
			
		||||
| 
						 | 
				
			
			@ -2435,18 +2435,18 @@ module TkTreatFont
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def font_copy(window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def font_copy(win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fnt = window.tagfontobj(wintag, winkey).dup
 | 
			
		||||
        fnt = win.tagfontobj(wintag, winkey).dup
 | 
			
		||||
      else
 | 
			
		||||
        fnt = window.tagfontobj(wintag).dup
 | 
			
		||||
        fnt = win.tagfontobj(wintag).dup
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fnt = window.fontobj(winkey).dup
 | 
			
		||||
        fnt = win.fontobj(winkey).dup
 | 
			
		||||
      else
 | 
			
		||||
        fnt = window.fontobj.dup
 | 
			
		||||
        fnt = win.fontobj.dup
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2458,7 +2458,7 @@ module TkTreatFont
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def latinfont_copy(win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if targetkey
 | 
			
		||||
      fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], 
 | 
			
		||||
                                                 *(__config_cmd << {}))
 | 
			
		||||
| 
						 | 
				
			
			@ -2468,22 +2468,22 @@ module TkTreatFont
 | 
			
		|||
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.fontobj(winkey).latin_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.latin_replace(window.fontobj.latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.fontobj.latin_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  alias asciifont_copy latinfont_copy
 | 
			
		||||
 | 
			
		||||
  def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def kanjifont_copy(win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if targetkey
 | 
			
		||||
      fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], 
 | 
			
		||||
                                                 *(__config_cmd << {}))
 | 
			
		||||
| 
						 | 
				
			
			@ -2493,15 +2493,15 @@ module TkTreatFont
 | 
			
		|||
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.kanji_replace(window.fontobj.kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.fontobj.kanji_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    self
 | 
			
		||||
| 
						 | 
				
			
			@ -4002,7 +4002,7 @@ end
 | 
			
		|||
#Tk.freeze
 | 
			
		||||
 | 
			
		||||
module Tk
 | 
			
		||||
  RELEASE_DATE = '2005-03-05'.freeze
 | 
			
		||||
  RELEASE_DATE = '2005-03-10'.freeze
 | 
			
		||||
 | 
			
		||||
  autoload :AUTO_PATH,        'tk/variable'
 | 
			
		||||
  autoload :TCL_PACKAGE_PATH, 'tk/variable'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,6 +148,7 @@ autoload :TkTextWindow,       'tk/textwindow'
 | 
			
		|||
 | 
			
		||||
autoload :TkAfter,            'tk/timer'
 | 
			
		||||
autoload :TkTimer,            'tk/timer'
 | 
			
		||||
autoload :TkRTTimer,          'tk/timer'
 | 
			
		||||
 | 
			
		||||
autoload :TkToplevel,         'tk/toplevel'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -227,8 +227,8 @@ class TkCanvas<TkWindow
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(tagOrId, index)
 | 
			
		||||
    number(tk_send_without_enc('index', tagid(tagOrId), index))
 | 
			
		||||
  def index(tagOrId, idx)
 | 
			
		||||
    number(tk_send_without_enc('index', tagid(tagOrId), idx))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(tagOrId, index, string)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,8 +112,8 @@ module TkcTagAccess
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    @c.index(@id, index)
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    @c.index(@id, idx)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(beforethis, string)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,8 +32,8 @@ class TkEntry<TkLabel
 | 
			
		|||
    #self
 | 
			
		||||
    index
 | 
			
		||||
  end
 | 
			
		||||
  def index(index)
 | 
			
		||||
    number(tk_send_without_enc('index', index))
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    number(tk_send_without_enc('index', idx))
 | 
			
		||||
  end
 | 
			
		||||
  def insert(pos,text)
 | 
			
		||||
    tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,14 +163,14 @@ class TkFont
 | 
			
		|||
  ###################################
 | 
			
		||||
  # class methods
 | 
			
		||||
  ###################################
 | 
			
		||||
  def TkFont.families(window=nil)
 | 
			
		||||
  def TkFont.families(win=nil)
 | 
			
		||||
    case (Tk::TK_VERSION)
 | 
			
		||||
    when /^4\.*/
 | 
			
		||||
      ['fixed']
 | 
			
		||||
 | 
			
		||||
    when /^8\.*/
 | 
			
		||||
      if window
 | 
			
		||||
        tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
 | 
			
		||||
      if win
 | 
			
		||||
        tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
 | 
			
		||||
      else
 | 
			
		||||
        tk_split_simplelist(tk_call('font', 'families'))
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -675,7 +675,7 @@ class TkFont
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def actual_core_tk4x(font, window=nil, option=nil)
 | 
			
		||||
  def actual_core_tk4x(font, win=nil, option=nil)
 | 
			
		||||
    # dummy
 | 
			
		||||
    if option == 'pointadjust' || option == :pointadjust
 | 
			
		||||
        1.0
 | 
			
		||||
| 
						 | 
				
			
			@ -695,13 +695,13 @@ class TkFont
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def actual_core_tk8x(font, window=nil, option=nil)
 | 
			
		||||
  def actual_core_tk8x(font, win=nil, option=nil)
 | 
			
		||||
    if option == 'compound' || option == :compound
 | 
			
		||||
      ""
 | 
			
		||||
    elsif option
 | 
			
		||||
      if window
 | 
			
		||||
      if win
 | 
			
		||||
        val = tk_call('font', 'actual', font, 
 | 
			
		||||
                      "-displayof", window, "-#{option}")
 | 
			
		||||
                      "-displayof", win, "-#{option}")
 | 
			
		||||
      else
 | 
			
		||||
        val = tk_call('font', 'actual', font, "-#{option}")
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -714,9 +714,9 @@ class TkFont
 | 
			
		|||
        val
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      l = tk_split_simplelist(if window
 | 
			
		||||
      l = tk_split_simplelist(if win
 | 
			
		||||
                                 tk_call('font', 'actual', font, 
 | 
			
		||||
                                                     "-displayof", window)
 | 
			
		||||
                                                     "-displayof", win)
 | 
			
		||||
                              else
 | 
			
		||||
                                 tk_call('font', 'actual', font)
 | 
			
		||||
                              end)
 | 
			
		||||
| 
						 | 
				
			
			@ -1124,20 +1124,20 @@ class TkFont
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def measure_core_tk4x(window, text)
 | 
			
		||||
  def measure_core_tk4x(win, text)
 | 
			
		||||
    0
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def measure_core_tk8x(window, text)
 | 
			
		||||
    if window
 | 
			
		||||
  def measure_core_tk8x(win, text)
 | 
			
		||||
    if win
 | 
			
		||||
      number(tk_call('font', 'measure', @compoundfont, 
 | 
			
		||||
                     '-displayof', window, text))
 | 
			
		||||
                     '-displayof', win, text))
 | 
			
		||||
    else
 | 
			
		||||
      number(tk_call('font', 'measure', @compoundfont, text))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def metrics_core_tk4x(font, window, option=nil)
 | 
			
		||||
  def metrics_core_tk4x(font, win, option=nil)
 | 
			
		||||
    # dummy
 | 
			
		||||
    if option
 | 
			
		||||
      ""
 | 
			
		||||
| 
						 | 
				
			
			@ -1146,17 +1146,17 @@ class TkFont
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def metrics_core_tk8x(font, window, option=nil)
 | 
			
		||||
  def metrics_core_tk8x(font, win, option=nil)
 | 
			
		||||
    if option
 | 
			
		||||
      if window
 | 
			
		||||
      if win
 | 
			
		||||
        number(tk_call('font', 'metrics', font, 
 | 
			
		||||
                       "-displayof", window, "-#{option}"))
 | 
			
		||||
                       "-displayof", win, "-#{option}"))
 | 
			
		||||
      else
 | 
			
		||||
        number(tk_call('font', 'metrics', font, "-#{option}"))
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      l = tk_split_list(if window
 | 
			
		||||
                          tk_call('font','metrics',font,"-displayof",window)
 | 
			
		||||
      l = tk_split_list(if win
 | 
			
		||||
                          tk_call('font','metrics',font,"-displayof",win)
 | 
			
		||||
                        else
 | 
			
		||||
                          tk_call('font','metrics',font)
 | 
			
		||||
                        end)
 | 
			
		||||
| 
						 | 
				
			
			@ -1357,18 +1357,18 @@ class TkFont
 | 
			
		|||
    actual_core(@compoundfont, nil, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def actual_displayof(window, option=nil)
 | 
			
		||||
    window = '.' unless window
 | 
			
		||||
    actual_core(@compoundfont, window, option)
 | 
			
		||||
  def actual_displayof(win, option=nil)
 | 
			
		||||
    win = '.' unless win
 | 
			
		||||
    actual_core(@compoundfont, win, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latin_actual(option=nil)
 | 
			
		||||
    actual_core(@latinfont, nil, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latin_actual_displayof(window, option=nil)
 | 
			
		||||
    window = '.' unless window
 | 
			
		||||
    actual_core(@latinfont, window, option)
 | 
			
		||||
  def latin_actual_displayof(win, option=nil)
 | 
			
		||||
    win = '.' unless win
 | 
			
		||||
    actual_core(@latinfont, win, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def kanji_actual(option=nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1380,13 +1380,13 @@ class TkFont
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def kanji_actual_displayof(window, option=nil)
 | 
			
		||||
  def kanji_actual_displayof(win, option=nil)
 | 
			
		||||
    #if JAPANIZED_TK
 | 
			
		||||
    if @kanjifont != ""
 | 
			
		||||
      window = '.' unless window
 | 
			
		||||
      actual_core(@kanjifont, window, option)
 | 
			
		||||
      win = '.' unless win
 | 
			
		||||
      actual_core(@kanjifont, win, option)
 | 
			
		||||
    else
 | 
			
		||||
      actual_core_tk4x(nil, window, option)
 | 
			
		||||
      actual_core_tk4x(nil, win, option)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1478,27 +1478,27 @@ class TkFont
 | 
			
		|||
    measure_core(nil, text)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def measure_displayof(window, text)
 | 
			
		||||
    window = '.' unless window
 | 
			
		||||
    measure_core(window, text)
 | 
			
		||||
  def measure_displayof(win, text)
 | 
			
		||||
    win = '.' unless win
 | 
			
		||||
    measure_core(win, text)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def metrics(option=nil)
 | 
			
		||||
    metrics_core(@compoundfont, nil, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def metrics_displayof(window, option=nil)
 | 
			
		||||
    window = '.' unless window
 | 
			
		||||
    metrics_core(@compoundfont, window, option)
 | 
			
		||||
  def metrics_displayof(win, option=nil)
 | 
			
		||||
    win = '.' unless win
 | 
			
		||||
    metrics_core(@compoundfont, win, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latin_metrics(option=nil)
 | 
			
		||||
    metrics_core(@latinfont, nil, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latin_metrics_displayof(window, option=nil)
 | 
			
		||||
    window = '.' unless window
 | 
			
		||||
    metrics_core(@latinfont, window, option)
 | 
			
		||||
  def latin_metrics_displayof(win, option=nil)
 | 
			
		||||
    win = '.' unless win
 | 
			
		||||
    metrics_core(@latinfont, win, option)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def kanji_metrics(option=nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1509,12 +1509,12 @@ class TkFont
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def kanji_metrics_displayof(window, option=nil)
 | 
			
		||||
  def kanji_metrics_displayof(win, option=nil)
 | 
			
		||||
    if JAPANIZED_TK
 | 
			
		||||
      window = '.' unless window
 | 
			
		||||
      metrics_core(@kanjifont, window, option)
 | 
			
		||||
      win = '.' unless win
 | 
			
		||||
      metrics_core(@kanjifont, win, option)
 | 
			
		||||
    else
 | 
			
		||||
      metrics_core_tk4x(nil, window, option)
 | 
			
		||||
      metrics_core_tk4x(nil, win, option)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -158,13 +158,13 @@ module TkGrid
 | 
			
		|||
    list(tk_call_without_enc('grid', 'location', master, x, y))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def propagate(master, bool=None)
 | 
			
		||||
  def propagate(master, mode=None)
 | 
			
		||||
    # master = master.epath if master.kind_of?(TkObject)
 | 
			
		||||
    master = _epath(master)
 | 
			
		||||
    if bool == None
 | 
			
		||||
    if mode == None
 | 
			
		||||
      bool(tk_call_without_enc('grid', 'propagate', master))
 | 
			
		||||
    else
 | 
			
		||||
      tk_call_without_enc('grid', 'propagate', master, bool)
 | 
			
		||||
      tk_call_without_enc('grid', 'propagate', master, mode)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -221,18 +221,18 @@ module TkTreatItemFont
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def tagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fnt = window.tagfontobj(wintag, winkey).dup
 | 
			
		||||
        fnt = win.tagfontobj(wintag, winkey).dup
 | 
			
		||||
      else
 | 
			
		||||
        fnt = window.tagfontobj(wintag).dup
 | 
			
		||||
        fnt = win.tagfontobj(wintag).dup
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fnt = window.fontobj(winkey).dup
 | 
			
		||||
        fnt = win.fontobj(winkey).dup
 | 
			
		||||
      else
 | 
			
		||||
        fnt = window.fontobj.dup
 | 
			
		||||
        fnt = win.fontobj.dup
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -247,7 +247,7 @@ module TkTreatItemFont
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def latintagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if targetkey
 | 
			
		||||
      fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], 
 | 
			
		||||
                                                 *(__item_config_cmd(tagid(tagOrId)) << {}))
 | 
			
		||||
| 
						 | 
				
			
			@ -258,22 +258,22 @@ module TkTreatItemFont
 | 
			
		|||
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.fontobj(winkey).latin_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.latin_replace(window.fontobj.latin_font_id)
 | 
			
		||||
        fontobj.latin_replace(win.fontobj.latin_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  alias asciitagfont_copy latintagfont_copy
 | 
			
		||||
 | 
			
		||||
  def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
  def kanjifont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
 | 
			
		||||
    if targetkey
 | 
			
		||||
      fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], 
 | 
			
		||||
                                                 *(__item_config_cmd(tagid(tagOrId)) << {}))
 | 
			
		||||
| 
						 | 
				
			
			@ -284,15 +284,15 @@ module TkTreatItemFont
 | 
			
		|||
 | 
			
		||||
    if wintag
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if winkey
 | 
			
		||||
        fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id)
 | 
			
		||||
      else
 | 
			
		||||
        fontobj.kanji_replace(window.fontobj.kanji_font_id)
 | 
			
		||||
        fontobj.kanji_replace(win.fontobj.kanji_font_id)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    self
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,46 +13,46 @@ module TkKinput
 | 
			
		|||
    'kanjiInput'.freeze
 | 
			
		||||
  ].freeze
 | 
			
		||||
 | 
			
		||||
  def TkKinput.start(window, style=None)
 | 
			
		||||
    tk_call('kinput_start', window, style)
 | 
			
		||||
  def TkKinput.start(win, style=None)
 | 
			
		||||
    tk_call('kinput_start', win, style)
 | 
			
		||||
  end
 | 
			
		||||
  def kinput_start(style=None)
 | 
			
		||||
    TkKinput.start(self, style)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkKinput.send_spot(window)
 | 
			
		||||
    tk_call('kinput_send_spot', window)
 | 
			
		||||
  def TkKinput.send_spot(win)
 | 
			
		||||
    tk_call('kinput_send_spot', win)
 | 
			
		||||
  end
 | 
			
		||||
  def kinput_send_spot
 | 
			
		||||
    TkKinput.send_spot(self)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkKinput.input_start(window, keys=nil)
 | 
			
		||||
    tk_call('kanjiInput', 'start', window, *hash_kv(keys))
 | 
			
		||||
  def TkKinput.input_start(win, keys=nil)
 | 
			
		||||
    tk_call('kanjiInput', 'start', win, *hash_kv(keys))
 | 
			
		||||
  end
 | 
			
		||||
  def kanji_input_start(keys=nil)
 | 
			
		||||
    TkKinput.input_start(self, keys)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkKinput.attribute_config(window, slot, value=None)
 | 
			
		||||
  def TkKinput.attribute_config(win, slot, value=None)
 | 
			
		||||
    if slot.kind_of? Hash
 | 
			
		||||
      tk_call('kanjiInput', 'attribute', window, *hash_kv(slot))
 | 
			
		||||
      tk_call('kanjiInput', 'attribute', win, *hash_kv(slot))
 | 
			
		||||
    else
 | 
			
		||||
      tk_call('kanjiInput', 'attribute', window, "-#{slot}", value)
 | 
			
		||||
      tk_call('kanjiInput', 'attribute', win, "-#{slot}", value)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  def kinput_attribute_config(slot, value=None)
 | 
			
		||||
    TkKinput.attribute_config(self, slot, value)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkKinput.attribute_info(window, slot=nil)
 | 
			
		||||
  def TkKinput.attribute_info(win, slot=nil)
 | 
			
		||||
    if slot
 | 
			
		||||
      conf = tk_split_list(tk_call('kanjiInput', 'attribute', 
 | 
			
		||||
                                   window, "-#{slot}"))
 | 
			
		||||
                                   win, "-#{slot}"))
 | 
			
		||||
      conf[0] = conf[0][1..-1]
 | 
			
		||||
      conf
 | 
			
		||||
    else
 | 
			
		||||
      tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf|
 | 
			
		||||
      tk_split_list(tk_call('kanjiInput', 'attribute', win)).collect{|conf|
 | 
			
		||||
        conf[0] = conf[0][1..-1]
 | 
			
		||||
        conf
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -62,8 +62,8 @@ module TkKinput
 | 
			
		|||
    TkKinput.attribute_info(self, slot)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkKinput.input_end(window)
 | 
			
		||||
    tk_call('kanjiInput', 'end', window)
 | 
			
		||||
  def TkKinput.input_end(win)
 | 
			
		||||
    tk_call('kanjiInput', 'end', win)
 | 
			
		||||
  end
 | 
			
		||||
  def kanji_input_end
 | 
			
		||||
    TkKinput.input_end(self)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,8 +73,8 @@ class TkListbox<TkTextWin
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    tk_send_without_enc('index', index).to_i
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    tk_send_without_enc('index', idx).to_i
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def value
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,8 +95,8 @@ class TkMenu<TkWindow
 | 
			
		|||
  def add_separator(keys=nil)
 | 
			
		||||
    add('separator', keys)
 | 
			
		||||
  end
 | 
			
		||||
  def index(index)
 | 
			
		||||
    ret = tk_send_without_enc('index', _get_eval_enc_str(index))
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    ret = tk_send_without_enc('index', _get_eval_enc_str(idx))
 | 
			
		||||
    (ret == 'none')? nil: number(ret)
 | 
			
		||||
  end
 | 
			
		||||
  def invoke(index)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,15 +17,15 @@ module TkManageFocus
 | 
			
		|||
    tk_call_without_enc('tk_focusFollowsMouse')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkManageFocus.next(window)
 | 
			
		||||
    tk_tcl2ruby(tk_call('tk_focusNext', window))
 | 
			
		||||
  def TkManageFocus.next(win)
 | 
			
		||||
    tk_tcl2ruby(tk_call('tk_focusNext', win))
 | 
			
		||||
  end
 | 
			
		||||
  def focusNext
 | 
			
		||||
    TkManageFocus.next(self)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkManageFocus.prev(window)
 | 
			
		||||
    tk_tcl2ruby(tk_call('tk_focusPrev', window))
 | 
			
		||||
  def TkManageFocus.prev(win)
 | 
			
		||||
    tk_tcl2ruby(tk_call('tk_focusPrev', win))
 | 
			
		||||
  end
 | 
			
		||||
  def focusPrev
 | 
			
		||||
    TkManageFocus.prev(self)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,13 +51,13 @@ module TkPack
 | 
			
		|||
    return info
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def propagate(master, bool=None)
 | 
			
		||||
  def propagate(master, mode=None)
 | 
			
		||||
    # master = master.epath if master.kind_of?(TkObject)
 | 
			
		||||
    master = _epath(master)
 | 
			
		||||
    if bool == None
 | 
			
		||||
    if mode == None
 | 
			
		||||
      bool(tk_call_without_enc('pack', 'propagate', master))
 | 
			
		||||
    else
 | 
			
		||||
      tk_call_without_enc('pack', 'propagate', master, bool)
 | 
			
		||||
      tk_call_without_enc('pack', 'propagate', master, mode)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,22 +30,22 @@ module TkPalette
 | 
			
		|||
    tk_call('tkDarken', color, percent)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkPalette.recolorTree(window, colors)
 | 
			
		||||
  def TkPalette.recolorTree(win, colors)
 | 
			
		||||
    if not colors.kind_of?(Hash)
 | 
			
		||||
      fail "2nd arg need to be Hash"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    colors.each{|key, value|
 | 
			
		||||
      begin
 | 
			
		||||
        if window.cget(key) == tk_call('set', "tkPalette(#{key})")
 | 
			
		||||
          window[key] = colors[key]
 | 
			
		||||
        if win.cget(key) == tk_call('set', "tkPalette(#{key})")
 | 
			
		||||
          win[key] = colors[key]
 | 
			
		||||
        end
 | 
			
		||||
      rescue
 | 
			
		||||
        # ignore
 | 
			
		||||
      end
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)}
 | 
			
		||||
    TkWinfo.children(win).each{|w| TkPalette.recolorTree(w, colors)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def recolorTree(colors)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,19 +25,19 @@ module TkTreatTagFont
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def font_copy(window, wintag=nil)
 | 
			
		||||
    @parent.tagfont_copy(@id, window, wintag)
 | 
			
		||||
  def font_copy(win, wintag=nil)
 | 
			
		||||
    @parent.tagfont_copy(@id, win, wintag)
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def latinfont_copy(window, wintag=nil)
 | 
			
		||||
    @parent.latintagfont_copy(@id, window, wintag)
 | 
			
		||||
  def latinfont_copy(win, wintag=nil)
 | 
			
		||||
    @parent.latintagfont_copy(@id, win, wintag)
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  alias asciifont_copy latinfont_copy
 | 
			
		||||
 | 
			
		||||
  def kanjifont_copy(window, wintag=nil)
 | 
			
		||||
    @parent.kanjitagfont_copy(@id, window, wintag)
 | 
			
		||||
  def kanjifont_copy(win, wintag=nil)
 | 
			
		||||
    @parent.kanjitagfont_copy(@id, win, wintag)
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,12 +69,36 @@ class TkText<TkTextWin
 | 
			
		|||
  #######################################
 | 
			
		||||
 | 
			
		||||
  module IndexModMethods
 | 
			
		||||
    def +(mod)
 | 
			
		||||
      return chars(mod) if mod.kind_of?(Numeric)
 | 
			
		||||
 | 
			
		||||
      mod = mod.to_s
 | 
			
		||||
      if mod =~ /^\s*[+-]?\d/
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' + ' << mod)
 | 
			
		||||
      else
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' ' << mod)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def -(mod)
 | 
			
		||||
      return chars(-mod) if mod.kind_of?(Numeric)
 | 
			
		||||
 | 
			
		||||
      mod = mod.to_s
 | 
			
		||||
      if mod =~ /^\s*[+-]?\d/
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' - ' << mod)
 | 
			
		||||
      elsif mod =~ /^\s*[-]\s+(\d.*)$/
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' - -' << $1)
 | 
			
		||||
      else
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' ' << mod)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def chars(mod)
 | 
			
		||||
      fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
 | 
			
		||||
      if mod < 0
 | 
			
		||||
        TkText::IndexString.new(id + ' ' << mod.to_s << ' chars')
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
 | 
			
		||||
      else
 | 
			
		||||
        TkText::IndexString.new(id + ' + ' << mod.to_s << ' chars')
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    alias char chars
 | 
			
		||||
| 
						 | 
				
			
			@ -82,25 +106,25 @@ class TkText<TkTextWin
 | 
			
		|||
    def lines(mod)
 | 
			
		||||
      fail ArgumentError, 'expect Integer'  unless mod.kind_of?(Integer)
 | 
			
		||||
      if mod < 0
 | 
			
		||||
        TkText::IndexString.new(id + ' ' << mod.to_s << ' lines')
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
 | 
			
		||||
      else
 | 
			
		||||
        TkText::IndexString.new(id + ' + ' << mod.to_s << ' lines')
 | 
			
		||||
        TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    alias line lines
 | 
			
		||||
 | 
			
		||||
    def linestart
 | 
			
		||||
      TkText::IndexString.new(id + ' linestart')
 | 
			
		||||
      TkText::IndexString.new(String.new(id) << ' linestart')
 | 
			
		||||
    end
 | 
			
		||||
    def lineend
 | 
			
		||||
      TkText::IndexString.new(id + ' lineend')
 | 
			
		||||
      TkText::IndexString.new(String.new(id) << ' lineend')
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def wordstart
 | 
			
		||||
      TkText::IndexString.new(id + ' wordstart')
 | 
			
		||||
      TkText::IndexString.new(String.new(id) << ' wordstart')
 | 
			
		||||
    end
 | 
			
		||||
    def wordend
 | 
			
		||||
      TkText::IndexString.new(id + ' wordend')
 | 
			
		||||
      TkText::IndexString.new(String.new(id) << ' wordend')
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,9 +183,9 @@ class TkText<TkTextWin
 | 
			
		|||
  end
 | 
			
		||||
  private :create_self
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    TkText::IndexString.new(tk_send_without_enc('index', 
 | 
			
		||||
                                                _get_eval_enc_str(index)))
 | 
			
		||||
                                                _get_eval_enc_str(idx)))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def get_displaychars(*index)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,11 +47,39 @@ class TkTextMark<TkObject
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
=begin
 | 
			
		||||
  # move to TkText::IndexModMethods module
 | 
			
		||||
  def +(mod)
 | 
			
		||||
    TkText::IndexString.new(@id + ' + ' + mod)
 | 
			
		||||
    return chars(mod) if mod.kind_of?(Numeric)
 | 
			
		||||
 | 
			
		||||
    mod = mod.to_s
 | 
			
		||||
    if mod =~ /^\s*[+-]?\d/
 | 
			
		||||
      TkText::IndexString.new(@id + ' + ' + mod)
 | 
			
		||||
    else
 | 
			
		||||
      TkText::IndexString.new(@id + ' ' + mod)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def -(mod)
 | 
			
		||||
    TkText::IndexString.new(@id + ' - ' + mod)
 | 
			
		||||
    return chars(-mod) if mod.kind_of?(Numeric)
 | 
			
		||||
 | 
			
		||||
    mod = mod.to_s
 | 
			
		||||
    if mod =~ /^\s*[+-]?\d/
 | 
			
		||||
      TkText::IndexString.new(@id + ' - ' + mod)
 | 
			
		||||
    elsif mod =~ /^\s*[-]\s+(\d.*)$/
 | 
			
		||||
      TkText::IndexString.new(@id + ' - -' + $1)
 | 
			
		||||
    else
 | 
			
		||||
      TkText::IndexString.new(@id + ' ' + mod)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
=end
 | 
			
		||||
 | 
			
		||||
  def pos
 | 
			
		||||
    @t.index(@id)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def pos=(where)
 | 
			
		||||
    set(where)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set(where)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -401,6 +401,8 @@ class TkTimer
 | 
			
		|||
 | 
			
		||||
    @current_pos   = 0
 | 
			
		||||
    @current_args  = @init_args
 | 
			
		||||
    @current_script = []
 | 
			
		||||
 | 
			
		||||
    @set_next = false if @in_callback
 | 
			
		||||
 | 
			
		||||
    self
 | 
			
		||||
| 
						 | 
				
			
			@ -428,6 +430,7 @@ class TkTimer
 | 
			
		|||
 | 
			
		||||
  def continue(wait=nil)
 | 
			
		||||
    fail RuntimeError, "is already running" if @running
 | 
			
		||||
    return restart() if @current_script.empty?
 | 
			
		||||
    sleep, cmd = @current_script
 | 
			
		||||
    fail RuntimeError, "no procedure to continue" unless cmd
 | 
			
		||||
    if wait
 | 
			
		||||
| 
						 | 
				
			
			@ -498,3 +501,98 @@ class TkTimer
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
TkAfter = TkTimer
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TkRTTimer < TkTimer
 | 
			
		||||
  DEFAULT_OFFSET_LIST_SIZE = 5
 | 
			
		||||
 | 
			
		||||
  def initialize(*args, &b)
 | 
			
		||||
    super(*args, &b)
 | 
			
		||||
 | 
			
		||||
    @offset_list = Array.new(DEFAULT_OFFSET_LIST_SIZE, 0.0)
 | 
			
		||||
    @est_time = nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def start(*args, &b)
 | 
			
		||||
    return nil if @running
 | 
			
		||||
    @est_time = nil
 | 
			
		||||
    @cb_start_time = Time.now
 | 
			
		||||
    super(*args, &b)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def cancel
 | 
			
		||||
    super()
 | 
			
		||||
    @est_time = nil
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  alias stop cancel
 | 
			
		||||
 | 
			
		||||
  def set_interval(interval)
 | 
			
		||||
    super(interval)
 | 
			
		||||
    @est_time = nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def _offset_ave
 | 
			
		||||
    size = @offset_list.size.to_f
 | 
			
		||||
    s = 0.0
 | 
			
		||||
    @offset_list.each{|n| s + n}
 | 
			
		||||
    s / size
 | 
			
		||||
  end
 | 
			
		||||
  private :_offset_ave
 | 
			
		||||
 | 
			
		||||
  def set_next_callback(args)
 | 
			
		||||
    if @running == false || @proc_max == 0 || @do_loop == 0
 | 
			
		||||
      Tk_CBTBL.delete(@id) ;# for GC
 | 
			
		||||
      @running = false
 | 
			
		||||
      @wait_var.value = 0
 | 
			
		||||
      return
 | 
			
		||||
    end
 | 
			
		||||
    if @current_pos >= @proc_max
 | 
			
		||||
      if @do_loop < 0 || (@do_loop -= 1) > 0
 | 
			
		||||
        @current_pos = 0
 | 
			
		||||
      else
 | 
			
		||||
        Tk_CBTBL.delete(@id) ;# for GC
 | 
			
		||||
        @running = false
 | 
			
		||||
        @wait_var.value = 0
 | 
			
		||||
        return
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @current_args = args
 | 
			
		||||
 | 
			
		||||
    cmd, *cmd_args = @loop_proc[@current_pos]
 | 
			
		||||
    @current_pos += 1
 | 
			
		||||
    @current_proc = cmd
 | 
			
		||||
 | 
			
		||||
    if TkComm._callback_entry?(@sleep_time)
 | 
			
		||||
      sleep = @sleep_time.call(self)
 | 
			
		||||
    else
 | 
			
		||||
      sleep = @sleep_time
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if @est_time
 | 
			
		||||
      @est_time = Time.at(@est_time.to_f + sleep / 1000.0)
 | 
			
		||||
    else
 | 
			
		||||
      @est_time = Time.at(@cb_start_time.to_f + sleep / 1000.0)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    offset = _offset_ave
 | 
			
		||||
 | 
			
		||||
    real_sleep = ((@est_time - Time.now)*1000.0 + offset).round
 | 
			
		||||
    real_sleep = 0 if real_sleep < 0
 | 
			
		||||
    @current_sleep = real_sleep
 | 
			
		||||
 | 
			
		||||
    set_callback(real_sleep, cmd_args)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def cb_call
 | 
			
		||||
    @cb_start_time = Time.now
 | 
			
		||||
 | 
			
		||||
    if @est_time
 | 
			
		||||
      @offset_list.shift
 | 
			
		||||
      @offset_list.push((@est_time - @cb_start_time) * 1000.0)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @cb_cmd.call
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,30 +36,30 @@ module TkWinfo
 | 
			
		|||
    TkWinfo.atomname(id, self)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.cells(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'cells', window))
 | 
			
		||||
  def TkWinfo.cells(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'cells', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_cells
 | 
			
		||||
    TkWinfo.cells self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.children(window)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'children', window))
 | 
			
		||||
  def TkWinfo.children(win)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'children', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_children
 | 
			
		||||
    TkWinfo.children self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.classname(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'class', window)
 | 
			
		||||
  def TkWinfo.classname(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'class', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_classname
 | 
			
		||||
    TkWinfo.classname self
 | 
			
		||||
  end
 | 
			
		||||
  alias winfo_class winfo_classname
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.colormapfull(window)
 | 
			
		||||
     bool(tk_call_without_enc('winfo', 'colormapfull', window))
 | 
			
		||||
  def TkWinfo.colormapfull(win)
 | 
			
		||||
     bool(tk_call_without_enc('winfo', 'colormapfull', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_colormapfull
 | 
			
		||||
    TkWinfo.colormapfull self
 | 
			
		||||
| 
						 | 
				
			
			@ -77,52 +77,52 @@ module TkWinfo
 | 
			
		|||
    TkWinfo.containing(x, y, self)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.depth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'depth', window))
 | 
			
		||||
  def TkWinfo.depth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'depth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_depth
 | 
			
		||||
    TkWinfo.depth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.exist?(window)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'exists', window))
 | 
			
		||||
  def TkWinfo.exist?(win)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'exists', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_exist?
 | 
			
		||||
    TkWinfo.exist? self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.fpixels(window, dist)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'fpixels', window, dist))
 | 
			
		||||
  def TkWinfo.fpixels(win, dist)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'fpixels', win, dist))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_fpixels(dist)
 | 
			
		||||
    TkWinfo.fpixels self, dist
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.geometry(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'geometry', window)
 | 
			
		||||
  def TkWinfo.geometry(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'geometry', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_geometry
 | 
			
		||||
    TkWinfo.geometry self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.height(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'height', window))
 | 
			
		||||
  def TkWinfo.height(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'height', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_height
 | 
			
		||||
    TkWinfo.height self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.id(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'id', window)
 | 
			
		||||
  def TkWinfo.id(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'id', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_id
 | 
			
		||||
    TkWinfo.id self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.interps(window=nil)
 | 
			
		||||
    if window
 | 
			
		||||
  def TkWinfo.interps(win=nil)
 | 
			
		||||
    if win
 | 
			
		||||
      tk_split_simplelist(tk_call_without_enc('winfo', 'interps',
 | 
			
		||||
                                              '-displayof', window))
 | 
			
		||||
                                              '-displayof', win))
 | 
			
		||||
    else
 | 
			
		||||
      tk_split_simplelist(tk_call_without_enc('winfo', 'interps'))
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -131,29 +131,29 @@ module TkWinfo
 | 
			
		|||
    TkWinfo.interps self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.mapped?(window)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'ismapped', window))
 | 
			
		||||
  def TkWinfo.mapped?(win)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'ismapped', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_mapped?
 | 
			
		||||
    TkWinfo.mapped? self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.manager(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'manager', window)
 | 
			
		||||
  def TkWinfo.manager(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'manager', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_manager
 | 
			
		||||
    TkWinfo.manager self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.appname(window)
 | 
			
		||||
    tk_call('winfo', 'name', window)
 | 
			
		||||
  def TkWinfo.appname(win)
 | 
			
		||||
    tk_call('winfo', 'name', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_appname
 | 
			
		||||
    TkWinfo.appname self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.parent(window)
 | 
			
		||||
    window(tk_call_without_enc('winfo', 'parent', window))
 | 
			
		||||
  def TkWinfo.parent(win)
 | 
			
		||||
    window(tk_call_without_enc('winfo', 'parent', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_parent
 | 
			
		||||
    TkWinfo.parent self
 | 
			
		||||
| 
						 | 
				
			
			@ -170,216 +170,216 @@ module TkWinfo
 | 
			
		|||
    TkWinfo.widget id, self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.pixels(window, dist)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pixels', window, dist))
 | 
			
		||||
  def TkWinfo.pixels(win, dist)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pixels', win, dist))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_pixels(dist)
 | 
			
		||||
    TkWinfo.pixels self, dist
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.reqheight(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'reqheight', window))
 | 
			
		||||
  def TkWinfo.reqheight(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'reqheight', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_reqheight
 | 
			
		||||
    TkWinfo.reqheight self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.reqwidth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'reqwidth', window))
 | 
			
		||||
  def TkWinfo.reqwidth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'reqwidth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_reqwidth
 | 
			
		||||
    TkWinfo.reqwidth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.rgb(window, color)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'rgb', window, color))
 | 
			
		||||
  def TkWinfo.rgb(win, color)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'rgb', win, color))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_rgb(color)
 | 
			
		||||
    TkWinfo.rgb self, color
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.rootx(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'rootx', window))
 | 
			
		||||
  def TkWinfo.rootx(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'rootx', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_rootx
 | 
			
		||||
    TkWinfo.rootx self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.rooty(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'rooty', window))
 | 
			
		||||
  def TkWinfo.rooty(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'rooty', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_rooty
 | 
			
		||||
    TkWinfo.rooty self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screen(window)
 | 
			
		||||
    tk_call('winfo', 'screen', window)
 | 
			
		||||
  def TkWinfo.screen(win)
 | 
			
		||||
    tk_call('winfo', 'screen', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screen
 | 
			
		||||
    TkWinfo.screen self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screencells(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screencells', window))
 | 
			
		||||
  def TkWinfo.screencells(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screencells', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screencells
 | 
			
		||||
    TkWinfo.screencells self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screendepth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screendepth', window))
 | 
			
		||||
  def TkWinfo.screendepth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screendepth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screendepth
 | 
			
		||||
    TkWinfo.screendepth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screenheight (window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenheight', window))
 | 
			
		||||
  def TkWinfo.screenheight (win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenheight', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screenheight
 | 
			
		||||
    TkWinfo.screenheight self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screenmmheight(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenmmheight', window))
 | 
			
		||||
  def TkWinfo.screenmmheight(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenmmheight', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screenmmheight
 | 
			
		||||
    TkWinfo.screenmmheight self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screenmmwidth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenmmwidth', window))
 | 
			
		||||
  def TkWinfo.screenmmwidth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenmmwidth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screenmmwidth
 | 
			
		||||
    TkWinfo.screenmmwidth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screenvisual(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'screenvisual', window)
 | 
			
		||||
  def TkWinfo.screenvisual(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'screenvisual', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screenvisual
 | 
			
		||||
    TkWinfo.screenvisual self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.screenwidth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenwidth', window))
 | 
			
		||||
  def TkWinfo.screenwidth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'screenwidth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_screenwidth
 | 
			
		||||
    TkWinfo.screenwidth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.server(window)
 | 
			
		||||
    tk_call('winfo', 'server', window)
 | 
			
		||||
  def TkWinfo.server(win)
 | 
			
		||||
    tk_call('winfo', 'server', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_server
 | 
			
		||||
    TkWinfo.server self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.toplevel(window)
 | 
			
		||||
    window(tk_call_without_enc('winfo', 'toplevel', window))
 | 
			
		||||
  def TkWinfo.toplevel(win)
 | 
			
		||||
    window(tk_call_without_enc('winfo', 'toplevel', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_toplevel
 | 
			
		||||
    TkWinfo.toplevel self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.visual(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'visual', window)
 | 
			
		||||
  def TkWinfo.visual(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'visual', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_visual
 | 
			
		||||
    TkWinfo.visual self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.visualid(window)
 | 
			
		||||
    tk_call_without_enc('winfo', 'visualid', window)
 | 
			
		||||
  def TkWinfo.visualid(win)
 | 
			
		||||
    tk_call_without_enc('winfo', 'visualid', win)
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_visualid
 | 
			
		||||
    TkWinfo.visualid self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.visualsavailable(window, includeids=false)
 | 
			
		||||
  def TkWinfo.visualsavailable(win, includeids=false)
 | 
			
		||||
    if includeids
 | 
			
		||||
      list(tk_call_without_enc('winfo', 'visualsavailable', 
 | 
			
		||||
                               window, "includeids"))
 | 
			
		||||
                               win, "includeids"))
 | 
			
		||||
    else
 | 
			
		||||
      list(tk_call_without_enc('winfo', 'visualsavailable', window))
 | 
			
		||||
      list(tk_call_without_enc('winfo', 'visualsavailable', win))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_visualsavailable(includeids=false)
 | 
			
		||||
    TkWinfo.visualsavailable self, includeids
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.vrootheight(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootheight', window))
 | 
			
		||||
  def TkWinfo.vrootheight(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootheight', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_vrootheight
 | 
			
		||||
    TkWinfo.vrootheight self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.vrootwidth(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootwidth', window))
 | 
			
		||||
  def TkWinfo.vrootwidth(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootwidth', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_vrootwidth
 | 
			
		||||
    TkWinfo.vrootwidth self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.vrootx(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootx', window))
 | 
			
		||||
  def TkWinfo.vrootx(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrootx', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_vrootx
 | 
			
		||||
    TkWinfo.vrootx self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.vrooty(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrooty', window))
 | 
			
		||||
  def TkWinfo.vrooty(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'vrooty', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_vrooty
 | 
			
		||||
    TkWinfo.vrooty self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.width(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'width', window))
 | 
			
		||||
  def TkWinfo.width(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'width', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_width
 | 
			
		||||
    TkWinfo.width self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.x(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'x', window))
 | 
			
		||||
  def TkWinfo.x(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'x', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_x
 | 
			
		||||
    TkWinfo.x self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.y(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'y', window))
 | 
			
		||||
  def TkWinfo.y(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'y', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_y
 | 
			
		||||
    TkWinfo.y self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.viewable(window)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'viewable', window))
 | 
			
		||||
  def TkWinfo.viewable(win)
 | 
			
		||||
    bool(tk_call_without_enc('winfo', 'viewable', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_viewable
 | 
			
		||||
    TkWinfo.viewable self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.pointerx(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pointerx', window))
 | 
			
		||||
  def TkWinfo.pointerx(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pointerx', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_pointerx
 | 
			
		||||
    TkWinfo.pointerx self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.pointery(window)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pointery', window))
 | 
			
		||||
  def TkWinfo.pointery(win)
 | 
			
		||||
    number(tk_call_without_enc('winfo', 'pointery', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_pointery
 | 
			
		||||
    TkWinfo.pointery self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkWinfo.pointerxy(window)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'pointerxy', window))
 | 
			
		||||
  def TkWinfo.pointerxy(win)
 | 
			
		||||
    list(tk_call_without_enc('winfo', 'pointerxy', win))
 | 
			
		||||
  end
 | 
			
		||||
  def winfo_pointerxy
 | 
			
		||||
    TkWinfo.pointerxy self
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,11 +192,11 @@ module Tk
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def overrideredirect(bool=None)
 | 
			
		||||
      if bool == None
 | 
			
		||||
    def overrideredirect(mode=None)
 | 
			
		||||
      if mode == None
 | 
			
		||||
        bool(tk_call_without_enc('wm', 'overrideredirect', path))
 | 
			
		||||
      else
 | 
			
		||||
        tk_call_without_enc('wm', 'overrideredirect', path, bool)
 | 
			
		||||
        tk_call_without_enc('wm', 'overrideredirect', path, mode)
 | 
			
		||||
        self
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -257,9 +257,9 @@ module Tk
 | 
			
		|||
      bool(tk_call('wm', 'stackorder', path, 'isbelow', win))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def state(state=nil)
 | 
			
		||||
      if state
 | 
			
		||||
        tk_call_without_enc('wm', 'state', path, state)
 | 
			
		||||
    def state(st=nil)
 | 
			
		||||
      if st
 | 
			
		||||
        tk_call_without_enc('wm', 'state', path, st)
 | 
			
		||||
        self
 | 
			
		||||
      else
 | 
			
		||||
        tk_call_without_enc('wm', 'state', path)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,34 +9,34 @@ module TkXIM
 | 
			
		|||
 | 
			
		||||
  TkCommandNames = ['imconfigure'.freeze].freeze
 | 
			
		||||
 | 
			
		||||
  def TkXIM.useinputmethods(value = None, window = nil)
 | 
			
		||||
  def TkXIM.useinputmethods(value = None, win = nil)
 | 
			
		||||
    if value == None
 | 
			
		||||
      if window
 | 
			
		||||
      if win
 | 
			
		||||
        bool(tk_call_without_enc('tk', 'useinputmethods', 
 | 
			
		||||
                                 '-displayof', window))
 | 
			
		||||
                                 '-displayof', win))
 | 
			
		||||
      else
 | 
			
		||||
        bool(tk_call_without_enc('tk', 'useinputmethods'))
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      if window
 | 
			
		||||
      if win
 | 
			
		||||
        bool(tk_call_without_enc('tk', 'useinputmethods', 
 | 
			
		||||
                                 '-displayof', window, value))
 | 
			
		||||
                                 '-displayof', win, value))
 | 
			
		||||
      else
 | 
			
		||||
        bool(tk_call_without_enc('tk', 'useinputmethods', value))
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkXIM.useinputmethods_displayof(window, value = None)
 | 
			
		||||
    TkXIM.useinputmethods(value, window)
 | 
			
		||||
  def TkXIM.useinputmethods_displayof(win, value = None)
 | 
			
		||||
    TkXIM.useinputmethods(value, win)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkXIM.caret(window, keys=nil)
 | 
			
		||||
  def TkXIM.caret(win, keys=nil)
 | 
			
		||||
    if keys
 | 
			
		||||
      tk_call_without_enc('tk', 'caret', window, *hash_kv(keys))
 | 
			
		||||
      tk_call_without_enc('tk', 'caret', win, *hash_kv(keys))
 | 
			
		||||
      self
 | 
			
		||||
    else
 | 
			
		||||
      lst = tk_split_list(tk_call_without_enc('tk', 'caret', window))
 | 
			
		||||
      lst = tk_split_list(tk_call_without_enc('tk', 'caret', win))
 | 
			
		||||
      info = {}
 | 
			
		||||
      while key = lst.shift
 | 
			
		||||
        info[key[1..-1]] = lst.shift
 | 
			
		||||
| 
						 | 
				
			
			@ -45,29 +45,29 @@ module TkXIM
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkXIM.configure(window, slot, value=None)
 | 
			
		||||
  def TkXIM.configure(win, slot, value=None)
 | 
			
		||||
    begin
 | 
			
		||||
      if /^8\.*/ === Tk::TK_VERSION  && JAPANIZED_TK
 | 
			
		||||
        if slot.kind_of? Hash
 | 
			
		||||
          tk_call('imconfigure', window, *hash_kv(slot))
 | 
			
		||||
          tk_call('imconfigure', win, *hash_kv(slot))
 | 
			
		||||
        else
 | 
			
		||||
          tk_call('imconfigure', window, "-#{slot}", value)
 | 
			
		||||
          tk_call('imconfigure', win, "-#{slot}", value)
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    rescue
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkXIM.configinfo(window, slot=nil)
 | 
			
		||||
  def TkXIM.configinfo(win, slot=nil)
 | 
			
		||||
    if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
 | 
			
		||||
      begin
 | 
			
		||||
        if /^8\.*/ === Tk::TK_VERSION  && JAPANIZED_TK
 | 
			
		||||
          if slot
 | 
			
		||||
            conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
 | 
			
		||||
            conf = tk_split_list(tk_call('imconfigure', win, "-#{slot}"))
 | 
			
		||||
            conf[0] = conf[0][1..-1]
 | 
			
		||||
            conf
 | 
			
		||||
          else
 | 
			
		||||
            tk_split_list(tk_call('imconfigure', window)).collect{|conf|
 | 
			
		||||
            tk_split_list(tk_call('imconfigure', win)).collect{|conf|
 | 
			
		||||
              conf[0] = conf[0][1..-1]
 | 
			
		||||
              conf
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -79,19 +79,19 @@ module TkXIM
 | 
			
		|||
        []
 | 
			
		||||
      end
 | 
			
		||||
    else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
 | 
			
		||||
      TkXIM.current_configinfo(window, slot)
 | 
			
		||||
      TkXIM.current_configinfo(win, slot)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def TkXIM.current_configinfo(window, slot=nil)
 | 
			
		||||
  def TkXIM.current_configinfo(win, slot=nil)
 | 
			
		||||
    begin
 | 
			
		||||
      if /^8\.*/ === Tk::TK_VERSION  && JAPANIZED_TK
 | 
			
		||||
        if slot
 | 
			
		||||
          conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
 | 
			
		||||
          conf = tk_split_list(tk_call('imconfigure', win, "-#{slot}"))
 | 
			
		||||
          { conf[0][1..-1] => conf[1] }
 | 
			
		||||
        else
 | 
			
		||||
          ret = {}
 | 
			
		||||
          tk_split_list(tk_call('imconfigure', window)).each{|conf|
 | 
			
		||||
          tk_split_list(tk_call('imconfigure', win)).each{|conf|
 | 
			
		||||
            ret[conf[0][1..-1]] = conf[1]
 | 
			
		||||
          }
 | 
			
		||||
          ret
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -139,24 +139,24 @@ class Tk::Iwidgets::Notebook
 | 
			
		|||
  end
 | 
			
		||||
  alias scrollbar yscrollbar
 | 
			
		||||
 | 
			
		||||
  def view(*index)
 | 
			
		||||
    if index.size == 0
 | 
			
		||||
  def view(*idxs)
 | 
			
		||||
    if idxss.size == 0
 | 
			
		||||
      window(tk_send_without_enc('view'))
 | 
			
		||||
    else
 | 
			
		||||
      tk_send_without_enc('view', *index)
 | 
			
		||||
      tk_send_without_enc('view', *idxs)
 | 
			
		||||
      self
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  alias xview view
 | 
			
		||||
  alias yview view
 | 
			
		||||
 | 
			
		||||
  def view_moveto(*index)
 | 
			
		||||
    view('moveto', *index)
 | 
			
		||||
  def view_moveto(*idxs)
 | 
			
		||||
    view('moveto', *idxs)
 | 
			
		||||
  end
 | 
			
		||||
  alias xview_moveto view_moveto
 | 
			
		||||
  alias yview_moveto view_moveto
 | 
			
		||||
  def view_scroll(*index)
 | 
			
		||||
    view('scroll', *index)
 | 
			
		||||
  def view_scroll(*idxs)
 | 
			
		||||
    view('scroll', *idxs)
 | 
			
		||||
  end
 | 
			
		||||
  alias xview_scroll view_scroll
 | 
			
		||||
  alias yview_scroll view_scroll
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,8 +73,8 @@ class Tk::Iwidgets::Promptdialog
 | 
			
		|||
  end
 | 
			
		||||
  alias icursor cursor=
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    number(tk_send_without_enc('index', index))
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    number(tk_send_without_enc('index', idx))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(pos,text)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -228,8 +228,8 @@ class Tk::Iwidgets::Scrolledcanvas
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(tagOrId, index)
 | 
			
		||||
    number(tk_send_without_enc('index', tagid(tagOrId), index))
 | 
			
		||||
  def index(tagOrId, idx)
 | 
			
		||||
    number(tk_send_without_enc('index', tagid(tagOrId), idx))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(tagOrId, index, string)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -152,8 +152,8 @@ class Tk::Iwidgets::Scrolledlistbox
 | 
			
		|||
    self
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    tk_send_without_enc('index', index).to_i
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    tk_send_without_enc('index', idx).to_i
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  #####################################
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -240,8 +240,8 @@ class Tk::Iwidgets::Scrolledtext
 | 
			
		|||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    tk_send_without_enc('index', _get_eval_enc_str(index))
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    tk_send_without_enc('index', _get_eval_enc_str(idx))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(index, *args)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,8 +57,8 @@ class Tk::Iwidgets::Selectionbox
 | 
			
		|||
    tk_send_without_enc('delete', first, last)
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  def index(index)
 | 
			
		||||
    tk_send_without_enc('index', index).to_i
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    tk_send_without_enc('index', idx).to_i
 | 
			
		||||
  end
 | 
			
		||||
  def nearest(y)
 | 
			
		||||
    tk_send_without_enc('nearest', y).to_i
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,8 +57,8 @@ class Tk::Iwidgets::Selectiondialog
 | 
			
		|||
    tk_send_without_enc('delete', first, last)
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  def index(index)
 | 
			
		||||
    tk_send_without_enc('index', index).to_i
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    tk_send_without_enc('index', idx).to_i
 | 
			
		||||
  end
 | 
			
		||||
  def nearest(y)
 | 
			
		||||
    tk_send_without_enc('nearest', y).to_i
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,8 +91,8 @@ class Tk::Iwidgets::Spinner
 | 
			
		|||
  end
 | 
			
		||||
  alias icursor cursor=
 | 
			
		||||
 | 
			
		||||
  def index(index)
 | 
			
		||||
    number(tk_send_without_enc('index', index))
 | 
			
		||||
  def index(idx)
 | 
			
		||||
    number(tk_send_without_enc('index', idx))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def insert(pos,text)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -517,10 +517,10 @@ end
 | 
			
		|||
# txt -         Name of text widget
 | 
			
		||||
# index -       The index of the character that the user clicked on.
 | 
			
		||||
 | 
			
		||||
def invoke (txt, index)
 | 
			
		||||
  tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
 | 
			
		||||
def invoke (txt, idx)
 | 
			
		||||
  tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
 | 
			
		||||
  return unless tag
 | 
			
		||||
  cursor = txt.cget('cursor')
 | 
			
		||||
  current_cursor = txt.cget('cursor')
 | 
			
		||||
  txt.cursor('watch')
 | 
			
		||||
  Tk.update
 | 
			
		||||
#  eval `cat #{tag[5..-1]}.rb`
 | 
			
		||||
| 
						 | 
				
			
			@ -528,9 +528,9 @@ def invoke (txt, index)
 | 
			
		|||
  eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
 | 
			
		||||
  Tk.update
 | 
			
		||||
#  txt.cursor('xterm')
 | 
			
		||||
  txt.cursor(cursor)
 | 
			
		||||
  txt.cursor(current_cursor)
 | 
			
		||||
 | 
			
		||||
  $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars")
 | 
			
		||||
  $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# showStatus --
 | 
			
		||||
| 
						 | 
				
			
			@ -791,7 +791,7 @@ end
 | 
			
		|||
#
 | 
			
		||||
def aboutBox
 | 
			
		||||
  Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', 
 | 
			
		||||
                'message'=>"Ruby/Tk widget demonstration Ver.1.5.2-en\n\n" + 
 | 
			
		||||
                'message'=>"Ruby/Tk widget demonstration Ver.1.5.3-en\n\n" + 
 | 
			
		||||
                           "based on demos of Tk8.1 -- 8.5  " + 
 | 
			
		||||
                           "( Copyright:: " + 
 | 
			
		||||
                           "(c) 1996-1997 Sun Microsystems, Inc. / " + 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -552,10 +552,10 @@ else # ver >= 8.4
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
# テキスト上での click に対する動作
 | 
			
		||||
def invoke (txt, index)
 | 
			
		||||
  tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
 | 
			
		||||
def invoke (txt, idx)
 | 
			
		||||
  tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
 | 
			
		||||
  return unless tag
 | 
			
		||||
  cursor = txt.cget('cursor')
 | 
			
		||||
  current_cursor = txt.cget('cursor')
 | 
			
		||||
  txt.cursor('watch')
 | 
			
		||||
  Tk.update
 | 
			
		||||
#  eval `cat #{tag[5..-1]}.rb`
 | 
			
		||||
| 
						 | 
				
			
			@ -563,9 +563,9 @@ def invoke (txt, index)
 | 
			
		|||
  eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
 | 
			
		||||
  Tk.update
 | 
			
		||||
#  txt.cursor('xterm')
 | 
			
		||||
  txt.cursor(cursor)
 | 
			
		||||
  txt.cursor(current_cursor)
 | 
			
		||||
 | 
			
		||||
  $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars")
 | 
			
		||||
  $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 状態表示
 | 
			
		||||
| 
						 | 
				
			
			@ -819,7 +819,7 @@ end
 | 
			
		|||
#
 | 
			
		||||
def aboutBox
 | 
			
		||||
  Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', 
 | 
			
		||||
                'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.2-jp\n\n" + 
 | 
			
		||||
                'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.3-jp\n\n" + 
 | 
			
		||||
                           "based on demos of Tk8.1 -- 8.5  " + 
 | 
			
		||||
                           "( Copyright:: " + 
 | 
			
		||||
                           "(c) 1996-1997 Sun Microsystems, Inc. / " + 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										68
									
								
								ext/tk/sample/tkrttimer.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								ext/tk/sample/tkrttimer.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
#!/usr/bin/env ruby
 | 
			
		||||
# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
 | 
			
		||||
 | 
			
		||||
require "tk"
 | 
			
		||||
 | 
			
		||||
root = TkRoot.new(:title=>'realtime timer sample')
 | 
			
		||||
 | 
			
		||||
f1 = TkFrame.new(:borderwidth=>2, :relief=>:ridge)
 | 
			
		||||
f1.pack(:side=>:bottom, :fill=>:both)
 | 
			
		||||
TkLabel.new(f1, :text=>'use TkTimer (TkAfter) class').pack(:anchor=>:center)
 | 
			
		||||
label1 = TkLabel.new(:parent=>f1, :relief=>:raised, 
 | 
			
		||||
                     :width=>10).pack(:fill=>:both)
 | 
			
		||||
 | 
			
		||||
f2 = TkFrame.new(:borderwidth=>2, :relief=>:ridge)
 | 
			
		||||
f2.pack(:side=>:bottom, :fill=>:both)
 | 
			
		||||
TkLabel.new(f2, :text=>'use TkRTTimer class').pack
 | 
			
		||||
label2 = TkLabel.new(:parent=>f2, :relief=>:raised, 
 | 
			
		||||
                     :width=>10).pack(:fill=>:both)
 | 
			
		||||
 | 
			
		||||
TkLabel.new(:text=>'Interval setting of each timer is 10 ms.', 
 | 
			
		||||
            :padx=>10, :pady=>5).pack
 | 
			
		||||
 | 
			
		||||
# define the procedure repeated by the TkTimer object
 | 
			
		||||
tick = proc{|aobj| #<== TkTimer object
 | 
			
		||||
  cnt = aobj.return_value + 1  # return_value keeps a result of the last proc
 | 
			
		||||
  label = aobj.current_args[0]
 | 
			
		||||
  label.text format("%d.%02d", *(cnt.divmod(100)))
 | 
			
		||||
  cnt #==> return value is kept by TkTimer object
 | 
			
		||||
      #    (so, can be send to the next repeat-proc)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
timer1 = TkTimer.new(10, -1, [tick, label1])    # 10 ms interval
 | 
			
		||||
timer2 = TkRTTimer.new(10, -1, [tick, label2])  # 10 ms interval
 | 
			
		||||
 | 
			
		||||
timer1.start(0, proc{ label1.text('0.00'); 0 })
 | 
			
		||||
timer2.start(0, proc{ label2.text('0.00'); 0 })
 | 
			
		||||
 | 
			
		||||
b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
 | 
			
		||||
  pack(:side=>:left, :fill=>:both, :expand=>true)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
b_stop  = TkButton.new(:text=>'Stop', :state=>:normal) {
 | 
			
		||||
  pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
b_start.command {
 | 
			
		||||
  timer1.continue
 | 
			
		||||
  timer2.continue
 | 
			
		||||
  b_stop.state(:normal)
 | 
			
		||||
  b_start.state(:disabled)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
b_stop.command {
 | 
			
		||||
  timer1.stop
 | 
			
		||||
  timer2.stop
 | 
			
		||||
  b_start.state(:normal)
 | 
			
		||||
  b_stop.state(:disabled)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TkButton.new(:text=>'Reset', :state=>:normal) {
 | 
			
		||||
  command { timer1.reset; timer2.reset }
 | 
			
		||||
  pack(:side=>:right, :fill=>:both, :expand=>:yes)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
 | 
			
		||||
Tk.root.bind(ev_quit, proc{Tk.exit}).focus
 | 
			
		||||
 | 
			
		||||
Tk.mainloop
 | 
			
		||||
| 
						 | 
				
			
			@ -581,5 +581,23 @@ if __FILE__ == $0
 | 
			
		|||
 | 
			
		||||
  STDOUT.print("\n================================================\n\n")
 | 
			
		||||
 | 
			
		||||
  STDOUT.print("\n========= reverse order (seek by lines) ========\n\n")
 | 
			
		||||
 | 
			
		||||
  tio.seek(-1, IO::SEEK_END)
 | 
			
		||||
  begin
 | 
			
		||||
    begin
 | 
			
		||||
      tio.seek(:linestart, IO::SEEK_CUR)
 | 
			
		||||
    rescue
 | 
			
		||||
      # maybe use old version of tk/textmark.rb
 | 
			
		||||
      tio.seek('0 char linestart', IO::SEEK_CUR)
 | 
			
		||||
    end
 | 
			
		||||
    STDOUT.print(gets)
 | 
			
		||||
    tio.seek('-1 char linestart -1 char', IO::SEEK_CUR)
 | 
			
		||||
  end while(tio.pos > 0)
 | 
			
		||||
 | 
			
		||||
  STDOUT.print("\n================================================\n\n")
 | 
			
		||||
 | 
			
		||||
  tio.seek(0, IO::SEEK_END)
 | 
			
		||||
 | 
			
		||||
  Tk.mainloop
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
 *              Oct. 24, 1997   Y. Matsumoto
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define TCLTKLIB_RELEASE_DATE "2005-03-02"
 | 
			
		||||
#define TCLTKLIB_RELEASE_DATE "2005-03-10"
 | 
			
		||||
 | 
			
		||||
#include "ruby.h"
 | 
			
		||||
#include "rubysig.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -652,7 +652,7 @@ _timer_for_tcl(clientData)
 | 
			
		|||
    /* struct invoke_queue *q, *tmp; */
 | 
			
		||||
    /* VALUE thread; */
 | 
			
		||||
 | 
			
		||||
    DUMP1("called timer_for_tcl");
 | 
			
		||||
    DUMP1("call _timer_for_tcl");
 | 
			
		||||
 | 
			
		||||
    thr_crit_bup = rb_thread_critical;
 | 
			
		||||
    rb_thread_critical = Qtrue;
 | 
			
		||||
| 
						 | 
				
			
			@ -1402,9 +1402,6 @@ lib_eventloop_ensure(args)
 | 
			
		|||
    struct evloop_params *ptr = (struct evloop_params *)args;
 | 
			
		||||
    volatile VALUE current_evloop = rb_thread_current();
 | 
			
		||||
 | 
			
		||||
    Tk_DeleteTimerHandler(timer_token);
 | 
			
		||||
    timer_token = (Tcl_TimerToken)NULL;
 | 
			
		||||
 | 
			
		||||
    DUMP2("eventloop_ensure: current-thread : %lx", current_evloop);
 | 
			
		||||
    DUMP2("eventloop_ensure: eventloop-thread : %lx", eventloop_thread);
 | 
			
		||||
    if (eventloop_thread != current_evloop) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1422,7 +1419,12 @@ lib_eventloop_ensure(args)
 | 
			
		|||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (NIL_P(eventloop_thread)) break; 
 | 
			
		||||
        if (NIL_P(eventloop_thread)) {
 | 
			
		||||
          Tk_DeleteTimerHandler(timer_token);
 | 
			
		||||
          timer_token = (Tcl_TimerToken)NULL;
 | 
			
		||||
 | 
			
		||||
          break; 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (RTEST(rb_funcall(eventloop_thread, ID_alive_p, 0, 0))) {
 | 
			
		||||
            DUMP2("eventloop-enshure: wake up parent %lx", eventloop_thread);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue