summaryrefslogtreecommitdiff
path: root/ext/tk/sample/tkextlib/vu
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/sample/tkextlib/vu')
-rw-r--r--ext/tk/sample/tkextlib/vu/canvItems.rb68
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker.rb4
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker2.rb24
-rw-r--r--ext/tk/sample/tkextlib/vu/dial.rb78
-rw-r--r--ext/tk/sample/tkextlib/vu/oscilloscope.rb34
-rw-r--r--ext/tk/sample/tkextlib/vu/pie.rb28
-rw-r--r--ext/tk/sample/tkextlib/vu/vu.rb48
7 files changed, 142 insertions, 142 deletions
diff --git a/ext/tk/sample/tkextlib/vu/canvItems.rb b/ext/tk/sample/tkextlib/vu/canvItems.rb
index c3e563058c..33acf4f7e7 100644
--- a/ext/tk/sample/tkextlib/vu/canvItems.rb
+++ b/ext/tk/sample/tkextlib/vu/canvItems.rb
@@ -10,63 +10,63 @@ xbm = File.join(File.dirname(File.expand_path(__FILE__)), 'm128_000.xbm')
sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ]
l0 = TkLabel.new(:width=>128, :height=>128,
- :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
c0 = TkCanvas.new(:width=>80, :height=>80,
- :insertwidth=>0, :highlightthickness=>0,
- :selectborderwidth=>0, :borderwidth=>2,
- :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5,
- :anchor=>:c)
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
st = Tk::Vu::TkcStripchart.new(c0, 3, 3, 80, 80,
- :background=>"#b7c0d7", :fill=>'slategray3',
- :jumpscroll=>1, :outline=>'black',
- :scaleline=>'blue', :stripline=>'red',
- :selected=>1, :values=>sval)
+ :background=>"#b7c0d7", :fill=>'slategray3',
+ :jumpscroll=>1, :outline=>'black',
+ :scaleline=>'blue', :stripline=>'red',
+ :selected=>1, :values=>sval)
TkcText.create(c0, 40, 40,
- :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text')
+ :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text')
l1 = TkLabel.new(:width=>128, :height=>128,
- :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
c1 = TkCanvas.new(:width=>80, :height=>80,
- :insertwidth=>0, :highlightthickness=>0,
- :selectborderwidth=>0, :borderwidth=>2,
- :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5,
- :anchor=>:c)
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
bar1 = Tk::Vu::TkcBarchart.new(c1, 3, 3, 80, 80,
- :background=>"#b7c0d7", :scalevalue=>10.0,
- :autocolor=>true, :selected=>1,
- :outline=>'black', :barline=>'yellow',
- :scalelinestyle=>0)
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :barline=>'yellow',
+ :scalelinestyle=>0)
bar2 = Tk::Vu::TkcBarchart.new(c1, 53, 3, 80, 80,
- :background=>"#b7c0d7", :scalevalue=>10.0,
- :autocolor=>true, :selected=>1,
- :outline=>'black', :fill=>"#b7c0d7",
- :barline=>'red', :scalelinestyle=>22)
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :fill=>"#b7c0d7",
+ :barline=>'red', :scalelinestyle=>22)
l2 = TkLabel.new(:width=>128, :height=>128,
- :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
c2 = TkCanvas.new(:width=>80, :height=>80,
- :insertwidth=>0, :highlightthickness=>0,
- :selectborderwidth=>0, :borderwidth=>2,
- :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5,
- :anchor=>:c)
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
begin
stick = Tk::Vu::TkcSticker.new(c2, 3, 3, 80, 80,
- :text=>"Tcl/Tk", :space=>0, :color=>'red',
- :outline=>'red', :font=>'Helvetica 14 bold',
- :fill=>'', :stipple=>'', :bar=>'blue',
- :orient=>:vertical, :anchor=>:s,
- :relheight=>1.0, :relwidth=>0.15,
- :relx=>0.1, :rely=>0.0)
+ :text=>"Tcl/Tk", :space=>0, :color=>'red',
+ :outline=>'red', :font=>'Helvetica 14 bold',
+ :fill=>'', :stipple=>'', :bar=>'blue',
+ :orient=>:vertical, :anchor=>:s,
+ :relheight=>1.0, :relwidth=>0.15,
+ :relx=>0.1, :rely=>0.0)
rescue
stick = nil
TkcText.new(c2, 40, 10, :text=>"No Sticker Item")
diff --git a/ext/tk/sample/tkextlib/vu/canvSticker.rb b/ext/tk/sample/tkextlib/vu/canvSticker.rb
index 431ca56fd7..e2cd604975 100644
--- a/ext/tk/sample/tkextlib/vu/canvSticker.rb
+++ b/ext/tk/sample/tkextlib/vu/canvSticker.rb
@@ -15,7 +15,7 @@ begin
st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
rescue
Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
- :message=>"This build of vu does not include the sticker item")
+ :message=>"This build of vu does not include the sticker item")
exit
end
#st.delete
@@ -57,7 +57,7 @@ steps << proc{
steps << proc{
puts 'A vertical bar appears in the lower right region and text jumps to the left.'
st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7,
- :relx=>0.6, :rely=>0.3, :bar=>'red')
+ :relx=>0.6, :rely=>0.3, :bar=>'red')
}
steps << proc{
diff --git a/ext/tk/sample/tkextlib/vu/canvSticker2.rb b/ext/tk/sample/tkextlib/vu/canvSticker2.rb
index 1e6b59a186..f54e748660 100644
--- a/ext/tk/sample/tkextlib/vu/canvSticker2.rb
+++ b/ext/tk/sample/tkextlib/vu/canvSticker2.rb
@@ -11,7 +11,7 @@ begin
st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
rescue
Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
- :message=>"This build of vu does not include the sticker item")
+ :message=>"This build of vu does not include the sticker item")
exit
end
@@ -21,7 +21,7 @@ c.destroy
#--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center}
#sti_conf = [ [10, 10, 180, 180], "Sticker ����@�����", :center ]
-#txt_conf = [ [210, 210], "Text ����@�����", :center ]
+#txt_conf = [ [210, 210], "Text ����@�����", :center ]
sti_conf = [ [10, 10, 350, 350],
Tk::UTF8_String("Sticker ����@�����"), :center ]
txt_conf = [ [250, 250],
@@ -65,32 +65,32 @@ txt = TkcText.new(c, txt_conf[0]){
anchor txt_conf[2]
disabledfill ''
disabledstipple ''
- fill 'blue'
- font fnt
+ fill 'blue'
+ font fnt
justify :left
offset '0,0'
state ''
stipple ''
- tags ['tex']
+ tags ['tex']
text txt_conf[1]
width 0
}
#---BINDINGS
c.bind('2', proc{
- sti[:orient] = :horizontal
- txt[:width] = 0 # horizontal
+ sti[:orient] = :horizontal
+ txt[:width] = 0 # horizontal
})
c.bind('3', proc{
- sti[:orient] = :vertical
- txt[:width] = 1 # top down
+ sti[:orient] = :vertical
+ txt[:width] = 1 # top down
})
Tk.root.bind('p', proc{
- c.postscript(:file=>'DEMO.ps')
- puts "DEMO.ps printed"
- })
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
Tk.root.bind('q', proc{exit})
diff --git a/ext/tk/sample/tkextlib/vu/dial.rb b/ext/tk/sample/tkextlib/vu/dial.rb
index d2ae0990c0..09bd3e9186 100644
--- a/ext/tk/sample/tkextlib/vu/dial.rb
+++ b/ext/tk/sample/tkextlib/vu/dial.rb
@@ -13,61 +13,61 @@ v_linked = TkVariable.new
v_needle = TkVariable.new
volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to=>0.1,
- :resolution=>0.001, :minortickinterval=>0.01,
- :tickinterval=>0.1, :beginangle=>-20,
- :endangle=>260, :variable=>v_volume)
+ :resolution=>0.001, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :beginangle=>-20,
+ :endangle=>260, :variable=>v_volume)
speed = Tk::Vu::Dial.new(:label=>"Speed", :from=>2000, :to=>100,
- :resolution=>10, :tickinterval=>100,
- :minortickinterval=>0, :variable=>v_speed,
- :showtags=>:label, :showvalue=>false)
+ :resolution=>10, :tickinterval=>100,
+ :minortickinterval=>0, :variable=>v_speed,
+ :showtags=>:label, :showvalue=>false)
speed.set_tag_constrain(100, 'Fast', 2000, 'Slow')
fwd = Tk::Vu::Dial.new(:from=>-10.0, :to=>-20.0, :resolution=>0.1,
- :tickinterval=>5.0, :minortickinterval=>1.0,
- :variable=>v_dir)
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
rev = Tk::Vu::Dial.new(:from=>-20.0, :to=>-10.0, :resolution=>0.1,
- :tickinterval=>5.0, :minortickinterval=>1.0,
- :variable=>v_dir)
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
small = Tk::Vu::Dial.new(:font=>"Helvetica -10", :from=>0, :to=>10,
- :resolution=>0.05, :tickinterval=>2,
- :minortickinterval=>0.5, :radius=>20,
- :dialcolor=>'red2', :activebackground=>'red',
- :variable=>v_rot)
+ :resolution=>0.05, :tickinterval=>2,
+ :minortickinterval=>0.5, :radius=>20,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
large = Tk::Vu::Dial.new(:font=>"Helvetica -8", :from=>0, :to=>10,
- :resolution=>0.05, :tickinterval=>1,
- :minortickinterval=>0.25, :radius=>40,
- :dialcolor=>'red2', :activebackground=>'red',
- :variable=>v_rot)
+ :resolution=>0.05, :tickinterval=>1,
+ :minortickinterval=>0.25, :radius=>40,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
turn = Tk::Vu::Dial.new(:needlecolor=>'red', :label=>"Linked",
- :variable=>v_linked)
+ :variable=>v_linked)
scale = TkScale.new(:label=>"Linked", :variable=>v_linked)
d1 = Tk::Vu::Dial.new(:resolution=>0.0001, :from=>-0.1, :to=>0.1,
- :showvalue=>true, :minortickinterval=>0.01,
- :tickinterval=>0.1, :radius=>30, :label=>"Dial",
- :beginangle=>-20, :endangle=>260, :variable=>v_needle,
- :relief=>:raised)
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :relief=>:raised)
d2 = Tk::Vu::Dial.new(:resolution=>0.01, :from=>-0.1, :to=>0.1,
- :showvalue=>true, :minortickinterval=>0.01,
- :tickinterval=>0.1, :radius=>30, :label=>"Dial 2",
- :beginangle=>-20, :endangle=>260, :variable=>v_needle,
- :dialrelief=>:flat, :needlecolor=>'red',
- :needletype=>:triangle, :relief=>:sunken)
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 2",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'red',
+ :needletype=>:triangle, :relief=>:sunken)
d3 = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
- :showvalue=>true, :minortickinterval=>0.01,
- :tickinterval=>0.1, :radius=>30, :label=>"Dial 3",
- :beginangle=>-20, :endangle=>260, :variable=>v_needle,
- :dialrelief=>:flat, :needlecolor=>'blue',
- :needletype=>:arc, :relief=>:ridge)
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 3",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'blue',
+ :needletype=>:arc, :relief=>:ridge)
f_btns = TkFrame.new
f_sep = TkFrame.new(:height=>2, :relief=>:sunken, :bd=>1)
@@ -77,12 +77,12 @@ v_volume.value = -0.1
v_speed.value = 500
update = TkTimer.new(proc{v_speed.numeric}, -1, proc{
- if v_volume == volume[:to]
- v_volume.numeric = volume[:from]
- else
- v_volume.numeric += volume[:resolution]
- end
- })
+ if v_volume == volume[:to]
+ v_volume.numeric = volume[:from]
+ else
+ v_volume.numeric += volume[:resolution]
+ end
+ })
b_start = TkButton.new(:text=>"Start", :command=>proc{update.start})
b_stop = TkButton.new(:text=>"Stop", :command=>proc{update.stop})
diff --git a/ext/tk/sample/tkextlib/vu/oscilloscope.rb b/ext/tk/sample/tkextlib/vu/oscilloscope.rb
index 43254c9b2e..2015e46645 100644
--- a/ext/tk/sample/tkextlib/vu/oscilloscope.rb
+++ b/ext/tk/sample/tkextlib/vu/oscilloscope.rb
@@ -23,43 +23,43 @@ c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true)
#---background
TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3',
- :tags=>['osc', 'frbg'])
+ :tags=>['osc', 'frbg'])
#---channel 0
ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0,
- :fill=>'', :jumpscroll=>false,
- :outline=>'', :scaleline=>'',
- :stripline=>'cyan', :tags=>['osc', 'ch0'])
+ :fill=>'', :jumpscroll=>false,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'cyan', :tags=>['osc', 'ch0'])
#---channel 1
ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1,
- :fill=>'', :jumpscroll=>0,
- :outline=>'', :scaleline=>'',
- :stripline=>'red', :tags=>['osc', 'ch1'])
+ :fill=>'', :jumpscroll=>0,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'red', :tags=>['osc', 'ch1'])
#---frame
TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg'])
#---position
txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y",
- :anchor=>:nw, :tags=>['osc', 'txt1'])
+ :anchor=>:nw, :tags=>['osc', 'txt1'])
#---BINDINGS
c.bind('B1-Motion', proc{|x, y, xx, yy|
- ch0[:values] = x
- ch1[:values] = y
- txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}"
+ ch0[:values] = x
+ ch1[:values] = y
+ txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}"
}, '%x %y %X %Y')
Tk.root.bind('v', proc{
- puts ch0[:values].join(' ')
- puts ch0[:values].size
- })
+ puts ch0[:values].join(' ')
+ puts ch0[:values].size
+ })
Tk.root.bind('p', proc{
- c.postscript(:file=>'DEMO.ps')
- puts "DEMO.ps printed"
- })
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
Tk.root.bind('q', proc{exit})
diff --git a/ext/tk/sample/tkextlib/vu/pie.rb b/ext/tk/sample/tkextlib/vu/pie.rb
index a567f840a0..ed598d6233 100644
--- a/ext/tk/sample/tkextlib/vu/pie.rb
+++ b/ext/tk/sample/tkextlib/vu/pie.rb
@@ -27,7 +27,7 @@ Tk.grid(pie, :sticky=>:news)
Tk.grid(f, :sticky=>:ew)
Tk.pack(fast_btn, slow_btn, quit_btn,
- :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4)
+ :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4)
Tk.root.grid_columnconfigure(0, :weight=>1)
Tk.root.grid_rowconfigure(0, :weight=>1)
@@ -37,20 +37,20 @@ priv = {
}
pie.bind('ButtonPress-1', proc{|w, x, y|
- priv[:x] = x
- priv[:y] = y
- priv[:pie_in] = (w.winfo_width/1.8 > x)
- priv[:angle] = w[:angle]
- priv[:origin] = w[:origin]
- }, '%W %x %y')
+ priv[:x] = x
+ priv[:y] = y
+ priv[:pie_in] = (w.winfo_width/1.8 > x)
+ priv[:angle] = w[:angle]
+ priv[:origin] = w[:origin]
+ }, '%W %x %y')
pie.bind('B1-Motion', proc{|w, x, y|
- if priv[:pie_in]
- w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3,
- :origin=>(priv[:origin] +
- ((w.winfo_height/2.2 > y)? -1: 1) *
- (priv[:x] - x)/3) % 360)
- end
- }, '%W %x %y')
+ if priv[:pie_in]
+ w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3,
+ :origin=>(priv[:origin] +
+ ((w.winfo_height/2.2 > y)? -1: 1) *
+ (priv[:x] - x)/3) % 360)
+ end
+ }, '%W %x %y')
Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/vu.rb b/ext/tk/sample/tkextlib/vu/vu.rb
index df9a7f38ad..d078ae16f2 100644
--- a/ext/tk/sample/tkextlib/vu/vu.rb
+++ b/ext/tk/sample/tkextlib/vu/vu.rb
@@ -10,13 +10,13 @@ puts "Show off barchart and dial widgets"
speed = TkVariable.new(0)
dial = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
- :showvalue=>true, :minortickinterval=>0.01,
- :tickinterval=>0.1, :radius=>50, :label=>"Dial",
- :beginangle=>-20, :endangle=>260, :dialcolor=>'red3',
- :active=>'red2', :variable=>speed)
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>50, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :dialcolor=>'red3',
+ :active=>'red2', :variable=>speed)
bar = Tk::Vu::Bargraph.new(:from=>0, :to=>100, :relief=>:groove,
- :border=>2, :label=>"Bar Chart")
+ :border=>2, :label=>"Bar Chart")
#######################################
@@ -30,24 +30,24 @@ def rand_bool
end
update = TkTimer.new(200, -1, proc{
- if (rand() - 0.5 + speed.numeric * 3) > 0
- current += 1
- else
- current -= 1
- end
- bar.set(current)
- if current < green
- current = 100 if current <= 0
- bar[:barcolor] = 'green'
- elsif current < blue
- bar[:barcolor] = 'blue'
- elsif current < purple
- bar[:barcolor] = 'purple'
- else
- bar[:barcolor] = 'red'
- current = 0 if current >= 100
- end
- })
+ if (rand() - 0.5 + speed.numeric * 3) > 0
+ current += 1
+ else
+ current -= 1
+ end
+ bar.set(current)
+ if current < green
+ current = 100 if current <= 0
+ bar[:barcolor] = 'green'
+ elsif current < blue
+ bar[:barcolor] = 'blue'
+ elsif current < purple
+ bar[:barcolor] = 'purple'
+ else
+ bar[:barcolor] = 'red'
+ current = 0 if current >= 100
+ end
+ })
#######################################
@@ -61,7 +61,7 @@ Tk.grid('x', nobar, :sticky=>:ew, :padx=>4, :pady=>4)
Tk.grid(quit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4)
Tk.root.grid_columnconfigure(2, :weight=>1)
Tk.root.grid_rowconfigure(1, :weight=>1)
-
+
#######################################
Tk.mainloop