1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb
nagai 41b74c6e20 * ext/tk/extconf.rb: New strategy for searching Tcl/Tk libraries.
* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes.
     ( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. )
* ext/tk/*: Unify sources between Ruby 1.8 & 1.9.
            Improve default_widget_set handling.
* ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9.
     ( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk
       callbacks may freeze. On Ruby 1.9, cannot create a second 
       master interpreter (creating slaves are OK); supported master
       interpreter is the default master interpreter only. )
* ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions.
         Tcllib 1.8/Tklib 0.4.1  ==>  Tcllib 1.11.1/Tklib 0.5
         BWidgets 1.7            ==>  BWidgets 1.8
         TkTable 2.9             ==>  TkTable 2.10
         TkTreeCtrl 2005-12-02   ==>  TkTreeCtrl 2.2.9
         Tile 0.8.0/8.5.1        ==>  Tile 0.8.3/8.6b1
         IncrTcl 2005-02-14      ==>  IncrTcl 2008-12-15
         TclX 2005-02-07         ==>  TclX 2008-12-15
         Trofs 0.4.3             ==>  Trofs 0.4.4


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-12 23:09:52 +00:00

82 lines
1.7 KiB
Ruby

#!/usr/bin/env ruby
require 'tk'
require 'tkextlib/vu/charts'
#######################################
Tk.root.geometry('+30+30')
delay = 2000
c = TkCanvas.new.pack
begin
st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
rescue
Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
:message=>"This build of vu does not include the sticker item")
exit
end
#st.delete
steps = []
steps << proc{
# I used a 75dpi screen for testing, but others should make no difference!
puts 'You\'ll see a small upright rectangle with "He" inside.'
st = Tk::Vu::TkcSticker.new(c, '6m', '10m', '13m', '27m', :text=>'Hello')
}
steps << proc{
puts 'You\'ll see the whole "Hello" drawn rotated 90 degrees.'
st[:orient] = :vertical
}
steps << proc{
puts 'The rectangle shrinks and the text is clipped to "Hell"'
#st.coords('6m', '10m', '13m', '20m')
st.coords('6m', '10m', '13m', '17m')
}
steps << proc{
puts 'Now you\'ll read "ello"'
st[:lefttrunc] = true
}
steps << proc{
puts 'Enlarging the rectangle shows the complete "Hello" again'
st.scale(0, 0, 3, 3)
}
steps << proc{
puts 'This time the text is repeated: "Hello", approx. 5mm space, "Hello"'
st[:space] = '5m'
}
steps << proc{
puts 'A vertical bar appears in the lower right region and text jumps to the left.'
st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7,
:relx=>0.6, :rely=>0.3, :bar=>'red')
}
steps << proc{
puts 'Paint the backgound.'
st[:fill] = 'yellow'
}
steps << proc{
puts "Let's test stippling."
st[:stipple] = 'gray25'
}
steps << proc{
puts 'Finally a large outline forces a single "Hello" and shrinks the bar.'
st[:width] = '6m'
}
Tk.root.bind('q', proc{exit})
TkTimer.new(delay, 1, *steps).start
Tk.mainloop