1#!/usr/bin/env ruby 2 3require 'tk' 4require 'tkextlib/vu/charts' 5 6####################################### 7 8c = TkCanvas.new.pack 9 10begin 11 st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) 12rescue 13 Tk.messageBox(:type=>'ok', :title=>"No sticker Item", 14 :message=>"This build of vu does not include the sticker item") 15 exit 16end 17 18c.destroy 19 20#--- 21#--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center} 22 23#sti_conf = [ [10, 10, 180, 180], "Sticker äöüß@²³¼½¾", :center ] 24#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ] 25sti_conf = [ [10, 10, 350, 350], 26 Tk::UTF8_String('Sticker \u00E4\u00F6\u00FC\u00DF\u0040\u00B2\u00B3\u00BC\u00BD\u00BE'), 27 :center ] 28txt_conf = [ [250, 250], 29 Tk::UTF8_String('Text \u00E4\u00F6\u00FC\u00DF\u0040\u00B2\u00B3\u00BC\u00BD\u00BE'), 30 :center ] 31 32#p sti_conf 33 34fnt = TkFont.new('Helvetica 24 bold') 35 36#---GUI 37c = TkCanvas.new(:width=>500, :height=>500, :bg=>'aquamarine3').pack 38 39#---CRRW Use the technique of eval the coord ... 40sti = Tk::Vu::TkcSticker.new(c, sti_conf[0]){ 41 anchor sti_conf[2] 42 bar 'black' 43 color 'red' 44 fill '' 45 font fnt 46 lefttrunc 0 47 outline '' 48 relheight 0.0 49 relwidth 0.0 50 relx 0.0 51 rely 0.0 52 space 0 53 stipple '' 54 tags 'sti' 55 text sti_conf[1] 56 width 0 57 orient :vertical 58 minwidth 0 59 minheight 0 60 maxwidth 32767 61 maxheight 32767 62} 63 64txt = TkcText.new(c, txt_conf[0]){ 65 activefill '' 66 activestipple '' 67 anchor txt_conf[2] 68 disabledfill '' 69 disabledstipple '' 70 fill 'blue' 71 font fnt 72 justify :left 73 offset '0,0' 74 state '' 75 stipple '' 76 tags ['tex'] 77 text txt_conf[1] 78 width 0 79} 80 81#---BINDINGS 82c.bind('2', proc{ 83 sti[:orient] = :horizontal 84 txt[:width] = 0 # horizontal 85 }) 86 87c.bind('3', proc{ 88 sti[:orient] = :vertical 89 txt[:width] = 1 # top down 90 }) 91 92Tk.root.bind('p', proc{ 93 c.postscript(:file=>'DEMO.ps') 94 puts "DEMO.ps printed" 95 }) 96 97Tk.root.bind('q', proc{exit}) 98 99##################### 100 101Tk.mainloop 102