diff options
Diffstat (limited to 'jni/ruby/ext/tk/sample/demos-jp')
85 files changed, 17905 insertions, 0 deletions
diff --git a/jni/ruby/ext/tk/sample/demos-jp/README b/jni/ruby/ext/tk/sample/demos-jp/README new file mode 100644 index 0000000..4278124 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/README @@ -0,0 +1,54 @@ + + Ruby/Tk widget-demo + version 1.2 ( 2000/04/08 ) + 永井@知能.九工大 (nagai@ai.kyutech.ac.jp) + +標準配布の Tcl/Tk 拡張パッケージを取り込んだ Ruby (以下 Ruby/Tk と呼びます) +では,Tk widget を用いた GUI の作成を行うことができます.実際に GUI を作成 +していく場合には様々な実例がサンプルとして存在すると便利なのですが,Ruby/Tk +にはそのような適当なサンプルスクリプト集合は存在しませんでした.それに対し, +拡張パッケージの元である Tcl/Tk には,Tk widget を用いてどのようなことがで +きるかを示すものとして widget-demo が存在しおり,Tcl/Tk を用いた GUI の作成 +を習得する際の代表的サンプルとなっています.本アーカイブは,Ruby/Tk の習得の +ための代表的なサンプルスクリプトとすべく,Tcl/Tk の widget-demo を移植したも +のです. + +今回のバージョンは ruby-1.4.x に対応としておきますが,旧バージョンに比べて, +ほとんど変更はありません.ruby-1.1c2 以上なら動くと思います.ruby-1.5.x につ +いてはテストしていません.そのため,非互換の影響が出ることがあるかもしれませ +んが,その場合でも少しの修正で動かせると思います.組み込む Tk のバージョンは, +4.2 でも 8.0 でも修正なく動かせるはずです.ただし,日本語版での移植となって +いるため,日本語化された Tk をご利用ください.スクリプトのテストは,旧バージョ +ンの際に Tk4.2jp と Tk8.0jp の上で行っています (完璧にではないですが).今回 +のバージョンでは ruby-1.4.x + Tk8.0jp 上での簡単なテストしか行っていませんが, +修正というほどの修正はしていませんので問題はないと考えています. + +本アーカイブに含まれるスクリプトの多くは,元となっている Tcl/Tk 版に比較的近 +いスクリプト記述となるようにしています.そのため,Ruby/Tk のサンプルと言うに +は,あまり Ruby らしくないとも言えるでしょう.にもかかわらず,そのような記述 +を取っている理由は,Ruby/Tk のドキュメント不足にあります. + +Tcl/Tk には適当な参考書が何冊か存在していますから,Ruby/Tk スクリプトを作成 +する際は,そのような Tcl/Tk の参考書で情報を補いながら作成することになると思 +います.各 widget の使用例として,Tcl/Tk の widget-demo を参照することもある +でしょう.Ruby/Tk 版の記述を widget-demo を Tcl/Tk 版の記述に近いものにして +おけば,その対比によって,Ruby/Tk の理解を早めることができると考えられます. +一旦 Ruby/Tk での 各 widget の使用方法を習得してしまえば,Ruby らしいスクリ +プトを作成することは難しくないでしょう.本アーカイブのスクリプトは,Ruby/Tk +を最初に習得するまでの踏台として利用していただければ幸いです. + +widget-demo の移植にあたっては,次の方にも移植したスクリプトを提供していただ +きました.ここに感謝の意を表します. + + 立石@JAIST (ttate@jaist.ac.jp) さん + 平松祥史 (hiramatu@cdrom.co.jp) さん + +平松さんによる Ruby/Tk 入門の Web page (http://www.cdrom.co.jp/~hiramatu/) +も Ruby/Tk の習得に有用と思えますので,ぜひご参照ください. + +また,前橋 (maebashi@iij.ad.jp) さんをはじめとして,widget-demo の移植に際し +て必要となった Ruby の Tk 関連ライブラリ修正について,問題点,バグの指摘をし +ていただいた方々にも感謝致します. + +そして最後に最大の感謝を Ruby 設計者の まつもと ゆきひろ (matz@netlab.co.jp) +さんに捧げたいと思います. diff --git a/jni/ruby/ext/tk/sample/demos-jp/README.1st b/jni/ruby/ext/tk/sample/demos-jp/README.1st new file mode 100644 index 0000000..68caf8b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/README.1st @@ -0,0 +1,20 @@ +このディレクトリには Ruby/Tk のデモスクリプトが収められています. + +'.rb' という拡張子を持っているファイルは,ランチャ─スクリプトで +ある 'widget' から呼び出されるサブスクリプトです.それぞれ独立に +は動きません.'widget' スクリプトから呼び出してください. + +もしランチャ─スクリプト 'widget' の起動と同時にいくつかのサブス +クリプトを起動したければ,そのサブスクリプトの名前を引数として与 +えてください. +( 例: /usr/local/bin/ruby widget button.rb entry1.rb text.rb ) +サブスクリプトの拡張子 '.rb' は省略することもできます. +( 例: /usr/local/bin/ruby widget button entry1 text ) + +もしランチャ─スクリプトのウィンドウが必要ない場合には,'-n' オ +プションを与えてください. +( 例: /usr/local/bin/ruby widget -n button.rb entry1.rb text.rb ) + +他のファイル (browse1 や hello など) は単独で動かすことが可能です. + + 2004/04/14 Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) diff --git a/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb b/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb new file mode 100644 index 0000000..c882f43 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +# +# animated label widget demo (called by 'widget') +# +# based on Tcl/Tk8.5a2 widget demos + +# toplevel widget が存在すれば削除する +if defined?($anilabel_demo) && $anilabel_demo + $anilabel_demo.destroy + $anilabel_demo = nil +end + +# demo 用の toplevel widget を生成 +$anilabel_demo = TkToplevel.new {|w| + title("Animated Label Demonstration") + iconname("anilabel") + positionWindow(w) +} + +base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には4つのアニメーションラベルが表示されています。左側にあるラベルは、内部のテキストメッセージをスクロールしたように見せることで動きを付けています。右側のラベルは、表示するイメージを変化させることで動きを与えています。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $anilabel_demo + $anilabel_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'anilabel'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# label demo 用フレーム生成 +f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts') +f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image') +Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both', + 'padx'=>10, 'pady'=>10) + +# animated label +class AnimatedTextLabel < TkLabel + def initialize(*args) + super(*args) + @timer = TkTimer.new{ _animation_callback } + @timer.loop_exec = -1 + # bind('Destroy'){ @timer.stop } + @btag = TkBindTag.new('Destroy'){ @timer.stop } + self.bindtags_unshift(@btag) + end + + def _animation_callback() + txt = self.text + self.text = (txt[1..-1] << txt[0]) + end + private :_animation_callback + + def start(interval) + @timer.set_interval(interval) + @timer.start + end + + def stop + @timer.stop + end +end + +# animated image +class AnimatedImageLabel < AnimatedTextLabel + def initialize(*args) + super(*args) + @destroy_image = false + @btag.bind_append('Destroy'){ + if @destroy_image + begin + self.image.delete + rescue + end + end + } + end + attr_accessor :destroy_image + + def _animation_callback() + img = self.image + + fmt = img.format + if fmt.kind_of?(Array) + if fmt[1].kind_of?(Hash) + # fmt == ['GIF', {'index'=>idx}] + idx = fmt[1]['index'] + else + # fmt == ['GIF', '-index', idx] :: Ruby1.8.2 returns this. + idx = fmt[2] + end + elsif fmt.kind_of?(String) && fmt =~ /GIF -index (\d+)/ + idx = $1.to_i + else + idx = -1 + end + + begin + img.format("GIF -index #{idx + 1}") + rescue => e + img.format("GIF -index 0") + end + end + private :_animation_callback +end + +# label 生成 +l1 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:ridge, + :font=>{:family=>'Courier', :size=>10}) +l2 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:groove, + :font=>{:family=>'Courier', :size=>10}) +l3 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:flat, + :font=>{:family=>'Courier', :size=>10}, :width=>18) +Tk.pack(l1, l2, l3, + :side=>:top, :expand=>true, :anchor=>:w, :padx=>10, :pady=>10) + +limg = AnimatedImageLabel.new(f_right, :borderwidth=>0) +limg.pack(:side=>:top, :expand=>true, :padx=>10, :pady=>10) + +# base64-encoded animated GIF file +tclPowerdData = <<EOD + R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM + zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm + mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt + YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP + dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM + ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC + DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0 + qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6 + NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT + 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk + UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY + 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC + Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4 + AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn + wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo + IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY + 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a + N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2 + KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA + LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK + z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA + eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+ + r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc + WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF + CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A + NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR + oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j + Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7 + ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw== +EOD + +l1.text('* Slow Animation *').start(300) +l2.text('* Fast Animation *').start(80) +l3.text('This is a longer scrolling text in a widget that will not show the whole message at once. ').start(150) + +limg.destroy_image = true +limg.image(TkPhotoImage.new(:format=>'GIF', :data=>tclPowerdData)).start(100) diff --git a/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb b/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb new file mode 100644 index 0000000..866316c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +# +# animated wave demo (called by 'widget') +# +# based on Tcl/Tk8.5a2 widget demos + +# destroy toplevel widget for this demo script +if defined?($aniwave_demo) && $aniwave_demo + $aniwave_demo.destroy + $aniwave_demo = nil +end + +# create toplevel widget +$aniwave_demo = TkToplevel.new {|w| + title("Animated Wave Demonstration") + iconname("aniwave") + positionWindow(w) +} + +base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true) + +# create label +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text 'このデモでは、ラインアイテムが一つだけ描かれたキャンバスウィジェットが表示されています。アニメーション処理は、そのラインアイテムの座標値を変更することで実現しています。' +} +msg.pack('side'=>'top') + +# create frame +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $aniwave_demo + $aniwave_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'aniwave'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# animated wave +class AnimatedWaveDemo + def initialize(frame, dir=:left) + @direction = dir + + # create canvas widget + @c = TkCanvas.new(frame, :width=>300, :height=>200, + :background=>'black') + @c.pack(:padx=>10, :pady=>10, :expand=>true) + + # Creates a coordinates list of a wave. + @waveCoords = [] + @backupCoords = [] + n = 0 + (-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] } + n = 305 + @waveCoords << [n, 0]; @backupCoords << [n, 0] + @waveCoords << [n+5, 200]; @backupCoords << [n+5, 200] + @coordsLen = @waveCoords.length + + # Create a smoothed line and arrange for its coordinates to be the + # contents of the variable waveCoords. + @line = TkcLine.new(@c, @waveCoords, + :width=>1, :fill=>'green', :smooth=>true) + + # Main animation "loop". + # Theoretically 100 frames-per-second (==10ms between frames) + @timer = TkTimer.new(10){ basicMotion; reverser } + + # Arrange for the animation loop to stop when the canvas is deleted + @c.bindtags_unshift(TkBindTag.new('Destroy'){ @timer.stop }) + end + + # Basic motion handler. Given what direction the wave is travelling + # in, it advances the y coordinates in the coordinate-list one step in + # that direction. + def basicMotion + @backupCoords, @waveCoords = @waveCoords, @backupCoords + (0...@coordsLen).each{|idx| + if @direction == :left + @waveCoords[idx][1] = @backupCoords[(idx+1 == @coordsLen)? 0: idx+1][1] + else + @waveCoords[idx][1] = @backupCoords[(idx == 0)? -1: idx-1][1] + end + } + @line.coords(@waveCoords) + end + + # Oscillation handler. This detects whether to reverse the direction + # of the wave by checking to see if the peak of the wave has moved off + # the screen (whose size we know already.) + def reverser + if @waveCoords[0][1] < 10 + @direction = :right + elsif @waveCoords[-1][1] < 10 + @direction = :left + end + end + + # animation control + def move + @timer.start + end + + def stop + @timer.stop + end +end + +# Start the animation processing +AnimatedWaveDemo.new(base_frame, :left).move diff --git a/jni/ruby/ext/tk/sample/demos-jp/arrow.rb b/jni/ruby/ext/tk/sample/demos-jp/arrow.rb new file mode 100644 index 0000000..2995f96 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/arrow.rb @@ -0,0 +1,247 @@ +# -*- coding: utf-8 -*- +# +# arrowhead widget demo (called by 'widget') +# + +# arrowSetup -- +# This method regenerates all the text and graphics in the canvas +# window. It's called when the canvas is initially created, and also +# whenever any of the parameters of the arrow head are changed +# interactively. +# +# Arguments: +# c - Name of the canvas widget. + +def arrowSetup(c) + v = $demo_arrowInfo + + # Remember the current box, if there is one. + tags = c.gettags('current') + if tags != [] + cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ } + else + cur = nil + end + + # Create the arrow and outline. + c.delete('all') + TkcLine.new(c, v.x1, v.y, v.x2, v.y, + { 'width'=>10 * v.width, + 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c], + 'arrow'=>'last' + }.update(v.bigLineStyle) ) + xtip = v.x2 - 10*v.b + deltaY = 10*v.c + 5*v.width + TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY, + v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y, + 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round') + + # Create the boxes for reshaping the line and arrowhead. + TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5, + {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) ) + TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5, + {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) ) + TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5, + {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) ) + c.itemconfigure cur, v.activeStyle if cur + + # Create three arrows in actual size with the same parameters + TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2) + tmp = v.x2+100 + TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width, + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width, + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width, + 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c]) + + # Create a bunch of other arrows and text items showing the + # current dimensions. + tmp = v.x2+10 + TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY, + 'arrow'=>'both', 'arrowshape'=>v.smallTips) + TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w') + tmp = v.x1-10 + TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width, + 'arrow'=>'both', 'arrowshape'=>v.smallTips) + TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e') + tmp = v.y+5*v.width+10*v.c+10 + TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp, + 'arrow'=>'both', 'arrowshape'=>v.smallTips) + TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n') + tmp = tmp+25 + TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp, + 'arrow'=>'both', 'arrowshape'=>v.smallTips) + TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n') + + if $tk_version =~ /^4.*/ + TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + TkcText.new(c, v.x1, 330, + 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",'anchor'=>'w', + 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*') + else + TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w', + 'font'=>'Helvetica 18') + TkcText.new(c, v.x1, 330, + 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", + 'anchor'=>'w', 'font'=>'Helvetica 18') + end + + v.count += 1 +end + +# toplevel widget が存在すれば削除する +if defined?($arrow_demo) && $arrow_demo + $arrow_demo.destroy + $arrow_demo = nil +end + +# demo 用の toplevel widget を生成 +$arrow_demo = TkToplevel.new {|w| + title("Arrowhead Editor Demonstration") + iconname("arrow") + positionWindow(w) +} + +base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', + 'text'=>"この widget で、キャンバスで使われるラインについて様々な幅や矢印の頭の形を試してみることができます。線の幅や矢印の形を変えるには、拡大された矢印についている 3つの四角をドラッグしてください。右側の矢印は普通の大きさでのサンプルを示しています。下のテキストはラインアイテムに対する設定オプションです。"){ + pack('side'=>'top') +} + +# frame 生成 +$arrow_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $arrow_demo + $arrow_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'arrow'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# canvas 設定 +$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350, + 'relief'=>'sunken', 'borderwidth'=>2) +$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both') + +# 値設定 +unless Struct.const_defined?("ArrowInfo") + $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc, + :x1, :x2, :y, :smallTips, :count, + :bigLineStyle, :boxStyle, :activeStyle).new +end +$demo_arrowInfo.a = 8 +$demo_arrowInfo.b = 10 +$demo_arrowInfo.c = 3 +$demo_arrowInfo.width = 2 +$demo_arrowInfo.motionProc = proc{} +$demo_arrowInfo.x1 = 40 +$demo_arrowInfo.x2 = 350 +$demo_arrowInfo.y = 150 +$demo_arrowInfo.smallTips = [5, 5, 2] +$demo_arrowInfo.count = 0 +if TkWinfo.depth($arrow_canvas) > 1 + $demo_arrowInfo.bigLineStyle = {'fill'=>'SkyBlue1'} + $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1} + $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1} +else + $demo_arrowInfo.bigLineStyle = {'fill'=>'black', + 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)} + $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1} + $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1} +end +$arrowTag_box = TkcTag.new($arrow_canvas) +arrowSetup $arrow_canvas +$arrowTag_box.bind('Enter', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.activeStyle)}) +$arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.boxStyle)}) +$arrowTag_box.bind('B1-Enter', proc{}) +$arrowTag_box.bind('B1-Leave', proc{}) +$arrow_canvas.itembind('box1', '1', + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove1 $arrow_canvas, x, y}}) +$arrow_canvas.itembind('box2', '1', + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove2 $arrow_canvas, x, y}}) +$arrow_canvas.itembind('box3', '1', + proc{$demo_arrowInfo.motionProc \ + = proc{|x,y| arrowMove3 $arrow_canvas, x, y}}) +$arrowTag_box.bind('B1-Motion', + proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y") +$arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas}) + +# arrowMove1 -- +# This method is called for each mouse motion event on box1 (the +# one at the vertex of the arrow). It updates the controlling parameters +# for the line and arrowhead. +# +# Arguments: +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. + +def arrowMove1(c,x,y) + v = $demo_arrowInfo + newA = (v.x2+5-c.canvasx(x).round)/10 + newA = 0 if newA < 0 + newA = 25 if newA > 25 + if newA != v.a + c.move('box1', 10*(v.a-newA), 0) + v.a = newA + end +end + +# arrowMove2 -- +# This method is called for each mouse motion event on box2 (the +# one at the trailing tip of the arrowhead). It updates the controlling +# parameters for the line and arrowhead. +# +# Arguments: +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. + +def arrowMove2(c,x,y) + v = $demo_arrowInfo + newB = (v.x2+5-c.canvasx(x).round)/10 + newB = 0 if newB < 0 + newB = 25 if newB > 25 + newC = (v.y+5-c.canvasy(y).round-5*v.width)/10 + newC = 0 if newC < 0 + newC = 20 if newC > 20 + if newB != v.b || newC != v.c + c.move('box2', 10*(v.b-newB), 10*(v.c-newC)) + v.b = newB + v.c = newC + end +end + +# arrowMove3 -- +# This method is called for each mouse motion event on box3 (the +# one that controls the thickness of the line). It updates the +# controlling parameters for the line and arrowhead. +# +# Arguments: +# c - The name of the canvas window. +# x, y - The coordinates of the mouse. + +def arrowMove3(c,x,y) + v = $demo_arrowInfo + newWidth = (v.y+2-c.canvasy(y).round)/5 + newWidth = 0 if newWidth < 0 + newWidth = 20 if newWidth > 20 + if newWidth != v.width + c.move('box3', 0, 5*(v.width-newWidth)) + v.width = newWidth + end +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/bind.rb b/jni/ruby/ext/tk/sample/demos-jp/bind.rb new file mode 100644 index 0000000..efba6e6 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/bind.rb @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +# +# text (tag bindings) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($bind_demo) && $bind_demo + $bind_demo.destroy + $bind_demo = nil +end + +# demo 用の toplevel widget を生成 +$bind_demo = TkToplevel.new {|w| + title("Text Demonstration - Tag Bindings") + iconname("bind") + positionWindow(w) +} + +base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true) + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $bind_demo + $bind_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'bind'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# bind 用メソッド +def tag_binding_for_bind_demo(tag, enter_style, leave_style) + tag.bind('Any-Enter', proc{tag.configure enter_style}) + tag.bind('Any-Leave', proc{tag.configure leave_style}) +end + +# text 生成 +txt = TkText.new(base_frame){|t| + # 生成 + setgrid 'true' + #width 60 + #height 24 + font $font + wrap 'word' + TkScrollbar.new(base_frame) {|s| + pack('side'=>'right', 'fill'=>'y') + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + } + pack('expand'=>'yes', 'fill'=>'both') + + # スタイル設定 + if TkWinfo.depth($root).to_i > 1 + tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised', + 'borderwidth'=>1} + tagstyle_normal = {'background'=>'', 'relief'=>'flat'} + else + tagstyle_bold = {'foreground'=>'white', 'background'=>'black'} + tagstyle_normal = {'foreground'=>'', 'background'=>''} + end + + # テキスト挿入 + insert 'insert', "テキストwidgetの表示スタイルを制御するのと同じタグのメカニズムを使って、テキストにTclのコマンドを割り当てることができます。これにより、マウスやキーボードのアクションで特定のTclのコマンドが実行されるようになります。例えば、下のキャンバスのデモプログラムについての説明文にはそのようなタグがついています。マウスを説明文の上に持っていくと説明文が光り、ボタン1を押すとその説明のデモが始まります。 + +" + insert('end', '1. キャンバス widget に作ることのできるアイテムの種類全てに関するサンプル。', (d1 = TkTextTag.new(t)) ) + insert('end', "\n\n") + insert('end', '2. 簡単な 2次元のプロット。データを表す点を動かすことができる。', (d2 = TkTextTag.new(t)) ) + insert('end', "\n\n") + insert('end', '3. テキストアイテムのアンカーと行揃え。', + (d3 = TkTextTag.new(t)) ) + insert('end', "\n\n") + insert('end', '4. ラインアイテムのための矢印の頭の形のエディタ。', + (d4 = TkTextTag.new(t)) ) + insert('end', "\n\n") + insert('end', '5. タブストップを変更するための機能つきのルーラー。', + (d5 = TkTextTag.new(t)) ) + insert('end', "\n\n") + insert('end', + '6. キャンバスがどうやってスクロールするのかを示すグリッド。', + (d6 = TkTextTag.new(t)) ) + + # binding + [d1, d2, d3, d4, d5, d6].each{|tag| + tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal) + } + d1.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb') + }) + d2.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb') + }) + d3.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb') + }) + d4.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb') + }) + d5.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb') + }) + d6.bind('1', + proc{ + eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb') + }) + + TkTextMarkInsert.new(t, '0.0') + configure('state','disabled') +} + +txt.width 60 +txt.height 24 diff --git a/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb b/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb new file mode 100644 index 0000000..d84e9a5 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# +# bitmap widget demo (called by 'widget') +# + +# bitmapRow -- +# Create a row of bitmap items in a window. +# +# Arguments: +# w - The parent window that is to contain the row. +# args - The names of one or more bitmaps, which will be displayed +# in a new row across the bottom of w along with their +# names. + +def bitmapRow(w,*args) + TkFrame.new(w){|row| + pack('side'=>'top', 'fill'=>'both') + for bitmap in args + TkFrame.new(row){|base| + pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c') + TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom') + Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom') + } + end + } +end + +# toplevel widget が存在すれば削除する +if defined?($bitmap_demo) && $bitmap_demo + $bitmap_demo.destroy + $bitmap_demo = nil +end + +# demo 用の toplevel widget を生成 +$bitmap_demo = TkToplevel.new {|w| + title("Bitmap Demonstration") + iconname("bitmap") + positionWindow(w) +} + +base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left', + 'text'=>"このウィンドウには、Tk に組み込まれたすべてのビットマップが、それらの名前と共に表示されています。Tcl のスクリプト中では、それぞれの名前を用いて参照します。"){ + pack('side'=>'top') +} + +# frame 生成 +$bitmap_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $bitmap_demo + $bitmap_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'bitmap'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 設定 +TkFrame.new(base_frame){|f| + bitmapRow(f,'error','gray25','gray50','hourglass') + bitmapRow(f,'info','question','questhead','warning') + pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both') +} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/browse1 b/jni/ruby/ext/tk/sample/demos-jp/browse1 new file mode 100644 index 0000000..568892e --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/browse1 @@ -0,0 +1,63 @@ +#!/usr/bin/env ruby + +# browse -- +# This script generates a directory browser, which lists the working +# directory and allow you to open files or subdirectories by +# double-clicking. + +require 'tk' + +# Create a scrollbar on the right side of the main window and a listbox +# on the left side. + +listbox = TkListbox.new(nil, 'relief'=>'sunken', + 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l| + TkScrollbar.new(nil, 'command'=>proc{|*args| l.yview *args}) {|s| + pack('side'=>'right', 'fill'=>'y') + l.yscrollcommand(proc{|first,last| s.set(first,last)}) + } + + pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes') +} + +root = TkRoot.new +root.minsize(1,1) + +# The procedure below is invoked to open a browser on a given file; if the +# file is a directory then another instance of this program is invoked; if +# the file is a regular file then the Mx editor is invoked to display +# the file. + +def browse (dir, file) + file = dir + File::Separator + file if dir != '.' + type = File.ftype(file) + if type == 'directory' + system($0 + ' ' + file + ' &') + else + if type == 'file' + if ENV['EDITOR'] + system(ENV['EDITOR'] + ' ' + file + ' &') + else + system('xedit ' + file + ' &') + end + else + STDOUT.print "\"#{file}\" isn't a directory or regular file" + end + end +end + +# Fill the listbox with a list of all the files in the directory (run +# the "ls" command to get that information). + +dir = ARGV[0] ? ARGV[0] : '.' +open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname| + listbox.insert('end', fname.chomp) +} + +# Set up bindings for the browser. + +Tk.bind_all('Control-c', proc{root.destroy}) +listbox.bind('Double-Button-1', + proc{TkSelection.get.each{|f| browse dir, f}}) + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/browse2 b/jni/ruby/ext/tk/sample/demos-jp/browse2 new file mode 100644 index 0000000..1a511c8 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/browse2 @@ -0,0 +1,82 @@ +#!/usr/bin/env ruby + +# browse -- +# This script generates a directory browser, which lists the working +# directory and allow you to open files or subdirectories by +# double-clicking. + +require 'tk' + +class Browse + BROWSE_WIN_COUNTER = TkVariable.new(0) + + def initialize(dir) + BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUNTER.to_i + 1 + + # create base frame + base = TkToplevel.new { + minsize(1,1) + title('Browse : ' + dir) + } + + # Create a scrollbar on the right side of the main window and a listbox + # on the left side. + list = TkListbox.new(base, 'relief'=>'sunken', + 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l| + TkScrollbar.new(base, 'command'=>proc{|*args| l.yview *args}) {|s| + pack('side'=>'right', 'fill'=>'y') + l.yscrollcommand(proc{|first,last| s.set(first,last)}) + } + + pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes') + + # Fill the listbox with a list of all the files in the directory (run + # the "ls" command to get that information). + open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname| + l.insert('end', fname.chomp) + } + + } + + # Set up bindings for the browser. + base.bind('Destroy', proc{ + Browse::BROWSE_WIN_COUNTER.value = \ + Browse::BROWSE_WIN_COUNTER.to_i - 1 + }) + base.bind('Control-c', proc{base.destroy}) + list.bind('Double-Button-1', + proc{TkSelection.get.each{|f| self.browse dir, f}}) + end + + # The method below is invoked to open a browser on a given file; if the + # file is a directory then another instance of this program is invoked; if + # the file is a regular file then the Mx editor is invoked to display + # the file. + def browse (dir, file) + file = dir + File::Separator + file if dir != '.' + type = File.ftype(file) + if type == 'directory' + Browse.new(file) + else + if type == 'file' + if ENV['EDITOR'] + system(ENV['EDITOR'] + ' ' + file + ' &') + else + system('xedit ' + file + ' &') + end + else + STDOUT.print "\"#{file}\" isn't a directory or regular file" + end + end + end + +end + +Browse.new(ARGV[0] ? ARGV[0] : '.') + +TkRoot.new { + withdraw + Browse::BROWSE_WIN_COUNTER.trace('w', proc{exit if Browse::BROWSE_WIN_COUNTER.to_i == 0}) +} + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/button.rb b/jni/ruby/ext/tk/sample/demos-jp/button.rb new file mode 100644 index 0000000..301100b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/button.rb @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# +# button widget demo (called by 'widget') +# +# + +# toplevel widget が存在すれば削除する +if defined?($button_demo) && $button_demo + $button_demo.destroy + $button_demo = nil +end + +# demo 用の toplevel widget を生成 +$button_demo = TkToplevel.new {|w| + title("Button Demonstration") + iconname("button") + positionWindow(w) +} + +# label 生成 +msg = TkLabel.new($button_demo) { + font $kanji_font + wraplength '4i' + justify 'left' + text "ボタンをクリックすると、ボタンの背景色がそのボタンに書かれている色になります。ボタンからボタンへの移動はタブを押すことでも可能です。またスペースで実行することができます。" +} +msg.pack('side'=>'top') + +# frame 生成 +$button_buttons = Tk::Frame.new($button_demo) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $button_demo + $button_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'button'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# button 生成 +TkButton.new($button_demo){ + text "Peach Puff" + width 10 + command proc{ + $button_demo.configure('bg','PeachPuff1') + $button_buttons.configure('bg','PeachPuff1') + } +}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2) + +TkButton.new($button_demo){ + text "Light Blue" + width 10 + command proc{ + $button_demo.configure('bg','LightBlue1') + $button_buttons.configure('bg','LightBlue1') + } +}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2) + +TkButton.new($button_demo){ + text "Sea Green" + width 10 + command proc{ + $button_demo.configure('bg','SeaGreen2') + $button_buttons.configure('bg','SeaGreen2') + } +}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2) + +TkButton.new($button_demo){ + text "Yellow" + width 10 + command proc{ + $button_demo.configure('bg','Yellow1') + $button_buttons.configure('bg','Yellow1') + } +}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2) diff --git a/jni/ruby/ext/tk/sample/demos-jp/check.rb b/jni/ruby/ext/tk/sample/demos-jp/check.rb new file mode 100644 index 0000000..422e898 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/check.rb @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# +# checkbutton widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($check_demo) && $check_demo + $check_demo.destroy + $check_demo = nil +end + +# demo 用の toplevel widget を生成 +$check_demo = TkToplevel.new {|w| + title("Checkbutton Demonstration") + iconname("check") + positionWindow(w) +} + +base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には 3 つのチェックボタンが表示されています。クリックするとボタンの選択状態が変わり、Tcl 変数 ( TkVariable オブジェクトでアクセスできます ) にそのボタンの状態を示す値を設定します。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" +} +msg.pack('side'=>'top') + +# 変数生成 +wipers = TkVariable.new(0) +brakes = TkVariable.new(0) +sober = TkVariable.new(0) + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $check_demo + $check_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'check'} + }.pack('side'=>'left', 'expand'=>'yes') + + + TkButton.new(frame) { + text '変数参照' + command proc{ + showVars(base_frame, + ['wipers', wipers], ['brakes', brakes], ['sober', sober]) + } + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + + +# checkbutton 生成 +[ TkCheckButton.new(base_frame, 'text'=>'ワイパー OK', 'variable'=>wipers), + TkCheckButton.new(base_frame, 'text'=>'ブレーキ OK', 'variable'=>brakes), + TkCheckButton.new(base_frame, 'text'=>'運転手 素面', 'variable'=>sober) +].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/check2.rb b/jni/ruby/ext/tk/sample/demos-jp/check2.rb new file mode 100644 index 0000000..558e588 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/check2.rb @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +# +# checkbutton widget demo2 (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($check2_demo) && $check2_demo + $check2_demo.destroy + $check2_demo = nil +end + +# demo 用の toplevel widget を生成 +$check2_demo = TkToplevel.new {|w| + title("Checkbutton Demonstration 2") + iconname("check2") + positionWindow(w) +} + +base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には4つのチェックボタンが表示されています。クリックするとボタンの選択状態が変わり、Tcl変数(TkVariableオブジェクトでアクセスできます)にそのボタンの状態を示す値を設定します。最初のボタンの状態は他の3つのボタンの状態にも依存して変化します。もし3つのボタンの一部だけにチェックが付けられている場合、最初のボタンはトライステート(3状態)モードでの表示を行います。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" +} +msg.pack('side'=>'top') + +# 変数生成 +safety = TkVariable.new(0) +wipers = TkVariable.new(0) +brakes = TkVariable.new(0) +sober = TkVariable.new(0) + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + TkButton.new(frame, :text=>'変数参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars($check2_demo, + ['safety', safety], ['wipers', wipers], + ['brakes', brakes], ['sober', sober]) + }), + TkButton.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'check2'}), + TkButton.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $check2_demo + $check2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) + frame.grid_columnconfigure(0, :weight=>1) +}.pack('side'=>'bottom', 'fill'=>'x') + + +# checkbutton 生成 +TkCheckButton.new(base_frame, :text=>'安全性検査', :variable=>safety, + :relief=>:flat, :onvalue=>'all', :offvalue=>'none', + :tristatevalue=>'partial'){ + pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') +} + +[ TkCheckButton.new(base_frame, 'text'=>'ワイパー OK', 'variable'=>wipers), + TkCheckButton.new(base_frame, 'text'=>'ブレーキ OK', 'variable'=>brakes), + TkCheckButton.new(base_frame, 'text'=>'運転手 素面', 'variable'=>sober) +].each{|w| + w.relief('flat') + w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w') +} + +# tristate check +in_check = false +tristate_check = proc{|n1,n2,op| + unless in_check + in_check = true + begin + if n1 == safety + if safety == 'none' + wipers.value = 0 + brakes.value = 0 + sober.value = 0 + elsif safety == 'all' + wipers.value = 1 + brakes.value = 1 + sober.value = 1 + end + else + if wipers == 1 && brakes == 1 && sober == 1 + safety.value = 'all' + elsif wipers == 1 || brakes == 1 || sober == 1 + safety.value = 'partial' + else + safety.value = 'none' + end + end + ensure + in_check = false + end + end +} + +[wipers, brakes, sober, safety].each{|v| v.trace('w', tristate_check)} diff --git a/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb b/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb new file mode 100644 index 0000000..df8c76a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# +# widget demo prompts the user to select a color (called by 'widget') +# +# Note: don't support ttk_wrapper. work with standard widgets only. +# + +# toplevel widget が存在すれば削除する +if defined?($clrpick_demo) && $clrpick_demo + $clrpick_demo.destroy + $clrpick_demo = nil +end + +# demo 用の toplevel widget を生成 +$clrpick_demo = TkToplevel.new {|w| + title("Color Selection Dialogs") + iconname("colors") + positionWindow(w) +} + +# label 生成 +#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', +Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', + 'text'=>"以下のボタンを押して、このウィンドウ上にあるウィジェットの前景色と背景色を選択して下さい。").pack('side'=>'top') + +# frame 生成 +# TkFrame.new($clrpick_demo) {|frame| +Tk::Frame.new($clrpick_demo) {|frame| + # TkButton.new(frame) { + Tk::Button.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $clrpick_demo + $clrpick_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + # TkButton.new(frame) { + Tk::Button.new(frame) { + text 'コード参照' + command proc{showCode 'clrpick'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# button 生成 +# TkButton.new($clrpick_demo, 'text'=>'背景色を設定 ...') {|b| +Tk::Button.new($clrpick_demo, 'text'=>'背景色を設定 ...') {|b| + command(proc{setColor $clrpick_demo, b, 'background', + ['background', 'highlightbackground']}) + pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m') +} + +# TkButton.new($clrpick_demo, 'text'=>'前景色を設定 ...') {|b| +Tk::Button.new($clrpick_demo, 'text'=>'前景色を設定 ...') {|b| + command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']}) + pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m') +} + +def setColor(w,button,name,options) + w.grab + initialColor = button[name] + color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w, + 'initialcolor'=>initialColor) + if color != "" + setColor_helper(w,options,color) + end + + w.grab('release') +end + +def setColor_helper(w, options, color) + options.each{|opt| + begin + w[opt] = color + rescue + end + } + TkWinfo.children(w).each{|child| + setColor_helper child, options, color + } +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/colors.rb b/jni/ruby/ext/tk/sample/demos-jp/colors.rb new file mode 100644 index 0000000..5e5f47c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/colors.rb @@ -0,0 +1,155 @@ +# -*- coding: utf-8 -*- +# +# listbox widget demo 'colors' (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($colors_demo) && $colors_demo + $colors_demo.destroy + $colors_demo = nil +end + +# demo 用の toplevel widget を生成 +$colors_demo = TkToplevel.new {|w| + title("Listbox Demonstration (colors)") + iconname("colors") + positionWindow(w) +} + +base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には色の名前が入ったスクロールバー付のリストボックスが表示されています。リストをスクロールさせるのはスクロールバーでもできますし、リストボックスの中でマウスのボタン2(中ボタン)を押したままドラッグしてもできます。ある色をボタン1(左ボタン)でダブルクリックするとアプリケーション全体がその色になります。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $colors_demo + $colors_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'colors'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +colors_lbox = nil +TkFrame.new(base_frame, 'borderwidth'=>10) {|w| + s = TkScrollbar.new(w) + colors_lbox = TkListbox.new(w) { + setgrid 1 + width 10 + height 12 + yscrollcommand proc{|first,last| s.set first,last} + } + s.command(proc{|*args| colors_lbox.yview(*args)}) + s.pack('side'=>'right', 'fill'=>'y') + colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both') +}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y') + +#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get}) +colors_lbox.bind('Double-1', proc{ + begin + TkPalette.setPalette TkSelection.get + rescue => e + p e + Tk.tk_call_without_enc('destroy', '.___tk_set_palette') + end + }) + +ins_data = [ + 'gray60','gray70','gray80','gray85','gray90','gray95', + 'snow1','snow2','snow3','snow4','seashell1','seashell2', + 'seashell3','seashell4','AntiqueWhite1','AntiqueWhite2', + 'AntiqueWhite3','AntiqueWhite4','bisque1','bisque2', + 'bisque3','bisque4','PeachPuff1','PeachPuff2', + 'PeachPuff3','PeachPuff4','NavajoWhite1','NavajoWhite2', + 'NavajoWhite3','NavajoWhite4','LemonChiffon1', + 'LemonChiffon2','LemonChiffon3','LemonChiffon4', + 'cornsilk1','cornsilk2','cornsilk3','cornsilk4', + 'ivory1','ivory2','ivory3','ivory4','honeydew1', + 'honeydew2','honeydew3','honeydew4','LavenderBlush1', + 'LavenderBlush2','LavenderBlush3','LavenderBlush4', + 'MistyRose1','MistyRose2','MistyRose3','MistyRose4', + 'azure1','azure2','azure3','azure4','SlateBlue1', + 'SlateBlue2','SlateBlue3','SlateBlue4','RoyalBlue1', + 'RoyalBlue2','RoyalBlue3','RoyalBlue4','blue1','blue2', + 'blue3','blue4','DodgerBlue1','DodgerBlue2', + 'DodgerBlue3','DodgerBlue4','SteelBlue1','SteelBlue2', + 'SteelBlue3','SteelBlue4','DeepSkyBlue1','DeepSkyBlue2', + 'DeepSkyBlue3','DeepSkyBlue4','SkyBlue1','SkyBlue2', + 'SkyBlue3','SkyBlue4','LightSkyBlue1','LightSkyBlue2', + 'LightSkyBlue3','LightSkyBlue4','SlateGray1', + 'SlateGray2','SlateGray3','SlateGray4', + 'LightSteelBlue1','LightSteelBlue2','LightSteelBlue3', + 'LightSteelBlue4','LightBlue1','LightBlue2', + 'LightBlue3','LightBlue4','LightCyan1','LightCyan2', + 'LightCyan3','LightCyan4','PaleTurquoise1', + 'PaleTurquoise2','PaleTurquoise3','PaleTurquoise4', + 'CadetBlue1','CadetBlue2','CadetBlue3','CadetBlue4', + 'turquoise1','turquoise2','turquoise3','turquoise4', + 'cyan1','cyan2','cyan3','cyan4','DarkSlateGray1', + 'DarkSlateGray2','DarkSlateGray3','DarkSlateGray4', + 'aquamarine1','aquamarine2','aquamarine3','aquamarine4', + 'DarkSeaGreen1','DarkSeaGreen2','DarkSeaGreen3', + 'DarkSeaGreen4','SeaGreen1','SeaGreen2','SeaGreen3', + 'SeaGreen4','PaleGreen1','PaleGreen2','PaleGreen3', + 'PaleGreen4','SpringGreen1','SpringGreen2', + 'SpringGreen3','SpringGreen4','green1','green2', + 'green3','green4','chartreuse1','chartreuse2', + 'chartreuse3','chartreuse4','OliveDrab1','OliveDrab2', + 'OliveDrab3','OliveDrab4','DarkOliveGreen1', + 'DarkOliveGreen2','DarkOliveGreen3','DarkOliveGreen4', + 'khaki1','khaki2','khaki3','khaki4','LightGoldenrod1', + 'LightGoldenrod2','LightGoldenrod3','LightGoldenrod4', + 'LightYellow1','LightYellow2','LightYellow3', + 'LightYellow4','yellow1','yellow2','yellow3','yellow4', + 'gold1','gold2','gold3','gold4','goldenrod1', + 'goldenrod2','goldenrod3','goldenrod4','DarkGoldenrod1', + 'DarkGoldenrod2','DarkGoldenrod3','DarkGoldenrod4', + 'RosyBrown1','RosyBrown2','RosyBrown3','RosyBrown4', + 'IndianRed1','IndianRed2','IndianRed3','IndianRed4', + 'sienna1','sienna2','sienna3','sienna4','burlywood1', + 'burlywood2','burlywood3','burlywood4','wheat1', + 'wheat2','wheat3','wheat4','tan1','tan2','tan3','tan4', + 'chocolate1','chocolate2','chocolate3','chocolate4', + 'firebrick1','firebrick2','firebrick3','firebrick4', + 'brown1','brown2','brown3','brown4','salmon1','salmon2', + 'salmon3','salmon4','LightSalmon1','LightSalmon2', + 'LightSalmon3','LightSalmon4','orange1','orange2', + 'orange3','orange4','DarkOrange1','DarkOrange2', + 'DarkOrange3','DarkOrange4','coral1','coral2','coral3', + 'coral4','tomato1','tomato2','tomato3','tomato4', + 'OrangeRed1','OrangeRed2','OrangeRed3','OrangeRed4', + 'red1','red2','red3','red4','DeepPink1','DeepPink2', + 'DeepPink3','DeepPink4','HotPink1','HotPink2', + 'HotPink3','HotPink4','pink1','pink2','pink3','pink4', + 'LightPink1','LightPink2','LightPink3','LightPink4', + 'PaleVioletRed1','PaleVioletRed2','PaleVioletRed3', + 'PaleVioletRed4','maroon1','maroon2','maroon3', + 'maroon4','VioletRed1','VioletRed2','VioletRed3', + 'VioletRed4','magenta1','magenta2','magenta3', + 'magenta4','orchid1','orchid2','orchid3','orchid4', + 'plum1','plum2','plum3','plum4','MediumOrchid1', + 'MediumOrchid2','MediumOrchid3','MediumOrchid4', + 'DarkOrchid1','DarkOrchid2','DarkOrchid3', + 'DarkOrchid4','purple1','purple2','purple3','purple4', + 'MediumPurple1','MediumPurple2','MediumPurple3', + 'MediumPurple4','thistle1','thistle2','thistle3', 'thistle4' +] + +colors_lbox.insert(0, *ins_data) diff --git a/jni/ruby/ext/tk/sample/demos-jp/combo.rb b/jni/ruby/ext/tk/sample/demos-jp/combo.rb new file mode 100644 index 0000000..8bbe369 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/combo.rb @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# +# combo.rb -- +# +# This demonstration script creates several combobox widgets. +# +# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($combo_demo) && $combo_demo + $combo_demo.destroy + $combo_demo = nil +end + +$combo_demo = TkToplevel.new {|w| + title("Combobox Demonstration") + iconname("combo") + positionWindow(w) +} + +base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true) + +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top, :fill=>:x) +以下では3種類のコンボボックスが表示されています.\ +最初のものは,エントリウィジェットと同じ様に,\ +ポイントしたり,クリックしたり,タイプしたりすることができます.\ +また,Returnキーを入力すれば現在の値がリストに追加され,\ +ドロップダウンリストから選択することができるようになります.\ +↓(下向き矢印)キーを押して表示されたリストから\ +矢印キーで他の候補を選んでReturnキーを押せば,値を選択できます.\ +2番目のコンボボックスは特定の値に固定されており,一切変更できません.\ +3番目のものはオーストラリアの都市のドロップダウンリストから\ +選択することだけが可能となっています. +EOL + +## variables +firstValue = TkVariable.new +secondValue = TkVariable.new +ozCity = TkVariable.new + +## See Code / Dismiss buttons +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'変数参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars(base_frame, + ['firstVariable', firstValue], + ['secondVariable', secondValue], + ['ozCity', ozCity]) + }), + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'combo'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $combo_demo.destroy + $combo_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) + +australianCities = [ + 'キャンベラ', 'シドニー', 'メルボルン', 'パース', 'アデレード', + 'ブリスベーン', 'ホバート', 'ダーウィン', 'アリス スプリングス' +] + + +secondValue.value = '変更不可' +ozCity.value = 'シドニー' + +Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f| + Ttk::Combobox.new(f, :textvariable=>firstValue){|b| + b.bind('Return', '%W'){|w| + w.values <<= w.value unless w.values.include?(w.value) + } + }.pack(:pady=>5, :padx=>10) + }, + + Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f| + Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) . + pack(:pady=>5, :padx=>10) + }, + + Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f| + Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly, + :values=>australianCities) . + pack(:pady=>5, :padx=>10) + }, + + :side=>:top, :pady=>5, :padx=>10) diff --git a/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb b/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb new file mode 100644 index 0000000..e993326 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +# +# simple scrollable canvas widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($cscroll_demo) && $cscroll_demo + $cscroll_demo.destroy + $cscroll_demo = nil +end + +# demo 用の toplevel widget を生成 +$cscroll_demo = TkToplevel.new {|w| + title("Scrollable Canvas Demonstration") + iconname("cscroll") + positionWindow(w) +} + +base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', + 'justify'=>'left', 'text'=>"このウィンドウにはスクロールバーやマウスのボタン2 でスクロールできるキャンバス widget が表示されています。四角の上でボタン1 をクリックすると、そのインデックスが標準出力に出力されます。"){ + pack('side'=>'top') +} + +# frame 生成 +$cscroll_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $cscroll_demo + $cscroll_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'cscroll'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 設定 +unless $tk_version =~ /^4\.[01]/ + $cscroll_grid = TkFrame.new(base_frame) { + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + } + TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0) +end + +# canvas 設定 +$cscroll_canvas = TkCanvas.new(base_frame, + 'relief'=>'sunken', 'borderwidth'=>2, + 'scrollregion'=>['-11c', '-11c', '50c', '20c'] + ) {|c| + if $tk_version =~ /^4\.[01]/ + pack('expand'=>'yes', 'fill'=>'both') + else + grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + end + + TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs| + c.yscrollcommand(proc{|first,last| vs.set first,last}) + if $tk_version =~ /^4\.[01]/ + pack('side'=>'right', 'fill'=>'y') + else + grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + end + } + + TkScrollbar.new(base_frame, 'orient'=>'horiz', + 'command'=>proc{|*args| c.xview(*args)}) {|hs| + c.xscrollcommand(proc{|first,last| hs.set first,last}) + if $tk_version =~ /^4\.[01]/ + pack('side'=>'bottom', 'fill'=>'x') + else + grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + end + } +} + +bg = $cscroll_canvas.configinfo('bg')[4] +(0..19).each{|i| + x = -10+3*i + y = -10 + (0..9).each{|j| + TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c", + 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect') + TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c", + 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text') + y += 3 + } +} + +$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas}) +$cscroll_canvas.itembind('all', 'Any-Leave', proc{scrollLeave $cscroll_canvas}) +$cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas}) +$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas}) +$cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y') +$cscroll_canvas.bind('B2-Motion', + proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y') + +def scrollEnter(c) + id = c.find_withtag('current')[0].id + id -= 1 if c.gettags('current').include?('text') + $oldFill = c.itemconfiginfo(id, 'fill')[4] + if TkWinfo.depth(c) > 1 + c.itemconfigure(id, 'fill'=>'SeaGreen1') + else + c.itemconfigure(id, 'fill'=>'black') + c.itemconfigure(id+1, 'fill'=>'white') + end +end + +def scrollLeave(c) + id = c.find_withtag('current')[0].id + id -= 1 if c.gettags('current').include?('text') + c.itemconfigure(id, 'fill'=>$oldFill) + c.itemconfigure(id+1, 'fill'=>'black') +end + +def scrollButton(c) + id = c.find_withtag('current')[0].id + id += 1 unless c.gettags('current').include?('text') + print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n" +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/ctext.rb b/jni/ruby/ext/tk/sample/demos-jp/ctext.rb new file mode 100644 index 0000000..bb354c4 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ctext.rb @@ -0,0 +1,204 @@ +# -*- coding: utf-8 -*- +# +# Canvas Text widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($ctext_demo) && $ctext_demo + $ctext_demo.destroy + $ctext_demo = nil +end + +# demo 用の toplevel widget を生成 +$ctext_demo = TkToplevel.new {|w| + title("Canvas Text Demonstration") + iconname("Text") + positionWindow(w) +} + +base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', + 'text'=>"このウィンドウにはキャンバスwidgetのテキスト機能をデモするためのテキスト文字列が表示されています。マウスを四角の中に持っていき、クリックすると位置ぎめ用の点からの相対位置を変えたり、行揃えを変えたりすることができます。また以下のような編集のための簡単なバインディングをサポートしています。 + + 1. マウスを持っていき、クリックし、入力できます。 + 2. ボタン1で選択できます。 + 3. マウスの位置にボタン2で選択したテキストをコピーできます。 + 4.バックスペースをコントロール-Hで挿入カーソルの直前の文字を削除します。 + 5. Deleteキーは挿入カーソルの直後の文字を削除します。"){ + pack('side'=>'top') +} + +# frame 生成 +$ctext_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $ctext_demo + $ctext_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'ctext'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# canvas 生成 +$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat', + 'borderwidth'=>0, 'width'=>500, 'height'=>350) +$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both') + +# font 設定 +if $tk_version =~ /^4.*/ + textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' +else + textFont = 'Helvetica 24' +end + +# canvas 設定 +TkcRectangle.new($ctext_canvas, 245, 195, 255, 205, + 'outline'=>'black', 'fill'=>'red') + +ctag_text_param = { + 'text'=>"これはキャンバスwidgetのテキスト機能をデモするための文字列です。\n上で述べたような編集を可能とするためのバインディングを施しています。", + 'width'=>440, 'anchor'=>'n', 'justify'=>'left' +} +if $tk_version =~ /^4.*/ + ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' + ctag_text_param['kanjifont'] = '-*-r-*--24-*-jisx0208.1983-0' +else + ctag_text_param['font'] = 'Helvetica 24' +end +$ctag_text = TkcTag.new($ctext_canvas) +$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param)) + +$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y") +$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") +$ctag_text.bind('Shift-1', + proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"}, + "%x %y") +$ctag_text.bind('Shift-B1-Motion', + proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") +$ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A") +$ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"}) +$ctag_text.bind('Control-h', proc{textBs $ctext_canvas}) +$ctag_text.bind('BackSpace', proc{textBs $ctext_canvas}) +$ctag_text.bind('Delete', proc{textDel $ctext_canvas}) +$ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"}, + "%x %y") + +# Next, create some items that allow the text's anchor position +# to be edited. + +def mkTextConfig(w,x,y,option,value,color) + item = TkcRectangle.new(w, x, y, x+30, y+30, + 'outline'=>'black', 'fill'=>color, 'width'=>1) + item.bind('1', proc{$ctag_text.configure option, value}) + w.addtag_withtag('config', item) +end + +x = 50 +y = 50 +color = 'LightSkyBlue1' +mkTextConfig $ctext_canvas, x, y, 'anchor', 'se', color +mkTextConfig $ctext_canvas, x+30, y, 'anchor', 's', color +mkTextConfig $ctext_canvas, x+60, y, 'anchor', 'sw', color +mkTextConfig $ctext_canvas, x, y+30, 'anchor', 'e', color +mkTextConfig $ctext_canvas, x+30, y+30, 'anchor', 'center', color +mkTextConfig $ctext_canvas, x+60, y+30, 'anchor', 'w', color +mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color +mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color +mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color +item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50, + 'outline'=>'black', 'fill'=>'red') +item.bind('1', proc{$ctag_text.configure 'anchor', 'center'}) +if $tk_version =~ /^4.*/ + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'anchor'=>'s', 'fill'=>'brown') +else + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', + 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown') +end + +# Lastly, create some items that allow the text's justification to be +# changed. + +x = 350 +y = 50 +color = 'SeaGreen2' +mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color +mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color +mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color +if $tk_version =~ /^4.*/ + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'anchor'=>'s', 'fill'=>'brown') +else + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', + 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown') +end + +$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas}) +$ctext_canvas.itembind('config', 'Leave', + proc{$ctext_canvas\ + .itemconfigure('current', + 'fill'=>$textConfigFill)}) + +$textConfigFill = '' + +def textEnter(w) + $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4] + w.itemconfigure 'current', 'fill', 'black' +end + +def textInsert(w, string) + return if string == "" + begin + $ctag_text.dchars 'sel.first', 'sel.last' + rescue + end + $ctag_text.insert 'insert', string +end + +def textPaste(w, pos) + begin + $ctag_text.insert pos, TkSelection.get + rescue + end +end + +def textB1Press(w,x,y) + w.icursor 'current', "@#{x},#{y}" + w.itemfocus 'current' + w.focus + w.select_from 'current', "@#{x},#{y}" +end + +def textB1Move(w,x,y) + w.select_to 'current', "@#{x},#{y}" +end + +def textBs(w) + begin + $ctag_text.dchars 'sel.first', 'sel.last' + rescue + char = $ctag_text.index('insert').to_i - 1 + $ctag_text.dchars(char) if char >= 0 + end +end + +def textDel(w) + begin + $ctag_text.dchars 'sel.first', 'sel.last' + rescue + $ctag_text.dchars 'insert' + end +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb b/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb new file mode 100644 index 0000000..e50c907 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +# a dialog box with a local grab (called by 'widget') +# +class TkDialog_Demo1 < TkDialog + ############### + private + ############### + def title + "Dialog with local grab" + end + + def message + 'モーダルダイアログボックスです。Tk の "grab" コマンドを使用してダイアログボックスで「ローカルグラブ」しています。下のいずれかのボタンを実行することによって、このダイアログに答えるまで、このグラブによってアプリケーションの他のウィンドウでは、ポインタ関係のイベントを受け取ることができなくなっています。' + end + + def bitmap + 'info' + end + + def default_button + 0 + end + + def buttons +# "了解 キャンセル コード参照" + ["了解", "キャンセル", "コード参照"] + end +end + +ret = TkDialog_Demo1.new('message_config'=>{'wraplength'=>'4i'}).value +case ret +when 0 + print "あなたは「了解」を押しましたね。\n" +when 1 + print "あなたは「キャンセル」を押しましたね。\n" +when 2 + showCode 'dialog1' +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb b/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb new file mode 100644 index 0000000..3e7d961 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# +# a dialog box with a global grab (called by 'widget') +# +class TkDialog_Demo2 < TkDialog + ############### + private + ############### + def title + "Dialog with global grab" + end + + def message + 'このダイアログボックスはグローバルグラブを使用しています。下のボタンを実行するまで、ディスプレイ上のいかなるものとも対話できません。グローバルグラブを使用することは、まず良い考えではありません。どうしても必要になるまで使おうと思わないで下さい。' + end + + def bitmap + 'info' + end + + def default_button + 0 + end + + def buttons +# "了解 キャンセル コード参照" + ["了解", "キャンセル", "コード参照"] + end +end + +ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'}, + 'prev_command'=>proc{|dialog| + Tk.after 100, proc{dialog.grab('global')} + }).value +case ret +when 0 + print "あなたは「了解」を押しましたね。\n" +when 1 + print "あなたは「キャンセル」を押しましたね。\n" +when 2 + showCode 'dialog2' +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README new file mode 100644 index 0000000..90677d3 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README @@ -0,0 +1,7 @@ +This directory contains a collection of demonstration programs that +are translated into Japanese. You need to use a Japanized "wish" to +see these Japanese-translated demonstration programs. You also need +to put this directory ("demos.jp") at the next to "demos" since some +of the programs refer to the image files at "demos". + +Please refer to the README file at "demos" for more detail. diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP new file mode 100644 index 0000000..42b4929 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP @@ -0,0 +1,14 @@ +This directory contains "widget" demo for the Japanized Tcl7.6/Tk4.2. +Most of the messages in the original are translated to Japanese. +But other tools in this directory are not translated. + +Following 2 kanji fonts are defined at the beginning of the file "widget." + + -*--24-*-jisx0208.1983-0 + -*--16-*-jisx0208.1983-0 + +These fonts are all part of the core distribution of X11R5, so +if you are running X11R5, you don't have to modify the file. + +But if you don't have these fonts, replace them with appropriate ones. +"-*--14-*-jisx0208.1983-0" will be a good choice. diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80 b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80 new file mode 100644 index 0000000..c71f977 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80 @@ -0,0 +1,46 @@ +This directory contains a collection of programs to demonstrate +the features of the Tk toolkit. The programs are all scripts for +"wish", a windowing shell. If wish has been installed in /usr/local +then you can invoke any of the programs in this directory just +by typing its file name to your command shell. Otherwise invoke +wish with the file as its first argument, e.g., "wish hello". +The rest of this file contains a brief description of each program. +Files with names ending in ".tcl" are procedure packages used by one +or more of the demo programs; they can't be used as programs by +themselves so they aren't described below. + +hello - Creates a single button; if you click on it, a message + is typed and the application terminates. + +widget - Contains a collection of demonstrations of the widgets + currently available in the Tk library. Most of the .tcl + files are scripts for individual demos available through + the "widget" program. + +ixset - A simple Tk-based wrapper for the "xset" program, which + allows you to interactively query and set various X options + such as mouse acceleration and bell volume. Thanks to + Pierre David for contributing this example. + +rolodex - A mock-up of a simple rolodex application. It has much of + the user interface for such an application but no back-end + database. This program was written in response to Tom + LaStrange's toolkit benchmark challenge. + +tcolor - A color editor. Allows you to edit colors in several + different ways, and will also perform automatic updates + using "send". + +rmt - Allows you to "hook-up" remotely to any Tk application + on the display. Select an application with the menu, + then just type commands: they'll go to that application. + +timer - Displays a seconds timer with start and stop buttons. + Control-c and control-q cause it to exit. + +browse - A simple directory browser. Invoke it with and argument + giving the name of the directory you'd like to browse. + Double-click on files or subdirectories to browse them. + Control-c and control-q cause the program to exit. + +sccs id = SCCS: @(#) README 1.3 96/02/16 10:49:14 diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms new file mode 100644 index 0000000..c0a44d3 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms @@ -0,0 +1,39 @@ +This software is copyrighted by the Regents of the University of +California, Sun Microsystems, Inc., and other parties. The following +terms apply to all files associated with the software unless explicitly +disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +GOVERNMENT USE: If you are acquiring this software on behalf of the +U.S. government, the Government shall have only "Restricted Rights" +in the software and related documentation as defined in the Federal +Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you +are acquiring the software on behalf of the Department of Defense, the +software shall be classified as "Commercial Computer Software" and the +Government shall have only "Restricted Rights" as defined in Clause +252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the +authors grant the U.S. Government and others acting in its behalf +permission to use and distribute the software in accordance with the +terms specified in this license. diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80 b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80 new file mode 100644 index 0000000..c0a44d3 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80 @@ -0,0 +1,39 @@ +This software is copyrighted by the Regents of the University of +California, Sun Microsystems, Inc., and other parties. The following +terms apply to all files associated with the software unless explicitly +disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +GOVERNMENT USE: If you are acquiring this software on behalf of the +U.S. government, the Government shall have only "Restricted Rights" +in the software and related documentation as defined in the Federal +Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you +are acquiring the software on behalf of the Department of Defense, the +software shall be classified as "Commercial Computer Software" and the +Government shall have only "Restricted Rights" as defined in Clause +252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the +authors grant the U.S. Government and others acting in its behalf +permission to use and distribute the software in accordance with the +terms specified in this license. diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry1.rb b/jni/ruby/ext/tk/sample/demos-jp/entry1.rb new file mode 100644 index 0000000..9be677d --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/entry1.rb @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# +# entry (no scrollbars) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($entry1_demo) && $entry1_demo + $entry1_demo.destroy + $entry1_demo = nil +end + +# demo 用の toplevel widget を生成 +$entry1_demo = TkToplevel.new {|w| + title("Entry Demonstration (no scrollbars)") + iconname("entry1") + positionWindow(w) +} + +base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text "3種類の異なるエントリが表示されています。文字を入力するにはポインタを持って行き、クリックしてからタイプしてください。標準的なMotifの編集機能が、Emacsのキーバインドとともに、サポートされています。例えば、バックスペースとコントロール-Hはカーソルの左の文字を削除し、デリートキーとコントロール-Dはカーソルの右側の文字を削除します。長過ぎてウィンドウに入り切らないものは、マウスのボタン2を押したままドラッグすることでスクロールさせることができます。日本語を入力するのはコントロール-バックスラッシュです。kinput2が動いていれば入力することができます。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $entry1_demo + $entry1_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'entry1'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# entry 生成 +e1 = TkEntry.new(base_frame, 'relief'=>'sunken') +e2 = TkEntry.new(base_frame, 'relief'=>'sunken') +e3 = TkEntry.new(base_frame, 'relief'=>'sunken') +[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')} + +# 初期値挿入 +e1.insert(0, '初期値') +e2.insert('end', "このエントリには長い文字列が入っていて、") +e2.insert('end', "長すぎてウィンドウには入り切らないので、") +e2.insert('end', "実際の所終りまで見るにはスクロールさせなければ") +e2.insert('end', "ならないでしょう。") + diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry2.rb b/jni/ruby/ext/tk/sample/demos-jp/entry2.rb new file mode 100644 index 0000000..5476d24 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/entry2.rb @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +# +# entry (with scrollbars) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($entry2_demo) && $entry2_demo + $entry2_demo.destroy + $entry2_demo = nil +end + +# demo 用の toplevel widget を生成 +$entry2_demo = TkToplevel.new {|w| + title("Entry Demonstration (with scrollbars)") + iconname("entry2") + positionWindow(w) +} + +base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text "3種類の異なるエントリが各々スクロールバー付で表示されています。文字を入力するにはポインタを持って行き、クリックしてからタイプしてください。標準的なMotifの編集機能が、Emacsのキーバインドとともに、サポートされています。例えば、バックスペースとコントロール-Hはカーソルの左の文字を削除し、デリートキーとコントロール-Dはカーソルの右側の文字を削除します。長過ぎてウィンドウに入り切らないものは、マウスのボタン2を押したままドラッグすることでスクロールさせることができます。日本語を入力するのはコントロール-バックスラッシュです。kinput2が動いていれば入力することができます。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $entry2_demo + $entry2_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'entry2'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +TkFrame.new(base_frame, 'borderwidth'=>10) {|w| + # entry 1 + s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz') + e1 = TkEntry.new(w, 'relief'=>'sunken') { + xscrollcommand proc{|first,last| s1.set first,last} + } + s1.command(proc{|*args| e1.xview(*args)}) + e1.pack('side'=>'top', 'fill'=>'x') + s1.pack('side'=>'top', 'fill'=>'x') + + # spacer + TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x') + + # entry 2 + s2 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz') + e2 = TkEntry.new(w, 'relief'=>'sunken') { + xscrollcommand proc{|first,last| s2.set first,last} + } + s2.command(proc{|*args| e2.xview(*args)}) + e2.pack('side'=>'top', 'fill'=>'x') + s2.pack('side'=>'top', 'fill'=>'x') + + # spacer + TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x') + + # entry 3 + s3 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz') + e3 = TkEntry.new(w, 'relief'=>'sunken') { + xscrollcommand proc{|first,last| s3.set first,last} + } + s3.command(proc{|*args| e3.xview(*args)}) + e3.pack('side'=>'top', 'fill'=>'x') + s3.pack('side'=>'top', 'fill'=>'x') + + # 初期値挿入 + e1.insert(0, '初期値') + e2.insert('end', "このエントリには長い文字列が入っていて、") + e2.insert('end', "長すぎてウィンドウには入り切らないので、") + e2.insert('end', "実際の所終りまで見るにはスクロールさせなければ") + e2.insert('end', "ならないでしょう。") + +}.pack('side'=>'top', 'fill'=>'x', 'expand'=>'yes') + diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry3.rb b/jni/ruby/ext/tk/sample/demos-jp/entry3.rb new file mode 100644 index 0000000..59c698d --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/entry3.rb @@ -0,0 +1,225 @@ +# -*- coding: utf-8 -*- +# entry3.rb -- +# +# This demonstration script creates several entry widgets whose +# permitted input is constrained in some way. It also shows off a +# password entry. +# +# based on Tcl/Tk8.4.4 widget demos + +if defined?($entry3_demo) && $entry3_demo + $entry3_demo.destroy + $entry3_demo = nil +end + +$entry3_demo = TkToplevel.new {|w| + title("Constrained Entry Demonstration") + iconname("entry3") + positionWindow(w) +} + +base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true) + +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +以下には4種類のエントリボックスが表示されています.各エントリボックスは,\ +マウスクリックで選択し文字を打ち込むことが可能ですが,それぞれがどのような\ +入力を受け付けることができるかには制約が設けられています.\ +一つめのエントリボックスは整数と見なされる文字列か入力文字がない空の状態か\ +の場合だけを受け付け,問題がある場合はエントリボックスが点滅します\ +(フォーカスが去る時にチェックされます).\ +二つめのエントリボックスは,入力された文字列の長さが\ +10文字未満の場合だけを受け付け,制限を越えて書き込もうとしたときには\ +ベルを鳴らして知らせます.\ +三つめは米国の電話番号を受け付けるエントリボックスです.\ +アルファベットは,電話機のダイヤル上で対応づけられている数字に変換されます.\ +不適切な文字が入力されたり数字以外の文字の位置に数字を入力しようとしたり\ +した場合には警告のベルが鳴ります.\ +四つめのエントリボックスは,8文字までの入力を受け付ける\ +パスワードフィールドです(8文字以上は特に警告を出すことなく無視されます).\ +入力された文字はアスタリスク記号に置き換えて表示されます. +EOL + +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $entry3_demo.destroy + $entry3_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'entry3' + }).pack(:side=>:left, :expand=>true) +} + +# focusAndFlash -- +# Error handler for entry widgets that forces the focus onto the +# widget and makes the widget flash by exchanging the foreground and +# background colours at intervals of 200ms (i.e. at approximately +# 2.5Hz). +# +# Arguments: +# widget - entry widget to flash +# fg - Initial foreground colour +# bg - Initial background colour +# count - Counter to control the number of times flashed +def focusAndFlash(widget, fg, bg, count=5) + return if count <= 0 + if fg && !fg.empty? && bg && !bg.empty? + TkTimer.new(200, count, + proc{widget.configure(:foreground=>bg, :background=>fg)}, + proc{widget.configure(:foreground=>fg, :background=>bg)} + ).start + else + # TkTimer.new(150, 3){Tk.bell}.start + Tk.bell + TkTimer.new(200, count, + proc{widget.configure(:foreground=>'white', + :background=>'black')}, + proc{widget.configure(:foreground=>'black', + :background=>'white')} + ).at_end{begin + widget.configure(:foreground=>fg, + :background=>bg) + rescue + # ignore + end}.start + end + widget.focus(true) +end + +l1 = TkLabelFrame.new(base_frame, :text=>"整数エントリ") +TkEntry.new(l1, :validate=>:focus, + :vcmd=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]) {|e| + fg = e.foreground + bg = e.background + invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W'] + pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') +} + +l2 = TkLabelFrame.new(base_frame, :text=>"長さ制約付きエントリ") +TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell}, + :vcmd=>[proc{|s| s.length < 10}, '%P'] + ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + +### PHONE NUMBER ENTRY ### +# Note that the source to this is quite a bit longer as the behaviour +# demonstrated is a lot more ambitious than with the others. + +# Initial content for the third entry widget +entry3content = TkVariable.new("1-(000)-000-0000") + +# Mapping from alphabetic characters to numbers. +$phoneNumberMap = {} +Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n| + chars.split('').each{|c| + $phoneNumberMap[c] = n + $phoneNumberMap[c.upcase] = n + } +} + +# phoneSkipLeft -- +# Skip over fixed characters in a phone-number string when moving left. +# +# Arguments: +# widget - The entry widget containing the phone-number. +def phoneSkipLeft(widget) + idx = widget.index('insert') + if idx == 8 + # Skip back two extra characters + widget.cursor = idx - 2 + elsif idx == 7 || idx == 12 + # Skip back one extra character + widget.cursor = idx - 1 + elsif idx <= 3 + # Can't move any further + Tk.bell + Tk.callback_break + end +end + +# phoneSkipRight -- +# Skip over fixed characters in a phone-number string when moving right. +# +# Arguments: +# widget - The entry widget containing the phone-number. +# add - Offset to add to index before calculation (used by validation.) +def phoneSkipRight(widget, add = 0) + idx = widget.index('insert') + if (idx + add == 5) + # Skip forward two extra characters + widget.cursor = idx + 2 + elsif (idx + add == 6 || idx + add == 10) + # Skip forward one extra character + widget.cursor = idx + 1 + elsif (idx + add == 15 && add == 0) + # Can't move any further + Tk.bell + Tk.callback_break + end +end + +# validatePhoneChange -- +# Checks that the replacement (mapped to a digit) of the given +# character in an entry widget at the given position will leave a +# valid phone number in the widget. +# +# widget - entry widget to validate +# vmode - The widget's validation mode +# idx - The index where replacement is to occur +# char - The character (or string, though that will always be +# refused) to be overwritten at that point. + +def validatePhoneChange(widget, vmode, idx, char) + return true if idx == nil + Tk.after_idle(proc{widget.configure(:validate=>vmode, + :invcmd=>proc{Tk.bell})}) + if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/ + widget.delete(idx) + widget.insert(idx, $phoneNumberMap[char] || char) + Tk.after_idle(proc{phoneSkipRight(widget, -1)}) + # Tk.update(true) # <- Don't work 'update' inter validation callback. + # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1). + return true + end + return false +end + + +l3 = TkLabelFrame.new(base_frame, :text=>"米国電話番号エントリ") +TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell}, + :textvariable=>entry3content, + :vcmd=>[ + proc{|w,v,i,s| validatePhoneChange(w,v,i,s)}, + "%W %v %i %S" + ]){|e| + # Click to focus goes to the first editable character... + bind('FocusIn', proc{|d,w| + if d != "NotifyAncestor" + w.cursor = 3 + Tk.after_idle(proc{w.selection_clear}) + end + }, '%d %W') + bind('Left', proc{|w| phoneSkipLeft(w)}, '%W') + bind('Right', proc{|w| phoneSkipRight(w)}, '%W') + pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') +} + +l4 = TkLabelFrame.new(base_frame, :text=>"パスワードエントリ") +TkEntry.new(l4, :validate=>:key, :show=>'*', + :vcmd=>[ + proc{|s| s.length <= 8}, + '%P' + ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m') + +TkFrame.new(base_frame){|f| + lower + TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew) + TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew) + TkGrid.columnconfigure(f, [0,1], :uniform=>1) + pack(:fill=>:both, :expand=>true) +} diff --git a/jni/ruby/ext/tk/sample/demos-jp/filebox.rb b/jni/ruby/ext/tk/sample/demos-jp/filebox.rb new file mode 100644 index 0000000..fc014bc --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/filebox.rb @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# +# widget demo prompts the user to select a file (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($filebox_demo) && $entry2_demo + $filebox_demo.destroy + $filebox_demo = nil +end + +# demo 用の toplevel widget を生成 +$filebox_demo = TkToplevel.new {|w| + title("File Selection Dialogs") + iconname("filebox") + positionWindow(w) +} + +base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left', + 'text'=>"エントリにファイル名を直接入力するか、\"Browse\" ボタンを押してファイル選択ダイアログからファイル名を選んで下さい。").pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $filebox_demo + $filebox_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'filebox'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +['開く', '保存'].each{|type| + TkFrame.new(base_frame) {|f| + TkLabel.new(f, 'text'=>"ファイルを#{type}: ", 'anchor'=>'e')\ + .pack('side'=>'left') + + TkEntry.new(f, 'width'=>20) {|e| + pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') + + TkButton.new(f, 'text'=>'Browse ...', + 'command'=>proc{fileDialog base_frame,e,type})\ + .pack('side'=>'left') + } + + pack('fill'=>'x', 'padx'=>'1c', 'pady'=>3) + } +} + +$tk_strictMotif = TkVarAccess.new('tk_strictMotif') +if ($tk_platform['platform'] == 'unix') + TkCheckButton.new(base_frame, + 'text'=>'Motifスタイルのダイアログを用いる', + 'variable'=>$tk_strictMotif, + 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c') +end + +def fileDialog(w,ent,operation) + # Type names Extension(s) Mac File Type(s) + # + #-------------------------------------------------------- + types = [ + ['Text files', ['.txt','.doc'] ], + ['Text files', [], 'TEXT' ], + ['Ruby Scripts', ['.rb'], 'TEXT' ], + ['Tcl Scripts', ['.tcl'], 'TEXT' ], + ['C Source Files', ['.c','.h'] ], + ['All Source Files', ['.rb','.tcl','.c','.h'] ], + ['Image Files', ['.gif'] ], + ['Image Files', ['.jpeg','.jpg'] ], + ['Image Files', [], ['GIFF','JPEG']], + ['All files', '*' ] + ] + + if operation == '開く' + file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w) + else + file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w, + 'initialfile'=>'Untitled', + 'defaultextension'=>'.txt') + end + if file != "" + ent.delete 0, 'end' + ent.insert 0, file + # ent.xview 'end' + Tk.update_idletasks # need this for Tk::Tile::Entry + # (to find right position of 'xview'). + ent.xview(ent.index('end')) + end +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/floor.rb b/jni/ruby/ext/tk/sample/demos-jp/floor.rb new file mode 100644 index 0000000..5101a02 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/floor.rb @@ -0,0 +1,1721 @@ +# -*- coding: utf-8 -*- +# +# floorDisplay widget demo (called by 'widget') +# + +# floorDisplay -- +# Recreate the floorplan display in the canvas given by "w". The +# floor given by "active" is displayed on top with its office structure +# visible. +# +# Arguments: +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). + +def floorDisplay(w,active) + return if $activeFloor == active + + w.delete('all') + $activeFloor = active + + # First go through the three floors, displaying the backgrounds for + # each floor. + + floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1']) + floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2']) + floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3']) + + # Raise the background for the active floor so that it's on top. + + w.raise("floor#{active}") + + # Create a dummy item just to mark this point in the display list, + # so we can insert highlights here. + + TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker') + + # Add the walls and labels for the active floor, along with + # transparent polygons that define the rooms on the floor. + # Make sure that the room polygons are on top. + + $floorLabels.clear + $floorItems.clear + send("floor_fg#{active}", w, $floor_colors['offices']) + w.raise('room') + + # Offset the floors diagonally from each other. + + w.move('floor1', '2c', '2c') + w.move('floor2', '1c', '1c') + + # Create items for the room entry and its label. + TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry) + TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"部屋番号: ") + w['scrollregion'] = w.bbox('all') +end + +# newRoom -- +# This method is invoked whenever the mouse enters a room +# in the floorplan. It changes tags so that the current room is +# highlighted. +# +# Arguments: +# w - The name of the canvas window. + +def newRoom(w) + id = w.find_withtag('current')[0] + $currentRoom.value = $floorLabels[id.id] if id != "" + Tk.update(true) +end + +# roomChanged -- +# This method is invoked whenever the currentRoom variable changes. +# It highlights the current room and unhighlights any previous room. +# +# Arguments: +# w - The canvas window displaying the floorplan. +# args - Not used. + +def roomChanged(w,*args) + w.delete('highlight') + item = $floorItems[$currentRoom.value] + return if item == nil + new = TkcPolygon.new(w, *(w.coords(item))) + new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight') + w.raise(new, 'marker') +end + +# floor_bg1 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor_bg1(w,fill,outline) + TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104, + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg']) + TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg']) +end + +# floor_bg2 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor_bg2(w,fill,outline) + TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129, + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) + TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg']) +end + +# floor_bg3 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor_bg3(w,fill,outline) + TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96, + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) + TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129, + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) + TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + TkcLine.new(w,107,300,159,300,159,248,107,248,107,300, + 'fill'=>outline, 'tags'=>['floor3','bg']) +end + +# floor_fg1 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the first +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor_fg1(w,color) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '101' + $floorItems['101'] = i + TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Pub Lift1' + $floorItems['Pub Lift1'] = i + TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Priv Lift1' + $floorItems['Priv Lift1'] = i + TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '110' + $floorItems['110'] = i + TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '109' + $floorItems['109'] = i + TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '111' + $floorItems['111'] = i + TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '117B' + $floorItems['117B'] = i + TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '112' + $floorItems['112'] = i + TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '113' + $floorItems['113'] = i + TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '117A' + $floorItems['117A'] = i + TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '117' + $floorItems['117'] = i + TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '114' + $floorItems['114'] = i + TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '115' + $floorItems['115'] = i + TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '116' + $floorItems['116'] = i + TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '118' + $floorItems['118'] = i + TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '120' + $floorItems['120'] = i + TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '122' + $floorItems['122'] = i + TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '121' + $floorItems['121'] = i + TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '106A' + $floorItems['106A'] = i + TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '105' + $floorItems['105'] = i + TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '106B' + $floorItems['106B'] = i + TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '104' + $floorItems['104'] = i + TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '108' + $floorItems['108'] = i + TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '107' + $floorItems['107'] = i + TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Smoking' + $floorItems['Smoking'] = i + TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '123' + $floorItems['123'] = i + TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '103' + $floorItems['103'] = i + TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '124' + $floorItems['124'] = i + TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '125' + $floorItems['125'] = i + TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '126' + $floorItems['126'] = i + TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '127' + $floorItems['127'] = i + TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'MShower' + $floorItems['MShower'] = i + TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Closet' + $floorItems['Closet'] = i + TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'WShower' + $floorItems['WShower'] = i + TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '130' + $floorItems['130'] = i + TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '102' + $floorItems['102'] = i + TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '128' + $floorItems['128'] = i + TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '129' + $floorItems['129'] = i + TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '133' + $floorItems['133'] = i + TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '132' + $floorItems['132'] = i + TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '134' + $floorItems['134'] = i + TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '135' + $floorItems['135'] = i + TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Ramona Stair' + $floorItems['Ramona Stair'] = i + TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'University Stair' + $floorItems['University Stair'] = i + TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Plaza Stair' + $floorItems['Plaza Stair'] = i + TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = 'Plaza Deck' + $floorItems['Plaza Deck'] = i + TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '106' + $floorItems['106'] = i + TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels[i.id] = '119' + $floorItems['119'] = i + TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall']) + TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall']) +end + +# floor_fg2 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the second +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor_fg2(w,color) + i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '238' + $floorItems['238'] = i + TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '237' + $floorItems['237'] = i + TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '246' + $floorItems['246'] = i + TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '247' + $floorItems['247'] = i + TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '202' + $floorItems['202'] = i + TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '206' + $floorItems['206'] = i + TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '212' + $floorItems['212'] = i + TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '245' + $floorItems['245'] = i + TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '244' + $floorItems['244'] = i + TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '243' + $floorItems['243'] = i + TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '242' + $floorItems['242'] = i + TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = 'Barbecue Deck' + $floorItems['Barbecue Deck'] = i + TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '240' + $floorItems['240'] = i + TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '241' + $floorItems['241'] = i + TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '239' + $floorItems['239'] = i + TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '248' + $floorItems['248'] = i + TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '236' + $floorItems['236'] = i + TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '235' + $floorItems['235'] = i + TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '234' + $floorItems['234'] = i + TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '233' + $floorItems['233'] = i + TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '230' + $floorItems['230'] = i + TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '232' + $floorItems['232'] = i + TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '229' + $floorItems['229'] = i + TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '227' + $floorItems['227'] = i + TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '228' + $floorItems['228'] = i + TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '226' + $floorItems['226'] = i + TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '225' + $floorItems['225'] = i + TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '224' + $floorItems['224'] = i + TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '223' + $floorItems['223'] = i + TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '222' + $floorItems['222'] = i + TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '221' + $floorItems['221'] = i + TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '204' + $floorItems['204'] = i + TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '205' + $floorItems['205'] = i + TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '207' + $floorItems['207'] = i + TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '208' + $floorItems['208'] = i + TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '209' + $floorItems['209'] = i + TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '217' + $floorItems['217'] = i + TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '217A' + $floorItems['217A'] = i + TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '216' + $floorItems['216'] = i + TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '215' + $floorItems['215'] = i + TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '214' + $floorItems['214'] = i + TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '213' + $floorItems['213'] = i + TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '210' + $floorItems['210'] = i + TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '211' + $floorItems['211'] = i + TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '203' + $floorItems['203'] = i + TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '220' + $floorItems['220'] = i + TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = 'Priv Lift2' + $floorItems['Priv Lift2'] = i + TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = 'Pub Lift 2' + $floorItems['Pub Lift 2'] = i + TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '218' + $floorItems['218'] = i + TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '219' + $floorItems['219'] = i + TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels[i.id] = '201' + $floorItems['201'] = i + TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall']) + TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall']) +end + +# floor_fg3 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the third +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor_fg3(w,color) + i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '316' + $floorItems['316'] = i + TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '309' + $floorItems['309'] = i + TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '308' + $floorItems['308'] = i + TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '307' + $floorItems['307'] = i + TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '305' + $floorItems['305'] = i + TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '324B' + $floorItems['324B'] = i + TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '324A' + $floorItems['324A'] = i + TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '320' + $floorItems['320'] = i + TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '310' + $floorItems['310'] = i + TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '312' + $floorItems['312'] = i + TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '313' + $floorItems['313'] = i + TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '314' + $floorItems['314'] = i + TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '315' + $floorItems['315'] = i + TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '316B' + $floorItems['316B'] = i + TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '316A' + $floorItems['316A'] = i + TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '319' + $floorItems['319'] = i + TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '311' + $floorItems['311'] = i + TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '318' + $floorItems['318'] = i + TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '317' + $floorItems['317'] = i + TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '323' + $floorItems['323'] = i + TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '325' + $floorItems['325'] = i + TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '321' + $floorItems['321'] = i + TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '322' + $floorItems['322'] = i + TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = 'Pub Lift3' + $floorItems['Pub Lift3'] = i + TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = 'Priv Lift3' + $floorItems['Priv Lift3'] = i + TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '303' + $floorItems['303'] = i + TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '324' + $floorItems['324'] = i + TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '304' + $floorItems['304'] = i + TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '301' + $floorItems['301'] = i + TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '327' + $floorItems['327'] = i + TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '326' + $floorItems['326'] = i + TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '302' + $floorItems['302'] = i + TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels[i.id] = '306' + $floorItems['306'] = i + TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall']) + TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall']) +end + +# Below is the "main program" that creates the floorplan demonstration. + +# toplevel widget が存在すれば削除する +if defined?($floor_demo) && $floor_demo + $floor_demo.destroy + $floor_demo = nil +end + +# demo 用の toplevel widget を生成 +$floor_demo = TkToplevel.new {|w| + title("Floorplan Canvas Demonstration") + iconname("Floorplan") + positionWindow(w) + geometry('+20+20') + minsize(100,100) +} + +base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', + 'text'=>"このウィンドウにはディジタルエクイップメント社のウェスタンリサーチラボラトリ (DECWRL) の間取りが書かれたキャンバス widget が入っています。これは 3階建てで、常にそのうちの1階分が選択、つまりその間取りが表示されるようになっています。ある階を選択するには、その上でマウスの左ボタンをクリックしてください。マウスが選択されている階の上を動くと、その下にある部屋の色が変わり、部屋番号が「部屋番号:」エントリに表示されます。また、エントリに部屋番号を書くとその部屋の色が変わります。"){ + pack('side'=>'top') +} + +# frame 生成 +$floor_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $floor_demo + $floor_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'floor'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$floor_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# 変数設定 +$floorLabels = {} +$floorItems = {} + +# canvas 設定 +if $tk_version =~ /^4\.[01]/ + $floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken', + 'highlightthickness'=>2) + $floor_canvas = TkCanvas.new($floor_canvas_frame, + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| + TkScrollbar.new(base_frame, 'orient'=>'horiz', + 'command'=>proc{|*args| c.xview(*args)}){|hs| + c.xscrollcommand(proc{|first,last| hs.set first,last}) + pack('side'=>'bottom', 'fill'=>'x') + } + TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs| + c.yscrollcommand(proc{|first,last| vs.set first,last}) + pack('side'=>'right', 'fill'=>'y') + } + } + $floor_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes') + $floor_canvas.pack('expand'=>'yes', 'fill'=>'both') + +else + TkFrame.new(base_frame) {|f| + pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes') + + h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal') + v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical') + + TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| + $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') + } + grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + } + + v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + + TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + + v.command(proc{|*args| $floor_canvas.yview(*args)}) + h.command(proc{|*args| $floor_canvas.xview(*args)}) + } +end + + +# Create an entry for displaying and typing in current room. + +$currentRoom = TkVariable.new +$floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken', + 'bd'=>2, 'textvariable'=>$currentRoom) + +# Choose colors, then fill in the floorplan. + +$floor_colors = {} +if TkWinfo.depth($floor_canvas) > 1 + $floor_colors['bg1'] = '#a9c1da' + $floor_colors['outline1'] = '#77889a' + $floor_colors['bg2'] = '#9ab0c6' + $floor_colors['outline2'] = '#687786' + $floor_colors['bg3'] = '#8ba0b3' + $floor_colors['outline3'] = '#596673' + $floor_colors['offices'] = 'Black' + $floor_colors['active'] = '#c4d1df' +else + $floor_colors['bg1'] = 'white' + $floor_colors['outline1'] = 'black' + $floor_colors['bg2'] = 'white' + $floor_colors['outline2'] = 'black' + $floor_colors['bg3'] = 'white' + $floor_colors['outline3'] = 'black' + $floor_colors['offices'] = 'Black' + $floor_colors['active'] = 'black' +end + +$activeFloor = '' +floorDisplay $floor_canvas,3 + +# Set up event bindings for canvas: + +$floor_canvas.itembind('floor1', '1', proc{floorDisplay $floor_canvas,1}) +$floor_canvas.itembind('floor2', '1', proc{floorDisplay $floor_canvas,2}) +$floor_canvas.itembind('floor3', '1', proc{floorDisplay $floor_canvas,3}) +$floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas}) +$floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''}) +$floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y') +$floor_canvas.bind('B2-Motion', + proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y') +$floor_canvas.bind('Destroy', proc{$currentRoom.unset}) +$currentRoom.value = '' +$currentRoom.trace('w',proc{roomChanged $floor_canvas}) + diff --git a/jni/ruby/ext/tk/sample/demos-jp/floor2.rb b/jni/ruby/ext/tk/sample/demos-jp/floor2.rb new file mode 100644 index 0000000..7ca705c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/floor2.rb @@ -0,0 +1,1719 @@ +# -*- coding: utf-8 -*- +# +# floorDisplay widget demo 2 (called by 'widget') +# + +# floorDisplay2 -- +# Recreate the floorplan display in the canvas given by "w". The +# floor given by "active" is displayed on top with its office structure +# visible. +# +# Arguments: +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). + +def floorDisplay2(w,active) + return if $activeFloor2 == active + + w.delete('all') + $activeFloor2 = active + + # First go through the three floors, displaying the backgrounds for + # each floor. + + floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1']) + floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2']) + floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3']) + + # Raise the background for the active floor so that it's on top. + + w.raise("floor#{active}") + + # Create a dummy item just to mark this point in the display list, + # so we can insert highlights here. + + w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker') + + # Add the walls and labels for the active floor, along with + # transparent polygons that define the rooms on the floor. + # Make sure that the room polygons are on top. + + $floorLabels2.clear + $floorItems2.clear + send("floor2_fg#{active}", w, $floor2_colors['offices']) + w.raise('room') + + # Offset the floors diagonally from each other. + + w.move('floor1', '2c', '2c') + w.move('floor2', '1c', '1c') + + # Create items for the room entry and its label. + w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry) + w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"部屋番号: ") + w['scrollregion'] = w.bbox('all') +end + +# newRoom2 -- +# This method is invoked whenever the mouse enters a room +# in the floorplan. It changes tags so that the current room is +# highlighted. +# +# Arguments: +# w - The name of the canvas window. + +def newRoom2(w) + id = w.find_withtag('current')[0] + $currentRoom2.value = $floorLabels2[id.id] if id != "" + Tk.update(true) +end + +# roomChanged2 -- +# This method is invoked whenever the currentRoom variable changes. +# It highlights the current room and unhighlights any previous room. +# +# Arguments: +# w - The canvas window displaying the floorplan. +# args - Not used. + +def roomChanged2(w,*args) + w.delete('highlight') + item = $floorItems2[$currentRoom2.value] + return if item == nil + new = TkcPolygon.new(w, *(w.coords(item))) + new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight') + w.raise(new, 'marker') +end + +# floor2_bg1 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor2_bg1(w,fill,outline) + w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104, + 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725, + 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327, + 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404, + 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325, + 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332, + 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363, + 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391, + 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7, + 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221, + 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5, + 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70, + 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill) + w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg']) + w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg']) +end + +# floor2_bg2 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor2_bg2(w,fill,outline) + w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129, + 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391, + 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280, + 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644, + 367,802,367,802,129,725,129,725,133,559,133,559,129, + 'tags'=>['floor2','bg'], 'fill'=>fill) + w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg']) + w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg']) +end + +# floor2_bg3 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +def floor2_bg3(w,fill,outline) + w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96, + 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300, + 'tags'=>['floor3','bg'], 'fill'=>fill) + w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129, + 315,129,315,133,176,133,176,129,159,129,159,370,258,370, + 'tags'=>['floor3','bg'], 'fill'=>fill) + w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg']) + w.create(TkcLine,107,300,159,300,159,248,107,248,107,300, + 'fill'=>outline, 'tags'=>['floor3','bg']) +end + +# floor2_fg1 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the first +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor2_fg1(w,color) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '101' + $floorItems2['101'] = i + w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Pub Lift1' + $floorItems2['Pub Lift1'] = i + w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Priv Lift1' + $floorItems2['Priv Lift1'] = i + w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,42,389,42,337,1,337,1,389, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '110' + $floorItems2['110'] = i + w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '109' + $floorItems2['109'] = i + w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,300,51,253,6,253,6,300, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '111' + $floorItems2['111'] = i + w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,98,248,98,309,79,309,79,248, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '117B' + $floorItems2['117B'] = i + w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,251,51,204,6,204,6,251, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '112' + $floorItems2['112'] = i + w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,6,156,51,156,51,203,6,203, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '113' + $floorItems2['113'] = i + w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,85,169,79,169,79,192,85,192, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '117A' + $floorItems2['117A'] = i + w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,77,302,77,168,53,168,53,302, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '117' + $floorItems2['117'] = i + w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,51,155,51,115,6,115,6,155, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '114' + $floorItems2['114'] = i + w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,95,115,53,115,53,168,95,168, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '115' + $floorItems2['115'] = i + w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,87,113,87,27,10,27,10,113, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '116' + $floorItems2['116'] = i + w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,89,91,128,91,128,113,89,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '118' + $floorItems2['118'] = i + w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,178,128,178,132,216,132,216,91, + 163,91,163,112,149,112,149,128, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '120' + $floorItems2['120'] = i + w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192, + 156,192,156,169,175,169,175,246,79,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '122' + $floorItems2['122'] = i + w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,138,169,154,169,154,191,138,191, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '121' + $floorItems2['121'] = i + w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,99,300,126,300,126,309,99,309, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '106A' + $floorItems2['106A'] = i + w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '105' + $floorItems2['105'] = i + w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,174,309,174,300,152,300,152,309, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '106B' + $floorItems2['106B'] = i + w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '104' + $floorItems2['104'] = i + w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,138,385,138,337,91,337,91,385, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '108' + $floorItems2['108'] = i + w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,256,337,140,337,140,385,256,385, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '107' + $floorItems2['107'] = i + w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,300,353,300,329,260,329,260,353, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Smoking' + $floorItems2['Smoking'] = i + w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '123' + $floorItems2['123'] = i + w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '103' + $floorItems2['103'] = i + w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '124' + $floorItems2['124'] = i + w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '125' + $floorItems2['125'] = i + w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '126' + $floorItems2['126'] = i + w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,409,209,409,229,399,229,399,253, + 486,253,486,239,474,239,474,209, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '127' + $floorItems2['127'] = i + w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,501,164,501,174,495,174,495,188, + 490,188,490,204,476,204,476,164, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'MShower' + $floorItems2['MShower'] = i + w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Closet' + $floorItems2['Closet'] = i + w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'WShower' + $floorItems2['WShower'] = i + w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166, + 697,166,697,275,553,275,531,254,515,254, + 515,174,503,174,503,161,486,161, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '130' + $floorItems2['130'] = i + w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,308,242,339,242,339,248,342,248, + 342,246,397,246,397,276,393,276, + 393,309,300,309,300,248,308,248, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '102' + $floorItems2['102'] = i + w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,397,255,486,255,486,276,397,276, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '128' + $floorItems2['128'] = i + w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,510,309,486,309,486,255,530,255, + 552,277,561,277,561,325,510,325, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '129' + $floorItems2['129'] = i + w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,696,281,740,281,740,387,642,387, + 642,389,561,389,561,277,696,277, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '133' + $floorItems2['133'] = i + w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,742,387,742,281,800,281,800,387, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '132' + $floorItems2['132'] = i + w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,800,168,800,280,699,280,699,168, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '134' + $floorItems2['134'] = i + w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,726,131,726,166,800,166,800,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '135' + $floorItems2['135'] = i + w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366, + 304,312,396,312,396,288,400,288,404,288, + 409,290,413,292,418,297,421,302,422,309, + 421,318,417,325,411,330,405,332,397,333, + 344,333,340,334,336,336,335,338,332,342, + 331,347,332,351,334,354,336,357,341,359, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Ramona Stair' + $floorItems2['Ramona Stair'] = i + w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20, + 122,28,123,32,123,68,220,68,220,87,90,87,90,23, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'University Stair' + $floorItems2['University Stair'] = i + w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56, + 358,48,363,39,365,29,348,25,335,22,321,14, + 300,5,283,1,260,0,246,0,242,2,236,4,231,8, + 227,13,223,17,221,22,220,34,260,34, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Plaza Stair' + $floorItems2['Plaza Stair'] = i + w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49, + 323,56,337,70,350,83,365,94,377,100, + 386,104,386,128,220,128, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = 'Plaza Deck' + $floorItems2['Plaza Deck'] = i + w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '106' + $floorItems2['106'] = i + w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115, + 95,128,114,128,114,151,157,151,157,153,112,153, + 112,130,97,130,97,168,175,168,175,131,146,131, + 'fill'=>'', 'tags'=>['floor1','room']) + $floorLabels2[i.id] = '119' + $floorItems2['119'] = i + w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor1','label']) + w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall']) + w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall']) +end + +# floor2_fg2 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the second +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor2_fg2(w,color) + i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222, + 800,222,800,168,748,168, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '238' + $floorItems2['238'] = i + w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '237' + $floorItems2['237'] = i + w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324, + 643,324,643,291,641,291,641,205,696,205, + 696,291,694,291,694,314,715,314,715,291, + 715,205,755,205,755,190,724,190,724,187, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '246' + $floorItems2['246'] = i + w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,694,279,643,279,643,314,694,314, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '247' + $floorItems2['247'] = i + w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246, + 397,246,397,255,476,255,476,250,482,250,559,250, + 559,274,482,274,482,278,396,278,396,274,232,274, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '202' + $floorItems2['202'] = i + w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196, + 306,196,306,180,175,180,175,169,156,169, + 156,196,176,196,176,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '206' + $floorItems2['206'] = i + w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,277,6,277,6,338,51,338, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '212' + $floorItems2['212'] = i + w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '245' + $floorItems2['245'] = i + w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,560,389,599,389,599,326,560,326, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '244' + $floorItems2['244'] = i + w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,601,389,601,326,643,326,643,389, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '243' + $floorItems2['243'] = i + w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,688,316,645,316,645,365,688,365, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '242' + $floorItems2['242'] = i + w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,802,367,759,367,759,226,802,226, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = 'Barbecue Deck' + $floorItems2['Barbecue Deck'] = i + w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,262,755,314,717,314,717,262, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '240' + $floorItems2['240'] = i + w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,316,689,316,689,365,755,365, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '241' + $floorItems2['241'] = i + w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,755,206,717,206,717,261,755,261, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '239' + $floorItems2['239'] = i + w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,695,277,643,277,643,206,695,206, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '248' + $floorItems2['248'] = i + w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,676,135,676,185,724,185,724,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '236' + $floorItems2['236'] = i + w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '235' + $floorItems2['235'] = i + w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,626,143,633,143,633,135,572,135, + 572,143,579,143,579,185,626,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '234' + $floorItems2['234'] = i + w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,557,135,571,135,571,145,578,145, + 578,185,527,185,527,131,557,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '233' + $floorItems2['233'] = i + w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,249,557,249,557,205,476,205, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '230' + $floorItems2['230'] = i + w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '232' + $floorItems2['232'] = i + w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,476,186,495,186,495,204,476,204, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '229' + $floorItems2['229'] = i + w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '227' + $floorItems2['227'] = i + w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '228' + $floorItems2['228'] = i + w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '226' + $floorItems2['226'] = i + w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '225' + $floorItems2['225'] = i + w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,234,198,306,198,306,249,234,249, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '224' + $floorItems2['224'] = i + w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '223' + $floorItems2['223'] = i + w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,268,179,221,179,221,135,268,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '222' + $floorItems2['222'] = i + w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,177,179,219,179,219,135,177,135, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '221' + $floorItems2['221'] = i + w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '204' + $floorItems2['204'] = i + w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '205' + $floorItems2['205'] = i + w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,256,385,256,340,212,340,212,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '207' + $floorItems2['207'] = i + w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,210,340,164,340,164,385,210,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '208' + $floorItems2['208'] = i + w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,115,340,162,340,162,385,115,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '209' + $floorItems2['209'] = i + w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,228,89,156,53,156,53,228, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '217' + $floorItems2['217'] = i + w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,169,97,169,97,190,89,190, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '217A' + $floorItems2['217A'] = i + w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '216' + $floorItems2['216'] = i + w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,179,51,135,6,135,6,179, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '215' + $floorItems2['215'] = i + w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,227,6,227,6,180,51,180, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '214' + $floorItems2['214'] = i + w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,51,275,6,275,6,229,51,229, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '213' + $floorItems2['213'] = i + w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,114,340,67,340,67,385,114,385, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '210' + $floorItems2['210'] = i + w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '211' + $floorItems2['211'] = i + w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '203' + $floorItems2['203'] = i + w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198, + 154,198,154,192,109,192,109,169,99,169, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '220' + $floorItems2['220'] = i + w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = 'Priv Lift2' + $floorItems2['Priv Lift2'] = i + w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = 'Pub Lift 2' + $floorItems2['Pub Lift 2'] = i + w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '218' + $floorItems2['218'] = i + w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '219' + $floorItems2['219'] = i + w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor2','room']) + $floorLabels2[i.id] = '201' + $floorItems2['201'] = i + w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor2','label']) + w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall']) + w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall']) +end + +# floor2_fg3 -- +# This method represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the third +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +def floor2_fg3(w,color) + i = TkcPolygon.new(w,89,228,89,180,70,180,70,228, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '316' + $floorItems2['316'] = i + w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,115,368,162,368,162,323,115,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '309' + $floorItems2['309'] = i + w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,164,323,164,368,211,368,211,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '308' + $floorItems2['308'] = i + w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,256,368,212,368,212,323,256,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '307' + $floorItems2['307'] = i + w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '305' + $floorItems2['305'] = i + w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,251,219,251,203,244,203,244,219, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '324B' + $floorItems2['324B'] = i + w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,251,249,244,249,244,232,251,232, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '324A' + $floorItems2['324A'] = i + w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,223,135,223,179,177,179,177,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '320' + $floorItems2['320'] = i + w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,114,368,114,323,67,323,67,368, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '310' + $floorItems2['310'] = i + w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,23,277,23,321,68,321,68,277, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '312' + $floorItems2['312'] = i + w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,23,229,68,229,68,275,23,275, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '313' + $floorItems2['313'] = i + w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,68,227,23,227,23,180,68,180, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '314' + $floorItems2['314'] = i + w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,95,179,95,135,23,135,23,179, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '315' + $floorItems2['315'] = i + w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,99,226,99,204,91,204,91,226, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '316B' + $floorItems2['316B'] = i + w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,91,202,99,202,99,180,91,180, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '316A' + $floorItems2['316A'] = i + w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198, + 174,198,174,226,101,226,101,179,97,179, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '319' + $floorItems2['319'] = i + w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '311' + $floorItems2['311'] = i + w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,154,191,111,191,111,169,154,169, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '318' + $floorItems2['318'] = i + w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,175,168,97,168,97,131,175,131, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '317' + $floorItems2['317'] = i + w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,274,194,274,221,306,221,306,194, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '323' + $floorItems2['323'] = i + w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,306,222,274,222,274,249,306,249, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '325' + $floorItems2['325'] = i + w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,263,179,224,179,224,135,263,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '321' + $floorItems2['321'] = i + w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,314,169,306,169,306,192,273,192, + 264,181,264,135,314,135, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '322' + $floorItems2['322'] = i + w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,307,240,339,240,339,206,307,206, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = 'Pub Lift3' + $floorItems2['Pub Lift3'] = i + w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,339,205,307,205,307,171,339,171, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = 'Priv Lift3' + $floorItems2['Priv Lift3'] = i + w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '303' + $floorItems2['303'] = i + w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,272,203,272,249,252,249,252,230, + 244,230,244,221,252,221,252,203, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '324' + $floorItems2['324'] = i + w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '304' + $floorItems2['304'] = i + w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,375,246,375,172,341,172,341,246, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '301' + $floorItems2['301'] = i + w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,397,246,377,246,377,185,397,185, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '327' + $floorItems2['327'] = i + w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '326' + $floorItems2['326'] = i + w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282, + 375,274,397,274,397,248,339,248,339,242,308,242, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '302' + $floorItems2['302'] = i + w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203, + 272,193,263,180,242,180,175,180,175,169,156,169, + 156,196,177,196,177,228,107,228,70,228,70,275,107,275, + 107,248,160,248,160,301,107,301,107,275,70,275, + 'fill'=>'', 'tags'=>['floor3','room']) + $floorLabels2[i.id] = '306' + $floorItems2['306'] = i + w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color, + 'anchor'=>'c', 'tags'=>['floor3','label']) + w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall']) + w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall']) +end + +# Below is the "main program" that creates the floorplan demonstration. + +# toplevel widget が存在すれば削除する +if defined?($floor2_demo) && $floor2_demo + $floor2_demo.destroy + $floor2_demo = nil +end + +# demo 用の toplevel widget を生成 +$floor2_demo = TkToplevel.new {|w| + title("Floorplan Canvas Demonstration 2") + iconname("Floorplan2") + positionWindow(w) + geometry('+20+20') + minsize(100,100) +} + +base_frame = TkFrame.new($floor2_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', + 'text'=>"このウィンドウにはディジタルエクイップメント社のウェスタンリサーチラボラトリ (DECWRL) の間取りが書かれたキャンバス widget が入っています。これは 3階建てで、常にそのうちの1階分が選択、つまりその間取りが表示されるようになっています。ある階を選択するには、その上でマウスの左ボタンをクリックしてください。マウスが選択されている階の上を動くと、その下にある部屋の色が変わり、部屋番号が「部屋番号:」エントリに表示されます。また、エントリに部屋番号を書くとその部屋の色が変わります。"){ + pack('side'=>'top') +} + +# frame 生成 +$floor2_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $floor2_demo + $floor2_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'floor2'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$floor2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# 変数設定 +$floorLabels2 = {} +$floorItems2 = {} + +# canvas 設定 +if $tk_version =~ /^4\.[01]/ + $floor2_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken', + 'highlightthickness'=>2) + $floor2_canvas = TkCanvas.new($floor2_canvas_frame, + 'width'=>900, 'height'=>500, 'borderwidth'=>0, + 'highlightthickness'=>0) {|c| + TkScrollbar.new(base_frame, 'orient'=>'horiz', + 'command'=>proc{|*args| c.xview(*args)}){|hs| + c.xscrollcommand(proc{|first,last| hs.set first,last}) + pack('side'=>'bottom', 'fill'=>'x') + } + TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs| + c.yscrollcommand(proc{|first,last| vs.set first,last}) + pack('side'=>'right', 'fill'=>'y') + } + } + $floor2_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes') + $floor2_canvas.pack('expand'=>'yes', 'fill'=>'both') + +else + TkFrame.new(base_frame) {|f| + pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes') + + h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal') + v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical') + + TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1| + $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500, + 'borderwidth'=>0, + 'highlightthickness'=>0) { + xscrollcommand(proc{|first,last| h.set first,last}) + yscrollcommand(proc{|first,last| v.set first,last}) + pack('expand'=>'yes', 'fill'=>'both') + } + grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + } + + v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + + TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + + v.command(proc{|*args| $floor2_canvas.yview(*args)}) + h.command(proc{|*args| $floor2_canvas.xview(*args)}) + } +end + +# Create an entry for displaying and typing in current room. + +$currentRoom2 = TkVariable.new +$floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken', + 'bd'=>2, 'textvariable'=>$currentRoom2) + +# Choose colors, then fill in the floorplan. + +$floor2_colors = {} +if TkWinfo.depth($floor2_canvas) > 1 + $floor2_colors['bg1'] = '#a9c1da' + $floor2_colors['outline1'] = '#77889a' + $floor2_colors['bg2'] = '#9ab0c6' + $floor2_colors['outline2'] = '#687786' + $floor2_colors['bg3'] = '#8ba0b3' + $floor2_colors['outline3'] = '#596673' + $floor2_colors['offices'] = 'Black' + $floor2_colors['active'] = '#c4d1df' +else + $floor2_colors['bg1'] = 'white' + $floor2_colors['outline1'] = 'black' + $floor2_colors['bg2'] = 'white' + $floor2_colors['outline2'] = 'black' + $floor2_colors['bg3'] = 'white' + $floor2_colors['outline3'] = 'black' + $floor2_colors['offices'] = 'Black' + $floor2_colors['active'] = 'black' +end + +$activeFloor2 = '' +floorDisplay2 $floor2_canvas,3 + +# Set up event bindings for canvas: + +$floor2_canvas.itembind('floor1', '1', proc{floorDisplay2 $floor2_canvas,1}) +$floor2_canvas.itembind('floor2', '1', proc{floorDisplay2 $floor2_canvas,2}) +$floor2_canvas.itembind('floor3', '1', proc{floorDisplay2 $floor2_canvas,3}) +$floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas}) +$floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''}) +$floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y') +$floor2_canvas.bind('B2-Motion', + proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y') +$floor2_canvas.bind('Destroy', proc{$currentRoom2.unset}) +$currentRoom2.value = '' +$currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas}) diff --git a/jni/ruby/ext/tk/sample/demos-jp/form.rb b/jni/ruby/ext/tk/sample/demos-jp/form.rb new file mode 100644 index 0000000..000fcb5 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/form.rb @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# +# form widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($form_demo) && $form_demo + $form_demo.destroy + $form_demo = nil +end + +# demo 用の toplevel widget を生成 +$form_demo = TkToplevel.new {|w| + title("Form Demonstration") + iconname("form") + positionWindow(w) +} + +base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "このウィンドウは簡単なフォーム入力用になっていて、さまざまなエントリに入力ができます。タブでエントリの切替えができます。" +} +msg.pack('side'=>'top', 'fill'=>'x') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $form_demo + $form_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'form'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# entry 生成 +form_data = [] +(1..5).each{|i| + f = TkFrame.new(base_frame, 'bd'=>2) + e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40) + l = TkLabel.new(f) + e.pack('side'=>'right') + l.pack('side'=>'left') + form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l} +} + +# 文字列設定 +form_data[1]['label'].text('名前:') +form_data[2]['label'].text('住所:') +form_data[5]['label'].text('電話:') + +# pack +(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb b/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb new file mode 100644 index 0000000..fc38d87 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb @@ -0,0 +1,2011 @@ +# -*- coding: utf-8 -*- +# +# Ruby/Tk Goldverg demo (called by 'widget') +# +# Based on Tcl/Tk8.5a2 widget demos. +# The following is the original comment of TkGoldberg.tcl. +# +#>>##+################################################################# +#>># +#>># TkGoldberg.tcl +#>># by Keith Vetter, March 13, 2003 +#>># +#>># "Man will always find a difficult means to perform a simple task" +#>># Rube Goldberg +#>># +#>># Reproduced here with permission. +#>># +#>>##+################################################################# +#>># +#>># Keith Vetter 2003-03-21: this started out as a simple little program +#>># but was so much fun that it grew and grew. So I apologize about the +#>># size but I just couldn't resist sharing it. +#>># +#>># This is a whizzlet that does a Rube Goldberg type animation, the +#>># design of which comes from an New Years e-card from IncrediMail. +#>># That version had nice sound effects which I eschewed. On the other +#>># hand, that version was in black and white (actually dark blue and +#>># light blue) and this one is fully colorized. +#>># +#>># One thing I learned from this project is that drawing filled complex +#>># objects on a canvas is really hard. More often than not I had to +#>># draw each item twice--once with the desired fill color but no +#>># outline, and once with no fill but with the outline. Another trick +#>># is erasing by drawing with the background color. Having a flood fill +#>># command would have been extremely helpful. +#>># +#>># Two wiki pages were extremely helpful: Drawing rounded rectangles +#>># which I generalized into Drawing rounded polygons, and regular +#>># polygons which allowed me to convert ovals and arcs into polygons +#>># which could then be rotated (see Canvas Rotation). I also wrote +#>># Named Colors to aid in the color selection. +#>># +#>># I could comment on the code, but it's just 26 state machines with +#>># lots of canvas create and move calls. + +if defined?($goldberg_demo) && $goldberg_demo + $goldberg_demo.destroy + $goldberg_demo = nil +end + +# demo toplevel widget +$goldberg_demo = TkToplevel.new {|w| + title("Tk Goldberg (demonstration)") + iconname("goldberg") +# positionWindow(w) +} + +base_frame = TkFrame.new($goldberg_demo).pack(:fill=>:both, :expand=>true) + +=begin +# label +msg = TkLabel.new($goldberg_demo) { + font 'Arial 10' + wraplength '4i' + justify 'left' + text "これは、あなたが自分のアニメーションをいかに入り組んだものにできるかを示すというだけのためのデモです。ボールをクリックすれば物が動き始めます!\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg" +} +msg.pack('side'=>'top') +=end + +=begin +# frame +TkFrame.new($goldberg_demo) {|frame| + TkButton.new(frame) { + text '閉じる' + command proc{ + tmppath = $goldberg_demo + $goldberg_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'goldberg'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') +=end + +######################################### + +class TkGoldberg_Demo + def initialize(parent) + @parent = parent + + @S = {} + @S['title'] = 'Tk Goldberg' + @S['speed'] = TkVariable.new(5) + @S['cnt'] = TkVariable.new(0) + # @S['message'] = TkVariable.new("\\nWelcome\\nto\\nRuby/Tk") + @S['message'] = TkVariable.new("\\n ようこそ!\\nRuby/Tk\\nの\\n世界へ") + @S['pause'] = TkVariable.new + @S['details'] = TkVariable.new(true) + + @S['mode'] = TkVariable.new(:MSTART, :symbol) + # :MSTART, :MGO, :MPAUSE, :MSSTEP, :MBSTEP, :MDONE, :MDEBUG + + # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + @speed = [1, 10, 20, 50, 80, 100, 150, 200, 300, 400, 500] + + # colors + @C = {} + @C['fg'] = 'black' + # @C['bg'] = 'gray75' + @C['bg'] = 'cornflowerblue' + + @C['0'] = 'white'; @C['1a'] = 'darkgreen'; @C['1b'] = 'yellow' + @C['2'] = 'red'; @C['3a'] = 'green'; @C['3b'] = 'darkblue' + @C['4'] = @C['fg']; @C['5a'] = 'brown'; @C['5b'] = 'white' + @C['6'] = 'magenta'; @C['7'] = 'green'; @C['8'] = @C['fg'] + @C['9'] = 'blue4'; @C['10a'] = 'white'; @C['10b'] = 'cyan' + @C['11a'] = 'yellow'; @C['11b'] = 'mediumblue'; @C['12'] = 'tan2' + @C['13a'] = 'yellow'; @C['13b'] = 'red'; @C['14'] = 'white' + @C['15a'] = 'green'; @C['15b'] = 'yellow'; @C['16'] = 'gray65' + @C['17'] = '#A65353'; @C['18'] = @C['fg']; @C['19'] = 'gray50' + @C['20'] = 'cyan'; @C['21'] = 'gray65'; @C['22'] = @C['20'] + @C['23a'] = 'blue'; @C['23b'] = 'red'; @C['23c'] = 'yellow' + @C['24a'] = 'red'; @C['24b'] = 'white'; + + @STEP = TkVariable.new_hash + @STEP.default_value_type = :numeric + + @XY = {} + + @XY6 = { + '-1'=>[366, 207], '-2'=>[349, 204], '-3'=>[359, 193], '-4'=>[375, 192], + '-5'=>[340, 190], '-6'=>[349, 177], '-7'=>[366, 177], '-8'=>[380, 176], + '-9'=>[332, 172], '-10'=>[342, 161], '-11'=>[357, 164], + '-12'=>[372, 163], '-13'=>[381, 149], '-14'=>[364, 151], + '-15'=>[349, 146], '-16'=>[333, 148], '0'=>[357, 219], + '1'=>[359, 261], '2'=>[359, 291], '3'=>[359, 318], '4'=>[361, 324], + '5'=>[365, 329], '6'=>[367, 334], '7'=>[367, 340], '8'=>[366, 346], + '9'=>[364, 350], '10'=>[361, 355], '11'=>[359, 370], '12'=>[359, 391], + '13,0'=>[360, 456], '13,1'=>[376, 456], '13,2'=>[346, 456], + '13,3'=>[330, 456], '13,4'=>[353, 444], '13,5'=>[368, 443], + '13,6'=>[339, 442], '13,7'=>[359, 431], '13,8'=>[380, 437], + '13,9'=>[345, 428], '13,10'=>[328, 434], '13,11'=>[373, 424], + '13,12'=>[331, 420], '13,13'=>[360, 417], '13,14'=>[345, 412], + '13,15'=>[376, 410], '13,16'=>[360, 403] + } + + @timer = TkTimer.new(@speed[@S['speed'].numeric]){|timer| + timer.set_interval(go) + } + + do_display + reset + + # Start everything going + @timer.start + end + + def do_display() + @ctrl = TkFrame.new(@parent, :relief=>:ridge, :bd=>2, :padx=>5, :pady=>5) + @screen = TkFrame.new(@parent, :bd=>2, + :relief=>:raised).pack(:side=>:left, :fill=>:both, + :expand=>true) + + @canvas = TkCanvas.new(@parent, :width=>850, :height=>700, + :bg=>@C['bg'], :highlightthickness=>0){ + scrollregion([0, 0, 1000, 1000]) # Kludge to move everything up + yview_moveto(0.05) + }.pack(:in=>@screen, :side=>:top, :fill=>:both, :expand=>true) + + @canvas.bind('3'){ @pause.invoke } + @canvas.bind('Destroy'){ @timer.stop } + + do_ctrl_frame + do_detail_frame + + # msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') { + msg = Tk::Label.new(@parent, :bg=>@C['bg'], :fg=>'white') { + font 'Arial 10' + wraplength 600 + justify 'left' + text "これは、あなたが自分のアニメーションをいかに入り組んだものにできるかを示すというだけのためのデモです。ボールをクリックすれば物が動き始めます!\n\"Man will always find a difficult means to perform a simple task\" - Rube Goldberg" + } + msg.place(:in=>@canvas, :relx=>0, :rely=>0, :anchor=>:nw) + + frame = TkFrame.new(@parent, :bg=>@C['bg']) + + # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) { + Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) { + text '閉じる' + command proc{ + tmppath = $goldberg_demo + $goldberg_demo = nil + tmppath.destroy + } + }.pack('side'=>'left') + + # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) { + Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) { + text 'コード参照' + command proc{showCode 'goldberg'} + }.pack('side'=>'left', 'padx'=>5) + + # @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl}, + @show = Tk::Button.new(frame, :text=>'>>', :command=>proc{show_ctrl}, + :bg=>@C['bg'], :activebackground=>@C['bg']) + @show.pack('side'=>'left') + frame.place(:in=>@canvas, :relx=>1, :rely=>0, :anchor=>:ne) + + Tk.update + end + + def do_ctrl_frame + @start = Tk::Button.new(@parent, :text=>'Start', :bd=>6, + :command=>proc{do_button(0)}) + if font = @start['font'] + @start.font(font.weight('bold')) + end + + @pause = TkCheckbutton.new(@parent, :text=>'Pause', :font=>font, + :command=>proc{do_button(1)}, :relief=>:raised, + :variable=>@S['pause']) + + @step = TkButton.new(@parent, :text=>'Single Step', :font=>font, + :command=>proc{do_button(2)}) + @bstep = TkButton.new(@parent, :text=>'Big Step', :font=>font, + :command=>proc{do_button(4)}) + @reset = TkButton.new(@parent, :text=>'Reset', :font=>font, + :command=>proc{do_button(3)}) + + @details = TkFrame.new(@parent, :bd=>2, :relief=>:ridge) + @detail = TkCheckbutton.new(@parent, :text=>'Details', :font=>font, + :relief=>:raised, :variable=>@S['details']) + + @msg_entry = TkEntry.new(@parent, :textvariable=>@S['message'], + :justify=>:center) + @speed_scale = TkScale.new(@parent, :orient=>:horizontal, + :from=>1, :to=>10, :font=>font, + :variable=>@S['speed'], :bd=>2, + :relief=>:ridge, :showvalue=>false) + @about = TkButton.new(@parent, :text=>'About', + :command=>proc{about}, :font=>font) + + Tk.grid(@start, :in=>@ctrl, :row=>0, :sticky=>:ew) + @ctrl.grid_rowconfigure(1, :minsize=>10) + Tk.grid(@pause, :in=>@ctrl, :row=>2, :sticky=>:ew) + Tk.grid(@step, :in=>@ctrl, :sticky=>:ew) + Tk.grid(@bstep, :in=>@ctrl, :sticky=>:ew) + Tk.grid(@reset, :in=>@ctrl, :sticky=>:ew) + @ctrl.grid_rowconfigure(10, :minsize=>20) + Tk.grid(@details, :in=>@ctrl, :row=>11, :sticky=>:ew) + Tk.grid(@detail, :in=>@details, :row=>0, :sticky=>:ew) + @ctrl.grid_rowconfigure(50, :weight=>1) + + @S['mode'].trace('w', proc{|*args| active_GUI(*args)}) + @S['details'].trace('w', proc{|*args| active_GUI(*args)}) + @S['speed'].trace('w', proc{|*args| active_GUI(*args)}) + + Tk.grid(@msg_entry, :in=>@ctrl, :row=>98, :sticky=>:ew, :pady=>5) + Tk.grid(@speed_scale, :in=>@ctrl, :row=>99, :sticky=>:ew) + Tk.grid(@about, :in=>@ctrl, :row=>100, :sticky=>:ew) + + @reset.bind('3'){@S['mode'].value = -1} # Debugging + end + + def do_detail_frame + @f_details = TkFrame.new(@details) + + @label = TkLabel.new(@f_details, :textvariable=>@S['cnt'], + :bd=>1, :relief=>:solid, :bg=>'white') + Tk.grid(@label, '-', '-', '-', :sticky=>:ew, :row=>0) + + idx = 1 + loop { + break unless respond_to?("move#{idx}") + l = TkLabel.new(@f_details, :text=>idx, :anchor=>:e, + :width=>2, :bd=>1, :relief=>:solid, :bg=>'white') + @STEP[idx] = 0 + ll = TkLabel.new(@f_details, :textvariable=>@STEP.ref(idx), + :width=>5, :bd=>1, :relief=>:solid, :bg=>'white') + row = (idx + 1)/2 + col = ((idx + 1) & 1) * 2 + Tk.grid(l, :sticky=>:ew, :row=>row, :column=>col) + Tk.grid(ll, :sticky=>:ew, :row=>row, :column=>(col + 1)) + idx += 1 + } + @f_details.grid_columnconfigure(1, :weight=>1) + end + + def show_ctrl + if @ctrl.winfo_mapped? + @ctrl.pack_forget + @show.text('>>') + else + @ctrl.pack(:side=>:right, :fill=>:both, :ipady=>5) + @show.text('<<') + end + end + + def draw_all + reset_step + @canvas.delete(:all) + idx = 0 + loop{ + m = "draw#{idx}" + break unless respond_to?(m) + send(m) + idx += 1 + } + end + + def active_GUI(var1, var2, op) + st = {false=>:disabled, true=>:normal} + + m = @S['mode'].to_sym + @S['pause'].value = (m == :MPAUSE) + @start.state(st[m != :MGO]) + @pause.state(st[m != :MSTART && m != :MDONE]) + @step.state(st[m != :MGO && m != :MDONE]) + @bstep.state(st[m != :MGO && m != :MDONE]) + @reset.state(st[m != :MSTART]) + + if @S['details'].bool + Tk.grid(@f_details, :in=>@details, :row=>2, :sticky=>:ew) + else + Tk.grid_forget(@f_details) + end + @speed_scale.label("Speed: #{@S['speed'].value}") + end + + def start + @S['mode'].value = :MGO + end + + def do_button(what) + case what + when 0 # Start + reset if @S['mode'].to_sym == :MDONE + @S['mode'].value = :MGO + + when 1 # Pause + @S['mode'].value = ((@S['pause'].bool)? :MPAUSE: :MGO) + + when 2 # Step + @S['mode'].value = :MSSTEP + + when 3 # Reset + reset + + when 4 # Big step + @S['mode'].value = :MBSTEP + end + end + + def go(who = nil) + now = Tk::Clock.clicks(:miliseconds) + if who # Start here for debugging + @S['active'] = [who] + @S['mode'].value = :MGO + end + return if @S['mode'].to_sym == :MDEBUG # Debugging + # If not paused, do the next move + n = next_step if @S['mode'].to_sym != :MPAUSE + @S['mode'].value = :MPAUSE if @S['mode'].to_sym == :MSSTEP # Single step + @S['mode'].value = :MSSTEP if @S['mode'].to_sym == :MBSTEP && n # big step + elapsed = Tk::Clock.clicks(:miliseconds) - now + delay = @speed[@S['speed'].to_i] - elapsed + delay = 1 if delay <= 0 + return delay + end + + def next_step + retval = false # Return value + + if @S['mode'].to_sym != :MSTART && @S['mode'].to_sym != :MDONE + @S['cnt'].numeric += 1 + end + alive = [] + @S['active'].each{|who| + who = who.to_i + n = send("move#{who}") + if (n & 1).nonzero? # This guy still alive + alive << who + end + if (n & 2).nonzero? # Next guy is active + alive << (who + 1) + retval = true + end + if (n & 4).nonzero? # End of puzzle flag + @S['mode'].value = :MDONE # Done mode + @S['active'] = [] # No more animation + return true + end + } + @S['active'] = alive + return retval + end + + def about + msg = "Ruby/Tk Version ::\nby Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)\n\n" + msg += "Original Version ::\n" + msg += "#{@S['title']}\nby Keith Vetter, March 2003\n(Reproduced by kind permission of the author)\n\n" + msg += "Man will always find a difficult means to perform a simple task" + msg += "\nRube Goldberg" + Tk.messageBox(:message=>msg, :title=>'About') + end + + ################################################################ + # + # All the drawing and moving routines + # + + # START HERE! banner + def draw0 + color = @C['0'] + TkcText.new(@canvas, + # [579, 119], :text=>'START HERE!', + [558, 119], :text=>'ここからスタート!', + :fill=>color, :anchor=>:w, + :tag=>'I0', :font=>['Times Roman', 12, :italic, :bold]) + TkcLine.new(@canvas, [719, 119, 763, 119], :tag=>'I0', :fill=>color, + :width=>5, :arrow=>:last, :arrowshape=>[18, 18, 5]) + @canvas.itembind('I0', '1'){ start } + end + + def move0(step = nil) + step = get_step(0, step) + + if @S['mode'].to_sym != :MSTART # Start the ball rolling + move_abs('I0', [-100, -100]) # Hide the banner + return 2 + end + + pos = [ + [673, 119], [678, 119], [683, 119], [688, 119], + [693, 119], [688, 119], [683, 119], [678, 119] + ] + step = step % pos.length + move_abs('I0', pos[step]) + return 1 + end + + # Dropping ball + def draw1 + color = @C['1a'] + color2 = @C['1b'] + TkcPolygon.new(@canvas, + [ 844, 133, 800, 133, 800, 346, 820, 346, + 820, 168, 844, 168, 844, 133 ], + :width=>3, :fill=>color, :outline=>'') + TkcPolygon.new(@canvas, + [ 771, 133, 685, 133, 685, 168, 751, 168, + 751, 346, 771, 346, 771, 133 ], + :width=>3, :fill=>color, :outline=>'') + TkcOval.new(@canvas, box(812, 122, 9), + :tag=>'I1', :fill=>color2, :outline=>'') + + @canvas.itembind('I1', '1'){ start } + end + + def move1(step = nil) + step = get_step(1, step) + pos = [ + [807, 122], [802, 122], [797, 123], [793, 124], [789, 129], [785, 153], + [785, 203], [785, 278, :x], [785, 367], [810, 392], [816, 438], + [821, 503], [824, 585, :y], [838, 587], [848, 593], [857, 601], + [-100, -100] + ] + return 0 if step >= pos.length + where = pos[step] + move_abs('I1', where) + move15a if where[2] == :y + return 3 if where[2] == :x + return 1 + end + + # Lighting the match + def draw2 + color = @C['2'] + + # Fulcrum + TkcPolygon.new(@canvas, [750, 369, 740, 392, 760, 392], + :fill=>@C['fg'], :outline=>@C['fg']) + + # Strike box + TkcRectangle.new(@canvas, [628, 335, 660, 383], + :fill=>'', :outline=>@C['fg']) + (0..2).each{|y| + yy = 335 + y*16 + TkcBitmap.new(@canvas, [628, yy], :bitmap=>'gray25', + :anchor=>:nw, :foreground=>@C['fg']) + TkcBitmap.new(@canvas, [644, yy], :bitmap=>'gray25', + :anchor=>:nw, :foreground=>@C['fg']) + } + + # Lever + TkcLine.new(@canvas, [702, 366, 798, 366], + :fill=>@C['fg'], :width=>6, :tag=>'I2_0') + + # R strap + TkcLine.new(@canvas, [712, 363, 712, 355], + :fill=>@C['fg'], :width=>3, :tag=>'I2_1') + + # L strap + TkcLine.new(@canvas, [705, 363, 705, 355], + :fill=>@C['fg'], :width=>3, :tag=>'I2_2') + + # Match stick + TkcLine.new(@canvas, [679, 356, 679, 360, 717, 360, 717, 356, 679, 356], + :fill=>@C['fg'], :width=>3, :tag=>'I2_3') + + # Match head + TkcPolygon.new(@canvas, + [ 671, 352, 677.4, 353.9, 680, 358.5, 677.4, 363.1, + 671, 365, 664.6, 363.1, 662, 358.5, 664.6, 353.9 ], + :fill=>color, :outline=>color, :tag=>'I2_4') + end + + def move2(step = nil) + step = get_step(2, step) + + stages = [0, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1] + xy = [] + xy[0] = [ + 686, 333, 692, 323, 682, 316, 674, 309, 671, 295, 668, 307, + 662, 318, 662, 328, 671, 336 + ] + xy[1] = [ + 687, 331, 698, 322, 703, 295, 680, 320, 668, 297, 663, 311, + 661, 327, 671, 335 + ] + xy[2] = [ + 686, 331, 704, 322, 688, 300, 678, 283, 678, 283, 674, 298, + 666, 309, 660, 324, 672, 336 + ] + + if step >= stages.length + @canvas.delete('I2') + return 0 + end + + if step == 0 # Rotate the match + beta = 20 + + ox, oy = anchor('I2_0', :s) # Where to pivot + + i = 0 + until @canvas.find_withtag("I2_#{i}").empty? + rotate_item("I2_#{i}", ox, oy, beta) + i += 1 + end + + # For the flame + TkcPolygon.new(@canvas, [], :tag=>'I2', :smooth=>true, :fill=>@C['2']) + + return 1 + end + @canvas.coords('I2', xy[stages[step]]) + return ((step == 7)? 3: 1) + end + + # Weight and pulleys + def draw3 + color = @C['3a'] + color2 = @C['3b'] + + xy = [ [602, 296], [577, 174], [518, 174] ] + xy.each{|x, y| # 3 Pulleys + TkcOval.new(@canvas, box(x, y, 13), + :fill=>color, :outline=>@C['fg'], :width=>3) + TkcOval.new(@canvas, box(x, y, 2), :fill=>@C['fg'], :outline=>@C['fg']) + } + + # Wall to flame + TkcLine.new(@canvas, [750, 309, 670, 309], :tag=>'I3_s', + :width=>3, :fill=>@C['fg'], :smooth=>true) + + # Flame to pulley 1 + TkcLine.new(@canvas, [670, 309, 650, 309], :tag=>'I3_0', + :width=>3, :fill=>@C['fg'], :smooth=>true) + TkcLine.new(@canvas, [650, 309, 600, 309], :tag=>'I3_1', + :width=>3, :fill=>@C['fg'], :smooth=>true) + + # Pulley 1 half way to 2 + TkcLine.new(@canvas, [589, 296, 589, 235], :tag=>'I3_2', + :width=>3, :fill=>@C['fg']) + + # Pulley 1 other half to 2 + TkcLine.new(@canvas, [589, 235, 589, 174], :width=>3, :fill=>@C['fg']) + + # Across the top + TkcLine.new(@canvas, [577, 161, 518, 161], :width=>3, :fill=>@C['fg']) + + # Down to weight + TkcLine.new(@canvas, [505, 174, 505, 205], :tag=>'I3_w', + :width=>3, :fill=>@C['fg']) + + # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle + x1, y1, x2, y2 = [515, 207, 495, 207] + TkcOval.new(@canvas, box(x1, y1, 6), + :tag=>'I3_', :fill=>color2, :outline=>color2) + TkcOval.new(@canvas, box(x2, y2, 6), + :tag=>'I3_', :fill=>color2, :outline=>color2) + TkcRectangle.new(@canvas, x1, y1 - 6, x2, y2 + 6, + :tag=>'I3_', :fill=>color2, :outline=>color2) + + TkcPolygon.new(@canvas, round_rect([492, 220, 518, 263], 15), + :smooth=>true, :tag=>'I3_', :fill=>color2, :outline=>color2) + + TkcLine.new(@canvas, [500, 217, 511, 217], + :tag=>'I3_', :fill=>color2, :width=>10) + + # Bottom weight target + TkcLine.new(@canvas, [502, 393, 522, 393, 522, 465], + :tag=>'I3__', :fill=>@C['fg'], :joinstyle=>:miter, :width=>10) + end + + def move3(step = nil) + step = get_step(3, step) + + pos = [ [505, 247], [505, 297], [505, 386.5], [505, 386.5] ] + rope = [] + rope[0] = [750, 309, 729, 301, 711, 324, 690, 300] + rope[1] = [750, 309, 737, 292, 736, 335, 717, 315, 712, 320] + rope[2] = [750, 309, 737, 309, 740, 343, 736, 351, 725, 340] + rope[3] = [750, 309, 738, 321, 746, 345, 742, 356] + + return 0 if step >= pos.length + + @canvas.delete("I3_#{step}") # Delete part of the rope + move_abs('I3_', pos[step]) # Move weight down + @canvas.coords('I3_s', rope[step]) # Flapping rope end + @canvas.coords('I3_w', [505, 174].concat(pos[step])) + if step == 2 + @canvas.move('I3__', 0, 30) + return 2 + end + return 1 + end + + # Cage and door + def draw4 + color = @C['4'] + x0, y0, x1, y1 = [527, 356, 611, 464] + + # Horizontal bars + y0.step(y1, 12){|y| + TkcLine.new(@canvas, [x0, y, x1, y], :fill=>color, :width=>1) + } + + # Vertical bars + x0.step(x1, 12){|x| + TkcLine.new(@canvas, [x, y0, x, y1], :fill=>color, :width=>1) + } + + # Swing gate + TkcLine.new(@canvas, [518, 464, 518, 428], + :tag=>'I4', :fill=>color, :width=>1) + end + + def move4(step = nil) + step = get_step(4, step) + + angles = [-10, -20, -30, -30] + return 0 if step >= angles.length + + rotate_item('I4', 518, 464, angles[step]) + @canvas.raise('I4') + + return((step == 3)? 3: 1) + end + + # Mouse + def draw5 + color = @C['5a'] + color2 = @C['5b'] + + xy = [377, 248, 410, 248, 410, 465, 518, 465] # Mouse course + xy.concat [518, 428, 451, 428, 451, 212, 377, 212] + + TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'], :width=>3) + + xy = [ + 534.5, 445.5, 541, 440, 552, 436, 560, 436, 569, 440, 574, 446, + 575, 452, 574, 454, 566, 456, 554, 456, 545, 456, 537, 454, 530, 452 + ] + TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_0'], :fill=>color) + + TkcLine.new(@canvas, [573, 452, 592, 458, 601, 460, 613, 456], # Tail + :tag=>['I5', 'I5_1'], :fill=>color, :smooth=>true, :width=>3) + + xy = box(540, 446, 2) # Eye + xy = [540, 444, 541, 445, 541, 447, 540, 448, 538, 447, 538, 445] + TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_2'], :fill=>@C['bg'], + :outline=>'', :smooth=>true) + + xy = [538, 454, 535, 461] # Front leg + TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_3'], :fill=>color, :width=>2) + + xy = [566, 455, 569, 462] # Back leg + TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_4'], :fill=>color, :width=>2) + + xy = [544, 455, 545, 460] # 2nd front leg + TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_5'], :fill=>color, :width=>2) + + xy = [560, 455, 558, 460] # 2nd back leg + TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_6'], :fill=>color, :width=>2) + end + + def move5(step = nil) + step = get_step(5, step) + + pos = [ + [553, 452], [533, 452], [513, 452], [493, 452], [473, 452], + [463, 442, 30], [445.5, 441.5, 30], [425.5, 434.5, 30], [422, 414], + [422, 394], [422, 374], [422, 354], [422, 334], [422, 314], [422, 294], + [422, 274, -30], [422, 260.5, -30, :x], [422.5, 248.5, -28], [425, 237] + ] + + return 0 if step >= pos.length + + x, y, beta, nxt = pos[step] + move_abs('I5', [x, y]) + if beta + ox, oy = centroid('I5_0') + (0..6).each{|id| rotate_item("I5_#{id}", ox, oy, beta) } + end + return 3 if nxt == :x + return 1 + end + + # Dropping gumballs + def draw6 + color = @C['6'] + xy = [324, 130, 391, 204] # Ball holder + xy = round_rect(xy, 10) + TkcPolygon.new(@canvas, xy, :smooth=>true, + :outline=>@C['fg'], :width=>3, :fill=>color) + xy = [339, 204, 376, 253] # Below the ball holder + TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>3, + :fill=>color, :tag=>'I6c') + xy = box(346, 339, 28) + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'') # Roter + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc, + :start=>80, :extent=>205) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc, + :start=>-41, :extent=>85) + + xy = box(346, 339, 15) # Center of rotor + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg'], :tag=>'I6m') + xy = [352, 312, 352, 254, 368, 254, 368, 322] # Top drop to rotor + TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'') + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2) + + xy = [353, 240, 367, 300] # Poke bottom hole + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'') + xy = [341, 190, 375, 210] # Poke another hole + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'') + + xy = [ + 368, 356, 368, 403, 389, 403, 389, 464, 320, 464, 320, 403, + 352, 403, 352, 366 + ] + TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'', + :width=>2) # Below rotor + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2) + xy = box(275, 342, 7) # On/off rotor + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg']) + xy = [276, 334, 342, 325] # Fan belt top + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + xy = [276, 349, 342, 353] # Fan belt bottom + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + + xy = [337, 212, 337, 247] # What the mouse pushes + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_') + xy = [392, 212, 392, 247] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_') + xy = [337, 230, 392, 230] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>7, :tag=>'I6_') + + who = -1 # All the balls + colors = %w(red cyan orange green blue darkblue) + colors *= 3 + + (0..16).each{|i| + loc = -i + color = colors[i] + x, y = @XY6["#{loc}"] + TkcOval.new(@canvas, box(x, y, 5), + :fill=>color, :outline=>color, :tag=>"I6_b#{i}") + } + draw6a(12) # The wheel + end + + def draw6a(beta) + @canvas.delete('I6_0') + ox, oy = [346, 339] + (0..3).each{|i| + b = beta + i * 45 + x, y = rotate_c(28, 0, 0, 0, b) + xy = [ox + x, oy + y, ox - x, oy - y] + TkcLine.new(@canvas, xy, :tag=>'I6_0', :fill=>@C['fg'], :width=>2) + } + end + + def move6(step = nil) + step = get_step(6, step) + + return 0 if step > 62 + + if step < 2 # Open gate for balls to drop + @canvas.move('I6_', -7, 0) + if step == 1 # Poke a hole + xy = [348, 226, 365, 240] + TkcRectangle.new(@canvas, xy, :fill=>@canvas.itemcget('I6c', :fill), + :outline=>'') + end + return 1 + end + + s = step - 1 # Do the gumball drop dance + (0..(((s - 1)/3).to_i)).each{|i| + tag = "I6_b#{i}" + break if @canvas.find_withtag(tag).empty? + loc = s - 3*i + + if @XY6["#{loc},#{i}"] + move_abs(tag, @XY6["#{loc},#{i}"]) + elsif @XY6["#{loc}"] + move_abs(tag, @XY6["#{loc}"]) + end + } + if s % 3 == 1 + first = (s + 2)/3 + i = first + loop { + tag = "I6_b#{i}" + break if @canvas.find_withtag(tag).empty? + loc = first - i + move_abs(tag, @XY6["#{loc}"]) + i += 1 + } + end + if s >= 3 # Rotate the motor + idx = s % 3 + draw6a(12 + s * 15) + end + return((s == 3)? 3 : 1) + end + + # On/off switch + def draw7 + color = @C['7'] + xy = [198, 306, 277, 374] # Box + TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>2, + :fill=>color, :tag=>'I7z') + @canvas.lower('I7z') + xy = [275, 343, 230, 349] + TkcLine.new(@canvas, xy, :tag=>'I7', :fill=>@C['fg'], :arrow=>:last, + :arrowshape=>[23, 23, 8], :width=>6) + xy = [225, 324] # On button + x, y = xy + TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg']) + xy = [218, 323] # On text + font = ['Times Roman', 8] + TkcText.new(@canvas, xy, :text=>'on', :anchor=>:e, + :fill=>@C['fg'], :font=>font) + xy = [225, 350] # Off button + x, y = xy + TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg']) + xy = [218, 349] # Off text + TkcText.new(@canvas, xy, :text=>'off', :anchor=>:e, + :fill=>@C['fg'], :font=>font) + end + + def move7(step = nil) + step = get_step(7, step) + + numsteps = 30 + return 0 if step > numsteps + beta = 30.0 / numsteps + rotate_item('I7', 275, 343, beta) + + return((step == numsteps)? 3: 1) + end + + # Electricity to the fan + def draw8 + sine([271, 248, 271, 306], 5, 8, :tag=>'I8_s', :fill=>@C['8'], :width=>3) + end + + def move8(step = nil) + step = get_step(8, step) + + return 0 if step > 3 + if step == 0 + sparkle(anchor('I8_s', :s), 'I8') + return 1 + elsif step == 1 + move_abs('I8', anchor('I8_s', :c)) + elsif step == 2 + move_abs('I8', anchor('I8_s', :n)) + else + @canvas.delete('I8') + end + return((step == 2)? 3: 1) + end + + # Fan + def draw9 + color = @C['9'] + xy = [266, 194, 310, 220] + TkcOval.new(@canvas, xy, :outline=>color, :fill=>color) + xy = [280, 209, 296, 248] + TkcOval.new(@canvas, xy, :outline=>color, :fill=>color) + xy = [ + 288, 249, 252, 249, 260, 240, 280, 234, + 296, 234, 316, 240, 324, 249, 288, 249 + ] + TkcPolygon.new(@canvas, xy, :fill=>color, :smooth=>true) + + xy = [248, 205, 265, 214, 264, 205, 265, 196] # Spinner + TkcPolygon.new(@canvas, xy, :fill=>color) + + xy = [255, 206, 265, 234] # Fan blades + TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], + :width=>3, :tag=>'I9_0') + xy = [255, 176, 265, 204] + TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], + :width=>3, :tag=>'I9_0') + xy = [255, 206, 265, 220] + TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], + :width=>1, :tag=>'I9_1') + xy = [255, 190, 265, 204] + TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], + :width=>1, :tag=>'I9_1') + end + + def move9(step = nil) + step = get_step(9, step) + + if (step & 1).nonzero? + @canvas.itemconfigure('I9_0', :width=>4) + @canvas.itemconfigure('I9_1', :width=>1) + @canvas.lower('I9_1', 'I9_0') + else + @canvas.itemconfigure('I9_0', :width=>1) + @canvas.itemconfigure('I9_1', :width=>4) + @canvas.lower('I9_0', 'I9_1') + end + return 3 if step == 0 + return 1 + end + + # Boat + def draw10 + color = @C['10a'] + color2 = @C['10b'] + xy = [191, 230, 233, 230, 233, 178, 191, 178] # Sail + TkcPolygon.new(@canvas, xy, :fill=>color, :width=>3, :outline=>@C['fg'], + :tag=>'I10') + xy = box(209, 204, 31) # Front + TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :style=>:pie, + :start=>120, :extent=>120, :tag=>'I10') + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :start=>120, :extent=>120, :tag=>'I10') + xy = box(249, 204, 31) # Back + TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>3, + :style=>:pie, :start=>120, :extent=>120, :tag=>'I10') + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :start=>120, :extent=>120, :tag=>'I10') + + xy = [200, 171, 200, 249] # Mast + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10') + xy = [159, 234, 182, 234] # Bow sprit + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10') + xy = [180, 234, 180, 251, 220, 251] # Hull + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6, :tag=>'I10') + + xy = [92, 255, 221, 255] # Waves + sine(xy, 2, 25, :fill=>color2, :width=>1, :tag=>'I10w') + + xy = @canvas.coords('I10w')[4..-5] # Water + xy.concat([222, 266, 222, 277, 99, 277]) + TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>color2) + xy = [222, 266, 222, 277, 97, 277, 97, 266] # Water bottom + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + + xy = box(239, 262, 17) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :start=>95, :extent=>103) + xy = box(76, 266, 21) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :extent=>190) + end + + def move10(step = nil) + step = get_step(10, step) + + pos = [ + [195, 212], [193, 212], [190, 212], [186, 212], [181, 212], [176, 212], + [171, 212], [166, 212], [161, 212], [156, 212], [151, 212], [147, 212], + [142, 212], [137, 212], [132, 212, :x], [127, 212], [121, 212], + [116, 212], [111, 212] + ] + + return 0 if step >= pos.length + + where = pos[step] + move_abs('I10', where) + + return 3 if where[2] == :x + return 1 + end + + # 2nd ball drop + def draw11 + color = @C['11a'] + color2 = @C['11b'] + xy = [23, 264, 55, 591] # Color the down tube + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'') + xy = box(71, 460, 48) # Color the outer loop + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'') + + xy = [55, 264, 55, 458] # Top right side + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + xy = [55, 504, 55, 591] # Bottom right side + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + xy = box(71, 460, 48) # Outer loop + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :start=>110, :extent=>-290, :tag=>'I11i') + xy = box(71, 460, 16) # Inner loop + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>'', + :width=>3, :tag=>'I11i') + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['bg'], :width=>3) + + xy = [23, 264, 23, 591] # Left side + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + xy = box(1, 266, 23) # Top left curve + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, + :style=>:arc, :extent=>90) + + xy = box(75, 235, 9) # The ball + TkcOval.new(@canvas, xy, :fill=>color2, :outline=>'', + :width=>3, :tag=>'I11') + end + + def move11(step = nil) + step = get_step(11, step) + + pos = [ + [75, 235], [70, 235], [65, 237], [56, 240], [46, 247], [38, 266], + [38, 296], [38, 333], [38, 399], [38, 475], [74, 496], [105, 472], + [100, 437], [65, 423], [-100, -100], [38, 505], [38, 527, :x], [38, 591] + ] + + return 0 if step >= pos.length + where = pos[step] + move_abs('I11', where) + return 3 if where[2] == :x + return 1 + end + + # Hand + def draw12 + xy = [ + 20, 637, 20, 617, 20, 610, 20, 590, 40, 590, 40, 590, + 60, 590, 60, 610, 60, 610 + ] + xy.concat([60, 610, 65, 620, 60, 631]) # Thumb + xy.concat([60, 631, 60, 637, 60, 662, 60, 669, 52, 669, + 56, 669, 50, 669, 50, 662, 50, 637]) + + y0 = 637 # Bumps for fingers + y1 = 645 + 50.step(21, -10){|x| + x1 = x - 5 + x2 = x - 10 + xy << x << y0 << x1 << y1 << x2 << y0 + } + TkcPolygon.new(@canvas, xy, :fill=>@C['12'], :outline=>@C['fg'], + :smooth=>true, :tag=>'I12', :width=>3) + end + + def move12(step = nil) + step = get_step(12, step) + + pos = [[42.5, 641, :x]] + return 0 if step >= pos.length + where = pos[step] + move_abs('I12', where) + return 3 if where[2] == :x + return 1 + end + + # Fax + def draw13 + color = @C['13a'] + xy = [86, 663, 149, 663, 149, 704, 50, 704, 50, 681, 64, 681, 86, 671] + xy2 = [ + 784, 663, 721, 663, 721, 704, 820, 704, 820, 681, 806, 681, 784, 671 + ] + radii = [2, 9, 9, 8, 5, 5, 2] + + round_poly(@canvas, xy, radii, :width=>3, + :outline=>@C['fg'], :fill=>color) + round_poly(@canvas, xy2, radii, :width=>3, + :outline=>@C['fg'], :fill=>color) + + xy = [56, 677] + x, y = xy + TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'], + :width=>3, :tag=>'I13') + xy = [809, 677] + x, y = xy + TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'], + :width=>3, :tag=>'I13R') + + xy = [112, 687] # Label + TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'], + :font=>['Times Roman', 12, :bold]) + xy = [762, 687] + TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'], + :font=>['Times Roman', 12, :bold]) + + xy = [138, 663, 148, 636, 178, 636] # Paper guide + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3) + xy = [732, 663, 722, 636, 692, 636] + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3) + + sine([149, 688, 720, 688], 5, 15, + :tag=>'I13_s', :fill=>@C['fg'], :width=>3) + end + + def move13(step = nil) + step = get_step(13, step) + + numsteps = 7 + + if step == numsteps + 2 + move_abs('I13_star', [-100, -100]) + @canvas.itemconfigure('I13R', :fill=>@C['13b'], :width=>2) + return 2 + end + if step == 0 # Button down + @canvas.delete('I13') + sparkle([-100, -100], 'I13_star') # Create off screen + return 1 + end + x0, y0 = anchor('I13_s', :w) + x1, y1 = anchor('I13_s', :e) + x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f + move_abs('I13_star', [x, y0]) + return 1 + end + + # Paper in fax + def draw14 + color = @C['14'] + xy = [102, 661, 113, 632, 130, 618] # Left paper edge + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color, + :width=>3, :tag=>'I14L_0') + xy = [148, 629, 125, 640, 124, 662] # Right paper edge + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color, + :width=>3, :tag=>'I14L_1') + draw14a('L') + + xy = [ + 768.0, 662.5, 767.991316225, 662.433786215, 767.926187912, 662.396880171 + ] + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color, + :width=>3, :tag=>'I14R_0') + @canvas.lower('I14R_0') + # NB. these numbers are VERY sensitive, you must start with final size + # and shrink down to get the values + xy = [ + 745.947897349, 662.428358855, 745.997829056, 662.452239237, 746.0, 662.5 + ] + TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color, + :width=>3, :tag=>'I14R_1') + @canvas.lower('I14R_1') + end + + def draw14a(side) + color = @C['14'] + xy = @canvas.coords("I14#{side}_0") + xy2 = @canvas.coords("I14#{side}_1") + x0, y0, x1, y1, x2, y2 = xy + x3, y3, x4, y4, x5, y5 = xy2 + + zz = [ + x0, y0, x0, y0, xy, x2, y2, x2, y2, + x3, y3, x3, y3, xy2, x5, y5, x5, y5 + ].flatten + @canvas.delete("I14#{side}") + TkcPolygon.new(@canvas, zz, :tag=>"I14#{side}", :smooth=>true, + :fill=>color, :outline=>color, :width=>3) + @canvas.lower("I14#{side}") + end + + def move14(step = nil) + step = get_step(14, step) + + # Paper going down + sc = 0.9 - 0.05*step + if sc < 0.3 + @canvas.delete('I14L') + return 0 + end + + ox, oy = @canvas.coords('I14L_0') + @canvas.scale('I14L_0', ox, oy, sc, sc) + ox, oy = @canvas.coords('I14L_1')[-2..-1] + @canvas.scale('I14L_1', ox, oy, sc, sc) + draw14a('L') + + # Paper going up + sc = 0.35 + 0.05*step + sc = 1/sc + + ox, oy = @canvas.coords('I14R_0') + @canvas.scale('I14R_0', ox, oy, sc, sc) + ox, oy = @canvas.coords('I14R_1')[-2..-1] + @canvas.scale('I14R_1', ox, oy, sc, sc) + draw14a('R') + + return((step == 10)? 3: 1) + end + + # Light beam + def draw15 + color = @C['15a'] + xy = [824, 599, 824, 585, 820, 585, 829, 585] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I15a') + xy = [789, 599, 836, 643] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3) + xy = [778, 610, 788, 632] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3) + xy = [766, 617, 776, 625] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3) + + xy = [633, 600, 681, 640] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3) + xy = [635, 567, 657, 599] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2) + xy = [765, 557, 784, 583] + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2) + + sine([658, 580, 765, 580], 3, 15, + :tag=>'I15_s', :fill=>@C['fg'], :width=>3) + end + + def move15a + color = @C['15b'] + @canvas.scale('I15a', 824, 599, 1, 0.3) # Button down + xy = [765, 621, 681, 621] + TkcLine.new(@canvas, xy, :dash=>'-', :width=>3, :fill=>color, :tag=>'I15') + end + + def move15(step = nil) + step = get_step(15, step) + + numsteps = 6 + + if step == numsteps + 2 + move_abs('I15_star', [-100, -100]) + return 2 + end + if step == 0 # Break the light beam + sparkle([-100, -100], 'I15_star') + xy = [765, 621, 745, 621] + @canvas.coords('I15', xy) + return 1 + end + x0, y0 = anchor('I15_s', :w) + x1, y1 = anchor('I15_s', :e) + x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f + move_abs('I15_star', [x, y0]) + return 1 + end + + # Bell + def draw16 + color = @C['16'] + xy = [722, 485, 791, 556] + TkcRectangle.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>3) + xy = box(752, 515, 25) # Bell + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'black', + :tag=>'I16b', :width=>2) + xy = box(752, 515, 5) # Bell button + TkcOval.new(@canvas, xy, :fill=>'black', :outline=>'black', :tag=>'I16b') + + xy = [784, 523, 764, 549] # Clapper + TkcLine.new(@canvas, xy, :width=>3, :tag=>'I16c', :fill=>@C['fg']) + xy = box(784, 523, 4) + TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>@C['fg'], :tag=>'I16d') + end + + def move16(step = nil) + step = get_step(16, step) + + # Note: we never stop + ox, oy = [760, 553] + if (step & 1).nonzero? + beta = 12 + @canvas.move('I16b', 3, 0) + else + beta = -12 + @canvas.move('I16b', -3, 0) + end + rotate_item('I16c', ox, oy, beta) + rotate_item('I16d', ox, oy, beta) + + return ((step == 1)? 3: 1) + end + + # Cat + def draw17 + color = @C['17'] + + xy = [584, 556, 722, 556] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + xy = [584, 485, 722, 485] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3) + + xy = [664, 523, 717, 549] # Body + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :fill=>color, :width=>3, + :style=>:chord, :start=>128, :extent=>260, :tag=>'I17') + + xy = [709, 554, 690, 543] # Paw + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color, + :width=>3, :tag=>'I17') + xy = [657, 544, 676, 555] + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color, + :width=>3, :tag=>'I17') + + xy = box(660, 535, 15) # Lower face + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc, + :start=>150, :extent=>240, :tag=>'I17_') + TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1, + :style=>:chord, :start=>150, :extent=>240, :tag=>'I17_') + xy = [674, 529, 670, 513, 662, 521, 658, 521, 650, 513, 647, 529] # Ears + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'', :width=>1, + :tag=>['I17_', 'I17_c']) + xy = [652, 542, 628, 539] # Whiskers + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + xy = [652, 543, 632, 545] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + xy = [652, 546, 632, 552] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + + xy = [668, 543, 687, 538] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, + :tag=>['I17_', 'I17_w']) + xy = [668, 544, 688, 546] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, + :tag=>['I17_', 'I17_w']) + xy = [668, 547, 688, 553] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, + :tag=>['I17_', 'I17_w']) + + xy = [649, 530, 654, 538, 659, 530] # Left eye + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, + :smooth=>true, :tag=>'I17') + xy = [671, 530, 666, 538, 661, 530] # Right eye + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, + :smooth=>true, :tag=>'I17') + xy = [655, 543, 660, 551, 665, 543] # Mouth + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, + :smooth=>true, :tag=>'I17') + end + + def move17(step = nil) + step = get_step(17, step) + + if step == 0 + @canvas.delete('I17') # Delete most of the cat + xy = [655, 543, 660, 535, 665, 543] # Mouth + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, + :smooth=>true, :tag=>'I17_') + xy = box(654, 530, 4) # Left eye + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'', + :tag=>'I17_') + xy = box(666, 530, 4) # Right eye + TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'', + :tag=>'I17_') + + @canvas.move('I17_', 0, -20) # Move face up + xy = [652, 528, 652, 554] # Front leg + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + xy = [670, 528, 670, 554] # 2nd front leg + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + + xy = [ # Body + 675, 506, 694, 489, 715, 513, 715, 513, 715, 513, 716, 525, + 716, 525, 716, 525, 706, 530, 695, 530, 679, 535, 668, 527, + 668, 527, 668, 527, 675, 522, 676, 517, 677, 512 + ] + TkcPolygon.new(@canvas, xy, :fill=>@canvas.itemcget('I17_c', :fill), + :outline=>@C['fg'], :width=>3, :smooth=>true, + :tag=>'I17_') + xy = [716, 514, 716, 554] # Back leg + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + xy = [694, 532, 694, 554] # 2nd back leg + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_') + xy = [715, 514, 718, 506, 719, 495, 716, 488] # Tail + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, + :smooth=>true, :tag=>'I17_') + + @canvas.raise('I17w') # Make whiskers visible + @canvas.move('I17_', -5, 0) # Move away from the wall a bit + return 2 + end + return 0 + end + + # Sling shot + def draw18 + color = @C['18'] + xy = [721, 506, 627, 506] # Sling hold + TkcLine.new(@canvas, xy, :width=>4, :fill=>@C['fg'], :tag=>'I18') + + xy = [607, 500, 628, 513] # Sling rock + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :tag=>'I18a') + + xy = [526, 513, 606, 507, 494, 502] # Sling band + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>4, :tag=>'I18b') + xy = [485, 490, 510, 540, 510, 575, 510, 540, 535, 491] # Sling + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6) + end + + def move18(step = nil) + step = get_step(18, step) + + pos = [ + [587, 506], [537, 506], [466, 506], [376, 506], [266, 506, :x], + [136, 506], [16, 506], [-100, -100] + ] + + b = [] + b[0] = [490, 502, 719, 507, 524, 512] # Band collapsing + b[1] = [ + 491, 503, 524, 557, 563, 505, 559, 496, 546, 506, 551, 525, + 553, 536, 538, 534, 532, 519, 529, 499 + ] + b[2] = [ + 491, 503, 508, 563, 542, 533, 551, 526, 561, 539, 549, 550, 530, 500 + ] + b[3] = [ + 491, 503, 508, 563, 530, 554, 541, 562, 525, 568, 519, 544, 530, 501 + ] + + return 0 if step >= pos.length + + if step == 0 + @canvas.delete('I18') + @canvas.itemconfigure('I18b', :smooth=>true) + end + if b[step] + @canvas.coords('I18b', b[step]) + end + + where = pos[step] + move_abs('I18a', where) + return 3 if where[2] == :x + return 1 + end + + # Water pipe + def draw19 + color = @C['19'] + xx = [[249, 181], [155, 118], [86, 55], [22, 0]] + xx.each{|x1, x2| + TkcRectangle.new(@canvas, x1, 453, x2, 467, + :fill=>color, :outline=>'', :tag=>'I19') + TkcLine.new(@canvas, x1, 453, x2, 453, + :fill=>@C['fg'], :width=>1) # Pipe top + TkcLine.new(@canvas, x1, 467, x2, 467, + :fill=>@C['fg'], :width=>1) # Pipe bottom + } + @canvas.raise('I11i') + + xy = box(168, 460, 16) # Bulge by the joint + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'') + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc, + :start=>21, :extent=>136) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc, + :start=>-21, :extent=>-130) + + xy = [249, 447, 255, 473] # First joint 26x6 + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + + xy = box(257, 433, 34) # Bend up + TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1, + :style=>:pie, :start=>0, :extent=>-91) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>0, :extent=>-90) + xy = box(257, 433, 20) + TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1, + :style=>:pie, :start=>0, :extent=>-92) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>0, :extent=>-90) + xy = box(257, 421, 34) # Bend left + TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1, + :style=>:pie, :start=>0, :extent=>91) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>0, :extent=>90) + xy = box(257, 421, 20) + TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1, + :style=>:pie, :start=>0, :extent=>90) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>0, :extent=>90) + xy = box(243, 421, 34) # Bend down + TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1, + :style=>:pie, :start=>90, :extent=>90) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>90, :extent=>90) + xy = box(243, 421, 20) + TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1, + :style=>:pie, :start=>90, :extent=>90) + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, + :style=>:arc, :start=>90, :extent=>90) + + xy = [270, 427, 296, 433] # 2nd joint bottom + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + xy = [270, 421, 296, 427] # 2nd joint top + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + xy = [249, 382, 255, 408] # Third joint right + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + xy = [243, 382, 249, 408] # Third joint left + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + xy = [203, 420, 229, 426] # Last joint + TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1) + + xy = box(168, 460, 6) # Handle joint + TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>'', :tag=>'I19a') + xy = [168, 460, 168, 512] # Handle bar + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>5, :tag=>'I19b') + end + + def move19(step = nil) + step = get_step(19, step) + + angles = [30, 30, 30] + return 2 if step == angles.length + ox, oy = centroid('I19a') + rotate_item('I19b', ox, oy, angles[step]) + + return 1 + end + + # Water pouring + def draw20 + # do nothing + end + + def move20(step = nil) + step = get_step(20, step) + + pos = [451, 462, 473, 484, 496, 504, 513, 523, 532] + freq = [20, 40, 40, 40, 40, 40, 40, 40, 40] + pos = [ + [451, 20], [462, 40], [473, 40], [484, 40], [496, 40], + [504, 40], [513, 40], [523, 40], [532, 40, :x] + ] + return 0 if step >= pos.length + + @canvas.delete('I20') + where = pos[step] + y, f = where + h20(y, f) + return 3 if where[2] == :x + return 1 + end + + def h20(y, f) + color = @C['20'] + @canvas.delete('I20') + + sine([208, 428, 208, y], 4, f, :tag=>['I20', 'I20s'], + :width=>3, :fill=>color, :smooth=>true) + TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3, + :fill=>color, :smooth=>1, :tag=>['I20', 'I20a']) + TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3, + :fill=>color, :smooth=>1, :tag=>['I20', 'I20b']) + @canvas.move('I20a', 8, 0) + @canvas.move('I20b', 16, 0) + end + + # Bucket + def draw21 + color = @C['21'] + xy = [217, 451, 244, 490] # Right handle + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a') + xy = [201, 467, 182, 490] # Left handle + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a') + + xy = [245, 490, 237, 535] # Right side + xy2 = [189, 535, 181, 490] # Left side + TkcPolygon.new(@canvas, xy + xy2, :fill=>color, :outline=>'', + :tag=>['I21', 'I21f']) + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21') + TkcLine.new(@canvas, xy2, :fill=>@C['fg'], :width=>2, :tag=>'I21') + + xy = [182, 486, 244, 498] # Top + TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :width=>2, + :tag=>['I21', 'I21f']) + TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>2, + :tag=>['I21', 'I21t']) + xy = [189, 532, 237, 540] # Bottom + TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2, + :tag=>['I21', 'I21b']) + end + + def move21(step = nil) + step = get_step(21, step) + + numsteps = 30 + return 0 if step >= numsteps + + x1, y1, x2, y2 = @canvas.coords('I21b') + # lx1, ly1, lx2, ly2 = @canvas.coords('I21t') + lx1, ly1, lx2, ly2 = [183, 492, 243, 504] + + f = step / numsteps.to_f + y2 = y2 - 3 + xx1 = x1 + (lx1 - x1) * f + yy1 = y1 + (ly1 - y1) * f + xx2 = x2 + (lx2 - x2) * f + yy2 = y2 + (ly2 - y2) * f + + @canvas.itemconfigure('I21b', :fill=>@C['20']) + @canvas.delete('I21w') + TkcPolygon.new(@canvas, x2, y2, x1, y1, xx1, yy1, xx2, yy1, + :tag=>['I21', 'I21w'], :outline=>'', :fill=>@C['20']) + @canvas.lower('I21w', 'I21') + @canvas.raise('I21b') + @canvas.lower('I21f') + + return((step == numsteps - 1)? 3: 1) + end + + # Bucket drop + def draw22 + # do nothing + end + + def move22(step = nil) + step = get_step(22, step) + pos = [[213, 513], [213, 523], [213, 543, :x], [213, 583], [213, 593]] + + @canvas.itemconfigure('I21f', :fill=>@C['22']) if step == 0 + return 0 if step >= pos.length + where = pos[step] + move_abs('I21', where) + h20(where[1], 40) + @canvas.delete('I21_a') # Delete handles + + return 3 if where[2] == :x + return 1 + end + + # Blow dart + def draw23 + color = @C['23a'] + color2 = @C['23b'] + color3 = @C['23c'] + + xy = [185, 623, 253, 650] # Block + TkcRectangle.new(@canvas, xy, :fill=>'black', :outline=>@C['fg'], + :width=>2, :tag=>'I23a') + xy = [187, 592, 241, 623] # Balloon + TkcOval.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b') + TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :tag=>'I23b', + :style=>:arc, :start=>12, :extent=>336) + xy = [239, 604, 258, 589, 258, 625, 239, 610] # Balloon nozzle + TkcPolygon.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b') + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23b') + + xy = [285, 611, 250, 603] # Dart body + TkcOval.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'], + :width=>3, :tag=>'I23d') + xy = [249, 596, 249, 618, 264, 607, 249, 596] # Dart tail + TkcPolygon.new(@canvas, xy, :fill=>color3, :outline=>@C['fg'], + :width=>3, :tag=>'I23d') + xy = [249, 607, 268, 607] # Dart detail + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d') + xy = [285, 607, 305, 607] # Dart needle + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d') + end + + def move23(step = nil) + step = get_step(23, step) + + pos = [ + [277, 607], [287, 607], [307, 607, :x], [347, 607], [407, 607], + [487, 607], [587, 607], [687, 607], [787, 607], [-100, -100] + ] + + return 0 if step >= pos.length + if step <= 1 + ox, oy = anchor('I23a', :n) + @canvas.scale('I23b', ox, oy, 0.9, 0.5) + end + where = pos[step] + move_abs('I23d', where) + + return 3 if where[2] == :x + return 1 + end + + # Balloon + def draw24 + color = @C['24a'] + xy = [366, 518, 462, 665] # Balloon + TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], + :width=>3, :tag=>'I24') + xy = [414, 666, 414, 729] # String + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I24') + xy = [410, 666, 404, 673, 422, 673, 418, 666] # Nozzle + TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], + :width=>3, :tag=>'I24') + + xy = [387, 567, 390, 549, 404, 542] # Reflections + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true, + :width=>2, :tag=>'I24') + xy = [395, 568, 399, 554, 413, 547] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true, + :width=>2, :tag=>'I24') + xy = [403, 570, 396, 555, 381, 553] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true, + :width=>2, :tag=>'I24') + xy = [408, 564, 402, 547, 386, 545] + TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true, + :width=>2, :tag=>'I24') + end + + def move24(step = nil) + step = get_step(24, step) + + return 0 if step > 4 + return 2 if step == 4 + + if step == 0 + @canvas.delete('I24') # Exploding balloon + xy = [ + 347, 465, 361, 557, 271, 503, 272, 503, 342, 574, 259, 594, + 259, 593, 362, 626, 320, 737, 320, 740, 398, 691, 436, 738, + 436, 739, 476, 679, 528, 701, 527, 702, 494, 627, 548, 613, + 548, 613, 480, 574, 577, 473, 577, 473, 474, 538, 445, 508, + 431, 441, 431, 440, 400, 502, 347, 465, 347, 465 + ] + TkcPolygon.new(@canvas, xy, :tag=>'I24', :fill=>@C['24b'], + :outline=>@C['24a'], :width=>10, :smooth=>true) + msg = Tk.subst(@S['message'].value) + TkcText.new(@canvas, centroid('I24'), :text=>msg, :tag=>['I24', 'I24t'], + :justify=>:center, :font=>['Times Roman', 18, :bold]) + return 1 + end + + @canvas.itemconfigure('I24t', :font=>['Times Roman', 18 + 6*step, :bold]) + @canvas.move('I24', 0, -60) + ox, oy = centroid('I24') + @canvas.scale('I24', ox, oy, 1.25, 1.25) + return 1 + end + + # Displaying the message + def move25(step = nil) + step = get_step(25, step) + + if step == 0 + @XY['25'] = Tk::Clock.clicks(:miliseconds) + return 1 + end + elapsed = Tk::Clock.clicks(:miliseconds) - @XY['25'] + return 1 if elapsed < 5000 + return 2 + end + + # Collapsing balloon + def move26(step = nil) + step = get_step(26, step) + + if step >= 3 + @canvas.delete('I24', 'I26') + TkcText.new(@canvas, 430, 735, :anchor=>:s, :tag=>'I26', + #:text=>'click to continue', + :text=>'クリックでリセットします', + :font=>['Times Roman', 20, :bold]) + @canvas.bind('1', proc{reset}) + return 4 + end + + ox, oy = centroid('I24') + @canvas.scale('I24', ox, oy, 0.8, 0.8) + @canvas.move('I24', 0, 60) + @canvas.itemconfigure('I24t', :font=>['Times Roman', 30 - 6*step, :bold]) + return 1 + end + + ################################################################ + # + # Helper functions + # + def box(x, y, r) + [x - r, y - r, x + r, y + r] + end + + def move_abs(item, xy) + x, y = xy + ox, oy = centroid(item) + dx = x - ox + dy = y - oy + @canvas.move(item, dx, dy) + end + + def rotate_item(item, ox, oy, beta) + xy = @canvas.coords(item) + xy2 = [] + 0.step(xy.length - 1, 2){|idx| + x, y = xy[idx, 2] + xy2.concat(rotate_c(x, y, ox, oy, beta)) + } + @canvas.coords(item, xy2) + end + + def rotate_c(x, y, ox, oy, beta) + # rotates vector (ox,oy)->(x,y) by beta degrees clockwise + + x -= ox # Shift to origin + y -= oy + + beta = beta * Math.atan(1) * 4 / 180.0 # Radians + xx = x * Math.cos(beta) - y * Math.sin(beta) # Rotate + yy = x * Math.sin(beta) + y * Math.cos(beta) + + xx += ox # Shift back + yy += oy + + [xx, yy] + end + + def reset + draw_all + @canvas.bind_remove('1') + @S['mode'].value = :MSTART + @S['active'] = [0] + end + + # Each Move## keeps its state info in STEP, this retrieves and increments it + def get_step(who, step) + if step + @STEP[who] = step + else + if !@STEP.exist?(who) || @STEP[who] == "" + @STEP[who] = 0 + else + @STEP[who] += 1 + end + end + @STEP[who] + end + + def reset_step + @S['cnt'].value = 0 + @STEP.keys.each{|k| @STEP[k] = ''} + end + + def sine(xy0, amp, freq, opts = {}) + x0, y0, x1, y1 = xy0 + step = 2 + xy = [] + if y0 == y1 # Horizontal + x0.step(x1, step){|x| + beta = (x - x0) * 2 * Math::PI / freq + y = y0 + amp * Math.sin(beta) + xy << x << y + } + else + y0.step(y1, step){|y| + beta = (y - y0) * 2 * Math::PI / freq + x = x0 + amp * Math.sin(beta) + xy << x << y + } + end + TkcLine.new(@canvas, xy, opts) + end + + def round_rect(xy, radius, opts={}) + x0, y0, x3, y3 = xy + r = @canvas.winfo_pixels(radius) + d = 2 * r + + # Make sure that the radius of the curve is less than 3/8 size of the box! + maxr = 0.75 + if d > maxr * (x3 - x0) + d = maxr * (x3 - x0) + end + if d > maxr * (y3 - y0) + d = maxr * (y3 - y0) + end + + x1 = x0 + d + x2 = x3 - d + y1 = y0 + d + y2 = y3 - d + + xy = [x0, y0, x1, y0, x2, y0, x3, y0, x3, y1, x3, y2] + xy.concat([x3, y3, x2, y3, x1, y3, x0, y3, x0, y2, x0, y1]) + return xy + end + + def round_poly(canv, xy, radii, opts) + lenXY = xy.length + lenR = radii.length + if lenXY != 2*lenR + raise "wrong number of vertices and radii" + end + + knots = [] + x0 = xy[-2]; y0 = xy[-1] + x1 = xy[0]; y1 = xy[1] + xy << xy[0] << xy[1] + + 0.step(lenXY - 1, 2){|i| + radius = radii[i/2] + r = canv.winfo_pixels(radius) + + x2 = xy[i+2]; y2 = xy[i+3] + z = _round_poly2(x0, y0, x1, y1, x2, y2, r) + knots.concat(z) + + x0 = x1; y0 = y1 + x1 = x2; y1 = y2 + } + TkcPolygon.new(canv, knots, {:smooth=>true}.update(opts)) + end + + def _round_poly2(x0, y0, x1, y1, x2, y2, radius) + d = 2 * radius + maxr = 0.75 + + v1x = x0 - x1 + v1y = y0 - y1 + v2x = x2 - x1 + v2y = y2 - y1 + + vlen1 = Math.sqrt(v1x*v1x + v1y*v1y) + vlen2 = Math.sqrt(v2x*v2x + v2y*v2y) + + if d > maxr * vlen1 + d = maxr * vlen1 + end + if d > maxr * vlen2 + d = maxr * vlen2 + end + + xy = [] + xy << (x1 + d * v1x / vlen1) << (y1 + d * v1y / vlen1) + xy << x1 << y1 + xy << (x1 + d * v2x / vlen2) << (y1 + d * v2y / vlen2) + + return xy + end + + def sparkle(oxy, tag) + xy = [ + [299, 283], [298, 302], [295, 314], [271, 331], + [239, 310], [242, 292], [256, 274], [281, 273] + ] + xy.each{|x, y| + TkcLine.new(@canvas, 271, 304, x, y, + :fill=>'white', :width=>3, :tag=>tag) + } + move_abs(tag, oxy) + end + + def centroid(item) + anchor(item, :c) + end + + def anchor(item, where) + x1, y1, x2, y2 = @canvas.bbox(item) + case(where) + when :n + y = y1 + when :s + y = y2 + else + y = (y1 + y2) / 2.0 + end + case(where) + when :w + x = x1 + when :e + x = x2 + else + x = (x1 + x2) / 2.0 + end + return [x, y] + end +end + +TkGoldberg_Demo.new(base_frame) diff --git a/jni/ruby/ext/tk/sample/demos-jp/hello b/jni/ruby/ext/tk/sample/demos-jp/hello new file mode 100644 index 0000000..e942f3d --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/hello @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +require 'tk' + +TkButton.new(nil, + 'text'=>"こんにちは、世界", + 'command'=>proc{print "こんにちは、世界\n"; exit} +).pack + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/hscale.rb b/jni/ruby/ext/tk/sample/demos-jp/hscale.rb new file mode 100644 index 0000000..2dfbf38 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/hscale.rb @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +require "tkcanvas" + +if defined?($hscale_demo) && $hscale_deom + $hscale_demo.destroy + $hscale_demo = nil +end + +$hscale_demo = TkToplevel.new {|w| + title("Horizontal Scale Demonstration") + iconname("hscale") +} +positionWindow($hscale_demo) + +base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true) + +msg = TkLabel.new(base_frame) { + font $font + wraplength '3.5i' + justify 'left' + text "下には矢印が1つと水平なスケールが表示されています。\ +スケール上でマウスボタン1をクリック、またはドラッグすると\ +矢印の長さを変えることができます。" +} +msg.pack('side'=>'top') + +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc { + tmppath = $hscale_demo + $hscale_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc { showCode 'hscale' } + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +def setWidth(w, width) + width = width + 21 + x2 = width - 30 + if x2 < 21 + x2 = 21 + end + w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15 + w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15 +end + +TkFrame.new(base_frame) {|frame| + canvas = TkCanvas.new(frame) {|c| + width 50 + height 50 + bd 0 + highlightthickness 0 + TkcPolygon.new(c, '0', '0', '1', '1', '2', '2') { + fill 'DeepSkyBlue' + tags 'poly' + } + TkcLine.new(c, '0', '0', '1', '1', '2', '2', '0', '0') { + fill 'black' + tags 'line' + } + }.pack('side'=>'top', 'expand'=>'yes', 'anchor'=>'s', 'fill'=>'x', 'padx'=>'15') + scale = TkScale.new(frame) { + orient 'horizontal' + length 284 + from 0 + to 250 + command proc{|value| setWidth(canvas, value)} + tickinterval 50 + }.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n') + scale.set 75 +}.pack('side'=>'top', 'fill'=>'x') diff --git a/jni/ruby/ext/tk/sample/demos-jp/icon.rb b/jni/ruby/ext/tk/sample/demos-jp/icon.rb new file mode 100644 index 0000000..6b9e1a5 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/icon.rb @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# +# iconic button widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($icon_demo) && $icon_demo + $icon_demo.destroy + $icon_demo = nil +end + +# demo 用の toplevel widget を生成 +$icon_demo = TkToplevel.new {|w| + title("Iconic Button Demonstration") + iconname("icon") + positionWindow(w) +} + +base_frame = TkFrame.new($icon_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text "このウィンドウにはラジオボタンとチェックボタン上にビットマップや画像を表示する 3 つの方法を示しています。左にあるのは2つのラジオボタンで、それぞれが、ビットマップと選択を示すインジケータでできています。中央にあるのは、選択済みかどうかによって異なる画像を表示するチェックボタンです。右側にあるのは選択済みかどうかによって背景色が変わるビットマップを表示するチェックボタンです。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $icon_demo + $icon_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'icon'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# image 生成 +flagup = \ +TkBitmapImage.new('file'=>[$demo_dir,'..', + 'images','flagup.xbm'].join(File::Separator), + 'maskfile'=>\ + [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) +flagdown = \ +TkBitmapImage.new('file'=>[$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator), + 'maskfile'=>\ + [$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator)) + +# 変数生成 +letters = TkVariable.new + +# frame 生成 +TkFrame.new(base_frame, 'borderwidth'=>10){|w| + TkFrame.new(w) {|f| + # TkRadioButton.new(f){ + Tk::RadioButton.new(f){ + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) + variable letters + value 'full' + }.pack('side'=>'top', 'expand'=>'yes') + + # TkRadioButton.new(f){ + Tk::RadioButton.new(f){ + bitmap '@' + [$demo_dir,'..', + 'images','noletter.xbm'].join(File::Separator) + variable letters + value 'empty' + }.pack('side'=>'top', 'expand'=>'yes') + + }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') + + # TkCheckButton.new(w) { + Tk::CheckButton.new(w) { + image flagdown + selectimage flagup + indicatoron 0 + selectcolor self['background'] + }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') + + # TkCheckButton.new(w) { + Tk::CheckButton.new(w) { + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) + indicatoron 0 + selectcolor 'SeaGreen1' + }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') + +}.pack('side'=>'top') + diff --git a/jni/ruby/ext/tk/sample/demos-jp/image1.rb b/jni/ruby/ext/tk/sample/demos-jp/image1.rb new file mode 100644 index 0000000..0c69b2a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/image1.rb @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# +# two image widgets demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($image1_demo) && $image1_demo + $image1_demo.destroy + $image1_demo = nil +end + +# demo 用の toplevel widget を生成 +$image1_demo = TkToplevel.new {|w| + title('Image Demonstration #1') + iconname("Image1") + positionWindow(w) +} + +base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "このデモでは2つのラベル上に画像をそれぞれ表示しています。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $image1_demo + $image1_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'image1'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# image 生成 +image1a = \ +TkPhotoImage.new('file'=>[$demo_dir,'..', + 'images','earth.gif'].join(File::Separator)) +image1b = \ +TkPhotoImage.new('file'=>[$demo_dir,'..', + 'images','earthris.gif'].join(File::Separator)) + +# label 生成 +#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'), +# TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken') +#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')} +[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'), + Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken') +].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/image2.rb b/jni/ruby/ext/tk/sample/demos-jp/image2.rb new file mode 100644 index 0000000..aa507c5 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/image2.rb @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# +# widget demo 'load image' (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($image2_demo) && $image2_demo + $image2_demo.destroy + $image2_demo = nil +end + +# demo 用の toplevel widget を生成 +$image2_demo = TkToplevel.new {|w| + title('Image Demonstration #2') + iconname("Image2") + positionWindow(w) +} + +base_frame = TkFrame.new($image2_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "このデモではTkの photo image を使用して画像を見ることができます。最初にエントリ内ににディレクトリ名を入れて下さい。次に下のリストボックスにこのディレクトリをロードするため、リターンを押してください。その後、画像を選択するためにリストボックスの中のファイル名をダブルクリックして下さい。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $image2_demo + $image2_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'image2'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# 変数生成 +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) + +# image 生成 +$image2a = TkPhotoImage.new + +# ファイル名入力部 +TkLabel.new(base_frame, 'text'=>'ディレクトリ:')\ +.pack('side'=>'top', 'anchor'=>'w') + +image2_e = TkEntry.new(base_frame) { + width 30 + textvariable $dirName +}.pack('side'=>'top', 'anchor'=>'w') + +TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20)\ +.pack('side'=>'top', 'anchor'=>'w') + +TkLabel.new(base_frame, 'text'=>'ファイル:')\ +.pack('side'=>'top', 'anchor'=>'w') + +TkFrame.new(base_frame){|w| + s = TkScrollbar.new(w) + l = TkListbox.new(w) { + width 20 + height 10 + yscrollcommand proc{|first,last| s.set first,last} + } + s.command(proc{|*args| l.yview(*args)}) + l.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y') + s.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y') + #l.insert(0,'earth.gif', 'earthris.gif', 'mickey.gif', 'teapot.ppm') + l.insert(0,'earth.gif', 'earthris.gif', 'teapot.ppm') + l.bind('Double-1', proc{|x,y| loadImage $image2a,l,x,y}, '%x %y') + + image2_e.bind 'Return', proc{loadDir l} + +}.pack('side'=>'top', 'anchor'=>'w') + +# image 配置 +[ TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20), + TkLabel.new(base_frame, 'text'=>'画像:'), + # TkLabel.new(base_frame, 'image'=>$image2a) + Tk::Label.new(base_frame, 'image'=>$image2a) +].each{|w| w.pack('side'=>'top', 'anchor'=>'w')} + +# メソッド定義 +def loadDir(w) + w.delete(0,'end') + Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f| + w.insert('end',File.basename(f)) + } +end + +def loadImage(img,w,x,y) + img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator)) +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/image3.rb b/jni/ruby/ext/tk/sample/demos-jp/image3.rb new file mode 100644 index 0000000..5c1ceb2 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/image3.rb @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- +# image3.rb +# +# This demonstration script creates a simple collection of widgets +# that allow you to select and view images in a Tk label. +# +# widget demo 'load image' (called by 'widget') +# + +# toplevel widget +if defined?($image3_demo) && $image3_demo + $image3_demo.destroy + $image3_demo = nil +end + +# demo toplevel widget +$image3_demo = TkToplevel.new {|w| + title('Image Demonstration #3') + iconname("Image3") + positionWindow(w) +} + +base_frame = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true) + +# +def loadDir3(w) + w.delete(0,'end') + Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f| + w.insert('end',File.basename(f)) + } +end + +# selectAndLoadDir3 -- +# This procedure pops up a dialog to ask for a directory to load into +# the listobx and (if the user presses OK) reloads the directory +# listbox from the directory named in the demo's entry. +# +# Arguments: +# w - Name of the toplevel window of the demo. +def selectAndLoadDir3(w, lbox) + dir = Tk.chooseDirectory(:initialdir=>$dirName.value, + :parent=>w, :mustexist=>true) + if dir.length > 0 + $dirName.value = dir + loadDir3(lbox) + end +end + +def loadImage3(w,x,y) + $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator)) +end + + +# label +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "このデモではTkの photo image を使用して画像を 見ることができます。最初にエントリ内ににディレクトリ名を入れて下さい。次に下のリストボックスにこのディレクトリをロードするため、リターンを押してください。その後、画像を選択するためにリストボックスの中のファイル名をダブルクリックして下さい。" +} +msg.pack('side'=>'top') + +# frame +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $image3_demo + $image3_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'image3'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# variable +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) + +# image +begin + $image3a.delete +rescue +end +$image3a = TkPhotoImage.new + +# +image3_f = TkFrame.new(base_frame).pack(:fill=>:both, :expand=>true) + +image3_df = TkLabelFrame.new(base_frame, :text=>'ディレクトリ:') + +image3_ff = TkLabelFrame.new(base_frame, :text=>'ファイル:', + :padx=>'2m', :pady=>'2m') +image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) { + pack(:side=>:left, :fill=>:y, :expand=>true) + yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y, + :expand=>true)) + insert(0, *(%w(earth.gif earthris.gif teapot.ppm))) + bind('Double-1', proc{|x,y| loadImage3(self, x, y)}, '%x %y') +} + +image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){ + pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true) + bind('Return', proc{loadDir3(image3_lbx)}) +} + +TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"ディレクトリ選択", + :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) { + pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m') +} + +image3_if = TkLabelFrame.new(base_frame, :text=>'イメージ:') {|f| + # TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m') + Tk::Label.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m') +} + +Tk.grid(image3_df, '-', + :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f) +Tk.grid(image3_ff, image3_if, + :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f) +TkGrid.columnconfigure(image3_f, 1, :weight=>1) + diff --git a/jni/ruby/ext/tk/sample/demos-jp/items.rb b/jni/ruby/ext/tk/sample/demos-jp/items.rb new file mode 100644 index 0000000..b1d66f3 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/items.rb @@ -0,0 +1,379 @@ +# -*- coding: utf-8 -*- +# +# canvas item types widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($items_demo) && $items_demo + $items_demo.destroy + $items_demo = nil +end + +# demo 用の toplevel widget を生成 +$items_demo = TkToplevel.new {|w| + title("Canvas Item Demonstration") + iconname("Items") + positionWindow(w) +} + +base_frame = TkFrame.new($items_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text "このウィンドウにはキャンバス widget が入っており、その中にはキャンバス widget がサポートする様々なタイプのアイテムの例が入っています。次のような操作ができます。\n ボタン-1 ドラッグ:\tアイテムを動かす。\n ボタン-2 ドラッグ:\t見えている部分をずらす。\n ボタン-3 ドラッグ:\t領域を囲う。\n コントロール-F:\t領域の下のアイテムを表示する。" +}.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $items_demo + $items_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'items'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +cvs = nil +TkFrame.new(base_frame) {|cf| + # canvas 生成 + cvs = TkCanvas.new(cf) {|c| + focus + scrollregion '0c 0c 30c 24c' + width '15c' + height '10c' + relief 'sunken' + borderwidth 2 + + hs = TkScrollbar.new(cf) {|s| + orient 'horizontal' + command proc{|*args| c.xview(*args)} + c.xscrollcommand proc{|first,last| s.set first,last} + } + + vs = TkScrollbar.new(cf) {|s| + command proc{|*args| c.yview(*args)} + c.yscrollcommand proc{|first,last| s.set first,last} + } + + if $tk_version =~ /^4\.[01]/ + hs.pack('side'=>'bottom', 'fill'=>'x') + vs.pack('side'=>'right', 'fill'=>'y') + c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both') + + else + c.grid('in'=>cf, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + vs.grid('row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + hs.grid('row'=>1, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0) + + end + + } +}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes') + +# Display a 3x3 rectangular grid +TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2) +TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2) +TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2) +TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2) +TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2) + +if $tk_version =~ /^4.*/ + font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*' + font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*' +else + font1 = 'Helvetica 12' + font2 = 'Helvetica 24 bold' +end +if TkWinfo.depth($root).to_i > 1 + blue = 'DeepSkyBlue3' + red = 'red' + bisque = 'bisque3' + green = 'SeaGreen3' +else + blue = 'black' + red = 'black' + bisque = 'black' + green = 'black' +end + +# tag オブジェクトを生成 +$tag_item = TkcGroup.new(cvs) + +# Set up demos within each of the areas of the grid. +TkcText.new(cvs, '5c', '.2c', 'text'=>'ライン', 'anchor'=>'n') +TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c', + 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt', + 'join'=>'miter', 'tags'=>$tag_item ) +TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item) +TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item) +TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c', + '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c', + '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', + 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) +TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c', + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) +TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c', + 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', + 'tags'=>$tag_item ) + +TkcText.new(cvs, '15c', '.2c', + 'text'=>'曲線 (滑らかにつないだ直線)', 'anchor'=>'n') +TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c', + 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item ) +TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c', + 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item ) +TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c', + '16.5c','4.5c','13.5c','7.5c','12c','6c', + 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), + 'fill'=>red, 'tags'=>$tag_item ) + +TkcText.new(cvs, '25c', '.2c', 'text'=>'多角形', 'anchor'=>'n') +TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c', + '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c', + 'fill'=>'green', 'outline'=>'black', 'width'=>4, + 'tags'=>$tag_item ) +TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c', + '28c','1c','29c','1c','29c','4c','29c','4c', + 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item) +TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c', + '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', + '7.5c','22c','7.5c', + 'stipple'=>'@' + [$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), + 'outline'=>'black', 'tags'=>$tag_item ) + +TkcText.new(cvs, '5c', '8.2c', 'text'=>'矩形', 'anchor'=>'n') +TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c', + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) +TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c', + 'fill'=>green, 'tags'=>$tag_item ) +TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'', + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) + +TkcText.new(cvs, '15c', '8.2c', 'text'=>'楕円', 'anchor'=>'n') +TkcOval.new(cvs, '11c','9.5c','14c','12.5c', + 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item) +TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c', + 'fill'=>green, 'tags'=>$tag_item ) +TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'', + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), + 'fill'=>blue, 'tags'=>$tag_item ) + +TkcText.new(cvs, '25c', '8.2c', 'text'=>'テキスト', 'anchor'=>'n') +TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c') +TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c', + 'text'=>'短いテキスト。ワードラップ、左揃え、アンカーは北(上)。□は各テキストのアンカーポイントを示す。', 'tags'=>$tag_item ) +TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c') +TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue, + 'text'=>"いくつかの行。\nそれぞれ独立に\n行揃え。\n全て左端がアンカーされている。", 'justify'=>'center', 'tags'=>$tag_item ) +TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c') +if $tk_version =~ /^4\.[01]/ + TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, + 'stipple'=>'@' + [$demo_dir, '..', + 'images', 'grey.5'].join(File::Separator), + 'text'=>'Stippled characters', 'tags'=>$tag_item ) +else + TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, + 'stipple'=>'gray50', 'text'=>'Stippled characters', + 'tags'=>$tag_item ) +end + +TkcText.new(cvs, '5c', '16.2c', 'text'=>'弧', 'anchor'=>'n') +TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black', + 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item) +#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', +# 'outline'=>blue, 'start'=>135, 'extent'=>270, +# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator), +# 'tags'=>$tag_item) +TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', + 'outline'=>blue, 'start'=>135, 'extent'=>270, + 'outlinestipple'=>'@'+[$demo_dir, '..', + 'images','gray25.xbm'].join(File::Separator), + 'tags'=>$tag_item) +TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice', + 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, + 'tags'=>$tag_item) +TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord', + 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270, + 'tags'=>$tag_item) + +TkcText.new(cvs, '15c', '16.2c', 'text'=>'ビットマップ', 'anchor'=>'n') +#TkcBitmap.new(cvs, '13c','20c', +# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), +# 'tags'=>$tag_item) +TkcBitmap.new(cvs, '13c','20c', + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'face.xbm'].join(File::Separator), + 'tags'=>$tag_item) +#TkcBitmap.new(cvs, '17c','18.5c', +# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), +# 'tags'=>$tag_item) +TkcBitmap.new(cvs, '17c','18.5c', + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'noletter.xbm'].join(File::Separator), + 'tags'=>$tag_item) +#TkcBitmap.new(cvs, '17c','21.5c', +# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), +# 'tags'=>$tag_item) +# ↓の形式でも可能 +TkcBitmap.new(cvs, '17c','21.5c') { + bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator) + tags $tag_item +} +#TkcBitmap.new(cvs, '17c','21.5c') { +# bitmap '@' + ['images', 'letters'].join(File::Separator) +# tags $tag_item +#} + +TkcText.new(cvs, '25c', '16.2c', 'text'=>'ウィンドウ', 'anchor'=>'n') +TkButton.new(cvs) {|b| + text '押してね' + command proc{butPress cvs, red} + TkcWindow.new(cvs, '21c','18c', + 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item) +} +TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e| + insert 'end', '編集してね' + TkcWindow.new(cvs, '21c','21c', + 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item) +} +TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c', + 'width'=>'.5c', 'tickinterval'=>0 ) {|scl| + TkcWindow.new(cvs, '28.5c','17.5c', + 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item) +} +TkcText.new(cvs, '21c', '17.9c', 'text'=>'ボタン:', 'anchor'=>'sw') +TkcText.new(cvs, '21c', '20.9c', 'text'=>'エントリ:', 'anchor'=>'sw') +TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'スケール:', 'anchor'=>'s') + +# Set up event bindings for canvas: +cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs}) +cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs}) +cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y') +cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y') +cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y') +cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y') +cvs.bind('Control-f', proc{itemsUnderArea cvs}) +cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y') +cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y') +# Utility methods for highlighting the item under the pointer + +$restoreCmd = nil +def itemEnter (c) + if TkWinfo.depth(c).to_i == 1 + $restoreCmd = nil + return + end + type = c.itemtype('current') + if type == TkcWindow + $restoreCmd = nil + return + end + if type == TkcBitmap + bg = (c.itemconfiginfo('current', 'background'))[4] + $restoreCmd = proc{c.itemconfigure 'current', 'background', bg} + c.itemconfigure 'current', 'background', 'SteelBlue2' + return + end + fill = (c.itemconfiginfo('current', 'fill'))[4] + if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == [] + outline = (c.itemconfiginfo('current', 'outline'))[4] + $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline} + c.itemconfigure 'current', 'outline', 'SteelBlue2' + else + $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill} + c.itemconfigure 'current', 'fill', 'SteelBlue2' + end +end + +def itemLeave(c) + $restoreCmd.call if $restoreCmd +end + +# Utility methods for stroking out a rectangle and printing what's +# underneath the rectangle's area. + +def itemMark(c,x,y) + $areaX1 = c.canvasx(x) + $areaY1 = c.canvasy(y) + c.delete 'area' +end + +def itemStroke(c,x,y) + x = c.canvasx(x) + y = c.canvasy(y) + if $areaX1 != x && $areaY1 != y + c.delete 'area' + c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y, + '-outline', 'black') + $areaX2 = x + $areaY2 = y + end +end + +def itemsUnderArea(c) + area = c.find_withtag('area') + items = [] + c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i| + items.push(i) if i.gettags.include?($tag_item) + } + print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush + items.clear + c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i| + items.push(i) if i.gettags.include?($tag_item) + } + print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush +end + +$areaX1 = 0 +$areaY1 = 0 +$areaX2 = 0 +$areaY2 = 0 + +# Utility methods to support dragging of items. + +def itemStartDrag(c,x,y) + $lastX = c.canvasx(x) + $lastY = c.canvasy(y) +end + +def itemDrag(c,x,y) + x = c.canvasx(x) + y = c.canvasy(y) + c.move('current', x - $lastX, y - $lastY) + $lastX = x + $lastY = y +end + +# Method that's invoked when the button embedded in the canvas +# is invoked. + +def butPress(w,color) + i = TkcText.new(w, '25c', '18.1c', + 'text'=>'いてて!!', 'fill'=>color, 'anchor'=>'n') + Tk.after(500, proc{w.delete i}) +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/ixset b/jni/ruby/ext/tk/sample/demos-jp/ixset new file mode 100644 index 0000000..40a77f4 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ixset @@ -0,0 +1,333 @@ +#!/usr/bin/env ruby + +# ixset -- +# A nice interface to "xset" to change X server settings +# + +require 'tk' + +class Xsettings + # + # Button actions + # + def quit + @root.destroy + end + + def ok + writesettings + quit + end + + def cancel + readsettings + dispsettings + end + + # apply is just "writesettings" + + + # + # Read current settings + # + def readsettings + xfd = open("|xset q", 'r') + xfd.readlines.each{|line| + fields = line.chomp.strip.split(/\s+/) + case fields[0] + when "auto" + if fields[1] == 'repeat:' + @kbdrep = fields[2] + @w_kbdrep.set(@kbdrep) + @kbdcli = fields[6] + end + + when "bell" + @bellvol = fields[2] + @bellpit = fields[5] + @belldur = fields[8] + + when "acceleration:" + @mouseacc = fields[1] + @mousethr = fields[3] + + when "prefer" + if fields[2] == 'yes' + @screenbla = 'blank' + else + @screenbla = 'noblank' + end + @w_screenbla.set(@screenbla) + + when "timeout:" + @screentim = fields[1] + @screencyc = fields[3] + + end + } + + xfd.close + end + + # + # Write settings into the X server + # + def writesettings + @bellvol = @w_bellvol.get + @bellpit = @w_bellpit.get + @belldur = @w_belldur.get + + @kbdrep = @w_kbdrep.get + if @kbdrep == 'on' + @kbdcli = @w_kbdcli.get + else + @kbdcli = 'off' + end + + @mouseacc = @w_mouseacc.get + @mousethr = @w_mousethr.get + + @screentim = @w_screentim.get + @screencyc = @w_screencyc.get + @screenbla = @w_screenbla.get + + system("xset \ + b #{@bellvol} #{@bellpit} #{@belldur} \ + c #{@kbdcli} \ + r #{@kbdrep} \ + m #{@mouseacc} #{@mousethr} \ + s #{@screentim} #{@screencyc} \ + s #{@screenbla}") + end + + # + # Sends all settings to the window + # + def dispsettings + @w_bellvol.set(@bellvol) + @w_bellpit.set(@bellpit) + @w_belldur.set(@belldur) + + @w_kbdonoff.set(@w_kbdrep.get) + @w_kbdcli.set(@kbdcli) + + @w_mouseacc.set(@mouseacc) + @w_mousethr.set(@mousethr) + + @w_screenblank.set(@w_screenbla.get) + @w_screenpat.set(@w_screenbla.get) + + @w_screentim.set(@screentim) + @w_screencyc.set(@screencyc) + end + + # + # Create all windows, and pack them + # + class LabelEntry + def initialize(parent, text, length) + @frame = TkFrame.new(parent) + TkLabel.new(@frame, 'text'=>text).pack('side'=>'left','expand'=>'y') + @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') { + pack('side'=>'left','expand'=>'y') + } + end + def pack(keys) + @frame.pack(keys) + end + def get + @entry.value + end + def set(value) + @entry.delete(0,'end') + @entry.insert(0, value) + end + end + + def createwindows + win = self + + # + # Buttons + # + buttons = TkFrame.new(@root) {|f| + [ TkButton.new(f, 'command'=>proc{win.ok}, 'text'=>'Ok'), + TkButton.new(f, 'command'=>proc{win.writesettings}, 'text'=>'Apply'), + TkButton.new(f, 'command'=>proc{win.cancel}, 'text'=>'Cancel'), + TkButton.new(f, 'command'=>proc{win.quit}, 'text'=>'Quit') ].each{|b| + b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) + } + } + + # + # Bell settings + # + bell = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2) + l = TkLabel.new(bell, 'text'=>'Bell Settings') + @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200, + 'tickinterval'=>20, 'orient'=>'horizontal', + 'label'=>"Volume (%)") + + f = TkFrame.new(bell) + @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6) + @w_bellpit.pack('side'=>'left', 'padx'=>5) + @w_belldur = LabelEntry.new(f, "Duration (ms)", 6) + @w_belldur.pack('side'=>'right', 'padx'=>5) + + l.pack('side'=>'top', 'expand'=>'yes') + @w_bellvol.pack('side'=>'top', 'expand'=>'yes') + f.pack('side'=>'top', 'expand'=>'yes') + + # + # Keyboard settings + # + kbdonoff = nil + kbdcli = nil + kbd = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2) + l = TkLabel.new(kbd, 'text'=>'Keyboard Repeat Settings') + f = TkFrame.new(kbd) + @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat', + 'onvalue'=>'on', 'offvalue'=>'off', + 'variable'=>@w_kbdrep ) { + def self.set(value) + if value == 'on' + self.select + else + self.deselect + end + end + pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both') + } + @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200, + 'tickinterval'=>20, 'orient'=>'horizontal', + 'label'=>'Click Volume (%)') + @w_kbdcli.pack('side'=>'left', 'expand'=>'yes') + l.pack('side'=>'top', 'expand'=>'yes') + f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x') + + # + # Mouse settings + # + mouse = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2) + l = TkLabel.new(mouse, 'text'=>'Mouse Settings') + f = TkFrame.new(mouse) + @w_mouseacc = LabelEntry.new(f, 'Acceleration', 3) + @w_mouseacc.pack('side'=>'left') + @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3) + @w_mousethr.pack('side'=>'right') + l.pack('side'=>'top') + f.pack('side'=>'top', 'expand'=>'yes') + + # + # Screen Saver settings + # + screen = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2) + l = TkLabel.new(screen, 'text'=>'Screen-saver Settings') + f = TkFrame.new(screen) + ff1 = TkFrame.new(f) + [ @w_screenblank = TkRadioButton.new(ff1, 'text'=>'Blank', + 'relief'=>'flat', + 'variable'=>@w_screenbla, + 'value'=>'blank') { + def self.set(value) + if value == 'blank' + self.select + else + self.deselect + end + end + }, + @w_screenpat = TkRadioButton.new(ff1, 'text'=>'Pattern', + 'relief'=>'flat', + 'variable'=>@w_screenbla, + 'value'=>'noblank') { + def self.set(value) + if value != 'blank' + self.select + else + self.deselect + end + end + } + ].each {|w| w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') } + + ff2 = TkFrame.new(f) + [ @w_screentim = LabelEntry.new(ff2, 'Timeout (s)', 5), + @w_screencyc = LabelEntry.new(ff2, 'Cycle (s)', 5) ].each{|w| + w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'e') + } + + ff1.pack('side'=>'left') + ff2.pack('side'=>'left') + + l.pack('side'=>'top') + f.pack('side'=>'top', 'expand'=>'yes') + + # + # Main window + # + buttons.pack('side'=>'top', 'fill'=>'both') + bell.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes') + kbd.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes') + mouse.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes') + screen.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes') + + # + # Let the user resize our window + # + @root.minsize(10,10) + end + + def initialize + @root = TkRoot.new + + @kbdrep = 'on' + @w_kbdrep = TkVariable.new(@kbdrep) + def @w_kbdrep.get + self.value + end + def @w_kbdrep.set(val) + self.value=val + end + + @kbdcli = 0 + + @bellvol = 100 + @bellpit = 440 + @belldur = 100 + + @mouseacc = "3/1" + @mousethr = 4 + + @screenbla = "blank" + @w_screenbla = TkVariable.new(@screenbla) + def @w_screenbla.get + self.value + end + def @w_screenbla.set(val) + self.value=val + end + + @screentim = 600 + @screencyc = 600 + + # + # Listen what "xset" tells us... + # + readsettings + + # + # Create all windows + # + createwindows + + # + # Write xset parameters + # + dispsettings + end +end + +Xsettings.new + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/ixset2 b/jni/ruby/ext/tk/sample/demos-jp/ixset2 new file mode 100644 index 0000000..e11ce2a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ixset2 @@ -0,0 +1,369 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +# ixset -- +# A nice interface to "xset" to change X server settings +# + +require 'tk' + +class Xsettings + # + # Button actions + # + def quit + @root.destroy + end + + def ok + writesettings + quit + end + + def cancel + readsettings + dispsettings + @btn_APPLY.state(:disabled) + @btn_CANCEL.state(:disabled) + end + + # apply is just "writesettings" + def apply + writesettings + @btn_APPLY.state(:disabled) + @btn_CANCEL.state(:disabled) + end + + # + # Read current settings + # + def readsettings + xfd = open("|xset q", 'r') + xfd.readlines.each{|line| + fields = line.chomp.strip.split(/\s+/) + case fields[0] + when "auto" + if fields[1] == 'repeat:' + @kbdrep = fields[2] + @w_kbdrep.set(@kbdrep) + @kbdcli = fields[6] + end + + when "bell" + @bellvol = fields[2] + @bellpit = fields[5] + @belldur = fields[8] + + when "acceleration:" + @mouseacc = fields[1] + @mousethr = fields[3] + + when "prefer" + if fields[2] == 'yes' + @screenbla = 'blank' + else + @screenbla = 'noblank' + end + @w_screenbla.set(@screenbla) + + when "timeout:" + @screentim = fields[1] + @screencyc = fields[3] + + end + } + + xfd.close + end + + # + # Write settings into the X server + # + def writesettings + @bellvol = @w_bellvol.get + @bellpit = @w_bellpit.get + @belldur = @w_belldur.get + + @kbdrep = @w_kbdrep.get + if @kbdrep == 'on' + @kbdcli = @w_kbdcli.get + else + @kbdcli = 'off' + end + + @mouseacc = @w_mouseacc.get + @mousethr = @w_mousethr.get + + @screentim = @w_screentim.get + @screencyc = @w_screencyc.get + @screenbla = @w_screenbla.get + + system("xset \ + b #{@bellvol} #{@bellpit} #{@belldur} \ + c #{@kbdcli} \ + r #{@kbdrep} \ + m #{@mouseacc} #{@mousethr} \ + s #{@screentim} #{@screencyc} \ + s #{@screenbla}") + end + + # + # Sends all settings to the window + # + def dispsettings + @w_bellvol.set(@bellvol) + @w_bellpit.set(@bellpit) + @w_belldur.set(@belldur) + + @w_kbdonoff.set(@w_kbdrep.get) + @w_kbdcli.set(@kbdcli) + + @w_mouseacc.set(@mouseacc) + @w_mousethr.set(@mousethr) + + @w_screenblank.set(@w_screenbla.get) + @w_screenpat.set(@w_screenbla.get) + + @w_screentim.set(@screentim) + @w_screencyc.set(@screencyc) + end + + # + # Create all windows, and pack them + # + class LabelEntry + def initialize(parent, text, length, range=[]) + @frame = TkFrame.new(parent) + TkLabel.new(@frame, 'text'=>text).pack('side'=>'left') + if range.size > 0 + @entry = TkSpinbox.new(@frame, 'width'=>length, 'relief'=>'sunken', + 'from'=>range[0], 'to'=>range[1]) + else + @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') + end + @entry.pack('side'=>'right','expand'=>'y', 'fill'=>'x') + end + def epath + @frame + end + def pack(keys) + @frame.pack(keys) + end + def get + @entry.value + end + def set(value) + @entry.delete(0,'end') + @entry.insert(0, value) + end + end + + def createwindows + win = self + + # + # Buttons + # + btn_frame = TkFrame.new(@root) + buttons = [ + @btn_OK = TkButton.new(btn_frame, 'command'=>proc{win.ok}, + 'default'=>'active', 'text'=>'了解'), + @btn_APPLY = TkButton.new(btn_frame, 'command'=>proc{win.writesettings}, + 'default'=>'normal', 'text'=>'適用', + 'state'=>'disabled'), + @btn_CANCEL = TkButton.new(btn_frame, 'command'=>proc{win.cancel}, + 'default'=>'normal', 'text'=>'取消', + 'state'=>'disabled'), + @btn_QUIT = TkButton.new(btn_frame, 'command'=>proc{win.quit}, + 'default'=>'normal', 'text'=>'中止') + ] + buttons.each{|b| b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) } + + @root.bind('Return', proc{@btn_OK.flash; @btn_OK.invoke}) + @root.bind('Escape', proc{@btn_QUIT.flash; @btn_QUIT.invoke}) + @root.bind('1', proc{|w| + unless buttons.index(w) + @btn_APPLY.state(:normal) + @btn_CANCEL.state(:normal) + end + }, '%W') + @root.bind('Key', proc{|w, k| + unless buttons.index(w) + case k + when 'Return', 'Escape', 'Tab', /.*Shift.*/ + # do nothing + else + @btn_APPLY.state(:normal) + @btn_CANCEL.state(:normal) + end + end + }, '%W %K') + + # + # Bell settings + # + bell = TkLabelframe.new(@root, 'text'=>'ベル設定', + 'padx'=>'1.5m', 'pady'=>'1.5m') + @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200, + 'tickinterval'=>20, 'orient'=>'horizontal', + 'label'=>"音量 (%)") + + f = TkFrame.new(bell) + @w_bellpit = LabelEntry.new(f, "音程 (Hz)", 6, [25, 20000]) + @w_bellpit.pack('side'=>'left', 'padx'=>5) + @w_belldur = LabelEntry.new(f, "持続時間 (ms)", 6, [1, 10000]) + @w_belldur.pack('side'=>'right', 'padx'=>5) + + @w_bellvol.pack('side'=>'top', 'expand'=>'yes') + f.pack('side'=>'top', 'expand'=>'yes') + + # + # Keyboard settings + # + kbdonoff = nil + kbdcli = nil + kbd = TkLabelframe.new(@root, 'text'=>'キーボードリピート設定', + 'padx'=>'1.5m', 'pady'=>'1.5m') + f = TkFrame.new(kbd) + @w_kbdonoff = TkCheckButton.new(f, 'text'=>'クリック音あり', + 'relief'=>'flat', + 'onvalue'=>'on', 'offvalue'=>'off', + 'variable'=>@w_kbdrep ) { + def self.set(value) + if value == 'on' + self.select + else + self.deselect + end + end + pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x', 'padx'=>[0, '1m']) + } + @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200, + 'tickinterval'=>20, 'orient'=>'horizontal', + 'label'=>'クリック音量 (%)') + @w_kbdcli.pack('side'=>'left', 'expand'=>'yes', + 'fill'=>'x', 'padx'=>['1m', 0]) + f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x') + + # + # Mouse settings + # + mouse = TkLabelframe.new(@root, 'text'=>'マウス設定', + 'padx'=>'1.5m', 'pady'=>'1.5m') + f = TkFrame.new(mouse) + @w_mouseacc = LabelEntry.new(f, '加速量', 5) + @w_mouseacc.pack('side'=>'left', 'padx'=>[0, '1m']) + @w_mousethr = LabelEntry.new(f, '閾値 (pixels)', 3, [1, 2000]) + @w_mousethr.pack('side'=>'right', 'padx'=>['1m', 0]) + f.pack('side'=>'top', 'expand'=>'yes') + + # + # Screen Saver settings + # + screen = TkLabelframe.new(@root, 'text'=>'スクリーンセーバ設定', + 'padx'=>'1.5m', 'pady'=>'1.5m') + @w_screenblank = TkRadioButton.new(screen, 'text'=>'ブランク表示', + 'relief'=>'flat', 'anchor'=>'w', + 'variable'=>@w_screenbla, + 'value'=>'blank') { + def self.set(value) + if value == 'blank' + self.select + else + self.deselect + end + end + } + + @w_screenpat = TkRadioButton.new(screen, 'text'=>'パターン表示', + 'relief'=>'flat', 'anchor'=>'w', + 'variable'=>@w_screenbla, + 'value'=>'noblank') { + def self.set(value) + if value != 'blank' + self.select + else + self.deselect + end + end + } + + @w_screentim = LabelEntry.new(screen, 'タイムアウト (s)', 5, [1, 100000]) + @w_screencyc = LabelEntry.new(screen, '周期 (s)', 5, [1, 100000]) + + Tk.grid(@w_screenblank, @w_screentim, 'sticky'=>'e') + Tk.grid(@w_screenpat, @w_screencyc, 'sticky'=>'e') + TkGrid.configure(@w_screenblank, @w_screenpat, 'sticky'=>'ew') + + # + # Main window + # + param = { + 'side'=>'top', 'fill'=>'both', 'expand'=>'yes', + 'padx'=>'1m', 'pady'=>'1m' + } + btn_frame.pack('side'=>'top', 'fill'=>'both') + bell.pack(param) + kbd.pack(param) + mouse.pack(param) + screen.pack(param) + + # + # Let the user resize our window + # + @root.minsize(10,10) + end + + def initialize(title) + @root = TkRoot.new('title'=>title) + + @kbdrep = 'on' + @w_kbdrep = TkVariable.new(@kbdrep) + def @w_kbdrep.get + self.value + end + def @w_kbdrep.set(val) + self.value=val + end + + @kbdcli = 0 + + @bellvol = 100 + @bellpit = 440 + @belldur = 100 + + @mouseacc = "3/1" + @mousethr = 4 + + @screenbla = "blank" + @w_screenbla = TkVariable.new(@screenbla) + def @w_screenbla.get + self.value + end + def @w_screenbla.set(val) + self.value=val + end + + @screentim = 600 + @screencyc = 600 + + # + # Listen what "xset" tells us... + # + readsettings + + # + # Create all windows + # + createwindows + + # + # Write xset parameters + # + dispsettings + end +end + +Xsettings.new(File.basename($0,'.rb')) + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb b/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb new file mode 100644 index 0000000..835a24c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb @@ -0,0 +1,273 @@ +# -*- coding: utf-8 -*- +# +# Based on the widget demo of Tcl/Tk8.5.2 +# The following is the original copyright text. +#---------------------------------------------------------------------------- +# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net> +# +# Calculate a Knight's tour of a chessboard. +# +# This uses Warnsdorff's rule to calculate the next square each +# time. This specifies that the next square should be the one that +# has the least number of available moves. +# +# Using this rule it is possible to get to a position where +# there are no squares available to move into. In this implementation +# this occurs when the starting square is d6. +# +# To solve this fault an enhancement to the rule is that if we +# have a choice of squares with an equal score, we should choose +# the one nearest the edge of the board. +# +# If the call to the Edgemost function is commented out you can see +# this occur. +# +# You can drag the knight to a specific square to start if you wish. +# If you let it repeat then it will choose random start positions +# for each new tour. +#---------------------------------------------------------------------------- +require 'tk' + +class Knights_Tour + # Return a list of accessible squares from a given square + def valid_moves(square) + moves = [] + [ + [-1,-2], [-2,-1], [-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2] + ].each{|col_delta, row_delta| + col = (square % 8) + col_delta + row = (square.div(8)) + row_delta + moves << (row * 8 + col) if row > -1 && row < 8 && col > -1 && col < 8 + } + moves + end + + # Return the number of available moves for this square + def check_square(square) + valid_moves(square).find_all{|pos| ! @visited.include?(pos)}.length + end + + # Select the next square to move to. Returns -1 if there are no available + # squares remaining that we can move to. + def next_square(square) + minimum = 9 + nxt = -1 + valid_moves(square).each{|pos| + unless @visited.include?(pos) + cnt = check_square(pos) + if cnt < minimum + minimum = cnt + nxt = pos + elsif cnt == minimum + nxt = edgemost(nxt, pos) + end + end + } + nxt + end + + # Select the square nearest the edge of the board + def edgemost(nxt, pos) + col_A = 3 - ((3.5 - nxt % 8).abs.to_i) + col_B = 3 - ((3.5 - pos % 8).abs.to_i) + row_A = 3 - ((3.5 - nxt.div(8)).abs.to_i) + row_B = 3 - ((3.5 - pos.div(8)).abs.to_i) + (col_A * row_A < col_B * row_B)? nxt : pos + end + + # Display a square number as a standard chess square notation. + def _N(square) + '%c%d' % [(97 + square % 8), (square.div(8) + 1)] + end + + # Perform a Knight's move and schedule the next move. + def move_piece(last, square) + @log.insert(:end, "#{@visited.length}. #{_N last} -> #{_N square}\n", '') + @log.see(:end) + @board.itemconfigure(1+last, :state=>:normal, :outline=>'black') + @board.itemconfigure(1+square, :state=>:normal, :outline=>'red') + @knight.coords(@board.coords(1+square)[0..1]) + @visited << square + if (nxt = next_square(square)) != -1 + @after_id = Tk.after(@delay.numeric){move_piece(square, nxt) rescue nil} + else + @start_btn.state :normal + if @visited.length == 64 + if @initial == square + @log.insert :end, '周遊(closed tour)成功!' + else + @log.insert :end, "成功\n", {} + Tk.after(@delay.numeric * 2){tour(rand(64))} if @continuous.bool + end + else + @log.insert :end, "失敗!\n", {} + end + end + end + + # Begin a new tour of the board given a random start position + def tour(square = nil) + @visited.clear + @log.clear + @start_btn.state :disabled + 1.upto(64){|n| + @board.itemconfigure(n, :state=>:disabled, :outline=>'black') + } + unless square + square = @board.find_closest(*(@knight.coords << 0 << 65))[0].to_i - 1 + end + @initial = square + Tk.after_idle{ move_piece(@initial, @initial) rescue nil } + end + + def _stop + Tk.after_cancel(@after_id) rescue nil + end + + def _exit + _stop + $knightstour.destroy + end + + def set_delay(new) + @delay.numeric = new.to_i + end + + def drag_start(w, x, y) + w.dtag('selected') + w.addtag('selected', :withtag, 'current') + @dragging = [x, y] + end + + def drag_motion(w, x, y) + return unless @dragging + w.move('selected', x - @dragging[0], y - @dragging[1]) + @dragging = [x, y] + end + + def drag_end(w, x, y) + square = w.find_closest(x, y, 0, 65) + w.coords('selected', w.coords(square)[0..1]) + w.dtag('selected') + @dragging = nil + end + + def make_SeeDismiss + ## See Code / Dismiss + frame = Ttk::Frame.new($knightstour) + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'knightstour'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $knightstour.destroy + $knightstour = nil + }), + :padx=>4, :pady=>4) + frame.grid_columnconfigure(0, :weight=>1) + frame + end + + def create_gui(parent = nil) + $knightstour.destroy rescue nil + $knightstour = Tk::Toplevel.new(parent, :title=>"Knight's tour") + $knightstour.withdraw + base_f = Ttk::Frame.new($knightstour) + @board = Tk::Canvas.new(base_f, :width=>240, :height=>240) + @log = Tk::Text.new(base_f, :width=>12, :height=>1, + :font=>'Arial 8', :background=>'white') + scr = @log.yscrollbar(Ttk::Scrollbar.new(base_f)) + + @visited = [] + @delay = TkVariable.new(600) + @continuous = TkVariable.new(false) + + tool_f = Ttk::Frame.new($knightstour) + label = Ttk::Label.new(tool_f, :text=>'実行速度') + scale = Ttk::Scale.new(tool_f, :from=>8, :to=>2000, :variable=>@delay, + :command=>proc{|n| set_delay(n)}) + check = Ttk::Checkbutton.new(tool_f, :text=>'反復', + :variable=>@continuous) + @start_btn = Ttk::Button.new(tool_f, :text=>'開始', + :command=>proc{tour()}) + @exit_btn = Ttk::Button.new(tool_f, :text=>'終了', + :command=>proc{_exit()}) + + 7.downto(0){|row| + 0.upto(7){|col| + if ((col & 1) ^ (row & 1)).zero? + fill = 'bisque' + dfill = 'bisque3' + else + fill = 'tan3' + dfill = 'tan4' + end + coords = [col * 30 + 4, row * 30 + 4, col * 30 + 30, row * 30 + 30] + @board.create(TkcRectangle, coords, + :fill=>fill, :disabledfill=>dfill, + :width=>2, :state=>:disabled) + } + } + + @knight_font = TkFont.new(:size=>-24) + @knight = TkcText.new(@board, 0, 0, :font=>@knight_font, + :text=>Tk::UTF8_String.new('\u265e'), + :anchor=>'nw', # :tags=>'knight', + :fill=>'black', :activefill=>'#600000') + @knight.coords(@board.coords(rand(64)+1)[0..1]) + @knight.bind('ButtonPress-1', '%W %x %y'){|w,x,y| drag_start(w,x,y)} + @knight.bind('Motion', '%W %x %y'){|w,x,y| drag_motion(w,x,y)} + @knight.bind('ButtonRelease-1', '%W %x %y'){|w,x,y| drag_end(w,x,y)} + + Tk.grid(@board, @log, scr, :sticky=>'news') + base_f.grid_rowconfigure(0, :weight=>1) + base_f.grid_columnconfigure(0, :weight=>1) + + Tk.grid(base_f, '-', '-', '-', '-', '-', :sticky=>'news') + widgets = [label, scale, check, @start_btn] + sg = nil + unless $RubyTk_WidgetDemo + widgets << @exit_btn + if Tk.windowingsystem != 'aqua' + #widgets.unshift(Ttk::SizeGrip.new(tool_f)) + Ttk::SizeGrip.new(tool_f).pack(:side=>:right, :anchor=>'se') + end + end + Tk.pack(widgets, :side=>:right) + if Tk.windowingsystem == 'aqua' + TkPack.configure(widgets, :padx=>[4, 4], :pady=>[12, 12]) + TkPack.configure(widgets[0], :padx=>[4, 24]) + TkPack.configure(widgets[-1], :padx=>[16, 4]) + end + + Tk.grid(tool_f, '-', '-', '-', '-', '-', :sticky=>'ew') + + if $RubyTk_WidgetDemo + Tk.grid(make_SeeDismiss(), '-', '-', '-', '-', '-', :sticky=>'ew') + end + + $knightstour.grid_rowconfigure(0, :weight=>1) + $knightstour.grid_columnconfigure(0, :weight=>1) + + $knightstour.bind('Control-F2'){TkConsole.show} + $knightstour.bind('Return'){@start_btn.invoke} + $knightstour.bind('Escape'){@exit_btn.invoke} + $knightstour.bind('Destroy'){ _stop } + $knightstour.protocol('WM_DELETE_WINDOW'){ _exit } + + $knightstour.deiconify + $knightstour.tkwait_destroy + end + + def initialize(parent = nil) + create_gui(parent) + end +end + +Tk.root.withdraw unless $RubyTk_WidgetDemo +Thread.new{Tk.mainloop} if __FILE__ == $0 +Knights_Tour.new diff --git a/jni/ruby/ext/tk/sample/demos-jp/label.rb b/jni/ruby/ext/tk/sample/demos-jp/label.rb new file mode 100644 index 0000000..700e6a6 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/label.rb @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# +# label widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($label_demo) && $label_demo + $label_demo.destroy + $label_demo = nil +end + +# demo 用の toplevel widget を生成 +$label_demo = TkToplevel.new {|w| + title("Label Demonstration") + iconname("label") + positionWindow(w) +} + +base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には5つのラベルが表示されています。左側にはテキストラベルが3つあり、右側にはビットマップラベルとテキストラベルがあります。ラベルというのはあまり面白いものではありません。なぜなら眺める以外何もできないからです。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $label_demo + $label_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'label'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# label demo 用フレーム生成 +f_left = TkFrame.new(base_frame) +f_right = TkFrame.new(base_frame) +[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes', + 'padx'=>10, 'pady'=>10, 'fill'=>'both')} + +# label 生成 +[ TkLabel.new(f_left, 'text'=>'最初のラベル'), + TkLabel.new(f_left, 'text'=>'2 番目。ちょっと浮き上がらせてみました', + 'relief'=>'raised'), + TkLabel.new(f_left, 'text'=>'3 番目。沈んでいます ', 'relief'=>'sunken') +].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')} + +# TkLabel.new(f_right) { +Tk::Label.new(f_right) { + bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator)) + borderwidth 2 + relief 'sunken' +}.pack('side'=>'top') + +TkLabel.new(f_right) { text 'Tcl/Tk 所有者' }.pack('side'=>'top') diff --git a/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb b/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb new file mode 100644 index 0000000..80e106c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# +# labelframe.rb +# +# This demonstration script creates a toplevel window containing +# several labelframe widgets. +# +# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp" + + +if defined?($labelframe_demo) && $labelframe_demo + $labelframe_demo.destroy + $labelframe_demo = nil +end + +$labelframe_demo = TkToplevel.new {|w| + title("Labelframe Demonstration") + iconname("labelframe") + positionWindow(w) +} + +base_frame = TkFrame.new($labelframe_demo).pack(:fill=>:both, :expand=>true) + +# Some information +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +TkLabelFrame ウィジェットは関連する widget +群をまとめて取り扱うために用いられます。ラ +ベルは通常の文字列でも何らかのウィジェット +でもかまいません。もしあなたが使っている +Ruby にリンクされている Tk ライブラリが +labelframe ウィジェットを実装していない +場合、このデモはうまく動かないはずです。 +その場合には labelframe ウィジェットが実装 +されているようなより新しいバージョンの Tk +を組み合わせて試すようにしてください。 +EOL + +# The bottom buttons +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $labelframe_demo.destroy + $labelframe_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'labelframe' + }).pack(:side=>:left, :expand=>true) +} + +# Demo area +w = TkFrame.new(base_frame).pack(:side=>:bottom, :fill=>:both, + :expand=>true) + +# A group of radiobuttons in a labelframe +TkLabelFrame.new(w, :text=>'選択値', + :padx=>2, :pady=>2) {|f| + grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m') + + v = TkVariable.new + (1..4).each{|i| + TkRadiobutton.new(f, :text=>"This is value #{i}", + :variable=>v, :value=>i) { + pack(:side=>:top, :fill=>:x, :pady=>2) + } + } +} + + +# Using a label window to control a group of options. +$lfdummy = TkVariable.new(0) + +def lfEnableButtons(w) + TkWinfo.children(w).each{|child| + next if child.path =~ /\.cb$/ + if $lfdummy == 1 + child.state(:normal) + else + child.state(:disabled) + end + } +end + +TkLabelFrame.new(w, :pady=>2, :padx=>2){|f| + TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy, + :text=>"オプションを使用", :padx=>0) {|cb| + command proc{lfEnableButtons(f)} + f.labelwidget(cb) + } + grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m') + + %w(オプション1 オプション2 オプション3).each{|str| + TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2) + } + + lfEnableButtons(f) +} + +TkGrid.columnconfigure(w, [0,1], :weight=>1) diff --git a/jni/ruby/ext/tk/sample/demos-jp/mclist.rb b/jni/ruby/ext/tk/sample/demos-jp/mclist.rb new file mode 100644 index 0000000..67cec63 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/mclist.rb @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +# +# mclist.rb -- +# +# This demonstration script creates a toplevel window containing a Ttk +# tree widget configured as a multi-column listbox. +# +# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($mclist_demo) && $mclist_demo + $mclist_demo.destroy + $mclist_demo = nil +end + +$mclist_demo = TkToplevel.new {|w| + title("Multi-Column List") + iconname("mclist") + positionWindow(w) +} + +base_frame = TkFrame.new($mclist_demo).pack(:fill=>:both, :expand=>true) + +## Explanatory text +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', + :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6], + :text=><<EOL).pack(:fill=>:x) +Ttkとは,テーマ指定可能な新しいウィジェット集合です.\ +Ttk::Treeviewウィジェットは\ +Ttkウィジェットセットに含まれるウィジェットの一つで,\ +それが保持する木構造のデータそのものまでは表示することなく,\ +示したい情報をマルチカラムで表示させることができます. +このサンプルは,複数のカラムを持ったリストボックスを作成する簡単な例です. +各カラムのタイトル(heading)をクリックすれば,\ +そのカラムの情報に基づいてリストの並べ替えがなされるはずです.\ +また,カラムのタイトル間の区切り部分をドラッグすることで,\ +カラムの幅を変更することも可能です. +EOL + +## See Code / Dismiss +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'mclist'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $mclist_demo.destroy + $mclist_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +container = Ttk::Frame.new(base_frame) +tree = Ttk::Treeview.new(base_frame, :columns=>%w(country capital currency), + :show=>:headings) +if Tk.windowingsystem != 'aquq' + vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame)) + hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame)) +else + vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame)) + hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame)) +end + +container.pack(:fill=>:both, :expand=>true) +Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew') +Tk.grid(hsb, :in=>container, :sticky=>'nsew') +container.grid_columnconfigure(0, :weight=>1) +container.grid_rowconfigure(0, :weight=>1) + +## The data we're going to insert +data = [ + ['アルゼンチン', 'ブエノスアイレス', 'ARS'], + ['オーストラリア', 'キャンベラ', 'AUD'], + ['ブラジル', 'ブラジリア', 'BRL'], + ['カナダ', 'オタワ', 'CAD'], + ['中国', '北京', 'CNY'], + ['フランス', 'パリ', 'EUR'], + ['ドイツ', 'ベルリン', 'EUR'], + ['インド', 'ニューデリー', 'INR'], + ['イタリア', 'ローマ', 'EUR'], + ['日本', '東京', 'JPY'], + ['メキシコ', 'メキシコシティ', 'MXN'], + ['ロシア', 'モスクワ', 'RUB'], + ['南アフリカ', 'プレトリア', 'ZAR'], + ['英国', 'ロンドン', 'GBP'], + ['アメリカ', 'ワシントン D.C.', 'USD'], +] + +## Code to insert the data nicely +font = Ttk::Style.lookup(tree[:style], :font) +cols = %w(country capital currency) +cols.zip(%w(国名 首都 通貨)).each{|col, name| + tree.heading_configure(col, :text=>name, + :command=>proc{sort_by(tree, col, false)}) + tree.column_configure(col, :width=>TkFont.measure(font, name)) +} + +data.each{|country, capital, currency| + #tree.insert('', :end, :values=>[country, capital, currency]) + tree.insert(nil, :end, :values=>[country, capital, currency]) + cols.zip([country, capital, currency]).each{|col, val| + len = TkFont.measure(font, "#{val} ") + if tree.column_cget(col, :width) < len + tree.column_configure(col, :width=>len) + end + } +} + +## Code to do the sorting of the tree contents when clicked on +def sort_by(tree, col, direction) + tree.children(nil).map!{|row| [tree.get(row, col), row.id]} . + sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) . + each_with_index{|info, idx| tree.move(info[1], nil, idx)} + + tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)}) +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu.rb b/jni/ruby/ext/tk/sample/demos-jp/menu.rb new file mode 100644 index 0000000..05ea7a9 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/menu.rb @@ -0,0 +1,201 @@ +# -*- coding: utf-8 -*- +# +# menus widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($menu_demo) && $menu_demo + $menu_demo.destroy + $menu_demo = nil +end + +# demo 用の toplevel widget を生成 +$menu_demo = TkToplevel.new {|w| + title("File Selection Dialogs") + iconname("menu") + positionWindow(w) +} + +base_frame = TkFrame.new($menu_demo).pack(:fill=>:both, :expand=>true) + +# menu frame 生成 +$menu_frame = TkFrame.new(base_frame, 'relief'=>'raised', 'bd'=>2) +$menu_frame.pack('side'=>'top', 'fill'=>'x') + +begin + windowingsystem = Tk.windowingsystem() +rescue + windowingsystem = "" +end + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { + if $tk_platform['platform'] == 'macintosh' || + windowingsystem == "classic" || windowingsystem == "aqua" + text("このウィンドウは様々なメニューとカスケードメニューから構成されています。Command-X を入力すると、Xがコマンドキー記号に続いて表示されている文字ならば、アクセラレータを使った項目起動を行うことができます。メニュー要素中、最後のものは、そのメニューの最初の項目を選択することで独立させることができます。") + else + text("このウィンドウは様々なメニューとカスケードメニューから構成されています。Alt-X を入力すると、Xがメニューにアンダーライン付きで表示されている文字ならば、キーボードからの指定ができます。矢印キーでメニューのトラバースも可能です。メニューが指定された際には、スペースキーで実行することができます。あるいは、アンダーライン付きの文字を入力することでも実行できます。メニューのエントリがアクセラレータを持っている場合は、そのアクセラレータを入力することでメニューを指定することなしに実行することができます。メニュー要素中、最後のものは、そのメニューの最初の項目を選択することで独立させることができます。") + end +}.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $menu_demo + $menu_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'menu'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# menu 生成 +TkMenubutton.new($menu_frame, 'text'=>'File', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m, 'tearoff'=>false) {|file_menu| + m.configure('menu'=>file_menu) + add('command', 'label'=>'開く ...', 'command'=>proc{fail 'これは、デモですので"開く ..."に対するアクションは定義されていません。'}) + add('command', 'label'=>'新規', 'command'=>proc{fail 'これは、デモですので"新規"に対するアクションは定義されていません。'}) + add('command', 'label'=>'保存', 'command'=>proc{fail 'これは、デモですので"保存"に対するアクションは定義されていません。'}) + add('command', 'label'=>'保存(指定) ...', 'command'=>proc{fail 'これは、デモですので"保存(指定) ..."に対するアクションは定義されていません。'}) + add('separator') + add('command', 'label'=>'プリント設定 ...', 'command'=>proc{fail 'これは、デモですので"プリント設定 ..."に対するアクションは定義されていません。'}) + add('command', 'label'=>'プリント ...', 'command'=>proc{fail 'これは、デモですので"プリント ..."に対するアクションは定義されていません。'}) + add('separator') + add('command', 'label'=>'終了', 'command'=>proc{$menu_demo.destroy}) + } +} + +if $tk_platform['platform'] == 'macintosh' || + windowingsystem == "classic" || windowingsystem == "aqua" + modifier = 'Command' +elsif $tk_platform['platform'] == 'windows' + modifier = 'Control' +else + modifier = 'Meta' +end + +TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m, 'tearoff'=>false) {|basic_menu| + m.configure('menu'=>basic_menu) + add('command', 'label'=>'何もしない長いエントリ') + ['A','B','C','D','E','F','G'].each{|c| + # add('command', 'label'=>"文字 \"#{c}\" を印字", 'underline'=>4, + add('command', 'label'=>"Print letter \"#{c}\" (文字 \"#{c}\" を印字)", + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) + } + } +} + +TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m, 'tearoff'=>false) {|cascade_menu| + m.configure('menu'=>cascade_menu) + add('command', 'label'=>'Print hello(こんにちは)', + 'command'=>proc{print "Hello(こんにちは)\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) + $menu_demo.bind("#{modifier}-h", proc{print "Hello(こんにちは)\n"}) + add('command', 'label'=>'Print goodbye(さようなら)', + 'command'=>proc{print "Goodbye(さようなら)\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) + $menu_demo.bind("#{modifier}-g", proc{print "Goodbye(さようなら)\n"}) + + # TkMenu.new(m, 'tearoff'=>false) {|cascade_check| + TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_check| + cascade_menu.add('cascade', 'label'=>'Check buttons(チェックボタン)', + 'menu'=>cascade_check, 'underline'=>0) + oil = TkVariable.new(0) + add('check', 'label'=>'オイル点検', 'variable'=>oil) + trans = TkVariable.new(0) + add('check', 'label'=>'トランスミッション点検', 'variable'=>trans) + brakes = TkVariable.new(0) + add('check', 'label'=>'ブレーキ点検', 'variable'=>brakes) + lights = TkVariable.new(0) + add('check', 'label'=>'ライト点検', 'variable'=>lights) + add('separator') + add('command', 'label'=>'現在の値を表示', + 'command'=>proc{showVars($menu_demo, + ['オイル点検', oil], + ['トランスミッション点検', trans], + ['ブレーキ点検', brakes], + ['ライト点検', lights])} ) + invoke 1 + invoke 3 + } + + #TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| + TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_radio| + cascade_menu.add('cascade', 'label'=>'Radio buttons(ラジオボタン)', + 'menu'=>cascade_radio, 'underline'=>0) + pointSize = TkVariable.new + add('radio', 'label'=>'10 ポイント', 'variable'=>pointSize, 'value'=>10) + add('radio', 'label'=>'14 ポイント', 'variable'=>pointSize, 'value'=>14) + add('radio', 'label'=>'18 ポイント', 'variable'=>pointSize, 'value'=>18) + add('radio', 'label'=>'24 ポイント', 'variable'=>pointSize, 'value'=>24) + add('radio', 'label'=>'32 ポイント', 'variable'=>pointSize, 'value'=>32) + add('separator') + style = TkVariable.new + add('radio', 'label'=>'ローマン', 'variable'=>style, 'value'=>'roman') + add('radio', 'label'=>'ボールド', 'variable'=>style, 'value'=>'bold') + add('radio', 'label'=>'イタリック', 'variable'=>style, 'value'=>'italic') + add('separator') + add('command', 'label'=>'現在の値を表示', + 'command'=>proc{showVars($menu_demo, + ['ポイントサイズ', pointSize], + ['スタイル', style])} ) + invoke 1 + invoke 7 + } + } +} + +TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m, 'tearoff'=>false) {|icon_menu| + m.configure('menu'=>icon_menu) + add('command', + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'今あなたが選択したメニューの項目はテキストではなくビットマップを表示していました。それ以外の点では他のメニュー項目と変わりません。', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'了解')} ) + ['info', 'questhead', 'error'].each{|icon| + add('command', 'bitmap'=>icon, + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + } + } +} + +TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m, 'tearoff'=>false) {|more_menu| + m.configure('menu'=>more_menu) + [ 'エントリ','別のエントリ','何もしない','ほとんど何もしない', + '人生を意義あるものに' ].each{|i| + add('command', 'label'=>i, + 'command'=>proc{print "You invoked \"#{i}\"\n"}) + } + } +} + +TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m| + pack('side'=>'left') + TkMenu.new(m) {|colors_menu| + m.configure('menu'=>colors_menu) + ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| + add('command', 'label'=>c, 'background'=>c, + 'command'=>proc{print "You invoked \"#{c}\"\n"}) + } + } +} diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu84.rb b/jni/ruby/ext/tk/sample/demos-jp/menu84.rb new file mode 100644 index 0000000..6a57279 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/menu84.rb @@ -0,0 +1,213 @@ +# -*- coding: utf-8 -*- +# +# menus widget demo (called by 'widget') +# + +# toplevel widget +if defined?($menu84_demo) && $menu84_demo + $menu84_demo.destroy + $menu84_demo = nil +end + +# demo toplevel widget +$menu84_demo = TkToplevel.new {|w| + title("File Selection Dialogs") + iconname("menu84") + positionWindow(w) +} + +base_frame = TkFrame.new($menu84_demo).pack(:fill=>:both, :expand=>true) + +begin + windowingsystem = Tk.windowingsystem() +rescue + windowingsystem = "" +end + +# label +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { + if $tk_platform['platform'] == 'macintosh' || + windowingsystem == "classic" || windowingsystem == "aqua" + text("このウィンドウにはカスケードメニューを持つメニューバーが付けられています。Command+x ('x'はコマンドキーシンボルに続けて表示されている文字です) とタイプすることによっても項目の機能を呼び出すことができます。最後のメニューは、マウスでウィンドウの外にドラッグすることによって、独立したパレットとなるように切り放すことが可能です。") + else + text("このウィンドウにはカスケードメニューを持つメニューバーが付けられています。Alt+x ('x'はメニュー上で下線が引かれた文字です) とタイプすることによってもメニューを呼び出すことができます。矢印キーを使って、メニュー間を移動することも可能です。メニューが表示されている時には、現在位置の項目をスペースキーで選択したり、下線が引かれた文字を入力することでその項目を選択したりすることができます。もし項目にアクセラレータの指定がなされていたならば、その指定されたキー入力を行うことで、メニューを表示させることなく直接その項目の機能を呼び出せます。最後のメニューは、メニューの最初の項目を選択することによって、独立したパレットとなるように切り放すことが可能です。") + end +}.pack('side'=>'top') + + +menustatus = TkVariable.new(" ") +TkFrame.new(base_frame) {|frame| + TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken', + 'bd'=>1, 'font'=>['Helvetica', '10'], + 'anchor'=>'w').pack('side'=>'left', 'padx'=>2, + 'expand'=>true, 'fill'=>'both') + pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) +} + + +# frame +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $menu84_demo + $menu84_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'menu84'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + + +# create menu frame +$menu84_frame = TkMenu.new($menu84_demo, 'tearoff'=>false) + +# menu +TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| + $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0) + add('command', 'label'=>'Open...', 'command'=>proc{fail 'これは単なるデモですから、"Open..." 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'New', 'command'=>proc{fail 'これは単なるデモですから、"New" 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'Save', 'command'=>proc{fail 'これは単なるデモですから、"Save" 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'Save As...', 'command'=>proc{fail 'これは単なるデモですから、"Save As..." 項目の機能は特に定義されてはいません。'}) + add('separator') + add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'これは単なるデモですから、"Print Setup..." 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'Print...', 'command'=>proc{fail 'これは単なるデモですから、"Print..." 項目の機能は特に定義されてはいません。'}) + add('separator') + add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu84_demo.destroy}) +} + +if $tk_platform['platform'] == 'macintosh' || + windowingsystem = "classic" || windowingsystem = "aqua" + modifier = 'Command' +elsif $tk_platform['platform'] == 'windows' + modifier = 'Control' +else + modifier = 'Meta' +end + +TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| + $menu84_frame.add('cascade', 'label'=>'Basic', 'menu'=>m, 'underline'=>0) + add('command', 'label'=>'Long entry that does nothing') + ['A','B','C','D','E','F','G'].each{|c| + add('command', 'label'=>"Print letter \"#{c}\"", + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) + } +} + +TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| + $menu84_frame.add('cascade', 'label'=>'Cascades', 'menu'=>m, 'underline'=>0) + add('command', 'label'=>'Print hello', + 'command'=>proc{print "Hello\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) + $menu84_demo.bind("#{modifier}-h", proc{print "Hello\n"}) + add('command', 'label'=>'Print goodbye', + 'command'=>proc{print "Goodbye\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) + $menu84_demo.bind("#{modifier}-g", proc{print "Goodbye\n"}) + + TkMenu.new(m, 'tearoff'=>false) {|cascade_check| + m.add('cascade', 'label'=>'Check button', + 'menu'=>cascade_check, 'underline'=>0) + oil = TkVariable.new(0) + add('check', 'label'=>'オイル検査', 'variable'=>oil) + trans = TkVariable.new(0) + add('check', 'label'=>'トランスミッション検査', 'variable'=>trans) + brakes = TkVariable.new(0) + add('check', 'label'=>'ブレーキ検査', 'variable'=>brakes) + lights = TkVariable.new(0) + add('check', 'label'=>'ライト検査', 'variable'=>lights) + add('separator') + add('command', 'label'=>'Show current values', + 'command'=>proc{showVars($menu84_demo, + ['オイル', oil], + ['トランスミッション', trans], + ['ブレーキ', brakes], + ['ライト', lights])} ) + invoke 1 + invoke 3 + } + + TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| + m.add('cascade', 'label'=>'Radio buttons', + 'menu'=>cascade_radio, 'underline'=>0) + pointSize = TkVariable.new + add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10) + add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14) + add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18) + add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24) + add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32) + add('separator') + style = TkVariable.new + add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman') + add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold') + add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic') + add('separator') + add('command', 'label'=>'現在値の表示', + 'command'=>proc{showVars($menu84_demo, + ['pointSize', pointSize], + ['style', style])} ) + invoke 1 + invoke 7 + } +} + +TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| + $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0) + add('command', 'hidemargin'=>1, + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'あなたが選択したメニュー項目は、文字列の代わりにビットマップイメージで項目を表示したものです。それ以外の点では、ほかのメニュー項目との間で特に違いがあるわけではありません。', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'閉じる')} ) + ['info', 'questhead', 'error'].each{|icon| + add('command', 'bitmap'=>icon, 'hidemargin'=>1, + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + } + + entryconfigure(2, :columnbreak=>true) +} + +TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| + $menu84_frame.add('cascade', 'label'=>'More', 'menu'=>m, 'underline'=>0) + [ 'An entry','Another entry','Does nothing','Does almost nothing', + 'Make life meaningful' ].each{|i| + add('command', 'label'=>i, + 'command'=>proc{print "You invoked \"#{i}\"\n"}) + } + + m.entryconfigure('Does almost nothing', + 'bitmap'=>'questhead', 'compound'=>'left', + 'command'=>proc{ + TkDialog.new('title'=>'Compound Menu Entry', + 'message'=>'あなたが選択したメニュー項目は、ビットマップイメージと文字列とを同時に一つの項目に表示するようにしたものです。それ以外の点では、ほかのメニュー項目との間で特に違いがあるわけではありません。', + 'buttons'=>['了解'], 'bitmap'=>'') + }) +} + +TkMenu.new($menu84_frame) {|m| + $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0) + ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| + add('command', 'label'=>c, 'background'=>c, + 'command'=>proc{print "You invoked \"#{c}\"\n"}) + } +} + +$menu84_demo.menu($menu84_frame) + +TkMenu.bind('<MenuSelect>', proc{|w| + begin + label = w.entrycget('active', 'label') + rescue + label = " " + end + menustatus.value = label + Tk.update(true) + }, '%W') diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb b/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb new file mode 100644 index 0000000..77ecb5b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb @@ -0,0 +1,233 @@ +# -*- coding: utf-8 -*- +# +# menus widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($menu8x_demo) && $menu8x_demo + $menu8x_demo.destroy + $menu8x_demo = nil +end + +# demo 用の toplevel widget を生成 +$menu8x_demo = TkToplevel.new {|w| + title("Menu Demonstration (Tk8.x)") + iconname("menu") + positionWindow(w) +} + +base_frame = TkFrame.new($menu8x_demo).pack(:fill=>:both, :expand=>true) + +# version check +if $tk_version.to_f < 8.0 + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { + text("実行しようとしたスクリプトは Tk8.0 以上で利用できる機能を利用しているため、あなたの Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} では正常に実行できません。よってデモの実行を中止しました。ただし、下のコード参照ボタンを押すことで、実行が中止されたスクリプトのソースを参照することは可能です。") +}.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $menu8x_demo + $menu8x_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'menu8x'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +else ; # Tk8.x + +begin + windowingsystem = Tk.windowingsystem() +rescue + windowingsystem = "" +end + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { + if $tk_platform['platform'] == 'macintosh' || + windowingsystem == "classic" || windowingsystem == "aqua" + text("このウィンドウは様々なメニューとカスケードメニューから構成されています。Command-X を入力すると、Xがコマンドキー記号に続いて表示されている文字ならば、アクセラレータを使った項目起動を行うことができます。メニュー要素中、最後のものは、そのメニューの最初の項目を選択することで独立させることができます。") + else + text("このウィンドウは様々なメニューとカスケードメニューから構成されています。Alt-X を入力すると、Xがメニューにアンダーライン付きで表示されている文字ならば、キーボードからの指定ができます。矢印キーでメニューのトラバースも可能です。メニューが指定された際には、スペースキーで実行することができます。あるいは、アンダーライン付きの文字を入力することでも実行できます。メニューのエントリがアクセラレータを持っている場合は、そのアクセラレータを入力することでメニューを指定することなしに実行することができます。メニュー要素中、最後のものは、そのメニューの最初の項目を選択することで独立させることができます。") + end +}.pack('side'=>'top') + +# 状態表示の生成 +$menu8xstatus = TkVariable.new(" ") +TkFrame.new(base_frame) {|frame| + TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken', + 'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\ + .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $menu8x_demo + $menu8x_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'menu8x'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# menu 生成 +TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m| + TkMenu.new(m, 'tearoff'=>false) {|file_menu| + m.add('cascade', 'label'=>'File', 'menu'=>file_menu, 'underline'=>0) + add('command', 'label'=>'開く ...', 'command'=>proc{fail 'これは、デモですので"開く ..."に対するアクションは定義されていません。'}) + add('command', 'label'=>'新規', 'command'=>proc{fail 'これは、デモですので"新規"に対するアクションは定義されていません。'}) + add('command', 'label'=>'保存', 'command'=>proc{fail 'これは、デモですので"保存"に対するアクションは定義されていません。'}) + add('command', 'label'=>'保存(指定) ...', 'command'=>proc{fail 'これは、デモですので"保存(指定) ..."に対するアクションは定義されていません。'}) + add('separator') + add('command', 'label'=>'プリント設定 ...', 'command'=>proc{fail 'これは、デモですので"プリント設定 ..."に対するアクションは定義されていません。'}) + add('command', 'label'=>'プリント ...', 'command'=>proc{fail 'これは、デモですので"プリント ..."に対するアクションは定義されていません。'}) + add('separator') + add('command', 'label'=>'終了', 'command'=>proc{$menu8x_demo.destroy}) + } + + if $tk_platform['platform'] == 'macintosh' || + windowingsystem == "classic" || windowingsystem == "aqua" + modifier = 'Command' + elsif $tk_platform['platform'] == 'windows' + modifier = 'Control' + else + modifier = 'Meta' + end + + TkMenu.new(m, 'tearoff'=>false) {|basic_menu| + m.add('cascade', 'label'=>'Basic', 'menu'=>basic_menu, 'underline'=>0) + add('command', 'label'=>'何もしない長いエントリ') + ['A','B','C','D','E','F','G'].each{|c| + # add('command', 'label'=>"文字 \"#{c}\" を印字", 'underline'=>4, + add('command', 'label'=>"Print letter \"#{c}\" (文字 \"#{c}\" を印字)", + 'underline'=>14, 'accelerator'=>"Meta+#{c}", + 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}") + $menu8x_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"}) + } + } + + TkMenu.new(m, 'tearoff'=>false) {|cascade_menu| + m.add('cascade', 'label'=>'Cascades', 'menu'=>cascade_menu, 'underline'=>0) + add('command', 'label'=>'Print hello(こんにちは)', + 'command'=>proc{print "Hello(こんにちは)\n"}, + 'accelerator'=>"#{modifier}+H", 'underline'=>6) + $menu8x_demo.bind("#{modifier}-h", proc{print "Hello(こんにちは)\n"}) + add('command', 'label'=>'Print goodbye(さようなら)', + 'command'=>proc{print "Goodbye(さようなら)\n"}, + 'accelerator'=>"#{modifier}+G", 'underline'=>6) + $menu8x_demo.bind("#{modifier}-g", proc{print "Goodbye(さようなら)\n"}) + + TkMenu.new(m, 'tearoff'=>false) {|cascade_check| + cascade_menu.add('cascade', 'label'=>'Check buttons(チェックボタン)', + 'menu'=>cascade_check, 'underline'=>0) + oil = TkVariable.new(0) + add('check', 'label'=>'オイル点検', 'variable'=>oil) + trans = TkVariable.new(0) + add('check', 'label'=>'トランスミッション点検', 'variable'=>trans) + brakes = TkVariable.new(0) + add('check', 'label'=>'ブレーキ点検', 'variable'=>brakes) + lights = TkVariable.new(0) + add('check', 'label'=>'ライト点検', 'variable'=>lights) + add('separator') + add('command', 'label'=>'現在の値を表示', + 'command'=>proc{showVars($menu8x_demo, + ['オイル点検', oil], + ['トランスミッション点検', trans], + ['ブレーキ点検', brakes], + ['ライト点検', lights])} ) + invoke 1 + invoke 3 + } + + TkMenu.new(m, 'tearoff'=>false) {|cascade_radio| + cascade_menu.add('cascade', 'label'=>'Radio buttons(ラジオボタン)', + 'menu'=>cascade_radio, 'underline'=>0) + pointSize = TkVariable.new + add('radio', 'label'=>'10 ポイント', 'variable'=>pointSize, 'value'=>10) + add('radio', 'label'=>'14 ポイント', 'variable'=>pointSize, 'value'=>14) + add('radio', 'label'=>'18 ポイント', 'variable'=>pointSize, 'value'=>18) + add('radio', 'label'=>'24 ポイント', 'variable'=>pointSize, 'value'=>24) + add('radio', 'label'=>'32 ポイント', 'variable'=>pointSize, 'value'=>32) + add('separator') + style = TkVariable.new + add('radio', 'label'=>'ローマン', 'variable'=>style, 'value'=>'roman') + add('radio', 'label'=>'ボールド', 'variable'=>style, 'value'=>'bold') + add('radio', 'label'=>'イタリック', 'variable'=>style, 'value'=>'italic') + add('separator') + add('command', 'label'=>'現在の値を表示', + 'command'=>proc{showVars($menu8x_demo, + ['ポイントサイズ', pointSize], + ['スタイル', style])} ) + invoke 1 + invoke 7 + } + } + + TkMenu.new(m, 'tearoff'=>false) {|icon_menu| + m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0) + add('command', + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), + 'hidemargin'=>1, + 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', + 'text'=>'今あなたが選択したメニューの項目はテキストではなくビットマップを表示していました。それ以外の点では他のメニュー項目と変わりません。', + 'bitmap'=>'', 'default'=>0, + 'buttons'=>'了解')} ) + ['info', 'questhead', 'error'].each{|icon| + add('command', 'bitmap'=>icon, 'hidemargin'=>1, + 'command'=>proc{print "You invoked the #{icon} bitmap\n"}) + } + + entryconfigure(2, 'columnbreak'=>1) + } + + TkMenu.new(m, 'tearoff'=>false) {|more_menu| + m.add('cascade', 'label'=>'More', 'menu'=>more_menu, 'underline'=>0) + [ 'エントリ','別のエントリ','何もしない','ほとんど何もしない', + '人生を意義あるものに' ].each{|i| + add('command', 'label'=>i, + 'command'=>proc{print "You invoked \"#{i}\"\n"}) + } + } + + TkMenu.new(m) {|colors_menu| + m.add('cascade', 'label'=>'Colors', 'menu'=>colors_menu, 'underline'=>1) + ['red', 'orange', 'yellow', 'green', 'blue'].each{|c| + add('command', 'label'=>c, 'background'=>c, + 'command'=>proc{print "You invoked \"#{c}\"\n"}) + } + } + + $menu8x_demo.configure('menu'=>m) +} + +TkMenu.bind('<MenuSelect>', + proc{|w| + begin + label = w.entrycget('active', 'label') + rescue + label = ' ' + end + $menu8xstatus.value = label + Tk.update('idletasks') + }, '%W') + +end ; # Tk 8.x diff --git a/jni/ruby/ext/tk/sample/demos-jp/menubu.rb b/jni/ruby/ext/tk/sample/demos-jp/menubu.rb new file mode 100644 index 0000000..06f9eb8 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/menubu.rb @@ -0,0 +1,238 @@ +# -*- coding: utf-8 -*- +require "tkcanvas" + +def optionMenu(menubutton, varName, firstValue, *rest) + varName.value = firstValue + configoptions = {'textvariable'=>varName,'indicatoron'=>'on', + 'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2, + 'anchor'=>'c','direction'=>'flush'} + configoptions.each {|key, value| + menubutton.configure(key, value) + } + menu = TkMenu.new(menubutton) { + tearoff 'off' + add 'radio', 'label'=>firstValue, 'variable'=>varName + } + menubutton.menu(menu) + for i in rest + menu.add 'radio', 'label'=>i, 'variable'=>varName + end + + return menu +end + +if defined?($menubu_demo) && $menubu_demo + $menubu_demo.destroy + $menubu_demo = nil +end + +$menubu_demo = TkToplevel.new {|w| + title("Menu Button Demonstration") + iconname("menubutton") +} + +positionWindow($menubu_demo) + +base_frame = TkFrame.new($menubu_demo).pack(:fill=>:both, :expand=>true) + +# version check +if $tk_version.to_f < 8.0 + +# label 生成 +TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { + text("実行しようとしたスクリプトは Tk8.0 以上で利用できる機能を利用しているため、あなたの Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} では正常に実行できません。よってデモの実行を中止しました。ただし、下のコード参照ボタンを押すことで、実行が中止されたスクリプトのソースを参照することは可能です。") +}.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $menubu_demo + $menubu_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'menubu'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +else ; # Tk8.x + +body = TkFrame.new(base_frame) +body.pack('expand'=>'yes', 'fill'=>'both') + +below = TkMenubutton.new(body) { + text "Below" + underline 0 + direction 'below' + relief 'raised' +} +belowMenu = TkMenu.new(below) { + tearoff 0 + add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""} + add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""} +} +below.menu(belowMenu) +below.grid('row'=>0, 'column'=>1, 'sticky'=>'n') + +below = TkMenubutton.new(body) { + text "Below" + underline 0 + direction 'below' + relief 'raised' +} +belowMenu = TkMenu.new(below) { + tearoff 0 + add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""} + add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""} +} +below.menu(belowMenu) +below.grid('row'=>0, 'column'=>1, 'sticky'=>'n') + +below = TkMenubutton.new(body) { + text "Below" + underline 0 + direction 'below' + relief 'raised' +} +belowMenu = TkMenu.new(below) { + tearoff 0 + add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""} + add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""} +} +below.menu(belowMenu) +below.grid('row'=>0, 'column'=>1, 'sticky'=>'n') + +right = TkMenubutton.new(body) { + text "Right" + underline 0 + direction 'right' + relief 'raised' +} +rightMenu = TkMenu.new(right) { + tearoff 0 + add 'command', 'label'=>"Right menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""} + add 'command', 'label'=>"Right menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Right menu.\""} +} +right.menu(rightMenu) +right.grid('row'=>1, 'column'=>0, 'sticky'=>'w') + +left = TkMenubutton.new(body) { + text "Left" + underline 0 + direction 'left' + relief 'raised' +} +leftMenu = TkMenu.new(left) { + tearoff 0 + add 'command', 'label'=>"Left menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""} + add 'command', 'label'=>"Left menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Left menu.\""} +} +left.menu(leftMenu) +left.grid('row'=>1, 'column'=>2, 'sticky'=>'e') + +center = TkFrame.new(body) { + grid('row'=>1, 'column'=>1, 'sticky'=>'news') +} + +above = TkMenubutton.new(body) { + text "Above" + underline 0 + direction 'above' + relief 'raised' +} +aboveMenu = TkMenu.new(above) { + tearoff 0 + add 'command', 'label'=>"Above menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Above menu.\""} + add 'command', 'label'=>"Above menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Above menu.\""} +} +above.menu(aboveMenu) +above.grid('row'=>2, 'column'=>1, 'sticky'=>'s') + +center = TkFrame.new(body) { + grid('row'=>1, 'column'=>1, 'sticky'=>'news') +} + +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc { + tmppath = $menubu_demo + $menubu_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc { showCode 'menubu' } + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x', 'pady'=>'2m') + +msg = TkLabel.new(center) { +# font $font + wraplength '4i' + justify 'left' + text "これはメニューボタンのデモです。\"Below\"のボタンは\ +下にメニューを出し、\"Right\"のボタンは右にメニューを出して、\ +……となります。この文章の下には2つのオプションメニューがあります。\ +1つは普通のメニューで、もう1つは16色のパレットです。" +} +msg.pack('side'=>'top', 'padx'=>25, 'pady'=>25) + +TkFrame.new(center) {|f| + menubuttonoptions = TkVariable.new + mbutton = TkMenubutton.new(f) + options = optionMenu(mbutton, menubuttonoptions, + 'one', 'two', 'three') + mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25) + paletteColor = TkVariable.new + colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75', + 'Red','Green','Blue','gray50','Yellow','Cyan','Magenta', + 'White','Brown','DarkSeaGreen','DarkViolet'] + colorMenuButton = TkMenubutton.new(f) + m = optionMenu(colorMenuButton, paletteColor, *colors) + begin + windowingsystem = Tk.windowingsystem() + rescue + windowingsystem = "" + end + if windowingsystem == "classic" || windowingsystem == "aqua" + topBorderColor = 'Black' + bottomBorderColor = 'Black' + else + topBorderColor = 'gray50' + bottomBorderColor = 'gray75' + end + for i in 0..15 + image = TkPhotoImage.new('height'=>16, 'width'=>16) + image.put(topBorderColor, 0, 0, 16, 1) + image.put(topBorderColor, 0, 1, 1, 16) + image.put(bottomBorderColor, 0, 15, 16, 16) + image.put(bottomBorderColor, 15, 1, 16, 16) + image.put(colors[i], 1, 1, 15, 15) + + selectimage = TkPhotoImage.new('height'=>16, 'width'=>16) + selectimage.put('Black', 0, 0, 16, 2) + selectimage.put('Black', 0, 2, 2, 16) + selectimage.put('Black', 2, 14, 16, 16) + selectimage.put('Black', 14, 2, 16, 14) + selectimage.put(colors[i], 2, 2, 14, 14) + + m.entryconfigure(i, 'image'=>image, 'selectimage'=>selectimage, 'hidemargin'=>'on') + end + m.configure('tearoff', 'on') + for c in ['Black', 'gray75', 'gray50', 'White'] + m.entryconfigure(c, 'columnbreak'=>1) + end + colorMenuButton.pack('side'=>'left', 'padx'=>25, 'pady'=>25) + pack 'padx'=>25, 'pady'=>25 +} + +end ; # Tk8.x diff --git a/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb b/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb new file mode 100644 index 0000000..ec7b4f2 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +# +# message boxes widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($msgbox_demo) && $msgbox_demo + $msgbox_demo.destroy + $msgbox_demo = nil +end + +# demo 用の toplevel widget を生成 +$msgbox_demo = TkToplevel.new {|w| + title("Message Box Demonstration") + iconname("messagebox") + positionWindow(w) +} + +base_frame = TkFrame.new($msgbox_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', + 'text'=>"まず表示するアイコンとメッセージボックスの種類を選んで下さい。その後に\"メッセージボックス\"ボタンを押すと、指定したメッセージボックスが表示されます。").pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $msgbox_demo + $msgbox_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'msgbox'} + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'メッセージボックス' + command proc{showMessageBox $msgbox_demo} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +$msgbox_leftframe = TkFrame.new(base_frame) +$msgbox_rightframe = TkFrame.new(base_frame) +$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', + 'pady'=>'.5c', 'padx'=>'.5c') +$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', + 'pady'=>'.5c', 'padx'=>'.5c') + +TkLabel.new($msgbox_leftframe, 'text'=>'アイコン').pack('side'=>'top') +TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ +.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no') + +$msgboxIcon = TkVariable.new('info') +['error', 'info', 'question', 'warning'].each {|icon| + TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon, + 'relief'=>'flat', 'value'=>icon, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') +} + +TkLabel.new($msgbox_rightframe, 'text'=>'種類').pack('side'=>'top') +TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ +.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no') + +$msgboxType = TkVariable.new('ok') +['abortretryignore', 'ok', 'okcancel', + 'retrycancel', 'yesno', 'yesnocancel'].each {|type| + TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType, + 'relief'=>'flat', 'value'=>type, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') +} + +def showMessageBox(w) + button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value, + 'title'=>'Message', 'parent'=>w, + 'message'=>"これは\"#{$msgboxType.value}\"という種類のメッセージボックスで、\"#{$msgboxIcon.value}\"のアイコンが表示されています。") + + Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w, + 'message'=>"あなたは \"#{button}\" を押しましたね。") +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb b/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb new file mode 100644 index 0000000..ad6d936 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# +# message boxes widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($msgbox2_demo) && $msgbox2_demo + $msgbox2_demo.destroy + $msgbox2_demo = nil +end + +# demo 用の toplevel widget を生成 +$msgbox2_demo = TkToplevel.new {|w| + title("Message Box Demonstration") + iconname("messagebox") + positionWindow(w) +} + +base_frame = TkFrame.new($msgbox2_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', + 'text'=>"まず表示するアイコンとメッセージボックスの種類を選んで下さい。その後に\"メッセージボックス\"ボタンを押すと、指定された形式で、メッセージと詳細テキストとを持ったメッセージボックスが表示されます。").pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $msgbox2_demo + $msgbox2_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'msgbox2'} + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'メッセージボックス' + command proc{showMessageBox2 $msgbox2_demo} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +$msgbox_leftframe = TkFrame.new(base_frame) +$msgbox_rightframe = TkFrame.new(base_frame) +$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', + 'pady'=>'.5c', 'padx'=>'.5c') +$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y', + 'pady'=>'.5c', 'padx'=>'.5c') + +TkLabel.new($msgbox_leftframe, 'text'=>'アイコン').pack('side'=>'top') +TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ +.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no') + +$msgboxIcon = TkVariable.new('info') +['error', 'info', 'question', 'warning'].each {|icon| + TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon, + 'relief'=>'flat', 'value'=>icon, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') +} + +TkLabel.new($msgbox_rightframe, 'text'=>'種類').pack('side'=>'top') +TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\ +.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no') + +$msgboxType = TkVariable.new('ok') +['abortretryignore', 'ok', 'okcancel', + 'retrycancel', 'yesno', 'yesnocancel'].each {|type| + TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType, + 'relief'=>'flat', 'value'=>type, 'width'=>16, + 'anchor'=>'w').pack('side'=>'top', 'pady'=>2, + 'anchor'=>'w', 'fill'=>'x') +} + +def showMessageBox2(w) + button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value, + 'title'=>'Message', 'parent'=>w, + 'message'=>"\"#{$msgboxType.value}\"タイプのメッセージボックス", + 'detail'=>"これは\"#{$msgboxType.value}\"という種類のメッセージボックスで、\"#{$msgboxIcon.value}\"のアイコンが表示されています。下のボタンのいずれかを選択してクリックしてください。") + + Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w, + 'message'=>"あなたは \"#{button}\" を押しましたね。") +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/paned1.rb b/jni/ruby/ext/tk/sample/demos-jp/paned1.rb new file mode 100644 index 0000000..53d2e71 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/paned1.rb @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# paned1.rb +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows horizontally. +# +# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp" + +if defined?($paned1_demo) && $paned1_demo + $paned1_demo.destroy + $paned1_demo = nil +end + +$paned1_demo = TkToplevel.new {|w| + title("Horizontal Paned Window Demonstration") + iconname("paned1") + positionWindow(w) +} + +base_frame = TkFrame.new($paned1_demo).pack(:fill=>:both, :expand=>true) + +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +下の色付けされた二つのウィンドウの間の仕切り枠は、一つの領域をそれぞれのウィンドウのために分割するためのものです。左ボタンで仕切りを操作すると、分割サイズ変更の操作途中では再表示はなされず、確定させたときに表示が更新されます。マウスによる仕切りの操作に追随してサイズを変更した表示がなわれるようにしたい場合は、マウスの中央ボタンを使ってください。 +もしあなたが使っている Ruby にリンクされている Tk ライブラリが panedwindow を実装していない +場合、このデモはうまく動かないはずです。その場合には panedwindow が実装されているような +より新しいバージョンの Tk を組み合わせて試す +ようにしてください。 +EOL + +# The bottom buttons +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $paned1_demo.destroy + $paned1_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'paned1' + }).pack(:side=>:left, :expand=>true) +} + +TkPanedwindow.new(base_frame, :orient=>:horizontal){|f| + add(Tk::Label.new(f, :text=>"This is the\nleft side", :bg=>'yellow'), + Tk::Label.new(f, :text=>"This is the\nright side", :bg=>'cyan')) + + pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m') +} diff --git a/jni/ruby/ext/tk/sample/demos-jp/paned2.rb b/jni/ruby/ext/tk/sample/demos-jp/paned2.rb new file mode 100644 index 0000000..65bd41c --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/paned2.rb @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +# +# paned2.rb -- +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows vertically. +# +# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp" + +if defined?($paned2_demo) && $paned2_demo + $paned2_demo.destroy + $paned2_demo = nil +end + +$paned2_demo = TkToplevel.new {|w| + title("Vertical Paned Window Demonstration") + iconname("paned2") + positionWindow(w) +} + +base_frame = TkFrame.new($paned2_demo).pack(:fill=>:both, :expand=>true) + +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +下のスクロールバー付きのウィジェットが置かれた二つのウィンドウの間の仕切り枠は、一つの領域をそれぞれのウィンドウのために分割するためのものです。左ボタンで仕切りを操作すると、分割サイズ変更の操作途中では再表示はなされず、確定させたときに表示が更新されます。マウスによる仕切りの操作に追随してサイズを変更した表示がなわれるようにしたい場合は、マウスの中央ボタンを使ってください。 +もしあなたが使っている Ruby にリンクされている Tk ライブラリが panedwindow を実装していない +場合、このデモはうまく動かないはずです。その場合には panedwindow が実装されているような +より新しいバージョンの Tk を組み合わせて試す +ようにしてください。 +EOL + +# The bottom buttons +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $paned2_demo.destroy + $paned2_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'paned2' + }).pack(:side=>:left, :expand=>true) +} + +paneList = TkVariable.new # define as normal variable (not array) +paneList.value = [ # ruby's array --> tcl's list + 'Ruby/Tk のウィジェット一覧', + 'TkButton', + 'TkCanvas', + 'TkCheckbutton', + 'TkEntry', + 'TkFrame', + 'TkLabel', + 'TkLabelframe', + 'TkListbox', + 'TkMenu', + 'TkMenubutton', + 'TkMessage', + 'TkPanedwindow', + 'TkRadiobutton', + 'TkScale', + 'TkScrollbar', + 'TkSpinbox', + 'TkText', + 'TkToplevel' +] + +# Create the pane itself +TkPanedwindow.new(base_frame, :orient=>:vertical){|f| + pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m') + + add(TkFrame.new(f){|paned2_top| + TkListbox.new(paned2_top, :listvariable=>paneList) { + # Invert the first item to highlight it + itemconfigure(0, :background=>self.cget(:foreground), + :foreground=>self.cget(:background) ) + yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right, + :fill=>:y)) + pack(:fill=>:both, :expand=>true) + } + }, + + TkFrame.new(f, :height=>120) {|paned2_bottom| + # The bottom window is a text widget with scrollbar + paned2_xscr = TkScrollbar.new(paned2_bottom) + paned2_yscr = TkScrollbar.new(paned2_bottom) + paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) { + insert('1.0', 'ここに配置されているのは、' + + 'ごく普通のテキストウィジェットです。') + xscrollbar(paned2_xscr) + yscrollbar(paned2_yscr) + } + Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew') + Tk.grid(paned2_xscr, :sticky=>'nsew') + TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1) + TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1) + } ) +} diff --git a/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb b/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb new file mode 100644 index 0000000..60556fd --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# +# This demonstration illustrates how Tcl/Tk can be used to construct +# simulations of physical systems. +# (called by 'widget') +# +# based on Tcl/Tk8.5a2 widget demos + +# destroy toplevel widget for this demo script +if defined?($pendulum_demo) && $pendulum_demo + $pendulum_demo.destroy + $pendulum_demo = nil +end + +# create toplevel widget +$pendulum_demo = TkToplevel.new {|w| + title("Pendulum Animation Demonstration") + iconname("pendulum") + positionWindow(w) +} + +base_frame = TkFrame.new($pendulum_demo).pack(:fill=>:both, :expand=>true) + +# create label +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text 'このデモは、物理系のシミュレーションに関わるようなアニメーション実行するために Ruby/Tk をどのように用いることができるかを示しています。左側のキャンバスは単純な振り子である物理系自体のグラフィカル表現であるのに対し、右側のキャンバスは系の位相空間のグラフ(角速度と角度とをプロットしたもの)になっています。左側のキャンバス上でクリックおよびドラッグを行って振り子の重りの位置を変えてみてください。' +} +msg.pack('side'=>'top') + +# create frame +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $pendulum_demo + $pendulum_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'pendulum'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# animated wave +class PendulumAnimationDemo + def initialize(frame) + # Create some structural widgets + @pane = TkPanedWindow.new(frame, :orient=>:horizontal).pack(:fill=>:both, :expand=>true) +# @pane.add(@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation')) +# @pane.add(@lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space')) + @lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation') + @lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space') + + # Create the canvas containing the graphical representation of the + # simulated system. + @c = TkCanvas.new(@lf1, :width=>320, :height=>200, :background=>'white', + :borderwidth=>2, :relief=>:sunken) + TkcText.new(@c, 5, 5, :anchor=>:nw, + :text=>'Click to Adjust Bob Start Position') + # Coordinates of these items don't matter; they will be set properly below + @plate = TkcLine.new(@c, 0, 25, 320, 25, :width=>2, :fill=>'grey50') + @rod = TkcLine.new(@c, 1, 1, 1, 1, :width=>3, :fill=>'black') + @bob = TkcOval.new(@c, 1, 1, 2, 2, + :width=>3, :fill=>'yellow', :outline=>'black') + TkcOval.new(@c, 155, 20, 165, 30, :fill=>'grey50', :outline=>'') + + # pack + @c.pack(:fill=>:both, :expand=>true) + + # Create the canvas containing the phase space graph; this consists of + # a line that gets gradually paler as it ages, which is an extremely + # effective visual trick. + @k = TkCanvas.new(@lf2, :width=>320, :height=>200, :background=>'white', + :borderwidth=>2, :relief=>:sunken) + @y_axis = TkcLine.new(@k, 160, 200, 160, 0, :fill=>'grey75', :arrow=>:last) + @x_axis = TkcLine.new(@k, 0, 100, 320, 100, :fill=>'grey75', :arrow=>:last) + + @graph = {} + 90.step(0, -10){|i| + # Coordinates of these items don't matter; + # they will be set properly below + @graph[i] = TkcLine.new(@k, 0, 0, 1, 1, :smooth=>true, :fill=>"grey#{i}") + } + + # labels + @label_theta = TkcText.new(@k, 0, 0, :anchor=>:ne, + :text=>'q', :font=>'Symbol 8') + @label_dtheta = TkcText.new(@k, 0, 0, :anchor=>:ne, + :text=>'dq', :font=>'Symbol 8') + + # pack + @k.pack(:fill=>:both, :expand=>true) + + # Initialize some variables + @points = [] + @theta = 45.0 + @dTheta = 0.0 + @length = 150 + + # animation loop + @timer = TkTimer.new(15){ repeat } + + # binding + @c.bindtags_unshift(btag = TkBindTag.new) + btag.bind('Destroy'){ @timer.stop } + btag.bind('1', proc{|x, y| @timer.stop; showPendulum(x.to_i, y.to_i)}, + '%x %y') + btag.bind('B1-Motion', proc{|x, y| showPendulum(x.to_i, y.to_i)}, '%x %y') + btag.bind('ButtonRelease-1', + proc{|x, y| showPendulum(x.to_i, y.to_i); @timer.start }, + '%x %y') + + btag.bind('Configure', proc{|w| @plate.coords(0, 25, w.to_i, 25)}, '%w') + + @k.bind('Configure', proc{|h, w| + h = h.to_i + w = w.to_i + @psh = h/2; + @psw = w/2 + @x_axis.coords(2, @psh, w-2, @psh) + @y_axis.coords(@psw, h-2, @psw, 2) + @label_theta.coords(@psw-4, 6) + @label_dtheta.coords(w-6, @psh+4) + }, '%h %w') + + # add + Tk.update + @pane.add(@lf1) + @pane.add(@lf2) + + # init display + showPendulum + + # animation start + @timer.start(500) + end + + # This procedure makes the pendulum appear at the correct place on the + # canvas. If the additional arguments x, y are passed instead of computing + # the position of the pendulum from the length of the pendulum rod and its + # angle, the length and angle are computed in reverse from the given + # location (which is taken to be the centre of the pendulum bob.) + def showPendulum(x=nil, y=nil) + if x && y && (x != 160 || y != 25) + @dTheta = 0.0 + x2 = x - 160 + y2 = y - 25 + @length = Math.hypot(x2, y2) + @theta = Math.atan2(x2,y2)*180/Math::PI + else + angle = @theta*Math::PI/180 + x = 160 + @length*Math.sin(angle) + y = 25 + @length*Math.cos(angle) + end + + @rod.coords(160, 25, x, y) + @bob.coords(x-15, y-15, x+15, y+15) + end + + # Update the phase-space graph according to the current angle and the + # rate at which the angle is changing (the first derivative with + # respect to time.) + def showPhase + unless @psw && @psh + @psw = @k.width/2 + @psh = @k.height/2 + end + @points << @theta + @psw << -20*@dTheta + @psh + if @points.length > 100 + @points = @points[-100..-1] + end + (0...100).step(10){|i| + first = - i + last = 11 - i + last = -1 if last >= 0 + next if first > last + lst = @points[first..last] + @graph[i].coords(lst) if lst && lst.length >= 4 + } + end + + # This procedure is the "business" part of the simulation that does + # simple numerical integration of the formula for a simple rotational + # pendulum. + def recomputeAngle + scaling = 3000.0/@length/@length + + # To estimate the integration accurately, we really need to + # compute the end-point of our time-step. But to do *that*, we + # need to estimate the integration accurately! So we try this + # technique, which is inaccurate, but better than doing it in a + # single step. What we really want is bound up in the + # differential equation: + # .. - sin theta + # theta + theta = ----------- + # length + # But my math skills are not good enough to solve this! + + # first estimate + firstDDTheta = -Math.sin(@theta * Math::PI/180) * scaling + midDTheta = @dTheta + firstDDTheta + midTheta = @theta + (@dTheta + midDTheta)/2 + # second estimate + midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling + midDTheta = @dTheta + (firstDDTheta + midDDTheta)/2 + midTheta = @theta + (@dTheta + midDTheta)/2 + # Now we do a double-estimate approach for getting the final value + # first estimate + midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling + lastDTheta = midDTheta + midDDTheta + lastTheta = midTheta + (midDTheta+ lastDTheta)/2 + # second estimate + lastDDTheta = -Math.sin(lastTheta * Math::PI/180) * scaling + lastDTheta = midDTheta + (midDDTheta + lastDDTheta)/2 + lastTheta = midTheta + (midDTheta + lastDTheta)/2 + # Now put the values back in our globals + @dTheta = lastDTheta + @theta = lastTheta + end + + # This method ties together the simulation engine and the graphical + # display code that visualizes it. + def repeat + # Simulate + recomputeAngle + + # Update the display + showPendulum + showPhase + end +end + +# Start the animation processing +PendulumAnimationDemo.new(base_frame) diff --git a/jni/ruby/ext/tk/sample/demos-jp/plot.rb b/jni/ruby/ext/tk/sample/demos-jp/plot.rb new file mode 100644 index 0000000..4147b35 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/plot.rb @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# +# 2-D plot widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($plot_demo) && $plot_demo + $plot_demo.destroy + $plot_demo = nil +end + +# demo 用の toplevel widget を生成 +$plot_demo = TkToplevel.new {|w| + title("Plot Demonstration") + iconname("Plot") + positionWindow(w) +} + +base_frame = TkFrame.new($plot_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', + 'text'=>"このウィンドウは簡単な2次元のプロットを含んだキャンバス widgetです。表示された点をマウスボタン1でドラッグしてデータをいじることができます。"){ + pack('side'=>'top') +} + +# frame 生成 +$plot_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $plot_demo + $plot_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'plot'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# font 設定 + if $tk_version =~ /^4.*/ + plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*' + else + font = 'Helvetica 18' + end + +# canvas 設定 +$plot_canvas = TkCanvas.new(base_frame,'relief'=>'raised','width'=>450,'height'=>300) +$plot_canvas.pack('side'=>'top', 'fill'=>'x') + +# plot 生成 +TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2) +TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2) +TkcText.new($plot_canvas, 225, 20, + 'text'=>"簡単なプロット", 'font'=>plotFont, 'fill'=>'brown') + +(0..10).each {|i| + x = 100 + (i * 30) + TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2) + TkcText.new($plot_canvas, x, 254, + 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n') +} +(0..5).each {|i| + y = 250 - (i * 40) + TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2) + TkcText.new($plot_canvas, 96, y, + 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e') +} + +for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] + x = 100 + (3*xx) + y = 250 - (4*yy)/5 + item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6, + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + item.addtag 'point' +end + +$plot_canvas.itembind('point', 'Any-Enter', + proc{$plot_canvas.itemconfigure 'current','fill','red'}) +$plot_canvas.itembind('point', 'Any-Leave', + proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'}) +$plot_canvas.itembind('point', '1', + proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y") +$plot_canvas.itembind('point', 'ButtonRelease-1', + proc{$plot_canvas.dtag 'selected'}) +$plot_canvas.bind('B1-Motion', + proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y") + +$plot = {'lastX'=>0, 'lastY'=>0} + +# plotDown -- +# This method is invoked when the mouse is pressed over one of the +# data points. It sets up state to allow the point to be dragged. +# +# Arguments: +# w - The canvas window. +# x, y - The coordinates of the mouse press. + +def plotDown (w, x, y) + w.dtag 'selected' + w.addtag_withtag 'selected', 'current' + w.raise 'current' + $plot['lastX'] = x + $plot['lastY'] = y +end + +# plotMove -- +# This method is invoked during mouse motion events. It drags the +# current item. +# +# Arguments: +# w - The canvas window. +# x, y - The coordinates of the mouse. + +def plotMove (w, x, y) + w.move 'selected', x - $plot['lastX'], y - $plot['lastY'] + $plot['lastX'] = x + $plot['lastY'] = y +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb b/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb new file mode 100644 index 0000000..dbcb423 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +# +# widet demo 'puzzle' (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($puzzle_demo) && $puzzle_demo + $puzzle_demo.destroy + $puzzle_demo = nil +end + +# demo 用の toplevel widget を生成 +$puzzle_demo = TkToplevel.new {|w| + title("15-Puzzle Demonstration") + iconname("15-Puzzle") + positionWindow(w) +} + +base_frame = TkFrame.new($puzzle_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下の15-パズルはボタンを集めてできています。空いている所の隣のピースをクリックすると、そのピースがその空いている場所にスライドします。この操作を続け、ピースがその数の順に上から下、左から右に並ぶようにしてください。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $puzzle_demo + $puzzle_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'puzzle'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +# +# Special trick: scrollbar widget を生成してその trough color を用いることで +# 空白部分のための暗色を選択し,設定する +# +begin + if Tk.windowingsystem() == 'aqua' + frameWidth = 168 + frameHeight = 168 + elsif Tk.default_widget_set == :Ttk + frameWidth = 148 + frameHeight = 124 + else + frameWidth = 120 + frameHeight = 120 + end +rescue + frameWidth = 120 + frameHeight = 120 +end + +# depend_on_button_width = true +depend_on_button_width = false + +s = TkScrollbar.new(base_frame) +base = TkFrame.new(base_frame) { + width frameWidth + height frameHeight + borderwidth 2 + relief 'sunken' + bg s['troughcolor'] +} +s.destroy +base.pack('side'=>'top', 'padx'=>'1c', 'pady'=>'1c') + +# proc のスコープを閉じるため,proc 生成メソッドを用意 +# こうしておかねば,ループ中で値が変化する num の影響を受けて +# puzzleSwitch の第 2 引数が変化してしまい,期待通りにはならない. +def def_puzzleswitch_proc(w, num) + proc{puzzleSwitch w, num} +end + +$xpos = {} +$ypos = {} +order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12] +(0..14).each{|i| + num = order[i] + $xpos[num] = (i % 4) * 0.25 + $ypos[num] = (i / 4) * 0.25 + TkButton.new(base) {|w| + relief 'raised' + text num + highlightthickness 0 + command def_puzzleswitch_proc(w, num) + if depend_on_button_width && (w.winfo_reqwidth * 4 > base.width) + base.width = w.winfo_reqwidth * 4 + end + }.place('relx'=>$xpos[num], 'rely'=>$ypos[num], + 'relwidth'=>0.25, 'relheight'=>0.25) +} +$xpos['space'] = 0.75 +$ypos['space'] = 0.75 + +############ +def puzzleSwitch(w, num) + if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \ + && ($ypos[num] <= ($ypos['space'] + 0.01)) \ + && ($xpos[num] >= ($xpos['space'] - 0.26)) \ + && ($xpos[num] <= ($xpos['space'] + 0.26))) \ + || (($xpos[num] >= ($xpos['space'] - 0.01)) \ + && ($xpos[num] <= ($xpos['space'] + 0.01)) \ + && ($ypos[num] >= ($ypos['space'] - 0.26)) \ + && ($ypos[num] <= ($ypos['space'] + 0.26))) + tmp = $xpos['space'] + $xpos['space'] = $xpos[num] + $xpos[num] = tmp + tmp = $ypos['space'] + $ypos['space'] = $ypos[num] + $ypos[num] = tmp + w.place('relx'=>$xpos[num], 'rely'=>$ypos[num]) + end +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio.rb b/jni/ruby/ext/tk/sample/demos-jp/radio.rb new file mode 100644 index 0000000..efb6135 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/radio.rb @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# +# radiobutton widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($radio_demo) && $radio_demo + $radio_demo.destroy + $radio_demo = nil +end + +# demo 用の toplevel widget を生成 +$radio_demo = TkToplevel.new {|w| + title("Radiobutton Demonstration") + iconname("radio") + positionWindow(w) +} + +base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下には2つのラジオボタングループが表示されています。ボタンをクリックすると、そのボタンだけがそのグループの中で選択されます。各グループに対してそのグループの中のどのボタンが選択されているかを示す変数が割り当てられています。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" +} +msg.pack('side'=>'top') + +# 変数生成 +size = TkVariable.new +color = TkVariable.new + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $radio_demo + $radio_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'radio'} + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text '変数参照' + command proc{ + showVars(base_frame, ['size', size], ['color', color]) + } + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +f_left = TkFrame.new(base_frame) +f_right = TkFrame.new(base_frame) +f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') +f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') + +# radiobutton 生成 +[10, 12, 18, 24].each {|sz| + TkRadioButton.new(f_left) { + text "ポイントサイズ #{sz}" + variable size + relief 'flat' + value sz + }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') +} + +['赤', '緑', '青', '黄', '橙', '紫'].each {|col| + TkRadioButton.new(f_right) { + text col + variable color + relief 'flat' + value col.downcase + }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') +} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio2.rb b/jni/ruby/ext/tk/sample/demos-jp/radio2.rb new file mode 100644 index 0000000..0633a8d --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/radio2.rb @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# +# radio2.rb +# +# This demonstration script creates a toplevel window containing +# several radiobutton widgets. +# +# radiobutton widget demo (called by 'widget') +# + +# toplevel widget +if defined?($radio2_demo) && $radio2_demo + $radio2_demo.destroy + $radio2_demo = nil +end + +# demo toplevel widget +$radio2_demo = TkToplevel.new {|w| + title("Radiobutton Demonstration 2") + iconname("radio2") + positionWindow(w) +} + +base_frame = TkFrame.new($radio2_demo).pack(:fill=>:both, :expand=>true) + +# label +msg = TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text "下には3つのラジオボタングループが表示されています。ボタンをクリックすると、そのボタンだけがそのグループの中で選択されます。各グループに対してそのグループの中のどのボタンが選択されているかを示す変数が割り当てられています。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" +} +msg.pack('side'=>'top') + +# +size = TkVariable.new +color = TkVariable.new +align = TkVariable.new + +# frame +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $radio2_demo + $radio2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'radio2'} + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text '変数参照' + command proc{ + showVars(base_frame, + ['size', size], ['color', color], ['compound', align]) + } + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame +f_left = TkLabelFrame.new(base_frame, 'text'=>'文字サイズ', + 'pady'=>2, 'padx'=>2) +f_mid = TkLabelFrame.new(base_frame, 'text'=>'色', + 'pady'=>2, 'padx'=>2) +f_right = TkLabelFrame.new(base_frame, 'text'=>'ビットマップ配置', + 'pady'=>2, 'padx'=>2) +f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') +f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') +f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c') + +# radiobutton +[10, 12, 18, 24].each {|sz| + TkRadioButton.new(f_left) { + text "ポイントサイズ #{sz}" + variable size + relief 'flat' + value sz + }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x') +} + +['赤', '緑', '青', '黄', '橙', '紫'].each {|col| + TkRadioButton.new(f_mid) { + text col + variable color + relief 'flat' + value col.downcase + anchor 'w' + }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x') +} + +# label = TkLabel.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead', +label = Tk::Label.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead', + 'compound'=>'left') +label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') +label.height(TkWinfo.reqheight(label)) +abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| + lower = a.downcase + TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', + 'value'=>lower, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) +} + +Tk.grid('x', abtn[0]) +Tk.grid(abtn[1], label, abtn[2]) +Tk.grid('x', abtn[3]) diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio3.rb b/jni/ruby/ext/tk/sample/demos-jp/radio3.rb new file mode 100644 index 0000000..3356b69 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/radio3.rb @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- +# +# radio3.rb +# +# This demonstration script creates a toplevel window containing +# several radiobutton widgets. +# +# radiobutton widget demo (called by 'widget') +# + +# toplevel widget +if defined?($radio3_demo) && $radio3_demo + $radio3_demo.destroy + $radio3_demo = nil +end + +# demo toplevel widget +$radio3_demo = TkToplevel.new {|w| + title("Radiobutton Demonstration 3") + iconname("radio3") + positionWindow(w) +} + +base_frame = TkFrame.new($radio3_demo).pack(:fill=>:both, :expand=>true) + +# label +msg = TkLabel.new(base_frame) { + font $font + wraplength '5i' + justify 'left' + text '下には3つのラジオボタングループが表示されています。ボタンをクリックすると、そのグループに属するすべてのボタンの中でクリックしたボタンだけが選択された状態になります。各グループには、そのグループの中のどのボタンが選択されているかを示す変数が割り当てられています。「トライステート」ボタンが押されたときには、ラジオボタンの表示がトライステートモードになります。いずれかのボタンを選択すれば、ボタンの状態は元のように個々のボタンのon/off状態を示すようになります。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。' +} +msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew') + +# variable +size = TkVariable.new +color = TkVariable.new +align = TkVariable.new + +# frame +TkFrame.new(base_frame) {|frame| + TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + TkButton.new(frame, :text=>'変数参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars(base_frame, ['size', size], + ['color', color], ['compound', align]) + }), + TkButton.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'radio3'}), + TkButton.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $radio3_demo + $radio3_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) + frame.grid_columnconfigure(0, :weight=>1) + TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew') +} + +# frame +f_left = TkLabelFrame.new(base_frame, 'text'=>'文字サイズ', + 'pady'=>2, 'padx'=>2) +f_mid = TkLabelFrame.new(base_frame, 'text'=>'色', + 'pady'=>2, 'padx'=>2) +f_right = TkLabelFrame.new(base_frame, 'text'=>'ビットマップ配置', + 'pady'=>2, 'padx'=>2) +f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) +f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2) +f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c') + +TkButton.new(base_frame, 'text'=>'トライステート', + 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){ + grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c') +} + +# radiobutton +[10, 12, 14, 18, 24].each {|sz| + TkRadioButton.new(f_left) { + text "ポイントサイズ #{sz}" + variable size + relief 'flat' + value sz + tristatevalue 'multi' + }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x') +} + +['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col| + TkRadioButton.new(f_mid) { + text col + variable color + relief 'flat' + value col.downcase + anchor 'w' + tristatevalue 'multi' + command proc{f_mid.fg(color.value)} + }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x') +} + +# label = TkLabel.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead', +label = Tk::Label.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead', + 'compound'=>'left') +label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top') +label.height(TkWinfo.reqheight(label)) +a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a| + TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat', + 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7, + 'command'=>proc{label.compound(align.value)}) +} + +Tk.grid('x', a_btn[0]) +Tk.grid(a_btn[1], label, a_btn[2]) +Tk.grid('x', a_btn[3]) diff --git a/jni/ruby/ext/tk/sample/demos-jp/rmt b/jni/ruby/ext/tk/sample/demos-jp/rmt new file mode 100644 index 0000000..dcfb328 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/rmt @@ -0,0 +1,268 @@ +#!/usr/bin/env ruby + +# rmt -- +# This script implements a simple remote-control mechanism for +# Tk applications. It allows you to select an application and +# then type commands to that application. + +require 'tk' + +class Rmt + def initialize(parent=nil) + win = self + + unless parent + parent = TkRoot.new + end + root = TkWinfo.toplevel(parent) + root.minsize(1,1) + + # The instance variable below keeps track of the remote application + # that we're sending to. If it's an empty string then we execute + # the commands locally. + @app = 'local' + @mode = 'Ruby' + + # The instance variable below keeps track of whether we're in the + # middle of executing a command entered via the text. + @executing = 0 + + # The instance variable below keeps track of the last command executed, + # so it can be re-executed in response to !! commands. + @lastCommand = "" + + # Create menu bar. Arrange to recreate all the information in the + # applications sub-menu whenever it is cascaded to. + + TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f| + pack('side'=>'top', 'fill'=>'x') + TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb| + TkMenu.new(mb) {|mf| + mb.menu(mf) + TkMenu.new(mf) {|ma| + postcommand proc{win.fillAppsMenu ma} + mf.add('cascade', 'label'=>'Select Application', + 'menu'=>ma, 'underline'=>0) + } + add('command', 'label'=>'Quit', + 'command'=>proc{root.destroy}, 'underline'=>0) + } + pack('side'=>'left') + } + } + + # Create text window and scrollbar. + + @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) { + yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')}) + pack('side'=>'left') + } + + @promptEnd = TkTextMark.new(@txt, 'insert') + + # Create a binding to forward commands to the target application, + # plus modify many of the built-in bindings so that only information + # in the current command can be deleted (can still set the cursor + # earlier in the text and select and insert; just can't delete). + + @txt.bindtags([@txt, TkText, root, 'all']) + @txt.bind('Return', proc{ + @txt.set_insert('end - 1c') + @txt.insert('insert', "\n") + win.invoke + Tk.callback_break + }) + @txt.bind('Delete', proc{ + begin + @txt.tag_remove('sel', 'sel.first', @promptEnd) + rescue + end + if @txt.tag_nextrange('sel', '1.0', 'end') == [] + if @txt.compare('insert', '<', @promptEnd) + Tk.callback_break + end + end + }) + @txt.bind('BackSpace', proc{ + begin + @txt.tag_remove('sel', 'sel.first', @promptEnd) + rescue + end + if @txt.tag_nextrange('sel', '1.0', 'end') == [] + if @txt.compare('insert', '<', @promptEnd) + Tk.callback_break + end + end + }) + @txt.bind('Control-d', proc{ + if @txt.compare('insert', '<', @promptEnd) + Tk.callback_break + end + }) + @txt.bind('Control-k', proc{ + if @txt.compare('insert', '<', @promptEnd) + @txt.set_insert(@promptEnd) + end + }) + @txt.bind('Control-t', proc{ + if @txt.compare('insert', '<', @promptEnd) + Tk.callback_break + end + }) + @txt.bind('Meta-d', proc{ + if @txt.compare('insert', '<', @promptEnd) + Tk.callback_break + end + }) + @txt.bind('Meta-BackSpace', proc{ + if @txt.compare('insert', '<=', @promptEnd) + Tk.callback_break + end + }) + @txt.bind('Control-h', proc{ + if @txt.compare('insert', '<=', @promptEnd) + Tk.callback_break + end + }) + + @txt.tag_configure('bold', 'font'=>['Courier', 12, 'bold']) + + @app = Tk.appname('rmt') + if (@app =~ /^rmt(.*)$/) + root.title("Tk Remote Controller#{$1}") + root.iconname("Tk Remote#{$1}") + end + prompt + @txt.focus + #@app = TkWinfo.appname(TkRoot.new) + end + + def tkTextInsert(w,s) + return if s == "" + begin + if w.compare('sel.first','<=','insert') \ + && w.compare('sel.last','>=','insert') + w.tag_remove('sel', 'sel.first', @promptEnd) + w.delete('sel.first', 'sel.last') + end + rescue + end + w.insert('insert', s) + w.see('insert') + end + + # The method below is used to print out a prompt at the + # insertion point (which should be at the beginning of a line + # right now). + + def prompt + @txt.insert('insert', "#{@app}: ") + @promptEnd.set('insert') + @promptEnd.gravity = 'left' + @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd) + end + + # The method below executes a command (it takes everything on the + # current line after the prompt and either sends it to the remote + # application or executes it locally, depending on "app". + + def invoke + cmd = @txt.get(@promptEnd, 'insert') + @executing += 1 + case (@mode) + when 'Tcl' + if Tk.info('complete', cmd) + if (cmd == "!!\n") + cmd = @lastCommand + else + @lastCommand = cmd + end + begin + msg = Tk.appsend(@app, false, cmd) + rescue + msg = "Error: #{$!}" + end + @txt.insert('insert', msg + "\n") if msg != "" + prompt + @promptEnd.set('insert') + end + + when 'Ruby' + if (cmd == "!!\n") + cmd = @lastCommand + end + complete = true + begin + eval("proc{#{cmd}}") + rescue + complete = false + end + if complete + @lastCommand = cmd + begin +# msg = Tk.appsend(@app, false, +# 'ruby', +# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"') + msg = Tk.rb_appsend(@app, false, cmd) + rescue + msg = "Error: #{$!}" + end + @txt.insert('insert', msg + "\n") if msg != "" + prompt + @promptEnd.set('insert') + end + end + + @executing -= 1 + @txt.yview_pickplace('insert') + end + + # The following method is invoked to change the application that + # we're talking to. It also updates the prompt for the current + # command, unless we're in the middle of executing a command from + # the text item (in which case a new prompt is about to be output + # so there's no need to change the old one). + + def newApp(appName, mode) + @app = appName + @mode = mode + if @executing == 0 + @promptEnd.gravity = 'right' + @txt.delete("#{@promptEnd.path} linestart", @promptEnd) + @txt.insert(@promptEnd, "#{appName}: ") + @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd) + @promptEnd.gravity = 'left' + end + end + + # The method below will fill in the applications sub-menu with a list + # of all the applications that currently exist. + + def fillAppsMenu(menu) + win = self + begin + menu.delete(0,'last') + rescue + end + TkWinfo.interps.sort.each{|ip| + begin + if Tk.appsend(ip, false, 'info commands ruby') == "" + mode = 'Tcl' + else + mode = 'Ruby' + end + menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), + 'command'=>proc{win.newApp ip, mode}) + rescue + menu.add('command', 'label'=>format("%s (unknown Tk)", ip), + 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled') + end + } + menu.add('command', 'label'=>format("local (Ruby/Tk)"), + 'command'=>proc{win.newApp 'local', 'Ruby'}) + end +end + +Rmt.new + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/rolodex b/jni/ruby/ext/tk/sample/demos-jp/rolodex new file mode 100644 index 0000000..2cc73e1 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/rolodex @@ -0,0 +1,320 @@ +#!/usr/bin/env ruby +# +# rolodex -- +# This script is a part of Tom LaStrange's rolodex +# +# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp> +# Time-stamp: "03/08/02 12:45:21 nagai" +# + +require "tk" + + +def show_help(topic,x=0,y=0) + if( topic.is_a?(TkWindow) ) + w = TkWinfo.containing(x,y) + if( TkWinfo.exist?(w) ) + topic = w + end + end + + if( $helpTopics.include?(topic) ) + msg = $helpTopics[topic] + else + msg = "Sorry, but no help is available for this topic" + end + TkDialog.new("title"=>"Rolodex Help", + "message"=>"Information on #{topic}:\n\n#{msg}", + "default_button"=>0, + "buttons"=>["OK"]) +end + +def fillCard + clearAction + $root.frame.entry[1].insert(0,"Takaaki Tateishi") + $root.frame.entry[2].insert(0,"Japan Advanced Institute of Science and Techonology") + $root.frame.entry[3].insert(0,"1-1 Asahidai, Tatsunokuchi") + $root.frame.entry[4].insert(0,"Ishikawa 923-1292, Japan") + $root.frame.entry[5].insert(0,"private") + $root.frame.entry[6].insert(0,"***-***-****") + $root.frame.entry[7].insert(0,"***-***-****") +end + +def addAction + for i in 1..7 + STDERR.print format("%-12s %s\n", + RolodexFrame::LABEL[i], + $root.frame.entry[i].value) + end +end + +def clearAction + for i in 1..7 + $root.frame.entry[i].delete(0,"end") + end +end + +def fileAction + TkDialog.new("title"=>"File Selection", + "message"=>"This is a dummy file selection dialog box.\n", + "default_button"=>0, + "buttons"=>["OK"]) + STDERR.print "dummy file name\n" +end + +def deleteAction + result = TkDialog.new("title"=>"Confirm Action", + "message"=>"Are you sure?", + "default_button"=>0, + "buttons"=>["Cancel"]) + if( result.value == 0 ) + clearAction + end +end + + +class RolodexFrame < TkFrame + attr_reader :entry, :label + + LABEL = ["","Name:","Address:","","","Home Phone:","Work Phone:","Fax:"] + + def initialize(parent=nil,keys=nil) + super(parent,keys) + self["relief"] = "flat" + + @i = [] + @label = [] + @entry = [] + for i in 1..7 + @i[i] = TkFrame.new(self) + @i[i].pack("side"=>"top", + "pady"=>2, + "anchor"=>"e") + @label[i] = TkLabel.new(@i[i], + "text"=>LABEL[i], + "anchor"=>"e") + @entry[i] = TkEntry.new(@i[i], + "width"=>30, + "relief"=>"sunken") + @entry[i].pack("side"=>"right") + @label[i].pack("side"=>"right") + end + end +end + +class RolodexButtons < TkFrame + attr_reader :clear, :add, :search, :delete + + def initialize(parent,keys=nil) + super(parent,keys) + @clear = TkButton.new(self, + "text" => "Clear") + @add = TkButton.new(self, + "text" => "Add") + @search = TkButton.new(self, + "text" => "Search") + @delete = TkButton.new(self, + "text" => "Delete") + for w in [@clear,@add,@search,@delete] + w.pack("side"=>"left", "padx"=>2) + end + end +end + +class RolodexMenuFrame < TkFrame + attr_reader :file_menu, :help_menu, :file, :help + + def initialize(parent,keys=nil) + super(parent,keys) + configure("relief"=>"raised", + "borderwidth"=>1) + + @file = TkMenubutton.new(self, + "text"=>"File", + "underline"=>0) + @file_menu = TkMenu.new(@file) + @file_menu.add("command", + "label" => "Load ...", + "command" => proc{fileAction}, + "underline" => 0) + @file_menu.add("command", + "label" => "Exit", + "command" => proc{$root.destroy}, + "underline" => 0) + @file.menu(@file_menu) + @file.pack("side"=>"left") + + @help = TkMenubutton.new(self, + "text"=>"Help", + "underline"=>0) + @help_menu = TkMenu.new(@help) + @help_menu.add("command", + "label"=>"On Context...", + "command"=>proc{show_help("context")}, + "underline"=>3) + @help_menu.add("command", + "label"=>"On Help...", + "command"=>proc{show_help("help")}, + "underline"=>3) + @help_menu.add("command", + "label"=>"On Window...", + "command"=>proc{show_help("window")}, + "underline"=>3) + @help_menu.add("command", + "label"=>"On Keys...", + "command"=>proc{show_help("keys")}, + "underline"=>3) + @help_menu.add("command", + "label"=>"On version...", + "command"=>proc{show_help("version")}, + "underline"=>3) + @help.menu(@help_menu) + @help.pack("side"=>"right") + end +end + +class Rolodex < TkRoot + attr_reader :frame, :buttons, :menu + + def initialize(*args) + super(*args) + @frame = RolodexFrame.new(self) + @frame.pack("side"=>"top", + "fill"=>"y", + "anchor"=>"center") + @buttons = RolodexButtons.new(self) + @buttons.pack("side"=>"bottom", + "pady"=>2, + "anchor"=>"center") + @menu = RolodexMenuFrame.new(self) + @menu.pack("before"=>@frame, + "side"=>"top", + "fill"=>"x") + end +end + +$root = Rolodex.new + +$root.buttons.delete.configure("command"=>proc{deleteAction}) +$root.buttons.add.configure("command"=>proc{addAction}) +$root.buttons.clear.configure("command"=>proc{clearAction}) +$root.buttons.search.configure("command"=>proc{addAction; fillCard}) + +$root.buttons.clear.configure("text"=>"Clear Ctrl+C") +$root.bind("Control-c",proc{clearAction}) + +$root.buttons.add.configure("text"=>"Add Ctrl+A") +$root.bind("Control-a",proc{addAction}) + +$root.buttons.search.configure("text"=>"Search Ctrl+S") +$root.bind("Control-s",proc{addAction; fillCard}) + +$root.buttons.delete.configure("text"=>"Delete... Ctrl+D") +$root.bind("Control-d",proc{deleteAction}) + +$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F") +$root.bind("Control-f",proc{fileAction}) + +$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q") +$root.bind("Control-q",proc{$root.destroy}) + +$root.frame.entry[1].focus + +$root.bind("Any-F1", + proc{|event| show_help(event.widget, event.x_root, event.y_root)}) +$root.bind("Any-Help", + proc{|event| show_help(event.widget, event.x_root, event.y_root)}) + + +$helpTopics = {} + +$helpTopics[$root.menu.file] = <<EOF +This is the "file" menu. It can be used to invoke\ +some overall operations on the rolodex applications,\ +such as loading a file or exiting. +EOF + +$helpTopics[$root.menu.file_menu.index(0)] = <<EOF +The "Load" entry in the "File" menu posts a dialog box\ +that you can use to select a rolodex file +EOF + +$helpTopics[$root.menu.file_menu.index(1)] = <<EOF +The "Exit" entry in the "File" menu causes the rolodex\ +application to terminate +EOF + +$helpTopics[$root.frame.entry[1]] = <<EOF +In this field of the rolodex entry you should\ +type the person's name +EOF + +$helpTopics[$root.frame.entry[2]] = <<EOF +In this field of the rolodex entry you should\ +type the first line of the person's address +EOF + +$helpTopics[$root.frame.entry[3]] = <<EOF +In this field of the rolodex entry you should\ +type the second line of the person's address +EOF + +$helpTopics[$root.frame.entry[4]] = <<EOF +In this field of the rolodex entry you should\ +type the third line of the person's address +EOF + +$helpTopics[$root.frame.entry[5]] = <<EOF +In this field of the rolodex entry you should\ +type the person's home phone number, or "private"\ +if the person doesn't want his or he number publicized +EOF + +$helpTopics[$root.frame.entry[6]] = <<EOF +In this field of the rolodex entry you should\ +type the person's work phone number +EOF + +$helpTopics[$root.frame.entry[7]] = <<EOF +In this field of the rolodex entry you should\ +type the phone number for the person's FAX machine +EOF + +$helpTopics["context"] = <<EOF +Unfortunately, this application doesn't support context-sensitive\ +help in the usual way, because when this demo was written Ruby/Tk\ +didn't have a grab mechanism and this is needed for context-sensitive\ +help. Instead, you can achive much the same effect by simply moving\ +the mouse over the window you're curious about and pressing the\ +Help or F1 keys. You can do this anytime. +EOF + +$helpTopics["help"] = <<EOF +This application provides only very crude help. Besides the\ +entries in this menu, you can get help on individual windows\ +by moving the mouse cursor over the window and pressing the\ +Help or F1 keys. +EOF + +$helpTopics["window"] = <<EOF +This window is a dummy rolodex application created as part of\ +Tom LaStrange's toolkit benchmark. It doesn't really do anything\ +useful except to demonstrate a few features of the Ruby/Tk. +EOF + +$helpTopics["keys"] = <<EOF +The following accelerator keys are defined for this application\ +(in addition to those already available for the entry windows): +Ctrl+A: Add +Ctrl+C: Clear +Ctrl+D: Delete +Ctrl+F: Enter file name +Ctrl+Q: Exit application (quit) +Ctrl+S: Search (dummy operation) +EOF + +$helpTopics["version"] = <<EOF +This is version 1.0.1. +EOF + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/rolodex-j b/jni/ruby/ext/tk/sample/demos-jp/rolodex-j new file mode 100644 index 0000000..f6e3afd --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/rolodex-j @@ -0,0 +1,300 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +# rolodex -- +# このスクリプトは Tom LaStrange の rolodex の一部です。 +# +# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp> +# Time-stamp: "04/04/09 00:32:12 nagai" +# + +require "tk" +Tk.encoding = "utf-8" + +def show_help(topic,x=0,y=0) + if( topic.is_a?(TkWindow) ) + w = TkWinfo.containing(x,y) + if( w.is_a?(TkWindow) ) + if( TkWinfo.exist?(w) ) + topic = w + end + end + end + + if( $helpTopics.include?(topic) ) + msg = $helpTopics[topic] + else + msg = "このトピックについてのヘルプはまだ使用できません" + end + TkDialog.new("title"=>"Rolodex Help", + "message"=>"「#{topic}」\n\n#{msg}", + "default_button"=>0, + "buttons"=>["OK"]) +end + +def fillCard + clearAction + $root.frame.entry[1].insert(0, "立石 孝彰") + $root.frame.entry[2].insert(0, "923-1292 石川県") + $root.frame.entry[3].insert(0, "辰口町 旭台 1-1") + $root.frame.entry[4].insert(0, "北陸先端科学技術大学院大学") + $root.frame.entry[5].insert(0,"private") + $root.frame.entry[6].insert(0,"***-***-****") + $root.frame.entry[7].insert(0,"***-***-****") +end + +def addAction + for i in 1..7 + STDERR.print format("%-12s %s\n", + RolodexFrame::LABEL[i], + $root.frame.entry[i].value) + end +end + +def clearAction + for i in 1..7 + $root.frame.entry[i].delete(0,"end") + end +end + +def fileAction + TkDialog.new("title"=>"File Selection", + "message"=>"これはファイル選択ダイアログのダミーです。\n", + "default_button"=>0, + "buttons"=>["OK"]) + STDERR.print "dummy file name\n" +end + +def deleteAction + result = TkDialog.new("title"=>"Confirm Action", + "message"=>"よろしいですか?", + "default_button"=>0, + "buttons"=>["キャンセル"]) + if( result.value == 0 ) + clearAction + end +end + + +class RolodexFrame < TkFrame + attr_reader :entry, :label + + LABEL = ["","名前:","住所","","","電話(自宅):","電話(会社):","Fax:"] + + def initialize(parent=nil,keys=nil) + super(parent,keys) + self["relief"] = "flat" + @i = [] + @label = [] + @entry = [] + for i in 1..7 + @i[i] = TkFrame.new(self) + @i[i].pack("side"=>"top", + "pady"=>2, + "anchor"=>"e") + @label[i] = TkLabel.new(@i[i], + "text"=>LABEL[i], + "anchor"=>"e") + @entry[i] = TkEntry.new(@i[i], + "width"=>30, + "relief"=>"sunken") + @entry[i].pack("side"=>"right") + @label[i].pack("side"=>"right") + end + end +end + +class RolodexButtons < TkFrame + attr_reader :clear, :add, :search, :delete + + def initialize(parent,keys=nil) + super(parent,keys) + @clear = TkButton.new(self,"text" => "クリアー") + @add = TkButton.new(self, "text" => "追加") + @search = TkButton.new(self, "text" => "検索") + @delete = TkButton.new(self, "text" => "消去") + for w in [@clear,@add,@search,@delete] + w.pack("side"=>"left", "padx"=>2) + end + end +end + +class RolodexMenuFrame < TkFrame + attr_reader :file_menu, :help_menu, :file, :help + + def initialize(parent,keys=nil) + super(parent,keys) + configure("relief"=>"raised", + "borderwidth"=>1) + + @file = TkMenubutton.new(self, + "text"=> "ファイル", + "underline"=>0) + @file_menu = TkMenu.new(@file) + @file_menu.add("command", + "label" => "読み込み ...", + "command" => proc{fileAction}, + "underline" => 0) + @file_menu.add("command", + "label" => "終了", + "command" => proc{$root.destroy}, + "underline" => 0) + @file.menu(@file_menu) + @file.pack("side"=>"left") + + @help = TkMenubutton.new(self, + "text"=> "ヘルプ", + "underline"=>0) + @help_menu = TkMenu.new(@help) + @help_menu.add("command", + "label"=> "コンテキストについて", + "command"=>proc{show_help("コンテキスト")}, + "underline"=>3) + @help_menu.add("command", + "label"=> "ヘルプについて", + "command"=>proc{show_help("ヘルプ")}, + "underline"=>3) + @help_menu.add("command", + "label"=> "ウィンドウについて", + "command"=>proc{show_help("ウィンドウ")}, + "underline"=>3) + @help_menu.add("command", + "label"=> "キー操作について", + "command"=>proc{show_help("キー操作")}, + "underline"=>3) + @help_menu.add("command", + "label"=> "バージョン情報", + "command"=>proc{show_help("バージョン情報")}, + "underline"=>3) + @help.menu(@help_menu) + @help.pack("side"=>"right") + end +end + +class Rolodex < TkRoot + attr_reader :frame, :buttons, :menu + + def initialize(*args) + super(*args) + @frame = RolodexFrame.new(self) + @frame.pack("side"=>"top", + "fill"=>"y", + "anchor"=>"center") + @buttons = RolodexButtons.new(self) + @buttons.pack("side"=>"bottom", + "pady"=>2, + "anchor"=>"center") + @menu = RolodexMenuFrame.new(self) + @menu.pack("before"=>@frame, + "side"=>"top", + "fill"=>"x") + end +end + +$root = Rolodex.new + +$root.buttons.delete.configure("command"=>proc{deleteAction}) +$root.buttons.add.configure("command"=>proc{addAction}) +$root.buttons.clear.configure("command"=>proc{clearAction}) +$root.buttons.search.configure("command"=>proc{addAction; fillCard}) + +$root.buttons.clear.configure("text"=> "クリアー Ctrl+C") +$root.bind("Control-c",proc{clearAction}) + +$root.buttons.add.configure("text"=> "追加 Ctrl+A") +$root.bind("Control-a",proc{addAction}) + +$root.buttons.search.configure("text"=> "検索 Ctrl+S") +$root.bind("Control-s",proc{addAction; fillCard}) + +$root.buttons.delete.configure("text"=> "消去 Ctrl+D") +$root.bind("Control-d",proc{deleteAction}) + +$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F") +$root.bind("Control-f",proc{fileAction}) + +$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q") +$root.bind("Control-q",proc{$root.destroy}) + +$root.frame.entry[1].focus + +$root.bind("Any-F1", + proc{|event| show_help(event.widget, event.x_root, event.y_root)}) +$root.bind("Any-Help", + proc{|event| show_help(event.widget, event.x_root, event.y_root)}) + + +$helpTopics = {} + +$helpTopics[$root.menu.file] = <<EOF +これは「ファイル」メニューです。「読み込み」や「終了」などを +行なうことができます。 +EOF + +$helpTopics[$root.menu.file_menu.index(0)] = <<EOF +ファイルの読み込みを行なうときに使います。 +EOF + +$helpTopics[$root.menu.file_menu.index(1)] = <<EOF +アプリケーションを終了するときに使います。 +EOF + +$helpTopics[$root.frame.entry[1]] = <<EOF +名前を記入するエントリです。 +EOF + +$helpTopics[$root.frame.entry[2]] = <<EOF +住所を記入するエントリです。 +EOF + +$helpTopics[$root.frame.entry[3]] = <<EOF +住所を記入するエントリです。 +EOF + +$helpTopics[$root.frame.entry[4]] = <<EOF +住所を記入するエントリです。 +EOF + +$helpTopics[$root.frame.entry[5]] = <<EOF +自宅の電話番号を記入するエントリです。公開\ +したくないときは private と記入します。 +EOF + +$helpTopics[$root.frame.entry[6]] = <<EOF +会社の電話番号を記入するエントリです。 +EOF + +$helpTopics[$root.frame.entry[7]] = <<EOF +FAX番号を記入するエントリです。 +EOF + +$helpTopics["コンテキスト"] = <<EOF +Ruby/Tkではgrabの機構がないためこのアプリケーションでは\ +コンテキストヘルプはサポートされていません。 +しかし同じような効果をbindとマウスの位置のWedgetを知る\ +ことで得ることができます。 +EOF + +$helpTopics["ヘルプ"] = <<EOF +マウスをウィンドウにあわせてF1キーを押すことによって\ +そのヘルプを見ることができます。 +EOF + +$helpTopics["ウィンドウ"] = <<EOF +このウィンドウはダミーです。 +EOF + +$helpTopics["キー操作"] = <<EOF +Ctrl+A: 追加 +Ctrl+C: クリアー +Ctrl+D: 消去 +Ctrl+F: ファイル選択 +Ctrl+Q: 終了 +Ctrl+S: 検索 +EOF + +$helpTopics["バージョン情報"] = <<EOF +バージョンは 1.0.1j です。 +EOF + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/ruler.rb b/jni/ruby/ext/tk/sample/demos-jp/ruler.rb new file mode 100644 index 0000000..5c34a5a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ruler.rb @@ -0,0 +1,203 @@ +# -*- coding: utf-8 -*- +# +# ruler widget demo (called by 'widget') +# + +# rulerMkTab -- +# This method creates a new triangular polygon in a canvas to +# represent a tab stop. +# +# Arguments: +# c - The canvas window. +# x, y - Coordinates at which to create the tab stop. + +def rulerMkTab(c,x,y) + v = $demo_rulerInfo + TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size) +end + +# toplevel widget が存在すれば削除する +if defined?($ruler_demo) && $ruler_demo + $ruler_demo.destroy + $ruler_demo = nil +end + +# demo 用の toplevel widget を生成 +$ruler_demo = TkToplevel.new {|w| + title("Ruler Demonstration") + iconname("ruler") + positionWindow(w) +} + +base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', + 'text'=>"このキャンバスwidgetはルーラーの模型です。ルーラーの右にあるのはタブストップの井戸で、ここから引っ張ってくることによってタブストップを作ることができます。また、すでにあるタブストップを動かすこともできます。タブストップを上方または下方にかすれて表示されるまでドラッグすると、マウスボタンを離した時にそのタブストップは消えます。"){ + pack('side'=>'top') +} + +# frame 生成 +$ruler_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $ruler_demo + $ruler_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'ruler'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# canvas 設定 +$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c') +$ruler_canvas.pack('side'=>'top', 'fill'=>'x') + +# 値設定 +unless Struct.const_defined?("RulerInfo") + $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y, + :top, :bottom, :size, :normalStyle, + :activeStyle, :deleteStyle).new +end +$demo_rulerInfo.grid = '.25c' +$demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c') +$demo_rulerInfo.right = TkWinfo.fpixels($ruler_canvas, '13c') +$demo_rulerInfo.top = TkWinfo.fpixels($ruler_canvas, '1c') +$demo_rulerInfo.bottom = TkWinfo.fpixels($ruler_canvas, '1.5c') +$demo_rulerInfo.size = TkWinfo.fpixels($ruler_canvas, '.2c') +$demo_rulerInfo.normalStyle = {'fill'=>'black'} +if TkWinfo.depth($ruler_canvas) > 1 + $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''} + $demo_rulerInfo.deleteStyle = {'fill'=>'red', + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} +else + $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''} + $demo_rulerInfo.deleteStyle = {'fill'=>'black', + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} +end + +TkcLine.new($ruler_canvas, + '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1) +(0..11).each{|i| + x = i+1 + TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1) + TkcLine.new($ruler_canvas, "#{x}.25c", '1c', "#{x}.25c", '0.8c', 'width'=>1) + TkcLine.new($ruler_canvas, "#{x}.5c", '1c', "#{x}.5c", '0.7c', 'width'=>1) + TkcLine.new($ruler_canvas, "#{x}.75c", '1c', "#{x}.75c", '0.8c', 'width'=>1) + TkcText.new($ruler_canvas, "#{x}.15c", '0.75c', 'text'=>i, 'anchor'=>'sw') +} + +$rulerTag_well = TkcTag.new($ruler_canvas) +$ruler_canvas\ +.addtag_withtag($rulerTag_well, + TkcRectangle.new($ruler_canvas, + '13.2c', '1c', '13.8c', '0.5c', + 'outline'=>'black', + 'fill'=>($ruler_canvas\ + .configinfo('background'))[4]) ) +$ruler_canvas\ +.addtag_withtag($rulerTag_well, + rulerMkTab($ruler_canvas, + TkWinfo.pixels($ruler_canvas, '13.5c'), + TkWinfo.pixels($ruler_canvas, '.65c') ) ) + +$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y') +$ruler_canvas.itembind('tab', '1', + proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y') +$ruler_canvas.bind('B1-Motion', + proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y') +$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)}) + +# rulerNewTab -- +# Does all the work of creating a tab stop, including creating the +# triangle object and adding tags to it to give it tab behavior. +# +# Arguments: +# c - The canvas window. +# x, y - The coordinates of the tab stop. + +def rulerNewTab(c,x,y) + v = $demo_rulerInfo + c.addtag_withtag('active', rulerMkTab(c,x,y)) + c.addtag_withtag('tab', 'active') + v.x = x + v.y = y + rulerMoveTab(c,x,y) +end + +# rulerSelectTab -- +# This method is invoked when mouse button 1 is pressed over +# a tab. It remembers information about the tab so that it can +# be dragged interactively. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse (identifies the point by +# which the tab was picked up for dragging). + +def rulerSelectTab(c,x,y) + v = $demo_rulerInfo + v.x = c.canvasx(x, v.grid) + v.y = v.top+2 + c.addtag_withtag('active', 'current') + c.itemconfigure('active', v.activeStyle) + c.raise('active') +end + +# rulerMoveTab -- +# This method is invoked during mouse motion events to drag a tab. +# It adjusts the position of the tab, and changes its appearance if +# it is about to be dragged out of the ruler. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse. + +def rulerMoveTab(c,x,y) + v = $demo_rulerInfo + return if c.find_withtag('active') == [] + cx = c.canvasx(x,v.grid) + cy = c.canvasy(y) + cx = v.left if cx < v.left + cx = v.right if cx > v.right + if (cy >= v.top && cy <= v.bottom) + cy = v.top+2 + c.itemconfigure('active', v.activeStyle) + else + cy = cy-v.size-2 + c.itemconfigure('active', v.deleteStyle) + end + c.move('active', cx-v.x, cy-v.y) + v.x = cx + v.y = cy +end + +# rulerReleaseTab -- +# This method is invoked during button release events that end +# a tab drag operation. It deselects the tab and deletes the tab if +# it was dragged out of the ruler. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse. + +def rulerReleaseTab(c) + v = $demo_rulerInfo + return if c.find_withtag('active') == [] + if v.y != v.top+2 + c.delete('active') + else + c.itemconfigure('active', v.normalStyle) + c.dtag('active') + end +end + diff --git a/jni/ruby/ext/tk/sample/demos-jp/sayings.rb b/jni/ruby/ext/tk/sample/demos-jp/sayings.rb new file mode 100644 index 0000000..cf4fe7b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/sayings.rb @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# +# listbox widget demo 'sayings' (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($sayings_demo) && $sayings_demo + $sayings_demo.destroy + $sayings_demo = nil +end + +# demo 用の toplevel widget を生成 +$sayings_demo = TkToplevel.new {|w| + title("Listbox Demonstration (well-known sayings)") + iconname("sayings") + positionWindow(w) +} + +base_frame = TkFrame.new($sayings_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下のリストボックスにはいろいろな格言が入っています。リストをスクロールさせるのはスクロールバーでもできますし、リストボックスの中でマウスのボタン2(中ボタン)を押したままドラッグしてもできます。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $sayings_demo + $sayings_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'sayings'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +sayings_lbox = nil +TkFrame.new(base_frame, 'borderwidth'=>10) {|w| + sv = TkScrollbar.new(w) + sh = TkScrollbar.new(w, 'orient'=>'horizontal') + sayings_lbox = TkListbox.new(w) { + setgrid 1 + width 20 + height 10 + yscrollcommand proc{|first,last| sv.set first,last} + xscrollcommand proc{|first,last| sh.set first,last} + } + sv.command(proc{|*args| sayings_lbox.yview(*args)}) + sh.command(proc{|*args| sayings_lbox.xview(*args)}) + + if $tk_version =~ /^4\.[01]/ + sv.pack('side'=>'right', 'fill'=>'y') + sh.pack('side'=>'bottom', 'fill'=>'x') + sayings_lbox.pack('expand'=>'yes', 'fill'=>'y') + + else + sayings_lbox.grid('row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + sv.grid('row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + sh.grid('row'=>1, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0) + end + +}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y') + +sayings_lbox.insert(0, +"Waste not, want not", +"Early to bed and early to rise makes a man healthy, wealthy, and wise", +"Ask not what your country can do for you, ask what you can do for your country", +"I shall return", +"NOT", +"A picture is worth a thousand words", +"User interfaces are hard to build", +"Thou shalt not steal", +"A penny for your thoughts", +"Fool me once, shame on you; fool me twice, shame on me", +"Every cloud has a silver lining", +"Where there's smoke there's fire", +"It takes one to know one", +"Curiosity killed the cat", +"Take this job and shove it", +"Up a creek without a paddle", +"I'm mad as hell and I'm not going to take it any more", +"An apple a day keeps the doctor away", +"Don't look a gift horse in the mouth" +) + diff --git a/jni/ruby/ext/tk/sample/demos-jp/search.rb b/jni/ruby/ext/tk/sample/demos-jp/search.rb new file mode 100644 index 0000000..238450a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/search.rb @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +# +# Text Search widget demo (called by 'widget') +# + +# textLoadFile -- +# This method below loads a file into a text widget, discarding +# the previous contents of the widget. Tags for the old widget are +# not affected, however. +# +# Arguments: +# w - The window into which to load the file. Must be a +# text widget. +# file - The name of the file to load. Must be readable. + +def textLoadFile(w,file) + w.delete('1.0', 'end') + f = open(file, 'r') + while(!f.eof?) + w.insert('end', f.read(1000)) + end + f.close +end + +# textSearch -- +# Search for all instances of a given string in a text widget and +# apply a given tag to each instance found. +# +# Arguments: +# w - The window in which to search. Must be a text widget. +# string - The string to search for. The search is done using +# exact matching only; no special characters. +# tag - Tag to apply to each instance of a matching string. + +def textSearch(w, string, tag) + tag.remove('0.0', 'end') + return if string == "" + cur = '1.0' + loop { + cur, len = w.search_with_length(string, cur, 'end') + break if cur == "" + tag.add(cur, "#{cur} + #{len} char") + cur = w.index("#{cur} + #{len} char") + } +end + +# textToggle -- +# This method is invoked repeatedly to invoke two commands at +# periodic intervals. It normally reschedules itself after each +# execution but if an error occurs (e.g. because the window was +# deleted) then it doesn't reschedule itself. +# +# Arguments: +# cmd1 - Command to execute when method is called. +# sleep1 - Ms to sleep after executing cmd1 before executing cmd2. +# cmd2 - Command to execute in the *next* invocation of this method. +# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again. + +def textToggle(cmd1,sleep1,cmd2,sleep2) + sleep_list = [sleep2, sleep1] + TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep}, + -1, cmd1, cmd2).start(sleep1) +end + +# toplevel widget が存在すれば削除する +if defined?($search_demo) && $search_demo + $search_demo.destroy + $search_demo = nil +end + +# demo 用の toplevel widget を生成 +$search_demo = TkToplevel.new {|w| + title("Text Demonstration - Search and Highlight") + iconname("search") + positionWindow(w) +} + +base_frame = TkFrame.new($search_demo).pack(:fill=>:both, :expand=>true) + +# frame 生成 +$search_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $search_demo + $search_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'search'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +TkFrame.new(base_frame) {|f| + TkLabel.new(f, 'text'=>'ファイル名:', + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + $search_fileName = TkVariable.new + TkEntry.new(f, 'width'=>40, + 'textvariable'=>$search_fileName) { + pack('side'=>'left') + bind('Return', proc{textLoadFile($search_text, $search_fileName.value) + $search_string_entry.focus}) + focus + } + TkButton.new(f, 'text'=>'読み込み', + 'command'=>proc{textLoadFile($search_text, + $search_fileName.value)})\ + .pack('side'=>'left', 'pady'=>5, 'padx'=>10) +}.pack('side'=>'top', 'fill'=>'x') + +TkFrame.new(base_frame) {|f| + TkLabel.new(f, 'text'=>'検索文字列:', + 'width'=>13, 'anchor'=>'w').pack('side'=>'left') + $search_searchString = TkVariable.new + $search_string_entry = TkEntry.new(f, 'width'=>40, + 'textvariable'=>$search_searchString) { + pack('side'=>'left') + bind('Return', proc{textSearch($search_text, $search_searchString.value, + $search_Tag)}) + } + TkButton.new(f, 'text'=>'反転', + 'command'=>proc{textSearch($search_text, + $search_searchString.value, + $search_Tag)}) { + pack('side'=>'left', 'pady'=>5, 'padx'=>10) + } +}.pack('side'=>'top', 'fill'=>'x') + +$search_text = TkText.new(base_frame, 'setgrid'=>true) {|t| + $search_Tag = TkTextTag.new(t) + TkScrollbar.new(base_frame, 'command'=>proc{|*args| t.yview(*args)}) {|sc| + t.yscrollcommand(proc{|first,last| sc.set first,last}) + pack('side'=>'right', 'fill'=>'y') + } + pack('expand'=>'yes', 'fill'=>'both') +} + +# Set up display styles for text highlighting. + +if TkWinfo.depth($search_demo) > 1 + textToggle(proc{ + $search_Tag.configure('background'=>'#ce5555', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) +else + textToggle(proc{ + $search_Tag.configure('background'=>'black', + 'foreground'=>'white') + }, + 800, + proc{ + $search_Tag.configure('background'=>'', 'foreground'=>'') + }, + 200 ) +end +$search_text.insert('1.0', "\ +このウィンドウは検索機構を実現するのにテキスト widget のタグ機能がどの \ +ように使われるのかをデモするものです。まず上のエントリにファイル名を入 \ +れ、<リターン> を押すか「ロード」ボタンを押してください。次にその下の \ +エントリに文字列を入力し、<リターン> を押すか「反転」ボタンを押してく \ +ださい。するとファイル中の、検索文字列と一致する部分に全て \"search_Tag\" \ +というタグがつけられ、タグの表示属性としてその文字列が点滅するように \ +設定されます。\n") +$search_text.insert('end', "\ +ファイル読み込みのカレントディレクトリは \"#{Dir.pwd}\" です。\ +") +$search_text.set_insert '0.0' + +$search_fileName.value = '' +$search_searchString.value = '' + +$search_text.width = 60 +$search_text.height = 20 diff --git a/jni/ruby/ext/tk/sample/demos-jp/spin.rb b/jni/ruby/ext/tk/sample/demos-jp/spin.rb new file mode 100644 index 0000000..fd51a3f --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/spin.rb @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# +# spin.rb -- +# +# This demonstration script creates several spinbox widgets. +# +# based on Tcl/Tk8.4.4 widget demos + +if defined?($spin_demo) && $spin_demo + $spin_demo.destroy + $spin_demo = nil +end + +$spin_demo = TkToplevel.new {|w| + title("Spinbox Demonstration") + iconname("spin") + positionWindow(w) +} + +base_frame = TkFrame.new($spin_demo).pack(:fill=>:both, :expand=>true) + +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'5i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +下には3種類のスピンボックスが表示されています。 +それぞれ、マウスで選択して文字を入力することができます。 +編集操作としては、Emacs 形式の多くに加えて、一般的な +Motif 形式のキー操作がサポートされています。たとえば、 +Backspace と Control-h とは入力カーソルの左側の文字を +削除し、Delete と Control-d とは右側の文字を削除します。 +入力枠の長さを越えるような長い文字列を入力した場合には、 +マウスのボタン2を押してドラッグすることで、入力文字列 +をスキャンすることが可能です。 +なお、最初のスピンボックスは、整数値とみなされるような +文字列しか入力が許されないことに注意してください。また、 +3番目のスピンボックスで選択候補に現れるのはオーストラ +リアの都市名のリストとなっています。 +もしあなたが使っている Ruby にリンクされている Tk ライ +ブラリが spinbox ウィジェットを実装していない場合、この +デモはうまく動かないはずです。その場合には spinbox ウィ +ジェットが実装されているようなより新しいバージョンの Tk +を組み合わせて試すようにしてください。 +EOL + +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $spin_demo.destroy + $spin_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'spin' + }).pack(:side=>:left, :expand=>true) +} + +australianCities = [ + 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide', + 'Brisbane', 'Hobart', 'Darwin', 'Alice Springs' +] + +[ + TkSpinbox.new(base_frame, :from=>1, :to=>10, :width=>10, :validate=>:key, + :validatecommand=>[ + proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P' + ]), + TkSpinbox.new(base_frame, :from=>0, :to=>3, :increment=>0.5, + :format=>'%05.2f', :width=>10), + TkSpinbox.new(base_frame, :values=>australianCities, :width=>10) +].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)} diff --git a/jni/ruby/ext/tk/sample/demos-jp/square b/jni/ruby/ext/tk/sample/demos-jp/square new file mode 100644 index 0000000..bb66282 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/square @@ -0,0 +1,81 @@ +#!/usr/bin/env ruby + +# square -- +# This script generates a demo application containing only +# a "square" widget. It's only usable if Tk has been compiled +# with tkSquare.c and with the -DSQUARE_DEMO compiler switch. +# This demo arranges the following bindings for the widget: +# +# Button-1 press/drag: moves square to mouse +# "a": toggle size animation on/off +# + +require 'tk' +require 'tkafter' + +class TkSquare<TkWindow + def create_self + begin + tk_call 'square', path + rescue + STDERR.print "\nSorry. Your Tk interpreter does not contain " + + 'a "square" demonstration widget.' + + "\n ( See documents included the Tcl/Tk source archive. )\n\n" + exit + end + end + def size(amount=nil) + if amount + tk_send 'size', amount + else + number(tk_send('size')) + end + end + def position(x,y) + tk_send 'position', x, y + end +end + +$s = TkSquare.new{ + pack('expand'=>'yes', 'fill'=>'both') + bind('1', proc{|x,y| center(x,y)}, '%s %y') + bind('B1-Motion', proc{|x,y| center(x,y)}, '%s %y') + bind('a', proc{animate}) + focus +} +TkRoot.new.minsize(1,1) + +# The procedure below centers the square on a given position. + +def center(x,y) + a = $s.size + $s.position(x-(a/2), y-(a/2)) +end + +# The procedures below provide a simple form of animation where +# the box changes size in a pulsing pattern: larger, smaller, larger, +# and so on. + +$inc = 0 + +def timer_proc + a = $s.size + return if $inc == 0 + $inc = -3 if a >= 40 + $inc = 3 if a <= 10 + $s.size(a+$inc) +end + +$timer = TkAfter.new(30, -1, proc{timer_proc}) + +def animate + if $inc == 0 + $inc = 3 + $timer.start + else + $inc = 0 + $timer.stop + end +end + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/states.rb b/jni/ruby/ext/tk/sample/demos-jp/states.rb new file mode 100644 index 0000000..2966e6d --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/states.rb @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# +# listbox widget demo 'states' (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($states_demo) && $states_demo + $states_demo.destroy + $states_demo = nil +end + +# demo 用の toplevel widget を生成 +$states_demo = TkToplevel.new {|w| + title("Listbox Demonstration (states)") + iconname("states") + positionWindow(w) +} + +base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true) + +# label 生成 +msg = TkLabel.new(base_frame) { + font $font + wraplength '4i' + justify 'left' + text "下にあるのは都道府県名が入ったスクロールバー付のリストボックスです。リストをスクロールさせるのはスクロールバーでもできますし、リストボックスの中でマウスのボタン2(中ボタン)を押したままドラッグしてもできます。" +} +msg.pack('side'=>'top') + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $states_demo + $states_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'states'} + }.pack('side'=>'left', 'expand'=>'yes') + +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +states_lbox = nil +TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w| + s = TkScrollbar.new(w) + states_lbox = TkListbox.new(w) { + setgrid 1 + height 12 + yscrollcommand proc{|first,last| s.set first,last} + } + s.command(proc{|*args| states_lbox.yview(*args)}) + s.pack('side'=>'right', 'fill'=>'y') + states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both') +}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y') + +ins_data = [ + '愛知','青森','秋田','石川','茨城','岩手','愛媛', + '大分','大阪','岡山','沖縄','香川','鹿児島','神奈川', + '岐阜','京都','熊本','群馬','高知','埼玉','佐賀', + '滋賀','静岡','島根','千葉','東京','徳島','栃木', + '鳥取','富山','長崎','長野','奈良','新潟','兵庫', + '広島','福井','福岡','福島','北海道','三重','宮城', + '宮崎','山形','山口','山梨','和歌山' +] + +states_lbox.insert(0, *ins_data) + diff --git a/jni/ruby/ext/tk/sample/demos-jp/style.rb b/jni/ruby/ext/tk/sample/demos-jp/style.rb new file mode 100644 index 0000000..813fde7 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/style.rb @@ -0,0 +1,270 @@ +# -*- coding: utf-8 -*- +# +# text (display styles) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($style_demo) && $style_demo + $style_demo.destroy + $style_demo = nil +end + + +# demo 用の toplevel widget を生成 +$style_demo = TkToplevel.new {|w| + title("Text Demonstration - Display Styles") + iconname("style") + positionWindow(w) +} + +base_frame = TkFrame.new($style_demo).pack(:fill=>:both, :expand=>true) + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $style_demo + $style_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'style'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + + +# text 生成 +txt = TkText.new(base_frame){|t| + # 生成 + setgrid 'true' + #width 70 + #height 32 + wrap 'word' + font $font + TkScrollbar.new(base_frame) {|s| + pack('side'=>'right', 'fill'=>'y') + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + } + pack('expand'=>'yes', 'fill'=>'both') + + # テキストタグ設定 (フォント関連) + family = 'Courier' + + if $tk_version =~ /^4.*/ + style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*') + style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font) + style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*') + # style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font) + style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*') + else + style_tag_bold = TkTextTag.new(t, 'font'=>[family, 12, :bold, :italic]) + style_tag_big = TkTextTag.new(t, 'font'=>[family, 14, :bold]) + style_tag_verybig = TkTextTag.new(t, 'font'=>['Helvetica', 24, :bold]) + style_tag_small = TkTextTag.new(t, 'font'=>'Times 8 bold') + end +### +# case($tk_version) +# when /^4.*/ +# style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font) +# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font) +# when /^8.*/ +# unless $style_demo_do_first +# $style_demo_do_first = true +# Tk.tk_call('font', 'create', '@bigascii', +# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*') +# Tk.tk_call('font', 'create', '@smallascii', +# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*') +# Tk.tk_call('font', 'create', '@cBigFont', +# '-compound', '@bigascii @msg_knj') +# Tk.tk_call('font', 'create', '@cSmallFont', +# '-compound', '@smallascii @kanji') +# end +# style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont') +# style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont') +# end + + # テキストタグ設定 (色,レリーフ関連) + if TkWinfo.depth($root).to_i > 1 + style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce') + style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red') + style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1) + style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1) + else + style_tag_color1 = TkTextTag.new(t, 'background'=>'black', + 'foreground'=>'white') + style_tag_color2 = TkTextTag.new(t, 'background'=>'black', + 'foreground'=>'white') + style_tag_raised = TkTextTag.new(t, 'background'=>'white', + 'relief'=>'raised', 'borderwidth'=>1) + style_tag_sunken = TkTextTag.new(t, 'background'=>'white', + 'relief'=>'sunken', 'borderwidth'=>1) + end + + # テキストタグ設定 (その他) + if $tk_version =~ /^4\.[01]/ + style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', + 'borderwidth'=>0, + 'bgstipple'=>'gray25') + else + style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', + 'borderwidth'=>0, + 'bgstipple'=>'gray12') + end + style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50') + style_tag_underline = TkTextTag.new(t, 'underline'=>'on') + style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on') + style_tag_right = TkTextTag.new(t, 'justify'=>'right') + style_tag_center = TkTextTag.new(t, 'justify'=>'center') + if $tk_version =~ /^4.*/ + style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') + style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*') + else + style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>[family, 10]) + style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>[family, 10]) + end + style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m', + 'rmargin'=>'10m') + style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p', + 'lmargin1'=>'12m', 'lmargin2'=>'6m', + 'rmargin'=>'10m') + + # テキスト挿入 + insert('end', 'このようにテキスト widget は情報を様々なスタイルで表示すること +ができます。') + insert('end', 'タグ', style_tag_big) + insert('end', 'というメカニズムでコントロールされます。 +タグとはテキスト widget 内のある文字 (の範囲)に対して適用できる +単なる名前のことです。タグは様々な表示スタイルに設定できます。 +設定すると、そのタグのついた文字は指定したスタイルで表示される +ようになります。使用できる表示スタイルは次の通りです。 +') + insert('end', ' +1. フォント', style_tag_big) + insert('end', ' どんな X のフォントでも使えます。') + insert('end', 'large', style_tag_verybig) + insert('end', ' +とか') +# insert('end', '小さい', style_tag_small) + insert('end', 'small', style_tag_small) + insert('end', 'とか。 +') + insert('end', ' +2. 色', style_tag_big) + insert('end', ' ') + insert('end', '背景色', style_tag_color1) + insert('end', 'も') + insert('end', '前景色', style_tag_color2) + insert('end', 'も') + insert('end', '両方', style_tag_color1, style_tag_color2) + insert('end', 'とも変えることができます。 +') + insert('end', ' +3. 網かけ', style_tag_big) + insert('end', ' このように描画の際に') + insert('end', '背景も', style_tag_bgstipple) + insert('end', '文字も', style_tag_fgstipple) + insert('end', '単なる塗りつぶし +でなく、網かけを使うことができます。 +') + insert('end', ' +4. 下線', style_tag_big) + insert('end', ' このように') + insert('end', '文字に下線を引く', style_tag_underline) + insert('end', 'ことができます。 +') + insert('end', ' +5. 打ち消し線', style_tag_big) + insert('end', ' このように') + insert('end', '文字に重ねて線を引く', style_tag_overstrike) + insert('end', 'ことができます。 +') + insert('end', ' +6. 3D 効果', style_tag_big) + insert('end', ' 背景に枠をつけて、文字を') + insert('end', '飛び出す', style_tag_raised) + insert('end', 'ようにしたり') + insert('end', '沈む', style_tag_sunken) + insert('end', ' +ようにできます。 +') + insert('end', ' +7. 行揃え', style_tag_big) + insert('end', ' このように行を +') + insert('end', '左に揃えたり +') + insert('end', '右に揃えたり +', style_tag_right) + insert('end', '真中に揃えたりできます。 +', style_tag_center) + insert('end', ' +8. 肩付き文字と添字', style_tag_big) + insert('end', ' 10') + insert('end', 'n', style_tag_super) + insert('end', ' のように肩付き文字の効果や、') + insert('end', ' +X') + insert('end', 'i', style_tag_sub) + insert('end', 'のように添字の効果を出すことができます。 +') + insert('end', ' +9. マージン', style_tag_big) + insert('end', 'テキストの左側に余分な空白を置くことができます: +') + insert('end', 'この段落はマージンの使用例です。スクリーン', + style_tag_margins) + insert('end', '上で折り返されて表示されている1行のテキストです。', + style_tag_margins) + insert('end', '左側には2種類のマージンを持ちます。', style_tag_margins) + insert('end', '1行目に対するものと、', style_tag_margins) + insert('end', '2行目以降の連続したマージン', style_tag_margins) + insert('end', 'です。また右側にもマージンがあります。', style_tag_margins) + insert('end', '行の折り返し位置を決めるために使用することができます。 +', style_tag_margins) + insert('end', ' +10. スペーシング', style_tag_big) + insert('end', '3つのパラメータで行のスペーシングを') + insert('end', '制御す +ることができます。Spacing1で、行の') + insert('end', '上にどのくらいの空間を置くか、 +spacing3') + insert('end', 'で行の下にどのくらいの空間を置くか、') + insert('end', '行が折り返されているなら +ば、spacing2で、') + insert('end', 'テキスト行を生成している行の間にどのくらい') + insert('end', 'の空間を置 +くかを示します。 +') + insert('end', 'これらのインデントされた段落はどのように', + style_tag_spacing) + insert('end', 'スペーシングがが行われるのかを示します。', + style_tag_spacing) + insert('end', '各段落は実際はテキストwidget', style_tag_spacing) + insert('end', 'の1行で、widgetによって折り畳まれています。 +', style_tag_spacing) + insert('end', 'Spacing1はこのテキストでは10pointに', style_tag_spacing) + insert('end', '設定されています。', style_tag_spacing) + insert('end', 'これにより、段落の間に大きな間隔が', style_tag_spacing) + insert('end', '存在しています。', style_tag_spacing) + insert('end', 'Spacing2は2pointに設定されています。', style_tag_spacing) + insert('end', 'これで段落の中にほんの少し間隔が存在しています。', + style_tag_spacing) + insert('end', 'Spacing3はこの例では使用されていません。 +', style_tag_spacing) + insert('end', '間隔がどこにあるかを見たければ、これらの段落の', + style_tag_spacing) + insert('end', 'なかでテキストを選択してください。選択の', style_tag_spacing) + insert('end', '反転した部分には余分にとられた間隔が', style_tag_spacing) + insert('end', '含まれています。 +', style_tag_spacing) + +} + +txt.width 70 +txt.height 32 diff --git a/jni/ruby/ext/tk/sample/demos-jp/tcolor b/jni/ruby/ext/tk/sample/demos-jp/tcolor new file mode 100644 index 0000000..f2d5458 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/tcolor @@ -0,0 +1,534 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +# tcolor -- +# このスクリプトはRGB,HSB,CYM形式をサポートする +# 簡易カラーエディタです。 +# +# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp) +# last update: Thu Jun 18 06:32:35 JST 1998 +# + +# まずはtk.rbを読み込む。 + +require "tk" + + +# Tkによって変更される変数はTkVariableのインスタンスを使う。 + +$colorSpace = TkVariable.new(:rgb) +$master = nil +$red = 65535 +$green = 0 +$blue = 0 +$color = "#ffff00000000" +$updating = TkVariable.new(0) +$autoUpdate = TkVariable.new(1) +$name = TkVariable.new($color) +$command = TkVariable.new("print(%%,\"\n\")") +# $command = TkVariable.new("") +$label1 = TkVariable.new("label1") +$label2 = TkVariable.new("label2") +$label3 = TkVariable.new("label3") + + +# リソースデータベースの設定 +if (TkVarAccess.new('tcl_platform')['platform'] == 'unix') + TkOptionDB.add('*Entry.background', 'white') +end + + +# 各イベント用のメソッド + +def rgbToHsv(red,green,blue) + + if ( red > green ) + max = red + min = green + else + max = green + min = red + end + + if ( blue > max ) + max = blue + else + if ( blue < min ) + min = blue + end + end + + range = max - min + + if ( max == 0 ) + sat = 0.0 + else + sat = (max-min)/max + end + + if ( sat == 0 ) + hue = 0.0 + else + rc = (max-red)/range + gc = (max-green)/range + bc = (max-blue)/range + if ( red == max ) + hue = 0.166667 * (bc - gc) + else + if ( green == max ) + hue = 0.166667 * (2.0 + rc - bc) + else + hue = 0.166667 * (4.0 + gc - rc) + end + end + if ( hue < 0.0 ) + hue = hue + 1.0 + end + end + + [hue,sat,max/65535] +end + + +def hsbToRgb(hue,sat,value) + v = 65535.0 * value + if( sat == 0 ) + ans = [v,v,v] + else + hue = hue*6.0 + if ( hue >= 6 ) + hue = 0.0 + end + i = hue.to_i + f = hue - i + p = 65535.0 * value * (1.0 - sat) + q = 65535.0 * value * (1.0 - (sat * f)) + t = 65535.0 * value * (1.0 - (sat * (1.0 - f))) + case i + when 0 + ans = [v,t,p] + when 1 + ans = [q,v,p] + when 2 + ans = [p,v,t] + when 3 + ans = [p,q,v] + when 4 + ans = [t,p,v] + when 5 + ans = [v,p,q] + else + raise(eException,"i value #{i} is out of range") + end + end + return ans +end + + +def _null_binding + Module.new.instance_eval{binding} +end +private :_null_binding + +def doUpdate + newCmd = $command.to_s.gsub("%%","\"#{$color}\"") + eval(newCmd, _null_binding) +end + + +def tc_scaleChanged + if( $updating.to_i == 1 ) + return + end + + $master = :scale if $master == nil + + scale1 = $root.middle.middle.scale1 + scale2 = $root.middle.middle.scale2 + scale3 = $root.middle.middle.scale3 + + case $colorSpace.value.intern + when :rgb + $red = (scale1.get * 65.535).to_i + $green = (scale2.get * 65.535).to_i + $blue = (scale3.get * 65.535).to_i + when :cmy + $red = (65535 - scale1.get * 65.535).to_i + $green = (65535 - scale2.get * 65.535).to_i + $blue = (65535 - scale3.get * 65.535).to_i + when :hsb + list = hsbToRgb(scale1.get / 1000.0, + scale2.get / 1000.0, + scale3.get / 1000.0) + $red = list[0] + $green = list[1] + $blue = list[2] + else + raise(Exception,"unknown colorSpace") + end + $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i) + $name.value = $color if $master == :scale + $root.middle.right.set_color($color) + if( $autoUpdate.to_i == 1 ) + doUpdate + end + Tk.update(true) + $master = nil if $master == :scale +end + + +def tc_setScales + $updating.value = 1 + + scale1 = $root.middle.middle.scale1 + scale2 = $root.middle.middle.scale2 + scale3 = $root.middle.middle.scale3 + + case $colorSpace.value.intern + when :rgb + scale1.set($red / 65.535) + scale2.set($green / 65.535) + scale3.set($blue / 65.535) + when :cmy + scale1.set((65535 - $red) / 65.535) + scale2.set((65535 - $green) / 65.535) + scale3.set((65535 - $blue) / 65.535) + when :hsb + list = rgbToHsv($red,$green,$blue) + scale1.set( list[0] * 1000.0 ) + scale2.set( list[1] * 1000.0 ) + scale3.set( list[2] * 1000.0 ) + else + raise(Exception,"unknown colorSpace") + end + + $updating.value = 0 +end + + +def tc_loadNamedColor(name) + $name.value = name + $master = :name if $master == nil + if name[0,1] != "#" + list = TkWinfo.rgb($root.middle.right.swatch,name) + $red = list[0] + $green = list[1] + $blue = list[2] + else + case name.length + when 4 + fmt = /#(.{1})(.{1})(.{1})/ + shift = 12 + when 7 + fmt = /#(.{2})(.{2})(.{2})/ + shift = 8 + when 10 + fmt = /#(.{3})(.{3})(.{3})/ + shift = 4 + when 13 + fmt = /#(.{4})(.{4})(.{4})/ + shift = 0 + else + raise(eException,"syntax error in color name \"#{name}\"") + end + name.scan(fmt){|strlist| + if strlist.length != 3 + raise(eException,"syntax error in color name \"#{name}\"") + end + $red = strlist[0].hex + $green = strlist[1].hex + $blue = strlist[2].hex + } + $red = $red << shift + $green = $green << shift + $blue = $blue << shift + end + + tc_setScales + $color = format("#%04x%04x%04x",$red,$green,$blue) + $root.middle.right.set_color($color) + if $autoUpdate.to_i == 1 + doUpdate + end + Tk.update(true) + $master = nil if $master == :name +end + + +def changeColorSpace(space) + case space + when :rgb + $label1.value = "Red" + $label2.value = "Green" + $label3.value = "Blue" + when :cmy + $label1.value = "Cyan" + $label2.value = "Magenta" + $label3.value = "Yellow" + when :hsb + $label1.value = "Hue" + $label2.value = "Saturation" + $label3.value = "Brightness" + end + tc_setScales +end + + + + + +# tcolor用のメニュー + +class TkColorMenuFrame<TkFrame + def initialize(parent) + super(parent, + "relief"=>"raised", + "borderwidth"=>"2") + + # Fileメニューボタンの生成 + @file = TkMenubutton.new(self){|button| + + # Fileメニューの作成 + @file_menu = TkMenu.new(button){ + add "radio", + "label" => "RGB color space", + "variable" => $colorSpace, + "value" => :rgb, + "underline" => "0", + "command" => proc{changeColorSpace(:rgb)} + add "radio", + "label" => "CMY color space", + "variable" => $colorSpace, + "value" => :cmy, + "underline" => "0", + "command" => proc{changeColorSpace(:cmy)} + add "radio", + "label" => "HSB color space", + "variable" => $colorSpace, + "value" => :hsb, + "underline" => "0", + "command" => proc{changeColorSpace(:hsb)} + add "separator" + add "radio", + "label" => "Automatic updates", + "variable" => $autoUpdate, + "value" => "1", + "underline" => "0" + add "radio", + "label" => "Manual updates", + "variable" => $autoUpdate, + "value" => "0", + "underline" => "0" + add "separator" + add "command", + "label" => "Exit program", + "underline" => "0", + "command" => proc{exit} + } + + # FileメニューとFileボタンを関連付ける + menu @file_menu + + text "File" + underline "0" + }.pack("side"=>"left") + + self + end +end + + +# 下部のフレームのためのクラス +class TkColorBotFrame<TkFrame + def initialize(parent) + super(parent, + "relief"=> "raised", + "borderwidth"=> 2) + + @commandLabel = TkLabel.new(self, + "text"=> "Command:") + @command = TkEntry.new(self, + "relief"=> "sunken", + "borderwidth"=> "2", + "textvariable"=> $command, + "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*") + @update = TkButton.new(self, + "text"=> "Update", + "command"=> proc{doUpdate}) + @commandLabel.pack("side"=>"left") + @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c") + @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c") + + self + end +end + + +# 中段左のフレーム +class TkColorMiddleLeftFrame<TkFrame + def initialize(parent) + super(parent) + + for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt", + "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt", + "/usr/openwin/lib/X11/rgb.txt"] + if !File.readable?(i) + next + end + f = File.open(i) + @scroll = TkScrollbar.new(self, + "orient"=>"vertical", + "relief"=>"sunken", + "borderwidth"=>"2") + @scroll.pack("side"=>"right","fill"=>"y") + @names = TkListbox.new(self, + "width"=>"20", + "height"=>"12", + "yscrollcommand"=> proc{|first,last| @scroll.set first,last}, + "relief"=>"sunken", + "borderwidth"=>"2", + "exportselection"=>"false") + @scroll.command(proc{|*args| @names.yview(*args)}) + @names.bind("Double-1",proc{ + tc_loadNamedColor(@names.get(@names.curselection))}) + @names.pack("side"=>"left") + while (line = f.gets) + line.chop! + linelist = line.split(/[ \t]+/) + if linelist.length == 4 + @names.insert("end",linelist[3]) + end + end + f.close + break + end + + self + end +end + + +# 中段中央のフレーム +class TkColorMiddleMiddleFrame<TkFrame + # @scale1,@scale2,@scale3を外部から参照のみ許可する。(変更不可) + attr_reader :scale1, :scale2, :scale3 + + def initialize(parent) + super(parent) + + @f1 = TkFrame.new(self) + @f2 = TkFrame.new(self) + @f3 = TkFrame.new(self) + @f4 = TkFrame.new(self) + + for f in [@f1,@f2,@f3] + f.pack("side"=>"top","expand"=>"yes") + end + @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x") + + @label1 = TkLabel.new(self,"textvariable"=>$label1) + @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c", + "orient"=>"horizontal", + "command"=>proc{tc_scaleChanged}) + @scale1.pack("side"=>"top","anchor"=>"w") + @label1.pack("side"=>"top","anchor"=>"w") + + @label2 = TkLabel.new(self,"textvariable"=>$label2) + @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c", + "orient"=>"horizontal", + "command"=>proc{tc_scaleChanged}) + @scale2.pack("side"=>"top","anchor"=>"w") + @label2.pack("side"=>"top","anchor"=>"w") + + @label3 = TkLabel.new(self,"textvariable"=>$label3) + @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c", + "orient"=>"horizontal", + "command"=>proc{tc_scaleChanged}) + @scale3.pack("side"=>"top","anchor"=>"w") + @label3.pack("side"=>"top","anchor"=>"w") + + @nameLabel = TkLabel.new(self,"text"=>"Name:") + @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2", + "textvariable"=>$name,"width"=>"10", + "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*") + @nameLabel.pack("side"=>"left") + @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x") + @name.bind("Return",proc{tc_loadNamedColor $name.to_s}) + + self + end +end + + +class TkColorMiddleRightFrame<TkFrame + attr_reader :swatch + + def initialize(parent) + super(parent) + @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c", + "background"=>$color) + @value = TkLabel.new(self, + "text"=>$color, + "width"=>"13", + "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*") + @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both") + @value.pack("side"=>"bottom","pady"=>".25c") + + self + end + + def set_color(color) + @swatch["background"] = color + @value["text"] = color + end +end + + + +# 中段のフレーム +class TkColorMiddleFrame<TkFrame + attr_reader :left, :middle, :right + + def initialize(parent) + super(parent, + "relief"=> "raised", + "borderwidth"=> "2") + + @left = TkColorMiddleLeftFrame.new(self) + @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c") + + @middle = TkColorMiddleMiddleFrame.new(self) + @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y") + + @right = TkColorMiddleRightFrame.new(self) + @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s") + + self + end +end + + +class TkColor<TkRoot + attr_reader :menu, :bottom, :middle + + def initialize(*args) + super(*args) + @menu = TkColorMenuFrame.new(self) + @menu.pack("side"=>"top", "fill"=>"x") + + @bottom = TkColorBotFrame.new(self) + @bottom.pack("side"=>"bottom","fill"=>"x") + + @middle = TkColorMiddleFrame.new(self) + @middle.pack("side"=>"top","fill"=>"both") + + self + end +end + + +$root = TkColor.new + +# イベントを待つ為にループに入る。 +changeColorSpace :rgb +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/text.rb b/jni/ruby/ext/tk/sample/demos-jp/text.rb new file mode 100644 index 0000000..e698a79 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/text.rb @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +# +# text (basic facilities) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($text_demo) && $text_demo + $text_demo.destroy + $text_demo = nil +end + +# demo 用の toplevel widget を生成 +$text_demo = TkToplevel.new {|w| + title("Text Demonstration - Basic Facilities") + iconname("text") + positionWindow(w) +} + +base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true) + +# version check +if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0) + undo_support = false +else + undo_support = true +end + +# frame 生成 +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $text_demo + $text_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'text'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# text 生成 +TkText.new(base_frame){|t| + # 生成 + relief 'sunken' + bd 2 + setgrid 1 + height 30 + TkScrollbar.new(base_frame) {|s| + pack('side'=>'right', 'fill'=>'y') + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + } + pack('expand'=>'yes', 'fill'=>'both') + + # テキスト挿入 + insert('0.0', <<EOT) +このウィンドウはテキスト widget です。1行またはそれ以上のテキストを表 +示・編集することができます。以下はテキスト widget でできる操作について +まとめたものです。 + +1. スクロール。スクロールバーでテキストの表示部分を動かすことができます。 + +2. スキャニング。テキストのウィンドウでマウスボタン2 (中ボタンを) を押 +して上下にドラッグしてください。そうするとテキストが高速でドラッグされ、 +内容をざっと眺めることができます。 + +3. テキストの挿入。マウスボタン1 (左ボタン) を押し、挿入カーソルをセッ +トしてからテキストを入力してください。入力したものが widget に入ります。 + +4. 選択。ある範囲の文字を選択するにはマウスボタン1 を押し、ドラッグし +てください。一度ボタンを離したら、シフトキーを押しながらボタン1 を押す +ことで選択範囲の調整ができます。これは選択範囲の最後をマウスカーソルに +最も近い位置にリセットし、ボタンを離す前にマウスをドラッグすることでさ +らに選択範囲を調整できます。ダブルクリックでワードを、またトリプルクリッ +クで行全体を選択することができます。 + +5. 消去と置換。テキストを消去するには、消去したい文字を選択してバック +スペースかデリートキーを入力してください。あるいは、新しいテキストを +入力すると選択されたテキストと置換されます。 + +6. 選択部分のコピー。選択部分をこのウィンドウの中のどこかにコピーする +には、まずコピーしたい所を選択(ここで、あるいは別のアプリケーションで) +し、ボタン 2 をクリックして、挿入カーソルの位置にコピーしてください。 + +7. 編集。テキスト widget は Emacs のキーバインドに加えて標準的なの Motif +の編集機能をサポートしています。バックスペースとコントロール-H は挿入 +カーソルの左側の文字を削除します。デリートキーとコントロール-D は挿入 +カーソルの右側の文字を削除します。Meta-バックスペースは挿入カーソルの +右側の単語を削除し、Meta-D は挿入カーソルの左側の単語を削除します。 +コントロール-K は挿入カーソルから行末までを削除し、その位置に改行 +しかなかった場合は、改行を削除します。#{ + if undo_support + undo_text = "Control-z は最後に行った変更の取り消し(undo)を行い、" + case $tk_platform['platform'] + when "unix", "macintosh" + undo_text << "Control-Shift-z" + else # 'windows' + undo_text << "Control-y" + end + undo_text << "はundoした変更の再適用(redo)を行います。" + else + "" + end +} + + +8. ウィンドウのリサイズ。この widget は "setGrid" オプションをオンにし +てありますので、ウィンドウをリサイズする時には高さと幅は常に文字高と文 +字幅の整数倍になります。また、ウィンドウを狭くした場合には長い行が自動 +的に折り返され、常に全ての内容が見えるようになっています。 +EOT + + set_insert('0.0') +} + diff --git a/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb b/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb new file mode 100644 index 0000000..4d896d2 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +# +# text widget peering demo (called by 'widget') +# +# based on Tcl/Tk8.5.0 widget demos + +if defined?($textpeer_demo) && $textpeer_demo + $textpeer_demo.destroy + $textpeer_demo = nil +end + +# demo toplevel widget +$textpeer_demo = TkToplevel.new {|w| + title("Text Wdget Peering Demonstration") + iconname("textpeer") + positionWindow(w) +} + +base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true) + +count = [0] + +## Define a widget that we peer from; it won't ever actually be shown though +first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}") +first.insert :end,"このデモは一つの組を成したテキストウィジェットを示します。" +first.insert :end,"それらのテキストウィジェットは対等(ピア;peer)の関係に" +first.insert :end,"なっています。" +first.insert :end,"それらは、基盤となるデータモデルは共通のものを持ちますが、" +first.insert :end,"画面表示位置、編集位置、選択範囲(selection)については" +first.insert :end,"独立に持つことができます。" +first.insert :end,"各テキストウィジェットの脇にある" +first.insert :end,"「ピア(peer)の作成」ボタンを使えば、" +first.insert :end,"新たなピアを追加することが可能です。" +first.insert :end,"また「ピア(peer)の消去」ボタンを使えば、" +first.insert :end,"特定のピアウィジェットを消去することもできます。" + +Tk.update_idletasks ## for 'first' widget + +## Procedures to make and kill clones; most of this is just so that the demo +## looks nice... +def makeClone(count, win, txt) + cnt = (count[0] += 1) + peer = TkText::Peer.new(txt, win, :widgetname=>"text#{cnt}") + sbar = TkScrollbar.new(win, :widgetname=>"sb#{cnt}") + peer.yscrollbar sbar + b1 = TkButton.new(win, :widgetname=>"clone#{cnt}", + :text=>'ピア(peer)の作成', + :command=>proc{makeClone(count, win, peer)}) + b2 = TkButton.new(win, :widgetname=>"kill#{cnt}", + :text=>'ピア(peer)の消去', + :command=>proc{killClone(win, cnt)}) + row = cnt * 2 + TkGrid.configure(peer, sbar, b1, :sticky=>'nsew', :row=>row) + TkGrid.configure('^', '^', b2, :sticky=>'nsew', :row=>(row+=1)) + TkGrid.configure(b1, b2, :sticky=>'new') + TkGrid.rowconfigure(win, b2, :weight=>1) +end + +def killClone(win, cnt) + Tk.destroy("#{win.path}.text#{cnt}", "#{win.path}.sb#{cnt}", + "#{win.path}.clone#{cnt}", "#{win.path}.kill#{cnt}") +end + +## Now set up the GUI +makeClone(count, base_frame, first) +makeClone(count, base_frame, first) +first.destroy + +## See Code / Dismiss buttons +TkFrame.new(base_frame){|f| + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $textpeer_demo.destroy + $textpeer_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'textpeer' + }).pack(:side=>:left, :expand=>true) + + TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000) +} +TkGrid.columnconfigure(base_frame, 0, :weight=>1) diff --git a/jni/ruby/ext/tk/sample/demos-jp/timer b/jni/ruby/ext/tk/sample/demos-jp/timer new file mode 100644 index 0000000..6cb7c87 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/timer @@ -0,0 +1,136 @@ +#!/usr/bin/env ruby +# +# timer -- +# This script generates a counter with start,stop and reset buttons. +# +# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp) +# last update: Sat Jun 27 12:24:14 JST 1998 +# + +require "tk" +require "thread" +require "tkafter" + +$time = "0.00" +$m = Mutex.new +$loop = false + +def timer_stop + $loop = false + $m.lock +end + +def timer_start + $loop = true + $m.unlock +end + +def timer_reset + $time = "0.00" + $root.countframe.counter['text'] = $time +end + +def timer_loop + if $loop + $time = $time.succ + $root.countframe.counter['text'] = $time + end + Tk.after(10,proc{timer_loop}) +end + + +# +# thread version +# +def timer_loop2 + while true + $m.lock + $time = $time.succ + $root.countframe.counter['text'] = $time + sleep(0.01) + $m.unlock + end +end + +# +# TkAfter +# +def timer_loop3 + if $loop + $time = $time.succ + $root.countframe.counter['text'] = $time + end +end + + +class CountFrame < TkFrame + attr_reader :counter + + def initialize(parent=nil,keys=nil) + super(parent,keys) + @counter = TkLabel.new(self, + 'text'=>$time, + 'relief'=>'raised') + @counter.pack('fill'=>'both') + self + end +end + + +class ButtonFrame < TkFrame + def initialize(parent=nil,keys=nil) + super(parent,keys) +=begin + @stop = TkButton.new(self, + 'text'=>'Stop', + 'command'=>proc{timer_stop}) + @start = TkButton.new(self, + 'text'=>'Start', + 'command'=>proc{timer_start}) +=end + @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled) + @start = TkButton.new(self, :text=>'Start', :state=>:normal) + + @stop.command proc{ + timer_stop + @start.state(:normal) + @stop.state(:disabled) + } + @start.command proc{ + timer_start + @stop.state(:normal) + @start.state(:disabled) + } + + @reset = TkButton.new(self, + 'text'=>'Reset', + 'command'=>proc{timer_reset}) + for b in [@stop,@start,@reset] + b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes') + end + end +end + + +class Timer < TkRoot + attr_reader :countframe + + def initialize(*args) + super(*args) + @countframe = CountFrame.new(self) + @buttonframe = ButtonFrame.new(self) + for f in [@buttonframe,@countframe] + f.pack('side'=>'top', 'fill'=>'both') + end + self + end +end + + +$root = Timer.new + +#$thread = Thread.start{timer_loop2} +#timer_loop +TkAfter.new(10,-1,proc{timer_loop3}).start + +Tk.mainloop diff --git a/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb b/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb new file mode 100644 index 0000000..3ee7a5f --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +# +# toolbar.rb -- +# +# This demonstration script creates a toolbar that can be torn off. +# +# based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($toolbar_demo) && $toolbar_demo + $toolbar_demo.destroy + $toolbar_demo = nil +end + +$toolbar_demo = TkToplevel.new {|w| + title("Ttk Menu Buttons") + iconname("toolbar") + positionWindow(w) +} + +base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true) + +if Tk.windowingsystem != 'aqua' + msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL) +このデモでは,ツールバーをどのようにして適切にテーマ対応させるか,\ +また,どのようにして切り離し可能にするかを示しています\ +(ただし,ツールバーの切り離しにはTcl/Tk8.5以上の機能が必要です).\ +ツールバーのボタンは,'Toolbutton'スタイルを使用するように明示することで,\ +"toolbar style"ボタンとなるように属性設定されています.\ +ツールバーの左端には簡単なマーカーが置かれています.\ +マーカー上にマウスカーソルが来ると移動アイコンにカーソルが変化します.\ +そこでツールバーを動かすようにドラッグすると,\ +ツールバー全体を切り離して独立したトップレベルウィジェットに\ +することができます.\ +切り離したツールバーが不要となった時には,\ +一般的なトップレベルウィジェットと同様に単純に閉じることで, +再び元のウィンドウに張り付けられるでしょう. +EOL +else + msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL) +このデモでは,ツールバーをどのようにして適切にテーマ対応させるかを\ +示しています.\ +ツールバーのボタンは,'Toolbutton'スタイルを使用するように明示することで,\ +"toolbar style"ボタンとなるように属性設定されています. +EOL +end + +## Set up the toolbar hull +tbar_base = Tk::Frame.new(base_frame, # Tk 標準の frame でなければなりません. + :widgetname=>'toolbar') # ウィンドウタイトル文字列とするために,ウィジェット名を明示しています. +sep = Ttk::Separator.new(base_frame) +to_base = Ttk::Frame.new(tbar_base, :cursor=>'fleur') +if Tk.windowingsystem != 'aqua' + to = Ttk::Separator.new(to_base, :orient=>:vertical) + to2 = Ttk::Separator.new(to_base, :orient=>:vertical) + to.pack(:fill=>:y, :expand=>true, :padx=>2, :side=>:left) + to2.pack(:fill=>:y, :expand=>true, :side=>:left) +end + +contents = Ttk::Frame.new(tbar_base) +Tk.grid(to_base, contents, :sticky=>'nsew') +tbar_base.grid_columnconfigure(contents, :weight=>1) +contents.grid_columnconfigure(1000, :weight=>1) + +if Tk.windowingsystem != 'aqua' + ## Bindings so that the toolbar can be torn off and reattached + to_base.bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)} + to. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)} + to2. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)} + def tbar_base.tearoff(w, x, y) + on_win = TkWinfo.containing(x, y) + return unless (on_win && on_win.path =~ /^#{@path}(\.|$)/) + self.grid_remove + w.grid_remove + self.wm_manage + # self.wm_title('Toolbar') # もしウィジェット名をウィンドウタイトルにしたくないなら,ここで設定してください + self.wm_protocol('WM_DELETE_WINDOW'){ self.untearoff(w) } + end + def tbar_base.untearoff(w) + self.wm_forget + w.grid + self.grid + end +end + +## Some content for the rest of the toplevel +text = TkText.new(base_frame, :width=>40, :height=>10) + +## Toolbar contents +tb_btn = Ttk::Button.new(tbar_base, :text=>'ボタン', :style=>'Toolbutton', + :command=>proc{ + text.insert(:end, "ボタンが押されました.\n") + }) +tb_chk = Ttk::Checkbutton.new(tbar_base, :text=>'チェックボタン', + :style=>'Toolbutton', + :variable=>(check = TkVariable.new), + :command=>proc{ + text.insert(:end, "チェックボタンの値は#{check.value}です.\n") + }) +tb_mbtn = Ttk::Menubutton.new(tbar_base, :text=>'メニュー') +tb_combo = Ttk::Combobox.new(tbar_base, :value=>TkFont.families, + :state=>:readonly) +tb_mbtn.menu(menu = Tk::Menu.new(tb_mbtn)) +menu.add(:command, :label=>'Just', :command=>proc{text.insert(:end, "Just\n")}) +menu.add(:command, :label=>'An', :command=>proc{text.insert(:end, "An\n")}) +menu.add(:command, :label=>'Example', + :command=>proc{text.insert(:end, "Example\n")}) +tb_combo.bind('<ComboboxSelected>'){ text.font.family = tb_combo.get } + +## Arrange contents +Tk.grid(tb_btn, tb_chk, tb_mbtn, tb_combo, + :in=>contents, :padx=>2, :sticky=>'ns') +Tk.grid(tbar_base, :sticky=>'ew') +Tk.grid(sep, :sticky=>'ew') +Tk.grid(msg, :sticky=>'ew') +Tk.grid(text, :sticky=>'nsew') +base_frame.grid_rowconfigure(text, :weight=>1) +base_frame.grid_columnconfigure(text, :weight=>1) + +## See Code / Dismiss buttons +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'toolbar'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $toolbar_demo.destroy + $toolbar_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + Tk.grid(frame, :sticky=>'ew') +} diff --git a/jni/ruby/ext/tk/sample/demos-jp/tree.rb b/jni/ruby/ext/tk/sample/demos-jp/tree.rb new file mode 100644 index 0000000..3f3b18b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/tree.rb @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +# +# tree.rb -- +# +# This demonstration script creates a toplevel window containing a Ttk +# tree widget. +# +# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp" + +if defined?($tree_demo) && $tree_demo + $tree_demo.destroy + $tree_demo = nil +end + +$tree_demo = TkToplevel.new {|w| + title("Directory Browser") + iconname("tree") + positionWindow(w) +} + +base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true) + +## Explanatory text +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', + :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6], + :text=><<EOL).pack(:fill=>:x) +Ttkとは,テーマ指定可能な新しいウィジェット集合です.\ +このサンプルは,ファイルシステムのような階層的なデータ集合を\ +参照できるようにしたTtk::Treeviewウィジェットを含んでいます.\ +Ttk::Treeviewウィジェットは,木構造自体の表示を可能にするだけでなく,\ +追加情報(このサンプルの場合はファイルサイズ)を表示するために\ +任意の個数の追加カラムも扱うこともできます.\ +また,カラムのタイトル間の区切り部分をドラッグすることで,\ +カラムの幅を変更することも可能です. +EOL + +## See Code / Dismiss +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'tree'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $tree_demo.destroy + $tree_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +## Code to populate the roots of the tree (can be more than one on Windows) +def populate_roots(tree) + TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir| + populate_tree(tree, tree.insert(nil, :end, :text=>dir, + :values=>[dir, 'directory'])) + } +end + +## Code to populate a node of the tree +def populate_tree(tree, node) + return if tree.get(node, :type) != 'directory' + + path = tree.get(node, :fullpath) + tree.delete(tree.children(node)) + Dir.glob("#{path}/*").sort.each{|f| + type = File.ftype(f) rescue nil + id = tree.insert(node, :end, + :text=>File.basename(f), :values=>[f, type]).id + if type == 'directory' + ## Make it so that this node is openable + tree.insert(id, 0, :text=>'dummy') + tree.itemconfigure(id, :text=>File.basename(f)) + elsif type == 'file' + size = File.size(f) + if size >= 1024*1024*1024 + size = '%.1f GB' % (size.to_f/1024/1024/1024) + elsif size >= 1024*1024 + size = '%.1f MB' % (size.to_f/1024/1024) + elsif size >= 1024 + size = '%.1f KB' % (size.to_f/1024) + else + size = '%.1f bytes' % (size.to_f/1024) + end + tree.set(id, :size, size) + end + } + + # Stop this code from rerunning on the current node + tree.set(node, :type, 'processed_directory') +end + +## Create the tree and set it up +tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size), + :displaycolumns=>['size']) +if Tk.windowingsystem != 'aqua' + vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame)) + hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame)) +else + vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame)) + hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame)) +end + +tree.heading_configure('#0', :text=>'Directory Structure') +tree.heading_configure('size', :text=>'File Size') +tree.column_configure('size', :stretch=>0, :width=>70) +populate_roots(tree) +tree.bind('<TreeviewOpen>', '%W'){|w| populate_tree(w, w.focus_item)} + +## Arrange the tree and its scrollbars in the toplevel +container = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) +container.lower +Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew') +Tk.grid(hsb, :in=>container, :sticky=>'nsew') +container.grid_columnconfigure(0, :weight=>1) +container.grid_rowconfigure(0, :weight=>1) diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb new file mode 100644 index 0000000..ccde541 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +# +# ttkbut.rb +# +# This demonstration script creates a toplevel window containing several +# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and +# radiobuttons. +# +# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp" + +if defined?($ttkbut_demo) && $ttkbut_demo + $ttkbut_demo.destroy + $ttkbut_demo = nil +end + +$ttkbut_demo = TkToplevel.new {|w| + title("Simple Ttk Widgets") + iconname("ttkbut") + positionWindow(w) +} + +base_frame = TkFrame.new($ttkbut_demo).pack(:fill=>:both, :expand=>true) + +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top, :fill=>:x) +Ttkとは,テーマ指定可能な新しいウィジェット集合です.\ +今,あなたが目にしているのはTtkのテーマ化ラベルで,\ +下にはTtkのラベルフレームの中に三つのグループのTtkウィジェットが\ +表示されています. +最初のグループは全てボタンであり,\ +それぞれクリックすれば現在のアプリケーションのテーマが設定されます. +2番目のグループは三つのチェックボタン集合です.\ +各集合の間には,セパレータウィジェットが置かれています.\ +なお「有効化」ボタンは,このトップレベルウィジェット内の\ +他のすべてのテーマ化ウィジェットの状態(state)が"disabled"かどうかを\ +コントロールすることに注意してください. +3番目のグループは関連付けられたラジオボタン集合となっています. +EOL + +## Add buttons for setting the theme +buttons = Ttk::Labelframe.new(base_frame, :text=>'ボタン') +# Ttk::Style.theme_names.each{|theme| +# Ttk::Button.new(buttons, :text=>theme, +# :command=>proc{Ttk::Style.theme_use theme}).pack(:pady=>2) +# } +Ttk.themes.each{|theme| + Ttk::Button.new(buttons, :text=>theme, + :command=>proc{Ttk.set_theme theme}).pack(:pady=>2) +} + +## Helper procedure for the top checkbutton +def setState(root, value, *excepts) + return if excepts.member?(root) + + ## Non-Ttk widgets (e.g. the toplevel) will fail, so make it silent + begin + root.state = value + rescue + end + + ## Recursively invoke on all children of this root that are in the same + ## toplevel widget + root.winfo_children.each{|w| + setState(w, value, *excepts) if w.winfo_toplevel == root.winfo_toplevel + } +end + +## Set up the checkbutton group +checks = Ttk::Labelframe.new(base_frame, :text=>'チェックボタン') +enabled = TkVariable.new(true) +e = Ttk::Checkbutton.new(checks, :text=>'有効化', :variable=>enabled, + :command=>proc{ + setState($ttkbut_demo, + ((enabled.bool)? "!disabled" : "disabled"), + e) + }) + +## See ttk_widget(n) for other possible state flags +sep1 = Ttk::Separator.new(checks) +sep2 = Ttk::Separator.new(checks) + +cheese = TkVariable.new +tomato = TkVariable.new +basil = TkVariable.new +oregano = TkVariable.new + +c1 = Ttk::Checkbutton.new(checks, :text=>'チーズ', :variable=>cheese) +c2 = Ttk::Checkbutton.new(checks, :text=>'トマト', :variable=>tomato) +c3 = Ttk::Checkbutton.new(checks, :text=>'バジル', :variable=>basil) +c4 = Ttk::Checkbutton.new(checks, :text=>'オレガノ', :variable=>oregano) + +Tk.pack(e, sep1, c1, c2, sep2, c3, c4, :fill=>:x, :pady=>2) + +## Set up the radiobutton group +radios = Ttk::Labelframe.new(base_frame, :text=>'ラジオボタン') + +happyness = TkVariable.new + +r1 = Ttk::Radiobutton.new(radios, :variable=>happyness, + :text=>'Great', :value=>'great') +r2 = Ttk::Radiobutton.new(radios, :variable=>happyness, + :text=>'Good', :value=>'good') +r3 = Ttk::Radiobutton.new(radios, :variable=>happyness, + :text=>'Ok', :value=>'ok') +r4 = Ttk::Radiobutton.new(radios, :variable=>happyness, + :text=>'Poor', :value=>'poor') +r5 = Ttk::Radiobutton.new(radios, :variable=>happyness, + :text=>'Awful', :value=>'awful') + +Tk.pack(r1, r2, r3, r4, r5, :fill=>:x, :padx=>3, :pady=>2) + +## See Code / Dismiss +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'変数参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{ + showVars(base_frame, ['有効化', enabled], + ['チーズ', cheese], ['トマト', tomato], + ['バジル', basil], ['オレガノ', oregano], + ['幸福度', happyness]) + }), + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'ttkbut'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $ttkbut_demo + $ttkbut_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x, :expand=>true) +} + +## Arrange things neatly +f = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) +f.lower +Tk.grid(buttons, checks, radios, :in=>f, :sticky=>'nwe', :pady=>2, :padx=>3) +f.grid_columnconfigure([0, 1, 2], :weight=>1, :uniform=>:yes) diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb new file mode 100644 index 0000000..aa9db50 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +# +# ttkmenu.rb -- +# +# This demonstration script creates a toplevel window containing several Ttk +# menubutton widgets. +# +# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($ttkmenu_demo) && $ttkmenu_demo + $ttkmenu_demo.destroy + $ttkmenu_demo = nil +end + +$ttkmenu_demo = TkToplevel.new {|w| + title("Ttk Menu Buttons") + iconname("ttkmenu") + positionWindow(w) +} + +base_frame = Ttk::Frame.new($ttkmenu_demo).pack(:fill=>:both, :expand=>true) + +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top, :fill=>:x) +Ttkとは,テーマ指定可能な新しいウィジェット集合です.\ +これによりテーマに対応することができるようになったウィジェットのひとつに\ +メニューボタンがあります.\ +以下では,テーマに対応したメニューボタンがいくつか表示されています.\ +それらを使って,現在使用中のテーマを変更することが可能です.\ +テーマの選択がメニューボタン自身の見掛けを変化させる様子や,\ +中央のメニューボタンだけが異なるスタイル\ +(ツールバーでの一般的な表示に適したもの)で表示されている様子に\ +注目してください.\ +なお,メニューボタンについてはテーマに対応したウィジェットがありますが,\ +メニューについてはテーマに対応したウィジェットは含まれていません.\ +その理由は,標準のTkのメニューウィジェットが\ +すべてのプラットホームで十分に良好な見掛けと操作性を持っている,\ +特に,多くの環境でその環境本来の操作体系となるように実装されていると\ +判断されたことによります. +EOL + +Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x) + +## See Code / Dismiss +Ttk::Frame.new($ttkmenu_demo) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'ttkmenu'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $ttkmenu_demo.destroy + $ttkmenu_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +b1 = Ttk::Menubutton.new(base_frame,:text=>'テーマを選択',:direction=>:above) +b2 = Ttk::Menubutton.new(base_frame,:text=>'テーマを選択',:direction=>:left) +b3 = Ttk::Menubutton.new(base_frame,:text=>'テーマを選択',:direction=>:right) +b4 = Ttk::Menubutton.new(base_frame,:text=>'テーマを選択',:direction=>:flush, + :style=>Ttk::Menubutton.style('Toolbutton')) +b5 = Ttk::Menubutton.new(base_frame,:text=>'テーマを選択',:direction=>:below) + +b1.menu(m1 = Tk::Menu.new(b1, :tearoff=>false)) +b2.menu(m2 = Tk::Menu.new(b2, :tearoff=>false)) +b3.menu(m3 = Tk::Menu.new(b3, :tearoff=>false)) +b4.menu(m4 = Tk::Menu.new(b4, :tearoff=>false)) +b5.menu(m5 = Tk::Menu.new(b5, :tearoff=>false)) + +Ttk.themes.each{|theme| + m1.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme}) + m2.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme}) + m3.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme}) + m4.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme}) + m5.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme}) +} + +f = Ttk::Frame.new(base_frame).pack(:fill=>:x) +f1 = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) +f.lower + +f.grid_anchor(:center) +TkGrid('x', b1, 'x', :in=>f, :padx=>3, :pady=>2) +TkGrid(b2, b4, b3, :in=>f, :padx=>3, :pady=>2) +TkGrid('x', b5, 'x', :in=>f, :padx=>3, :pady=>2) diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb b/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb new file mode 100644 index 0000000..f3b2fa5 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# +# ttknote.rb -- +# +# This demonstration script creates a toplevel window containing a Ttk +# notebook widget. +# +# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp" + +if defined?($ttknote_demo) && $ttknote_demo + $ttknote_demo.destroy + $ttknote_demo = nil +end + +$ttknote_demo = TkToplevel.new {|w| + title("Ttk Notebook Widget") + iconname("ttknote") + positionWindow(w) +} + +## See Code / Dismiss +Ttk::Frame.new($ttknote_demo) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'ttknote'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $ttknote_demo.destroy + $ttknote_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +base_frame = Ttk::Frame.new($ttknote_demo).pack(:fill=>:both, :expand=>true) + +## Make the notebook and set up Ctrl+Tab traversal +notebook = Ttk::Notebook.new(base_frame).pack(:fill=>:both, :expand=>true, + :padx=>2, :pady=>3) +notebook.enable_traversal + +## Popuplate the first pane +f_msg = Ttk::Frame.new(notebook) +msg_m = Ttk::Label.new(f_msg, :font=>$font, :wraplength=>'5i', + :justify=>:left, :anchor=>'n', :text=><<EOL) +Ttkとは,テーマ指定可能な新しいウィジェット集合です.\ +その中に含まれるウィジェットのひとつにノートブックウィジェットがあります.\ +ノートブックウィジェットは,\ +個別の内容を持ったパネルからの選択を可能にするような\ +タブの集合(タブセット)を定めます.\ +タブセットは最近の多くのユーザインターフェースで見られる機能です.\ +タブの選択は,マウスによるだけでなく,\ +ノートブックウィジェットのページの見出しが選択されている時であれば\ +Ctrl+Tabキーの入力によっても行うことができます.\ +このデモでは,見出しで下線付きの文字のキーとAltキーとを組み合わせることで\ +ページを選択することができるようにも設定しています.\ +ただし,2番目のタブは無効化されて選択できないようになっていることには\ +注意してください. +EOL +neat = TkVariable.new +after_id = nil +msg_b = Ttk::Button.new(f_msg, :text=>'すてきだ!(Neat!)', :underline=>6, + :command=>proc{ + neat.value = 'あぁ,そのとおりさ...' + Tk.after_cancel(after_id) if after_id + after_id = Tk.after(500){neat.value = ''} + }) +msg_b.winfo_toplevel.bind('Alt-n'){ msg_b.focus; msg_b.invoke } +msg_l = Ttk::Label.new(f_msg, :textvariable=>neat) +notebook.add(f_msg, :text=>'説明(Description)', :underline=>3, :padding=>2) +Tk.grid(msg_m, '-', :sticky=>'new', :pady=>2) +Tk.grid(msg_b, msg_l, :pady=>[2, 4], :padx=>20) +msg_b.grid_configure(:sticky=>'e') +msg_l.grid_configure(:sticky=>'w') +f_msg.grid_rowconfigure(1, :weight=>1) +f_msg.grid_columnconfigure([0, 1], :weight=>1, :uniform=>1) + +## Populate the second pane. Note that the content doesn't really matter +f_disabled = Ttk::Frame.new(notebook) +notebook.add(f_disabled, :text=>'無効化されたタブ', :state=>:disabled) + +## Popuplate the third pane +f_editor = Ttk::Frame.new(notebook) +notebook.add(f_editor, :text=>'テキストエディタ(Text Editor)', :underline=>9) +editor_t = Tk::Text.new(f_editor, :width=>40, :height=>10, :wrap=>:char) +if Tk.windowingsystem != 'aqua' + editor_s = editor_t.yscrollbar(Ttk::Scrollbar.new(f_editor)) +else + editor_s = editor_t.yscrollbar(Tk::Scrollbar.new(f_editor)) +end +editor_s.pack(:side=>:right, :fill=>:y, :padx=>[0,2], :pady=>2) +editor_t.pack(:fill=>:both, :expand=>true, :padx=>[2,0], :pady=>2) diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb new file mode 100644 index 0000000..a5c1a08 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- +# +# ttkpane.rb -- +# +# This demonstration script creates a Ttk pane with some content. +# +# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($ttkpane_demo) && $ttkpane_demo + $ttkpane_demo.destroy + $ttkpane_demo = nil +end + +$ttkpane_demo = TkToplevel.new {|w| + title("Themed Nested Panes") + iconname("ttkpane") + positionWindow(w) +} + +base_frame = TkFrame.new($ttkpane_demo).pack(:fill=>:both, :expand=>true) + +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top, :fill=>:x) +このデモは,埋め込み関係にあるテーマ付きペインドウィンドウを示しています.\ +それぞれの大きさは,含まれているペインの間にあるエリアをつかんで\ +境界をドラッグすることで変更できます. +EOL + +Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x) + +## See Code / Dismiss +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'ttkpane'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $ttkpane_demo.destroy + $ttkpane_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) + +outer = Ttk::Panedwindow.new(frame, :orient=>:horizontal) +outer.add(in_left = Ttk::Panedwindow.new(outer, :orient=>:vertical)) +outer.add(in_right = Ttk::Panedwindow.new(outer, :orient=>:vertical)) +in_left.add(left_top = Ttk::Labelframe.new(in_left, :text=>'ボタン')) +in_left.add(left_bot = Ttk::Labelframe.new(in_left, :text=>'時計')) +in_right.add(right_top = Ttk::Labelframe.new(in_right, :text=>'プログレス')) +in_right.add(right_bot = Ttk::Labelframe.new(in_right, :text=>'テキスト')) +if Tk.windowingsystem == 'aqua' + [left_top, left_bot, right_top, right_bot].each{|w| w.padding(3) } +end + +# Fill the button pane +Ttk::Button.new(left_top, :text=>'押してね', + :command=>proc{ + Tk.messageBox(:type=>'ok', :icon=>'info', + :message=>'いてて!', + :detail=>'That hurt...', :parent=>base_frame, + :title=>'Button Pressed') + }).pack(:padx=>2, :pady=>5) + + +zones_list = [ + [':Europe/Berlin'], + [':America/Argentina/Buenos_Aires', ':America/Buenos_Aires'], + [':Africa/Johannesburg'], + [':Europe/London'], + [':America/Los_Angeles'], + [':Europe/Moscow'], + [':America/New_York'], + [':Asia/Singapore'], + [':Australia/Sydney'], + [':Asia/Tokyo'], +] + +zones = [] + +# Check tzinfo support +if $tk_major_ver > 8 || ($tk_major_ver == 8 && $tk_minor_ver >= 5) + tzinfo = :tcl + + zones_list.each{|list| + list.each{|zone| + begin + # Force a pre-load of all the timezones needed; otherwise can end up + # poor-looking synch problems! + Tk.tk_call('clock', 'format', '0', '-timezone', zone) + rescue RuntimeError + # ignore + else + zones << [zone, zone[%r<[^/:]+$>].tr('_', ' ')] + break + end + } + } + +else + begin + require 'tzinfo' + tzinfo = :tzinfo + rescue Exception + begin + require 'tzfile' + tzinfo = :tzfile + rescue Exception + tzinfo = nil + end + end + + case tzinfo + when :tzinfo + zones_list.each{|list| + list.each{|zone| + begin + tz = TZInfo::Timezone.get(zone[%r<[^:]+$>]) + rescue Exception + # ignore + else + zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')] + break + end + } + } + + when :tzfile + zones_list.each{|list| + list.each{|zone| + begin + tz = TZFile.create(zone[%r<[^:]+$>]) + rescue Exception + # ignore + else + zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')] + break + end + } + } + + else + [ -7, -4, -2, -1, 0, +1, +3, +8, +9, +10 ].each{|zone| + zones << [zone, 'UTC%+03d00' % zone] + } + end +end + +time = TkVariable.new_hash + +case tzinfo +when :tcl + update_proc = proc{|now, tz, label| + time[label] = Tk.tk_call('clock', 'format', now.tv_sec, + '-timezone', tz, '-format', '%T') + } +when :tzinfo + update_proc = proc{|now, tz, label| + time[label] = tz.utc_to_local(now).strftime('%H:%M:%S') + } +when :tzfile + update_proc = proc{|now, tz, label| + time[label] = tz.at(now.tv_sec).strftime('%H:%M:%S') + } +else + update_proc = proc{|now, tz, label| + time[label] = (now + (tz * 3600)).strftime('%H:%M:%S') + } +end + +# Fill the clocks pane +zones.each_with_index{|(zone, label), idx| + Ttk::Separator.new(left_bot).pack(:fill=>:x) if idx > 0 + Ttk::Label.new(left_bot, :text=>label, :anchor=>'w').pack(:fill=>:x) + Ttk::Label.new(left_bot, :textvariable=>time.ref(label), + :anchor=>'w').pack(:fill=>:x) +} + +# Timer start +every = proc{ + now = Time.now.utc + zones.each{|zone, label| update_proc.call(now, zone, label) } +} +TkRTTimer.new(1000, -1, every).start(0, every) + +# Fill the progress pane +Ttk::Progressbar.new(right_top, :mode=>:indeterminate).pack(:fill=>:both, :expand=>true).start + +# Fill the text pane +if Tk.windowingsystem != 'aqua' + # The trick with the ttk::frame makes the text widget look like it fits with + # the current Ttk theme despite not being a themed widget itself. It is done + # by styling the frame like an entry, turning off the border in the text + # widget, and putting the text widget in the frame with enough space to allow + # the surrounding border to show through (2 pixels seems to be enough). + f = Ttk::Frame.new(right_bot, :style=>Ttk::Entry) + txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0) + txt.pack(:fill=>:both, :expand=>true, :in=>f, :pady=>2, :padx=>2) + scr = txt.yscrollbar(Ttk::Scrollbar.new(frame)) + scr.pack(:side=>:right, :fill=>:y, :in=>right_bot) + f.pack(:fill=>:both, :expand=>true) + outer.pack(:fill=>:both, :expand=>true) +else + txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0) + scr = txt.yscrollbar(TkScrollbar.new(frame)) + scr.pack(:side=>:right, :fill=>:y, :in=>right_bot) + txt.pack(:fill=>:both, :expand=>true, :in=>right_bot) + outer.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>[6, 10]) +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb new file mode 100644 index 0000000..ec28253 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# +# ttkprogress.rb -- +# +# This demonstration script creates several progress bar widgets. +# +# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" + +if defined?($ttkprogress_demo) && $ttkprogress_demo + $ttkprogress_demo.destroy + $ttkprogress_demo = nil +end + +$ttkprogress_demo = TkToplevel.new {|w| + title("Progress Bar Demonstration") + iconname("ttkprogress") + positionWindow(w) +} + +base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true) + +Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top, :fill=>:x) +下にあるのは二つのプログレスバーです.\ +上のものは"determinate"タイプのプログレスバーで,\ +例えばプログラムが与えられたタスクを終了するまでにどのくらいかかるかを\ +示すときなどに用いられます.\ +下のものは"indeterminate"タイプのプログレスバーで,\ +例えばプログラムが実行中(busy)であるものの\ +終了までにどれくらいかかるかは分からないという状態を\ +示すときなどに用いられます.\ +いずれのプログレスバーも,すぐ下にあるボタンを使うことで\ +自動アニメーションモードのON/OFFを切替えることができます. +EOL + +## See Code / Dismiss buttons +Ttk::Frame.new(base_frame) {|frame| + sep = Ttk::Separator.new(frame) + Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + Ttk::Button.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'ttkprogress'}), + Ttk::Button.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + $ttkprogress_demo.destroy + $ttkprogress_demo = nil + }), + :padx=>4, :pady=>4) + grid_columnconfigure(0, :weight=>1) + pack(:side=>:bottom, :fill=>:x) +} + +frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) + +p1 = Ttk::Progressbar.new(frame, :mode=>:determinate) +p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate) + +start = Ttk::Button.new(frame, :text=>'Start Progress', + :command=>proc{ p1.start; p2.start }) +stop = Ttk::Button.new(frame, :text=>'Stop Progress', + :command=>proc{ p1.stop; p2.stop }) + +Tk.grid(p1, '-', :pady=>5, :padx=>10) +Tk.grid(p2, '-', :pady=>5, :padx=>10) +Tk.grid(start, stop, :padx=>10, :pady=>5) +start.grid_configure(:sticky=>'e') +stop.grid_configure(:sticky=>'w') +frame.grid_columnconfigure(:all, :weight=>1) + diff --git a/jni/ruby/ext/tk/sample/demos-jp/twind.rb b/jni/ruby/ext/tk/sample/demos-jp/twind.rb new file mode 100644 index 0000000..f13a137 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/twind.rb @@ -0,0 +1,292 @@ +# -*- coding: utf-8 -*- +# +# text (embedded windows) widget demo (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($twind_demo) && $twind_demo + $twind_demo.destroy + $twind_demo = nil +end + +# demo 用の toplevel widget を生成 +$twind_demo = TkToplevel.new {|w| + title("Text Demonstration - Embedded Windows") + iconname("Embedded Windows") + positionWindow(w) +} + +base_frame = TkFrame.new($twind_demo).pack(:fill=>:both, :expand=>true) + +# frame 生成 +$twind_buttons = TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc{ + tmppath = $twind_demo + $twind_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc{showCode 'twind'} + }.pack('side'=>'left', 'expand'=>'yes') +} +$twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +$twind_text = nil +TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2, + 'relief'=>'sunken') {|f| + $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font, + 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + TkScrollbar.new(f) {|s| + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + }.pack('side'=>'right', 'fill'=>'y') + }.pack('expand'=>'yes', 'fill'=>'both') +}.pack('expand'=>'yes', 'fill'=>'both') + +# タグ生成 +$tag_center = TkTextTag.new($twind_text, + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) +$tag_buttons = TkTextTag.new($twind_text, + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) + +# テキストの生成 +$twind_text.insert('end', + 'テキストwidget上に他のwidgetを組み込むことができます。') +$twind_text.insert('end', + '組み込みウィンドウと呼ばれ、任意のwidgetが可能です。') +$twind_text.insert('end', + '例えば、ここに2つのボタンwidgetが組み込まれています。') +$twind_text.insert('end', '最初のボタンをクリックすと水平方向のスクロールを') +TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) { + #text 'ON' + text 'オン' + command proc{textWindOn $twind_text,$twind_buttons} + cursor 'top_left_arrow' + }) +$twind_text.insert('end', "にします。また2つめのボタンをクリックすると\n") +$twind_text.insert('end', '水平方向のスクロールを') +TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) { + #text 'OFF' + text 'オフ' + command proc{textWindOff $twind_text} + cursor 'top_left_arrow' + }) +$twind_text.insert('end', 'にします。') + +$twind_text.insert('end', 'もうひとつの例です。') +TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) { + text 'ここをクリック' + command proc{textWindPlot $twind_text} + cursor 'top_left_arrow' + }) +$twind_text.insert('end', 'すると、x-yプロットがここに現れます。') +$mark_plot = TkTextMark.new($twind_text, 'insert') +$mark_plot.gravity='left' +$twind_text.insert('end', 'マウスでデータを描画することができます。') +TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) { + text '消去' + command proc{textWindDel $twind_text} + cursor 'top_left_arrow' + }) +$twind_text.insert('end', 'をクリックすると元に戻ります。 + +') + +$twind_text.insert('end', '組み込みウィンドウだけをテキストwidget上に、実際の') +$twind_text.insert('end', 'テキストはなしで組み込むことは便利です。') +$twind_text.insert('end', 'この場合は、テキストwidgetはウィンドウマネージャの') +$twind_text.insert('end', 'ように動作します。例えば、ここにはテキストwidgetに') +$twind_text.insert('end', 'よってボタンがきれいに並べられています。') +$twind_text.insert('end', 'これらのボタンで背景色を変えることができます') +$twind_text.insert('end', '("Default"で元の色に戻すことができます)。') +$twind_text.insert('end', '"Short"というボタンをクリックすると文字列の長さが') +$twind_text.insert('end', '変わります。すると自動的にテキストwidgetが') +$twind_text.insert('end', 'レイアウトを整えてくれます。') +$twind_text.insert('end', 'もう一度同じボタンを押すと元に戻ります。 + +') + +TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) {|b| + text 'デフォルト' + command proc{embDefBg $twind_text} + cursor 'top_left_arrow' + $tag_buttons.add('end') + }, + 'padx'=>3 ) +embToggle = TkVariable.new('Short') +TkTextWindow.new($twind_text, 'end', + 'window'=>TkCheckButton.new($twind_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) + +[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', + 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', + 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1', + 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' +].each{|twind_color| + TkTextWindow.new($twind_text, 'end', + 'window'=>TkButton.new($twind_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) +} + +# メソッド定義 +def textWindOn (w,f) + if defined? $twind_scroll + begin + $twind_scroll.destroy + rescue + end + $twind_scroll = nil + end + + base = TkWinfo.parent( TkWinfo.parent(w) ) + $twind_scroll = TkScrollbar.new(base) {|s| + orient 'horizontal' + command proc{|*args| w.xview(*args)} + w.xscrollcommand proc{|first,last| s.set first,last} + w.wrap 'none' + pack('after'=>f, 'side'=>'bottom', 'fill'=>'x') + } + + return nil +end + +def textWindOff (w) + if defined? $twind_scroll + begin + $twind_scroll.destroy + rescue + end + $twind_scroll = nil + end + w.xscrollcommand '' + w.wrap 'word' +end + +def textWindPlot (t) + if (defined? $twind_plot) && (TkWinfo.exist?($twind_plot)) + return + end + + $twind_plot = TkCanvas.new(t) { + relief 'sunken' + width 450 + height 300 + cursor 'top_left_arrow' + } + + if $tk_version =~ /^4.*/ + font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*' + else + font = 'Helvetica 18' + end + + TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2) + TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2) + TkcText.new($twind_plot, 225, 20, + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + + (0..10).each {|i| + x = 100 + (i * 30) + TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2) + TkcText.new($twind_plot, x, 254, + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + } + (0..5).each {|i| + y = 250 - (i * 40) + TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2) + TkcText.new($twind_plot, 96, y, + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + } + + for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] + x = 100 + (3*xx) + y = 250 - (4*yy)/5 + item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6, + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + item.addtag 'point' + end + + $twind_plot.itembind('point', 'Any-Enter', + proc{$twind_plot.itemconfigure 'current', 'fill', 'red'}) + $twind_plot.itembind('point', 'Any-Leave', + proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + $twind_plot.itembind('point', '1', + proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y") + $twind_plot.itembind('point', 'ButtonRelease-1', + proc{$twind_plot.dtag 'selected'}) + $twind_plot.bind('B1-Motion', + proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y") + while ($twind_text.get($mark_plot) =~ /[ \t\n]/) + $twind_text.delete $mark_plot + end + $twind_text.insert $mark_plot,"\n" + TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot) + $tag_center.add $mark_plot + $twind_text.insert $mark_plot,"\n" +end + +$embPlot = {'lastX'=>0, 'lastY'=>0} + +def embPlotDown (w, x, y) + w.dtag 'selected' + w.addtag_withtag 'selected', 'current' + w.raise 'current' + $embPlot['lastX'] = x + $embPlot['lastY'] = y +end + +def embPlotMove (w, x, y) + w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY'] + $embPlot['lastX'] = x + $embPlot['lastY'] = y +end + +def textWindDel (w) + if (defined? $twind_text) && TkWinfo.exist?($twind_plot) + $twind_text.delete $twind_plot + $twind_plot = nil + while ($twind_text.get($mark_plot) =~ /[ \t\n]/) + $twind_text.delete $mark_plot + end + $twind_text.insert $mark_plot," " + end +end + +def embDefBg (w) + w['background'] = w.configinfo('background')[3] +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/twind2.rb b/jni/ruby/ext/tk/sample/demos-jp/twind2.rb new file mode 100644 index 0000000..a783ba4 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/twind2.rb @@ -0,0 +1,384 @@ +# -*- coding: utf-8 -*- +# +# text (embedded windows) widget demo 2 (called by 'widget') +# + +# toplevel widget が存在すれば削除する +if defined?($twind2_demo) && $twind2_demo + $twind2_demo.destroy + $twind2_demo = nil +end + +# demo 用の toplevel widget を生成 +$twind2_demo = TkToplevel.new {|w| + title("Text Demonstration - Embedded Windows 2") + iconname("Embedded Windows") + positionWindow(w) +} + +base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true) + +# frame 生成 +$twind2_buttons = TkFrame.new(base_frame) {|frame| + TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2), + :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) + TkGrid('x', + TkButton.new(frame, :text=>'コード参照', + :image=>$image['view'], :compound=>:left, + :command=>proc{showCode 'twind2'}), + TkButton.new(frame, :text=>'閉じる', + :image=>$image['delete'], :compound=>:left, + :command=>proc{ + tmppath = $twind2_demo + $twind2_demo = nil + $showVarsWin[tmppath.path] = nil + tmppath.destroy + }), + :padx=>4, :pady=>4) + frame.grid_columnconfigure(0, :weight=>1) +} +$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# frame 生成 +$twind2_text = nil +TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2, + 'relief'=>'sunken') {|f| + $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font, + # 'width'=>'70', 'height'=>35, 'wrap'=>'word', + 'width'=>'70', 'height'=>35, 'wrap'=>'char', + 'highlightthickness'=>0, 'borderwidth'=>0 ){|t| + TkScrollbar.new(f) {|s| + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + }.pack('side'=>'right', 'fill'=>'y') + }.pack('expand'=>'yes', 'fill'=>'both') +}.pack('expand'=>'yes', 'fill'=>'both') + +# タグ生成 +$tag2_center = TkTextTag.new($twind2_text, + 'justify' =>'center', + 'spacing1'=>'5m', + 'spacing3'=>'5m' ) +$tag2_buttons = TkTextTag.new($twind2_text, + 'lmargin1'=>'1c', + 'lmargin2'=>'1c', + 'rmargin' =>'1c', + 'spacing1'=>'3m', + 'spacing2'=>0, + 'spacing3'=>0 ) + +# テキストの生成 +$twind2_text.insert('end', 'テキストウィジェットには色々な種類のアイテム') +$twind2_text.insert('end', '(動的なものや静的なものの両方があります)を') +$twind2_text.insert('end', '数多く含めることができます。そうしたアイテムは') +$twind2_text.insert('end', '行替え、タブ、中央揃えなどの様々な方法で') +$twind2_text.insert('end', '配置することができます。') +$twind2_text.insert('end', '加えて、テキストウィジェットの内容物が') +$twind2_text.insert('end', 'ウィンドウサイズに比べて大きすぎる場合でも') +$twind2_text.insert('end', 'すべての方向にスムーズにスクロールさせて') +$twind2_text.insert('end', '確認することが可能です。') +$twind2_text.insert('end', "\n\n") +$twind2_text.insert('end', 'テキストウィジェット上には他のウィジェットを') +$twind2_text.insert('end', '含めることもできます。こうしたものは') +$twind2_text.insert('end', '「埋め込みウィンドウ」と呼ばれ、その中に') +$twind2_text.insert('end', 'いかなるウィジェットでも詰め込むことができます。') +$twind2_text.insert('end', '例えば,ここには2つの') +$twind2_text.insert('end', 'ボタンウィジェットが埋め込まれています。') +$twind2_text.insert('end', '最初のボタンをクリックすると、') +$twind2_text.insert('end', '水平方向のスクロールを ') +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text) { + #text 'ON' + text 'オン' + command proc{textWindOn2 $twind2_text,$twind2_buttons} + cursor 'top_left_arrow' + }) +$twind2_text.insert('end', "にします。また、2つめのボタンをクリックすると\n") +$twind2_text.insert('end', '水平方向のスクロールを') +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text) { + #text 'OFF' + text 'オフ' + command proc{textWindOff2 $twind2_text} + cursor 'top_left_arrow' + }) +$twind2_text.insert('end', "にします。\n\n") + +$twind2_text.insert('end', '次はもうひとつの例です。') +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text) { + text 'ここをクリック' + command proc{textWindPlot2 $twind2_text} + cursor 'top_left_arrow' + }) +$twind2_text.insert('end', 'すると、x-yプロットがここに現れます。') +$mark2_plot = TkTextMark.new($twind2_text, 'insert') +$mark2_plot.gravity='left' +$twind2_text.insert('end', 'マウスでドラッグすることで、') +$twind2_text.insert('end', 'プロット上のデータ点を移動することができます。') +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text) { + text '消去' + command proc{textWindDel2 $twind2_text} + cursor 'top_left_arrow' + }) +$twind2_text.insert('end', 'をクリックすると元に戻ります。') +$twind2_text.insert('end', "\n\n") + +$twind2_text.insert('end', '表示するテキストなしに埋め込みウィンドウだけを') +$twind2_text.insert('end', 'テキストウィジェットに含めることも有用でしょう。') +$twind2_text.insert('end', 'この場合、テキストウィジェットは') +$twind2_text.insert('end', 'ジオメトリマネージャのように働きます。') +$twind2_text.insert('end', '例えば、ここにはテキストウィジェットに') +$twind2_text.insert('end', 'よってボタンがきれいに整列して配置されています。') +$twind2_text.insert('end', 'これらのボタンをクリックすることで、') +$twind2_text.insert('end', 'このテキストウィジェットの背景色を') +$twind2_text.insert('end', '変えることができます("デフォルト"ボタンで') +$twind2_text.insert('end', '元の色に戻すことができます)。') +$twind2_text.insert('end', '"Short"というボタンをクリックすると文字列の長さが') +$twind2_text.insert('end', '変わり、テキストウィジェットが自動的に') +$twind2_text.insert('end', 'レイアウトを整える様子を見ることができます。') +$twind2_text.insert('end', 'もう一度同じボタンを押すと元に戻ります。') +$twind2_text.insert('end', "\n") + +btn_default = TkButton.new($twind2_text) {|b| + text 'デフォルト' + command proc{embDefBg2 $twind2_text} + cursor 'top_left_arrow' +} +TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3) +embToggle = TkVariable.new('Short') +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkCheckButton.new($twind2_text) { + textvariable embToggle + indicatoron 0 + variable embToggle + onvalue 'A much longer string' + offvalue 'Short' + cursor 'top_left_arrow' + pady 5 + padx 2 + }, + 'padx'=>3, + 'pady'=>2 ) + +[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4', + 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1', + 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1', + 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4' +].each{|twind_color| + TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text) { + text twind_color + cursor 'top_left_arrow' + command proc{$twind2_text.bg twind_color} + }, + 'padx'=>3, + 'pady'=>2 ) +} + +$tag2_buttons.add(btn_default, 'end') + +$text_normal2 = {} +$text_normal2['border'] = $twind2_text.cget('borderwidth') +$text_normal2['highlight'] = $twind2_text.cget('highlightthickness') +$text_normal2['pad'] = $twind2_text.cget('padx') + +$twind2_text.insert('end', "\nborder width や highlightthickness, ") +$twind2_text.insert('end', "padding を通常の値から変更することも可能です。\n") + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Big borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigB2 $twind2_text + })) + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Small borders", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallB2 $twind2_text + })) + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Big highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigH2 $twind2_text + })) + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Small highlight", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallH2 $twind2_text + })) + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Big pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinBigP2 $twind2_text + })) + +TkTextWindow.new($twind2_text, 'end', + 'window'=>TkButton.new($twind2_text, :text=>"Small pad", + :cursor=>'top_left_arrow', + 'command'=>proc{ + textWinSmallP2 $twind2_text + })) + +$twind2_text.insert('end', "\n\n更にイメージもテキストウィジェットに") +$twind2_text.insert('end', "うまく配置できます:") + +TkTextImage.new($twind2_text, 'end', + 'image'=>TkBitmapImage.new(:file=>[ + $demo_dir, '..', + 'images', 'face.xbm' + ].join(File::Separator))) + +# メソッド定義 +def textWinBigB2(w) + w.borderwidth 15 +end +def textWinSmallB2(w) + w.borderwidth $text_normal2['border'] +end +def textWinBigH2(w) + w.highlightthickness 15 +end +def textWinSmallH2(w) + w.highlightthickness $text_normal2['highlight'] +end +def textWinBigP2(w) + w.configure(:padx=>15, :pady=>15) +end +def textWinSmallP2(w) + w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad']) +end + +def textWindOn2 (w,f) + if defined? $twind2_scroll + begin + $twind2_scroll.destroy + rescue + end + $twind2_scroll = nil + end + + base = TkWinfo.parent( TkWinfo.parent(w) ) + $twind2_scroll = TkScrollbar.new(base) {|s| + orient 'horizontal' + command proc{|*args| w.xview(*args)} + w.xscrollcommand proc{|first,last| s.set first,last} + w.wrap 'none' + pack('after'=>f, 'side'=>'bottom', 'fill'=>'x') + } + + return nil +end + +def textWindOff2 (w) + if defined? $twind2_scroll + begin + $twind2_scroll.destroy + rescue + end + $twind2_scroll = nil + end + w.xscrollcommand '' + #w.wrap 'word' + w.wrap 'char' +end + +def textWindPlot2 (t) + if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot)) + return + end + + $twind2_plot = TkCanvas.new(t) { + relief 'sunken' + width 450 + height 300 + cursor 'top_left_arrow' + } + + #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*' + font = 'Helvetica 18' + + TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2) + TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2) + TkcText.new($twind2_plot, 225, 20, + 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown') + + (0..10).each {|i| + x = 100 + (i * 30) + TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2) + TkcText.new($twind2_plot, x, 254, + 'text'=>10*i, 'font'=>font, 'anchor'=>'n') + } + (0..5).each {|i| + y = 250 - (i * 40) + TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2) + TkcText.new($twind2_plot, 96, y, + 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e') + } + + for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]] + x = 100 + (3*xx) + y = 250 - (4*yy)/5 + item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6, + 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2') + item.addtag 'point' + end + + $twind2_plot.itembind('point', 'Any-Enter', + proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'}) + $twind2_plot.itembind('point', 'Any-Leave', + proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'}) + $twind2_plot.itembind('point', '1', + proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y") + $twind2_plot.itembind('point', 'ButtonRelease-1', + proc{$twind2_plot.dtag 'selected'}) + $twind2_plot.bind('B1-Motion', + proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y") + while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/) + $twind2_text.delete $mark2_plot + end + $twind2_text.insert $mark2_plot,"\n" + TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot) + $tag2_center.add $mark2_plot + $twind2_text.insert $mark2_plot,"\n" +end + +$embPlot2 = {'lastX'=>0, 'lastY'=>0} + +def embPlotDown2 (w, x, y) + w.dtag 'selected' + w.addtag_withtag 'selected', 'current' + w.raise 'current' + $embPlot2['lastX'] = x + $embPlot2['lastY'] = y +end + +def embPlotMove2 (w, x, y) + w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY'] + $embPlot2['lastX'] = x + $embPlot2['lastY'] = y +end + +def textWindDel2 (w) + if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot) + $twind2_text.delete $twind2_plot + $twind2_plot = nil + while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/) + $twind2_text.delete $mark2_plot + end + $twind2_text.insert $mark2_plot," " + end +end + +def embDefBg2 (w) + w['background'] = w.configinfo('background')[3] +end diff --git a/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb b/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb new file mode 100644 index 0000000..31596cf --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- +# +# unicodeout.rb -- +# +# This demonstration script shows how you can produce output (in label +# widgets) using many different alphabets. +# +# based on Tcl/Tk8.4.4 widget demos + +if defined?($unicodeout_demo) && $unicodeout_demo + $unicodeout_demo.destroy + $unicodeout_demo = nil +end + +$unicodeout_demo = TkToplevel.new {|w| + title("Unicode Label Demonstration") + iconname("unicodeout") + positionWindow(w) +} + +base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true) + +TkLabel.new(base_frame, + :font=>$font, :wraplength=>'5.4i', :justify=>:left, + :text=><<EOL).pack(:side=>:top) +これは,Tkにおける非欧米文字集合を用いる言語に対するサポートについての\ +サンプルです.ただし,下の表示においてあなたが実際にどのような表示を\ +目にするかは,あなたの環境にどのような文字集合がインストールされているかに\ +大きく依存します.また,対象となる文字集合がインストールされていない場合に\ +どのような表示がなされるかもあなたの環境次第です.\ +「コード参照」ボタンを押してソースを表示し,\ +Unicodeout_SampleFrameクラスの@@fontの定義を書き換えて\ +(ファイルの内容は変更されません)\ +「再実行」ボタンのクリックを試してみてください. +スクリプトが可搬性を持つように,文字列は\\uXXXXという\ +Tclのエスケープ表現を用いたUNICODE文字列で書かれています.\ +文字列は,Tk::UTF8_Stringメソッドによって,\ +「UTF8形式の文字列である」という\ +エンコード情報付きの文字列オブジェクト\ +(Tclのエスケープ表現の変換済み)に変換して\ +ラベルウィジェットに渡している点に注意してください. +EOL +#' + +TkFrame.new(base_frame){|f| + pack(:side=>:bottom, :fill=>:x, :pady=>'2m') + + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ + $unicodeout_demo.destroy + $unicodeout_demo = nil + }).pack(:side=>:left, :expand=>true) + + TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{ + showCode 'unicodeout' + }).pack(:side=>:left, :expand=>true) +} + +wait_msg = TkLabel.new(base_frame, + :text=>"フォント読み込みの完了まで" + + "しばらくお待ち下さい...", + :font=>"Helvetica 12 italic").pack + +class Unicodeout_SampleFrame < TkFrame + @@font = $font + # @@font = 'Helvetica 14' + # @@font = 'Courier 12' + # @@font = 'clearlyu 16' + # @@font = 'fixed 12' + # @@font = 'Times 12' + # @@font = 'Newspaper 12' + # @@font = '{New century schoolbook} 12' + + def initialize(base) + super(base) + grid_columnconfig(1, :weight=>1) + end + + def add_sample(lang, *args) + sample_txt = Tk::UTF8_String(args.join('')) + l = TkLabel.new(self, :font=>@@font, :text=>lang+':', + :anchor=>:nw, :pady=>0) + #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt, + s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt, + :anchor=>:nw, :width=>30, :pady=>0) + Tk.grid(l, s, :sticky=>:ew, :pady=>0) + l.grid_config(:padx, '1m') + end +end +f = Unicodeout_SampleFrame.new(base_frame) +f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m') + +# Processing when some characters are missing might take a while, so make +# sure we're displaying something in the meantime... + +oldCursor = $unicodeout_demo.cursor +$unicodeout_demo.cursor('watch') +Tk.update + +f.add_sample('Arabic', + '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94', + '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D') +f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57') +f.add_sample('Simpl. Chinese', '\u6C49\u8BED') +f.add_sample('Greek', + '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ', + '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1') +f.add_sample('Hebrew', + '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ', + '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9') +f.add_sample('Japanese', + '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ', + '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA') +f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00') +f.add_sample('Russian', + '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ', + '\u044F\u0437\u044B\u043A') + +wait_msg.destroy +$unicodeout_demo.cursor(oldCursor) diff --git a/jni/ruby/ext/tk/sample/demos-jp/vscale.rb b/jni/ruby/ext/tk/sample/demos-jp/vscale.rb new file mode 100644 index 0000000..6ae513b --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/vscale.rb @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +require "tkcanvas" + +if defined?($vscale_demo) && $vscale_demo + $vscale_demo.destroy + $vscale_demo = nil +end + +$vscale_demo = TkToplevel.new {|w| + title("Vertical Scale Demonstration") + iconname("vscale") +} +positionWindow($vscale_demo) + +base_frame = TkFrame.new($vscale_demo).pack(:fill=>:both, :expand=>true) + +msg = TkLabel.new(base_frame) { + font $font + wraplength '3.5i' + justify 'left' +# text "下には矢印が1つと乗直なスケールが表示されています。\ +#スケール上でマウスボタン1をクリック、またはドラッグすると\ +#矢印の長さを変えることができます。" + text "にはバーと縦型のスケールが表示されています。スケールでマウスのボタン1 をクリックするかドラッグしてバーの高さを変えることができます。終ったら「了解」ボタンを押してください。" +} +msg.pack('side'=>'top', 'padx'=>'.5c') + +TkFrame.new(base_frame) {|frame| + TkButton.new(frame) { + #text '了解' + text '閉じる' + command proc { + tmppath = $vscale_demo + $vscale_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'コード参照' + command proc { showCode 'vscale' } + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +def setHeight(w, height) + height = height + 21 + y2 = height - 30 + if y2 < 21 + y2 = 21 + end + w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20 + w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20 +end + +TkFrame.new(base_frame) {|frame| + borderwidth 10 + canvas = TkCanvas.new(frame) {|c| + width 50 + height 50 + bd 0 + highlightthickness 0 + TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) { + fill 'SeaGreen3' + tags 'poly' + } + TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) { + fill 'black' + tags 'line' + } + }.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y') + scale = TkScale.new(frame) { + orient 'vertical' + length 284 + from 0 + to 250 + command proc{|value| setHeight(canvas, value)} + tickinterval 50 + }.pack('side'=>'left', 'anchor'=>'ne') + scale.set 75 +}.pack diff --git a/jni/ruby/ext/tk/sample/demos-jp/widget b/jni/ruby/ext/tk/sample/demos-jp/widget new file mode 100644 index 0000000..5f5dfb9 --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-jp/widget @@ -0,0 +1,1122 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +# 漢字コード設定 ( tk.rb のロード時の encoding 推定/設定に使われる ) +#if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!!! +unless defined?(::Encoding.default_external) + $KCODE = 'euc' +else + DEFAULT_TK_ENCODING = 'EUC-JP' +end + +# tk 関係ライブラリの読み込み +require 'tk' +# require 'tkafter' + +$RubyTk_WidgetDemo = true + +# widget demo directory 位置の獲得 +# $demo_dir = File.dirname($0) +$demo_dir = File.dirname(__FILE__) + +# root の生成 +$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"} + +# tk バージョンの取得 +$tk_version = Tk::TK_VERSION +$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i} +$tk_patchlevel = Tk::TK_PATCHLEVEL + +# tcl_platform 情報へのアクセスオブジェクト +$tk_platform = TkVarAccess.new('tcl_platform') + +# フォント設定 +####### +case($tk_version) +when /^4.*/ + $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) + knjfont = '-*--16-*-jisx0208.1983-0' + $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + knjfont) + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + '-*--24-*-jisx0208.1983-0') + +#when '8.0' +# $font = TkFont.new('Helvetica -12') +# $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12') +# TkOption.add('*kanjiFont', knjfont, 'startupFile') +# $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold') + +when /^8.*/ + $font = TkFont.new('Helvetica -12') + $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12') + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('Helvetica 14 bold', 'Gothic 14 bold') + +else + $font = TkFont.new('Helvetica 14', nil) + knjfont = '-*--16-*-jisx0208.1983-0' + $kanji_font = TkFont.new('Helvetic 14', knjfont) + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('Helvetica 14', + '-*--24-*-jisx0208.1983-0') +end +####### + +# イメージ設定 +$image = {} + +if $tk_major_ver >= 8 +$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y + PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e + ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6 + EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG + KSAthiaOjBMPDhQONBiXABEAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33 + KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5 + RMAq8LqcIYGsrjPsW1XOmFUEADs= +EOD +end + +if $tk_major_ver >= 8 +$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm + lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['print'] = TkPhotoImage.new(:height=>19, :format=>'GIF', :data=><<EOD) + R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK + UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr + jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM + lJyMtZyMvZyUlJyUrZyUvZycnKWctaWlpa2czq2lzrWtvbWtzrW1tb21xr21 + 1sa9zs693s7OztbO3tbO597W1t7W7+fe7+fn5////+/n7+/v7+/v9////wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC + CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH + CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D + Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS + PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE + KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK + DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M + DkkpsKV5OYhjBxCMYAICAigUEAA7 +EOD +end + +# メニュー設定 +if $tk_major_ver >= 8 + $root.add_menubar([[['File', 0], + ['About ... ', proc{aboutBox}, 0, '<F1>'], + '---', + ['Quit', proc{exit}, 0, 'Ctrl-Q'] + ]]) +else + TkMenubar.new($root, + [[['File', 0], + ['About ... ', proc{aboutBox}, 0, '<F1>'], + '---', + ['Quit', proc{exit}, 0, 'Ctrl-Q'] + ]]).pack('side'=>'top', 'fill'=>'x') +end +$root.bind('F1', proc{aboutBox}) +$root.bind('Control-q', proc{exit}) + +=begin +TkFrame.new($root){|frame| + TkMenubutton.new(frame){|button| + m = TkMenu.new(button) { + add 'command', 'label'=>'Quit', 'command'=>proc{exit}, 'underline'=>0 + } + menu m + text 'File' + underline 0 + }.pack('side'=>'left') +}.pack('side'=>'top', 'fill'=>'x') +=end + +# テキストボックスの生成 +if $tk_version =~ /^4\.[01]/ + scr = TkScrollbar.new($root, 'orient'=>'vertical') + txt = TkText.new($root) { + #wrap 'word' + wrap 'char' + width 70 + height 30 + font $font + setgrid 'yes' + yscrollcommand proc{|first,last| scr.set first,last} + } + scr.command(proc{|*args| txt.yview(*args)}) + scr.pack('side'=>'right', 'fill'=>'y') + txt.pack('expand'=>'yes', 'fill'=>'both') +else + textFrame = TkFrame.new($root) + scr = TkScrollbar.new($root, 'orient'=>'vertical', + 'highlightthickness'=>0, 'takefocus'=>1) { + pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1) + } + txt = TkText.new($root) { + #wrap 'word' + wrap 'char' + width 70 + height 30 + font $font + setgrid 'yes' + highlightthickness 0 + padx 4 + pady 2 + takefocus 0 + bd 1 + yscrollcommand proc{|first,last| scr.set first,last} + } + scr.command(proc{|*args| txt.yview(*args)}) + +# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both', 'padx'=>1) +# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both') +# textFrame.pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>2) + textFrame.pack('expand'=>'yes', 'fill'=>'both') + # $root.withdraw.deiconify + Tk.update_idletasks + txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both') + + statusBar = TkFrame.new($root) {|f| + if $tk_version =~ /^4.*/ + statusfont = '-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*' + else + statusfont = 'Helvetica 10' + end + $statusBarLabel = \ + TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', + 'font'=>statusfont) \ + .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both') + TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w', + 'font'=>statusfont) \ + .pack('side'=>'left', 'padx'=>2) + }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2) +end + +# テキストタグ設定 +if $tk_version =~ /^4.*/ + tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*') +else + tag_title = TkTextTag.new(txt, 'font'=>'Helvetica 18 bold') +end +#tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font) +#tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font) +tag_kanji_title = TkTextTag.new(txt, 'font'=>$msg_kanji_font) +tag_middle = TkTextTag.new(txt, 'font'=>$kanji_font) +tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c') + +if TkWinfo.depth($root) == 1 + tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', + 'underline'=>1) + $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', + 'underline'=>1) + tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white') +else + tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', + 'foreground'=>'blue', 'underline'=>1) + $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', + 'foreground'=>'#303080', 'underline'=>1) +# tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1, +# 'background'=>'SeaGreen3') + tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red') +end + +#tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')}) +tag_demo.bind('ButtonRelease-1', + proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y') + +lastLine = TkVariable.new("") +newLine = TkVariable.new("") +tag_demo.bind('Enter', proc{|x,y| + lastLine.value = txt.index("@#{x},#{y} linestart") + tag_hot.add(lastLine.value, "#{lastLine.value} lineend") + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') +tag_demo.bind('Leave', + proc{ + tag_hot.remove('1.0','end') + txt.configure('cursor','xterm') + $statusBarLabel.configure('text'=>"") + }) +tag_demo.bind('Motion', proc{|x, y| + newLine.value = txt.index("@#{x},#{y} linestart") + if newLine.value != lastLine.value + tag_hot.remove('1.0','end') + lastLine.value = newLine.value + if ( txt.tag_names("@#{x},#{y}").find{|t| + t.kind_of?(String) && t =~ /^demo-/ + } ) + tag_hot.add(lastLine.value, + "#{lastLine.value} lineend -1 chars") + end + end + showStatus txt, txt.index("@#{x},#{y}") + }, + '%x %y') + +# テキスト生成 +txt.insert('end', 'Ruby/Tk : Widget', tag_title) +#txt.insert('end', " デモンストレーション\n", tag_middle) +txt.insert('end', " デモンストレーション\n", tag_kanji_title) +txt.insert('end', <<"EOT") + +このアプリケーションは、Tk Widget を用いてどのようなことができるか\ +を示すための、いくつかの小さなスクリプトに対するフロントエンドを提\ +供しています。以下に順番に挙げられているデモンストレーションを実行\ +するにはマウスでクリックしてください。デモンストレーションのウィン\ +ドウが現れると、デモンストレーションを生成した Ruby/Tk のコードを見\ +るために、"コード参照"ボタンをクリックすることができます。あなたが\ +望むなら、そのコードを修正することができます。修正したコードでデモ\ +ンストレーションを再実行するためには、コードが書かれたウィンドウに\ +ある"デモ再実行" ボタンをクリックしてください。\ +コードを修正してもオリジナルのファイルが書き換えられることは\ +ありませんから、心配せずに色々な変更を試してみてください。 + +一部のデモでは、比較的最近のバージョンの Tk でなければサポートして\ +いない機能を使って実装しています(例えば Tk8.4 以上など)。そのため、\ +そうした機能を持たない Tk ライブラリを使っている場合には、そうした\ +デモは正しく動きません。そのような機能が必要であれば、それをサポート\ +している Tk ライブラリを使うように tcltklib をコンパイルしなおして\ +ください。 + +もしあなたの Tk が (最初から含むかインストールしたかにより) \ +Ttk (Tile) 拡張を利用できる状態であるなら、\ +Ttk 拡張のデモ (sample/tkextlib/tile/demo.rb) もぜひ試してみてください。 +( 多分,現在のあなたの環境には Ttk 拡張は\ +#{ +begin + require 'tkextlib/tile' + "すでに導入されています" +rescue + "まだインストールされていません" +end +}\ +。) +Ttk 拡張は、Tk8.5 以上では標準の機能として組み込まれています。 + + +EOT + +#txt.insert('end',"ラベル, ボタン, チェックボタン, ラジオボタン\n",tag_middle) +txt.insert('end', "ラベル, ボタン, チェックボタン, ラジオボタン\n", + tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. ラベル (テキスト, ビットマップ)\n", + tag_demo, "demo-label") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. ラベルとUNICODEテキスト (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-unicodeout") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. ボタン \n", tag_demo, "demo-button") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. チェックボタン (複数を選択可能)\n", + tag_demo, "demo-check") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. 3状態チェックボタン (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-check2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. ラジオボタン (任意の一つを選択可能)\n", + tag_demo, "demo-radio") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "7. ラジオボタン (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-radio2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "8. 3状態ラジオボタン (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-radio3") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "9. ボタンで作られた15-パズルゲーム\n", + tag_demo, "demo-puzzle") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "10. ビットマップを使用したアイコンボタン\n", + tag_demo, "demo-icon") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "11. 画像を表示する二つのラベル\n", + tag_demo, "demo-image1") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "12. 画像を見るための簡単なユーザインターフェース\n", + tag_demo, "demo-image2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "13. 画像を見るための簡単なユーザインターフェース (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-image3") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "14. ラベル付きフレーム (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-labelframe") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "15. テーマに対応したウィジェットの簡単な例 (Tile/Ttk拡張への対応が必要)\n", + tag_demo, "demo-ttkbut") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "リストボックス\n", tag_middle) +txt.insert('end', "リストボックス\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. 都道府県.\n", tag_demo, "demo-states") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 色: アプリケーションのための配色を変える\n", + "#{tag_demo.id} demo-colors") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. 格言集\n", tag_demo, "demo-sayings") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. 国についてのマルチカラムリスト (Tile/Ttk拡張への対応が必要)\n", + tag_demo, "demo-mclist") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. ディレクトリブラウザ (Tile/Ttk拡張への対応が必要)\n", + tag_demo, "demo-tree") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "エントリとスピンボックス\n", tag_middle) +txt.insert('end', "エントリ\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. スクロールバーなし\n", tag_demo, "demo-entry1") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. スクロールバーあり\n", tag_demo, "demo-entry2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. 認証処理付きのエントリボックスとパスワードフィールド (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-entry3") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. スピンボックス (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-spin") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. コンボボックス (Tile/Ttk拡張への対応が必要)\n", + tag_demo, "demo-combo") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. 簡単なフォーム\n", tag_demo, "demo-form") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "テキスト\n", tag_middle) +txt.insert('end', "テキスト\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. 基本的なテキスト\n", tag_demo, "demo-text") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 表示スタイル.\n", tag_demo, "demo-style") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. ハイパーテキスト(タグバインド).\n", + tag_demo, "demo-bind") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. ウィンドウを埋め込んだテキスト\n", + tag_demo, "demo-twind") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. ウィンドウを埋め込んだテキスト (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-twind2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. 検索\n", tag_demo, "demo-search") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "7. テキストウィジェットの対等化(peering) (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-textpeer") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "キャンバス\n", tag_middle) +txt.insert('end', "キャンバス\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. アイテムの型\n", tag_demo, "demo-items") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 2 次元のプロット\n", tag_demo, "demo-plot") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. テキスト\n", tag_demo, "demo-ctext") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. 矢印の形\n", tag_demo, "demo-arrow") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. ルーラー\n", tag_demo, "demo-ruler") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. フロアプラン\n", tag_demo, "demo-floor") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "7. フロアプラン (異なるキャンバスアイテム作成方法を使用)\n", tag_demo, "demo-floor2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "8. スクロール可能なキャンバス\n", + tag_demo, "demo-cscroll") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "9. チェスボード上の騎士の巡回 (Tile/Ttk拡張への対応が必要)\n", + tag_demo, "demo-knightstour") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "スケールとプログレスバー\n", tag_middle) +txt.insert('end', "スケールとプログレスバー\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. 垂直スケール\n", tag_demo.id, "demo-vscale") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 水平スケール\n", tag_demo.id, "demo-hscale") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. プログレスバー (Tile/Ttk拡張への対応が必要)\n", tag_demo.id, "demo-ttkprogress") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +txt.insert('end', "ペインドウィンドウとノートブック\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. 水平方向 (機能に対応したバージョンのTkが必要)\n", + tag_demo.id, "demo-paned1") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 垂直方向 (機能に対応したバージョンのTkが必要)\n", + tag_demo.id, "demo-paned2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. テーマに対応した埋め込みペイン (Tile/Ttk拡張への対応が必要)\n", + tag_demo.id, "demo-ttkpane") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. ノートブックウィジェット (Tile/Ttk拡張への対応が必要)\n", + tag_demo.id, "demo-ttknote") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "メニューとツールバー\n", tag_middle) +txt.insert('end', "メニューとツールバー\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. メニューとカスケードを含んだウィンドウ\n", + tag_demo, "demo-menu") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. メニューとカスケードを含んだウィンドウ (Tk8.x 専用)\n", + tag_demo, "demo-menu8x") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. 〃 (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-menu84") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. メニューボタン (Tk8.x 専用)\n", + tag_demo, "demo-menubu") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "5. テーマに対応したメニューボタン (Tile/Ttk拡張への対応が必要)\n", + tag_demo.id, "demo-ttkmenu") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. テーマに対応したツールバー (Tile/Ttk拡張への対応が必要)\n", + tag_demo.id, "demo-toolbar") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "ダイアログウィンドウ\n", tag_middle) +txt.insert('end', "ダイアログウィンドウ\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. メッセージボックス\n", tag_demo, "demo-msgbox") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 詳細テキスト付きのメッセージボックス (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-msgbox2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. ファイル選択ダイアログ\n", tag_demo, "demo-filebox") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. 色選択ダイアログ\n", tag_demo, "demo-clrpick") +txt.insert('end', " \n ", tag_demospace) + +txt.insert('end', "\n") +#txt.insert('end', "アニメーション\n", tag_middle) +txt.insert('end', "アニメーション\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. アニメーションラベル (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-anilabel") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. 波形のアニメーション (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-aniwave") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. 振り子のシミュレーション (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-pendulum") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "4. A celebration of Rube Goldberg (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-goldberg") + +txt.insert('end', "\n") +#txt.insert('end', "その他\n", tag_middle) +txt.insert('end', "その他\n", tag_kanji_title) +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "1. 組み込みのビットマップ\n", tag_demo, "demo-bitmap") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "2. モーダルダイアログ(ローカルグラブ)\n", + tag_demo, "demo-dialog1") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "3. モーダルダイアログ(グローバルグラブ)\n", + tag_demo, "demo-dialog2") +txt.insert('end', " \n ", tag_demospace) + +txt.state('disabled') +scr.focus + +################################ +# method 定義 +################################ +def positionWindow(w) + w.geometry('+300+300') +end + +# 親ウィジェットと,変数名と TkVariable との組(配列)の並びを渡す +$showVarsWin = {} +def showVars1(parent, *args) + if $showVarsWin[parent.path] + begin + $showVarsWin[parent.path].destroy + rescue + end + end + top = TkToplevel.new(parent) {|w| + title "Variable values" + base = TkFrame.new(w).pack(:fill=>:both, :expand=>true) + TkLabel.new(base) { + text "変数値:" + width 20 + anchor 'center' + if $tk_version =~ /^4.*/ + font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*' + else + font 'Helvetica 14' + end + }.pack('side'=>'top', 'fill'=>'x') + len = 1 + args.each{|vnam,vbody| + len = vnam.to_s.length if vnam.to_s.length > len + } + args.each{|vnam,vbody| + TkFrame.new(base){|f| + #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left') + TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left') + TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\ + .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x') + }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x') + } + TkButton.new(base) { + text "了解" + command proc{w.destroy} + }.pack('side'=>'bottom', 'pady'=>2) + } + $showVarsWin[parent.path] = top +end + +def showVars2(parent, *args) + if $showVarsWin[parent.path] + begin + $showVarsWin[parent.path].destroy + rescue + end + end + $showVarsWin[parent.path] = TkToplevel.new(parent) {|top| + title "Variable values" + + base = TkFrame.new(top).pack(:fill=>:both, :expand=>true) + + TkLabelFrame.new(base, :text=>"変数値:", + :font=>{:family=>'Helvetica', :size=>14}){|f| + args.each{|vnam,vbody| + TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), + TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), + :padx=>2, :pady=>2, :sticky=>'w') + } + + f.grid(:sticky=>'news', :padx=>4) + f.grid_columnconfig(1, :weight=>1) + f.grid_rowconfig(100, :weight=>1) + } + TkButton.new(base, :text=>"了解", :width=>8, :default=>:active, + :command=>proc{top.destroy}){|b| + top.bind('Return', proc{b.invoke}) + top.bind('Escape', proc{b.invoke}) + + b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4]) + } + base.grid_columnconfig(0, :weight=>1) + base.grid_rowconfig(0, :weight=>1) + } +end + +if $tk_major_ver < 8 + alias showVars showVars1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 4 + alias showVars showVars1 +else # ver >= 8.4 + alias showVars showVars2 +end + +# 疑似トップレベルサポート +module PseudoToplevel_Evaluable + def pseudo_toplevel_eval(body = Proc.new) + Thread.current[:TOPLEVEL] = self + begin + body.call + ensure + Thread.current[:TOPLEVEL] = nil + end + end + + def pseudo_toplevel_evaluable? + @pseudo_toplevel_evaluable + end + def pseudo_toplevel_evaluable=(mode) + @pseudo_toplevel_evaluable = (mode)? true: false + end + + def self.extended(mod) + mod.__send__(:extend_object, mod) + mod.instance_variable_set('@pseudo_toplevel_evaluable', true) + end +end + +class Object + alias __method_missing__ method_missing + private :__method_missing__ + + def method_missing(id, *args) + begin + has_top = (top = Thread.current[:TOPLEVEL]) && + top.respond_to?(:pseudo_toplevel_evaluable?) && + top.pseudo_toplevel_evaluable? && + top.respond_to?(id) + rescue Exception => e + has_top = false + end + + if has_top + top.__send__(id, *args) + else + __method_missing__(id, *args) + end + end +end + +class Proc + def initialize(*args, &b) + super + @__pseudo_toplevel__ = Thread.current[:TOPLEVEL] + end + + alias __call__ call + def call(*args, &b) + if top = @__pseudo_toplevel__ + orig_top = Thread.current[:TOPLEVEL] + Thread.current[:TOPLEVEL] = top + begin + __call__(*args, &b) + ensure + Thread.current[:TOPLEVEL] = orig_top + end + else + __call__(*args, &b) + end + end +end + +def proc(&b) + Proc.new(&b) +end +def lambda(&b) + Proc.new(&b) +end + +def _null_binding + Module.new.instance_eval{extend PseudoToplevel_Evaluable} + # binding + # Module.new.instance_eval{binding} +end +private :_null_binding + +def eval_samplecode(code, file=nil) + #eval(code) + #_null_binding.pseudo_toplevel_eval{ eval(code) } + #Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } } + Thread.new{ + _null_binding.pseudo_toplevel_eval{ + begin + if file + eval(code, binding, "(eval:#{file})") + else + eval(code) + end + rescue Exception=>e + #p e + TkBgError.show(e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------") + end + } + } + Tk.update rescue nil +end + +# テキスト上での click に対する動作 +def invoke(txt, idx) + tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/} + return unless tag + + cursor = txt.cget('cursor') + txt.cursor('watch') + Tk.update rescue nil + # eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding) + # Tk.update + eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb') + txt.cursor(cursor) + + $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars") +end +=begin +def invoke (txt, idx) + tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/} + return unless tag + current_cursor = txt.cget('cursor') + txt.cursor('watch') + Tk.update +# eval `cat #{tag[5..-1]}.rb` +# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb` + eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join + Tk.update +# txt.cursor('xterm') + txt.cursor(current_cursor) + + $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars") +end +=end + +# 状態表示 +def showStatus (txt, index) + tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/} + cursor = txt.cget('cursor') + unless tag + $statusBarLabel.configure('text', " ") + newcursor = 'xterm' + else + demoname = tag[5..-1] + $statusBarLabel.configure('text', + "サンプルプログラム \"#{demoname}\" の実行 ") + newcursor = 'hand2' + end + txt.configure('cursor'=>newcursor) if cursor != newcursor +end + +# ソースコードの表示 +def showCode1(demo) + file = "#{demo}.rb" + $code_window = nil unless defined? $code_window + if $code_window == nil || TkWinfo.exist?($code_window) == false + $code_window = TkToplevel.new(nil) + f = TkFrame.new($code_window) + + TkButton.new(f) { + #text "了解" + text "閉じる" + command proc{ + $code_window.destroy + $code_window = nil + } + }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2) + TkButton.new(f) { + text "再実行" + # command proc{eval($code_text.get('1.0','end'), _null_binding)} + command proc{eval_samplecode($code_text.get('1.0','end'), '<viewer>')} + }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2) + + TkLabel.new(f,'text'=>'line:').pack('side'=>'left') + linenum =TkLabel.new(f,'text'=>'').pack('side'=>'left') + TkLabel.new(f,'text'=>' pos:').pack('side'=>'left') + posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left') + + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + + f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x') + + if $tk_version =~ /^4\.[01]/ + s = TkScrollbar.new($code_window, 'orient'=>'vertical') + $code_text = TkText.new($code_window) { + height 40 + setgrid 'yes' + yscrollcommand proc{|first,last| s.set first,last} + } + s.command(proc{|*args| $code_text.yview(*args)}) + s.pack('side'=>'right', 'fill'=>'y') + $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both') + else + TkFrame.new($code_window) {|f| + pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1) + + hs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'horizontal') + vs = TkScrollbar.new($code_window, 'highlightthickness'=>0, + 'orient'=>'vertical') + $code_text = TkText.new($code_window) {|t| + height 40 + #wrap 'word' + wrap 'char' + xscrollcommand proc{|first,last| hs.set first,last} + yscrollcommand proc{|first,last| vs.set first,last} + setgrid 'yes' + highlightthickness 0 + pady 2 + padx 3 + hs.command(proc{|*args| $code_text.xview(*args)}) + vs.command(proc{|*args| $code_text.yview(*args)}) + } + + $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1, + 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') +# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0, +# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news') + TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) + } + end + + btag = TkBindTag.new + + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') + + btags = $code_text.bindtags + btags.insert(btags.index($code_text.class) + 1, btag) + $code_text.bindtags = btags + + else + $code_window.deiconify + $code_window.raise + end + + $code_window.title("Demo code: #{file}") + $code_window.iconname(file) + code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read } + $code_text.delete('1.0', 'end') + code.force_encoding('EUC-JP') if defined?(::Encoding.default_external) + $code_text.insert('1.0', code) + TkTextMarkInsert.new($code_text,'1.0') + $set_linenum.call($code_text) +end + +def showCode2(demo) + file = "#{demo}.rb" + $code_window = nil unless defined? $code_window + if $code_window == nil || TkWinfo.exist?($code_window) == false + $code_window = TkToplevel.new(nil) + tf = TkFrame.new($code_window) + $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30, + :wrap=>'word', :bd=>1, :setgrid=>true, + :highlightthickness=>0, :pady=>2, :padx=>3) + xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + TkGrid($code_text, yscr, :sticky=>'news') + #TkGrid(xscr) + tf.grid_rowconfigure(0, :weight=>1) + tf.grid_columnconfigure(0, :weight=>1) + + bf = TkFrame.new($code_window) + + lf = TkFrame.new(bf) + TkLabel.new(lf, :text=>'line:').pack(:side=>:left) + linenum =TkLabel.new(lf, :text=>'').pack(:side=>:left) + TkLabel.new(lf, :text=>' pos:').pack(:side=>:left) + posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left) + + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + + #b_dis = TkButton.new(bf, :text=>'了解', :default=>:active, + b_dis = TkButton.new(bf, :text=>'閉じる', :default=>:active, + :command=>proc{ + $code_window.destroy + $code_window = nil + }, + :image=>$image['delete'], :compound=>:left) + b_prn = TkButton.new(bf, :text=>'印刷', + :command=>proc{printCode($code_text, file)}, + :image=>$image['print'], :compound=>:left) + b_run = TkButton.new(bf, :text=>'再実行', + :command=>proc{ + # eval($code_text.get('1.0','end'), _null_binding) + eval_samplecode($code_text.get('1.0','end'), '<viewer>') + }, + :image=>$image['refresh'], :compound=>:left) + + TkGrid(lf, 'x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4]) + bf.grid_columnconfigure(1, :weight=>1) + + TkGrid(tf, :sticky=>'news') + TkGrid(bf, :sticky=>'ew') + $code_window.grid_columnconfigure(0, :weight=>1) + $code_window.grid_rowconfigure(0, :weight=>1) + + $code_window.bind('Return', proc{|win| + b_dis.invoke unless win.kind_of?(TkText) + }, '%W') + $code_window.bindinfo('Return').each{|cmd, arg| + $code_window.bind_append('Escape', cmd, arg) + } + + btag = TkBindTag.new + + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') + + btags = $code_text.bindtags + btags.insert(btags.index($code_text.class) + 1, btag) + $code_text.bindtags = btags + + else + $code_window.deiconify + $code_window.raise + end + + $code_window.title("Demo code: #{file}") + $code_window.iconname(file) + code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read } + $code_text.delete('1.0', 'end') + code.force_encoding('EUC-JP') if defined?(::Encoding.default_external) + $code_text.insert('1.0', code) + TkTextMarkInsert.new($code_text,'1.0') + $set_linenum.call($code_text) +end + +if $tk_major_ver < 8 + alias showCode showCode1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 4 + alias showCode showCode1 +else # ver >= 8.4 + alias showCode showCode2 +end + + +# printCode -- +# Prints the source code currently displayed in the See Code dialog. +# Much thanks to Arjen Markus for this. +# +# Arguments: +# txt - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) + +def printCode(txt, file) + code = txt.get('1.0', 'end - 1c') + dir = '.' + dir = ENV['HOME'] if ENV['HOME'] + dir = ENV['TMP'] if ENV['TMP'] + dir = ENV['TEMP'] if ENV['TEMP'] + + fname = [dir, 'tkdemo-' + file].join(File::Separator) + open(fname, 'w'){|fid| fid.print(code)} + begin + case Tk::TCL_PLATFORM('platform') + when 'unix' + msg = `lp -c #{fname}` + unless $?.exitstatus == 0 + Tk.messageBox(:title=>'Print spooling failure', + :message=>'エラーが発生しました.' + + '印刷に失敗したものと思われます : ' + msg) + end + when 'windows' + begin + printTextWin32(fname) + rescue => e + Tk.messageBox(:title=>'Print spooling failure', + :message=>'エラーが発生しました.' + + '印刷に失敗したものと思われます : ' + + e.message) + end + when 'macintosh' + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'印刷機能はまだ実装されていません') + else + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'検出された環境 ' + + Tk::TCL_PLATFORM('platform') + + ' は未知の環境であるため,' + + '印刷機能は実装されていません: ') + end + ensure + File.delete(fname) + end +end + +# printTextWin32 -- +# Print a file under Windows +# +# Arguments: +# filename - Name of the file +# +def printTextWin32(fname) + require 'win32/registry' + begin + app = Win32::Registry::HKEY_CLASSES_ROOT['.txt'] + pcmd = nil + Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg| + pcmd = reg['command'] + } + rescue + app = Tk.tk_call('auto_execok', 'notepad.exe') + pcmd = "#{app} /p %1" + end + + pcmd.gsub!('%1', fname) + puts pcmd + cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd + + msg = `#{cmd}` + unless $?.exitstatus == 0 + fail RuntimeError, msg + end +end + +# aboutBox +# +# Pops up a message box with an "about" message +# +def aboutBox + Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', + 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.7.1-jp\n\n" + + "based on demos of Tk8.1 -- 8.5 " + + "( Copyright of Tcl/Tk demos:: " + + "(c) 1996-1997 Sun Microsystems, Inc. / " + + "(c) 1997-2000 Ajuba Solutions, Inc. / " + + "(c) 2001-2007 Donal K. Fellows / " + + "(c) 2002-2007 Daniel A. Steffen )\n\n" + + "Your Ruby & Tk Version ::\n" + + "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}\n\n" + + "Ruby/Tk release date :: tcltklib #{TclTkLib::RELEASE_DATE}; tk #{Tk::RELEASE_DATE}") +end + +#################################### +# 引数で指定されたデモを起動する +no_launcher = false +if ARGV[0] == '-n' + ARGV.shift + no_launcher = true if ARGV.size > 0 +else + # show the root widget to make it lower then demo windows + Tk.update rescue nil +end +ARGV.each{|cmd| + if cmd =~ /(.*).rb/ + cmd = $1 + end + #eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, + # _null_binding) + eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, cmd + '.rb') +} +if no_launcher + $root.withdraw # hide root window + Thread.start{ + loop do + count = 0 + $root.winfo_children.each{|w| + count += 1 if w.kind_of?(TkToplevel) + } + $root.destroy if count == 0 + end + } +end + +################################ +# イベント待ちに入る +Tk.mainloop |