From f465e8a1c86883864990ea44b77b6262967ea8cb 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@4991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 + ext/tk/MANIFEST | 3 + ext/tk/sample/tkballoonhelp.rb | 99 ++++++ ext/tk/sample/tkmultilistbox.rb | 650 ++++++++++++++++++++++++++++++++++++++++ ext/tk/sample/tktextframe.rb | 105 +++++++ 5 files changed, 865 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 diff --git a/ChangeLog b/ChangeLog index bc9b73b9cc..20a97f63b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 20 17:50:58 2003 Hidetoshi NAGAI + + * ext/tk/sample/tkballoonhelp.rb: new sample script + + * ext/tk/sample/tkmultilistbox.rb: ditto + + * ext/tk/sample/tktextframe.rb: ditto + Thu Nov 20 13:37:34 2003 Hidetoshi NAGAI * ruby.h: define is_ruby_native_thread() for no native thread diff --git a/ext/tk/MANIFEST b/ext/tk/MANIFEST index 1f46c670ec..f86797b5fb 100644 --- a/ext/tk/MANIFEST +++ b/ext/tk/MANIFEST @@ -23,6 +23,7 @@ lib/tktext.rb lib/tkvirtevent.rb lib/tkwinpkg.rb sample/safe-tk.rb +sample/tkballoonhelp.rb sample/tkbiff.rb sample/tkbrowse.rb sample/tkdialog.rb @@ -30,8 +31,10 @@ sample/tkfrom.rb sample/tkhello.rb sample/tkline.rb sample/tkmenubutton.rb +sample/tkmultilistbox.rb sample/tkoptdb-safeTk.rb sample/tkoptdb.rb +sample/tktextframe.rb sample/resource.ja sample/resource.en sample/tktimer.rb diff --git a/ext/tk/sample/tkballoonhelp.rb b/ext/tk/sample/tkballoonhelp.rb new file mode 100644 index 0000000000..312e376a07 --- /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 0000000000..9b66d401b9 --- /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 {