From 9ff1e787f915539b1980654e3d3d2013ff5c81d2 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 7 Jul 2008 07:38:25 +0000 Subject: wrong commit; sorry git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_269@17938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb | 194 ------------------------------ 1 file changed, 194 deletions(-) delete mode 100644 ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb (limited to 'ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb') diff --git a/ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb b/ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb deleted file mode 100644 index c2c95f771d..0000000000 --- a/ruby_1_8_6/ext/tk/sample/tkballoonhelp.rb +++ /dev/null @@ -1,194 +0,0 @@ -# -# tkballoonhelp.rb : simple balloon help widget -# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) -# -# Add a balloon help to a widget. -# This widget has only poor featureas. If you need more useful features, -# please try to use the Tix extension of Tcl/Tk under Ruby/Tk. -# -# The interval time to display a balloon help is defined 'interval' option -# (default is 1000ms). -# -require 'tk' - -class TkBalloonHelp'bisque').pack - @label.configure(_symbolkey2str(keys)) unless keys.empty? - @path = @label - end - - def epath - @epath - end - - def interval(val) - if val - @timer.interval(val) - else - @interval - end - end - - def command(cmd = Proc.new) - @command = cmd - self - end - - def show - x = TkWinfo.pointerx(@parent) - y = TkWinfo.pointery(@parent) - @frame.geometry("+#{x+1}+#{y+1}") - - if @command - case @command.arity - when 0 - @command.call - when 2 - @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent)) - when 3 - @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent), - self) - else - @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent), - self, @parent) - end - end - - @frame.deiconify - @frame.raise - - @org_cursor = @parent['cursor'] - @parent.cursor('crosshair') - end - - def erase - @parent.cursor(@org_cursor) - @frame.withdraw - end - - def destroy - @frame.destroy - end -end - -################################################ -# test -################################################ -if __FILE__ == $0 - TkButton.new('text'=>'This button has a balloon help') {|b| - pack('fill'=>'x') - TkBalloonHelp.new(b, 'text'=>' Message ') - } - TkButton.new('text'=>'This button has another balloon help') {|b| - pack('fill'=>'x') - TkBalloonHelp.new(b, 'text'=>'configured message', - 'interval'=>200, 'font'=>'courier', - 'background'=>'gray', 'foreground'=>'red') - } - - sb = TkScrollbox.new.pack(:fill=>:x) - sb.insert(:end, *%w(aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm)) -=begin - # CASE1 : command takes no arguemnt - bh = TkBalloonHelp.new(sb, :interval=>500, - :relief=>:ridge, :background=>'white', - :command=>proc{ - y = TkWinfo.pointery(sb) - TkWinfo.rooty(sb) - bh.text "current index == #{sb.nearest(y)}" - }) -=end -=begin - # CASE2 : command takes 2 arguemnts - bh = TkBalloonHelp.new(sb, :interval=>500, - :relief=>:ridge, :background=>'white', - :command=>proc{|x, y| - bh.text "current index == #{sb.nearest(y)}" - }) -=end -=begin - # CASE3 : command takes 3 arguemnts - TkBalloonHelp.new(sb, :interval=>500, - :relief=>:ridge, :background=>'white', - :command=>proc{|x, y, bhelp| - bhelp.text "current index == #{sb.nearest(y)}" - }) -=end -=begin - # CASE4a : command is a Proc object and takes 4 arguemnts - cmd = proc{|x, y, bhelp, parent| - bhelp.text "current index == #{parent.nearest(y)}" - } - - TkBalloonHelp.new(sb, :interval=>500, - :relief=>:ridge, :background=>'white', - :command=>cmd) - - sb2 = TkScrollbox.new.pack(:fill=>:x) - sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM)) - TkBalloonHelp.new(sb2, :interval=>500, - :padx=>5, :relief=>:raised, - :background=>'gray25', :foreground=>'white', - :command=>cmd) -=end -#=begin - # CASE4b : command is a Method object and takes 4 arguemnts - def set_msg(x, y, bhelp, parent) - bhelp.text "current index == #{parent.nearest(y)}" - end - cmd = self.method(:set_msg) - - TkBalloonHelp.new(sb, :interval=>500, - :relief=>:ridge, :background=>'white', - :command=>cmd) - - sb2 = TkScrollbox.new.pack(:fill=>:x) - sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM)) - TkBalloonHelp.new(sb2, :interval=>500, - :padx=>5, :relief=>:raised, - :background=>'gray25', :foreground=>'white', - :command=>cmd) -#=end - - Tk.mainloop -end -- cgit v1.2.3