From afb5bd38249dc611a645a5b2192835a5b603fa94 Mon Sep 17 00:00:00 2001 From: nagai Date: Thu, 20 Nov 2003 08:53:52 +0000 Subject: * ext/tk/sample/tkballoonhelp.rb: new sample script * ext/tk/sample/tkmultilistbox.rb: ditto * ext/tk/sample/tktextframe.rb: ditto git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/sample/tkballoonhelp.rb | 99 ++++++ ext/tk/sample/tkmultilistbox.rb | 650 ++++++++++++++++++++++++++++++++++++++++ ext/tk/sample/tktextframe.rb | 105 +++++++ 3 files changed, 854 insertions(+) create mode 100644 ext/tk/sample/tkballoonhelp.rb create mode 100644 ext/tk/sample/tkmultilistbox.rb create mode 100644 ext/tk/sample/tktextframe.rb (limited to 'ext/tk/sample') diff --git a/ext/tk/sample/tkballoonhelp.rb b/ext/tk/sample/tkballoonhelp.rb new file mode 100644 index 000000000..312e376a0 --- /dev/null +++ b/ext/tk/sample/tkballoonhelp.rb @@ -0,0 +1,99 @@ +# +# 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 show + x = TkWinfo.pointerx(@parent) + y = TkWinfo.pointery(@parent) + @frame.geometry("+#{x+1}+#{y+1}") + @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'=>500, 'font'=>'courier', + 'background'=>'gray', 'foreground'=>'red') + } + Tk.mainloop +end diff --git a/ext/tk/sample/tkmultilistbox.rb b/ext/tk/sample/tkmultilistbox.rb new file mode 100644 index 000000000..9b66d401b --- /dev/null +++ b/ext/tk/sample/tkmultilistbox.rb @@ -0,0 +1,650 @@ +# +# tkmultilistbox.rb : multiple listbox widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' + +class TkMultiListbox < TkListbox + include TkComposite + + # lbox_height : height of listboxes (pixel) + # title_info : array [ [,], ... ] + # keys : hash {