summaryrefslogtreecommitdiff
path: root/ext/tk/sample/demos-en
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/sample/demos-en')
-rw-r--r--ext/tk/sample/demos-en/arrow.rb18
-rw-r--r--ext/tk/sample/demos-en/bind.rb9
-rw-r--r--ext/tk/sample/demos-en/ctext.rb45
-rw-r--r--ext/tk/sample/demos-en/entry3.rb2
-rw-r--r--ext/tk/sample/demos-en/hello6
-rw-r--r--ext/tk/sample/demos-en/hscale.rb2
-rw-r--r--ext/tk/sample/demos-en/items.rb9
-rw-r--r--ext/tk/sample/demos-en/patch_1.1c193
-rw-r--r--ext/tk/sample/demos-en/pendulum.rb35
-rw-r--r--ext/tk/sample/demos-en/rolodex-j323
-rw-r--r--ext/tk/sample/demos-en/search.rb7
-rw-r--r--ext/tk/sample/demos-en/style.rb34
-rw-r--r--ext/tk/sample/demos-en/textpeer.rb72
-rw-r--r--ext/tk/sample/demos-en/twind.rb6
-rw-r--r--ext/tk/sample/demos-en/vscale.rb1
-rw-r--r--ext/tk/sample/demos-en/widget32
16 files changed, 222 insertions, 472 deletions
diff --git a/ext/tk/sample/demos-en/arrow.rb b/ext/tk/sample/demos-en/arrow.rb
index b62e1966eb..4a589a0892 100644
--- a/ext/tk/sample/demos-en/arrow.rb
+++ b/ext/tk/sample/demos-en/arrow.rb
@@ -77,11 +77,19 @@ def arrowSetup(c)
'arrow'=>'both', 'arrowshape'=>v.smallTips)
TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
- 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-*-*-*-*-*-*')
+ 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
diff --git a/ext/tk/sample/demos-en/bind.rb b/ext/tk/sample/demos-en/bind.rb
index b7e7122c57..5d6ec84edb 100644
--- a/ext/tk/sample/demos-en/bind.rb
+++ b/ext/tk/sample/demos-en/bind.rb
@@ -43,11 +43,11 @@ def tag_binding_for_bind_demo(tag, enter_style, leave_style)
end
# text
-TkText.new($bind_demo){|t|
+txt = TkText.new($bind_demo){|t|
#
setgrid 'true'
- width 60
- height 24
+ #width 60
+ #height 24
font $font
wrap 'word'
TkScrollbar.new($bind_demo) {|s|
@@ -120,3 +120,6 @@ TkText.new($bind_demo){|t|
TkTextMarkInsert.new(t, '0.0')
configure('state','disabled')
}
+
+txt.width 60
+txt.width 24
diff --git a/ext/tk/sample/demos-en/ctext.rb b/ext/tk/sample/demos-en/ctext.rb
index dbb5e32638..8c10880ed6 100644
--- a/ext/tk/sample/demos-en/ctext.rb
+++ b/ext/tk/sample/demos-en/ctext.rb
@@ -56,19 +56,28 @@ $ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
# font
-textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+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'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
+ 'width'=>440, 'anchor'=>'n', 'justify'=>'left'
+}
+if $tk_version =~ /^4.*/
+ ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ ctag_text_param['font'] = 'Helvetica 24'
+end
+
$ctag_text = TkcTag.new($ctext_canvas)
-$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200,
- 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
- 'width'=>440, 'anchor'=>'n',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*',
- 'kanjifont'=>'-*--24-*-jisx0208.1983-0',
- 'justify'=>'left') )
+$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")
@@ -110,9 +119,14 @@ 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'})
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+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.
@@ -123,9 +137,14 @@ 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
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+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',
diff --git a/ext/tk/sample/demos-en/entry3.rb b/ext/tk/sample/demos-en/entry3.rb
index 415b45f86c..68f77a0d48 100644
--- a/ext/tk/sample/demos-en/entry3.rb
+++ b/ext/tk/sample/demos-en/entry3.rb
@@ -28,7 +28,7 @@ problem. The second only accepts strings with fewer than ten \
characters and sounds the bell when an attempt to go over the limit \
is made. The third accepts US phone numbers, mapping letters to \
their digit equivalent and sounding the bell on encountering an \
-illegal character or if trying to type over a character that is not \
+invalid character or if trying to type over a character that is not \
a digit. The fourth is a password field that accepts up to eight \
characters (silently ignoring further ones), and displaying them as \
asterisk characters.
diff --git a/ext/tk/sample/demos-en/hello b/ext/tk/sample/demos-en/hello
index f06eabe518..5e86ad7e3e 100644
--- a/ext/tk/sample/demos-en/hello
+++ b/ext/tk/sample/demos-en/hello
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
require 'tk'
-unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
- require 'tkencoding'
-end
+#unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
+# require 'tkencoding'
+#end
TkButton.new(nil,
'text'=>"Hello Ruby world!",
diff --git a/ext/tk/sample/demos-en/hscale.rb b/ext/tk/sample/demos-en/hscale.rb
index 14e395b61a..743c4b4852 100644
--- a/ext/tk/sample/demos-en/hscale.rb
+++ b/ext/tk/sample/demos-en/hscale.rb
@@ -62,7 +62,6 @@ TkFrame.new($hscale_demo) {|frame|
scale.set 75
}.pack('side'=>'top', 'fill'=>'x')
-
def setWidth(w, width)
width = width + 21
x2 = width - 30
@@ -72,3 +71,4 @@ def setWidth(w, width)
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
+
diff --git a/ext/tk/sample/demos-en/items.rb b/ext/tk/sample/demos-en/items.rb
index 8ab7668a07..23191b59b9 100644
--- a/ext/tk/sample/demos-en/items.rb
+++ b/ext/tk/sample/demos-en/items.rb
@@ -94,8 +94,13 @@ 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)
-font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
-font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+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'
diff --git a/ext/tk/sample/demos-en/patch_1.1c1 b/ext/tk/sample/demos-en/patch_1.1c1
deleted file mode 100644
index d3952e71eb..0000000000
--- a/ext/tk/sample/demos-en/patch_1.1c1
+++ /dev/null
@@ -1,93 +0,0 @@
---- /usr/src/ruby-1.1c1/lib/tkcanvas.rb Tue Jul 21 18:18:02 1998
-+++ tkcanvas.rb Fri Jul 24 20:38:24 1998
-@@ -310,7 +310,7 @@
- || key == 'latinfont' || key == 'asciifont' )
- tagfont_configure(tagid(tagOrId), {key=>value})
- else
-- tk_call 'itemconfigure', tagid(tagOrId), "-#{key}", value
-+ tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
- end
- end
- end
---- /usr/src/ruby-1.1c1/lib/tkfont.rb Fri Jul 17 23:43:28 1998
-+++ tkfont.rb Fri Jul 24 17:46:22 1998
-@@ -42,7 +42,7 @@
- r | []
-
- when /^8\.*/
-- list(tk_call('font', 'names'))
-+ tk_split_simplelist(tk_call('font', 'names'))
-
- end
- end
-@@ -89,10 +89,14 @@
- if fnt == []
- TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
- else
-- compound = Hash[*list(tk_call('font', 'configure',
-- fnt))].collect{|key,value|
-- [key[1..-1], value]
-- }.assoc('compound')[1]
-+ begin
-+ compound = Hash[*list(tk_call('font', 'configure',
-+ fnt))].collect{|key,value|
-+ [key[1..-1], value]
-+ }.assoc('compound')[1]
-+ rescue
-+ compound = []
-+ end
- if compound == []
- TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \
- .call_font_configure(path, *(args + [{}]))
-@@ -156,14 +160,19 @@
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
-- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
-- if $1 == '-'
-- finfo['pixels'] = font[1].to_s
-+ if font[1]
-+ fsize = font[1].to_s
-+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
-+ if $1 == '-'
-+ finfo['pixels'] = $2
-+ else
-+ finfo['points'] = $2
-+ end
- else
-- finfo['points'] = font[1].to_s
-+ finfo['points'] = '13'
- end
- end
-- finfo[2..-1].each{|style|
-+ font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
-@@ -199,16 +208,19 @@
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
-- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
-- if $1 == '-'
-- finfo['pixels'] = $2
-+ if font[1]
-+ fsize = font[1].to_s
-+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
-+ if $1 == '-'
-+ finfo['pixels'] = $2
-+ else
-+ finfo['points'] = $2
-+ end
- else
-- finfo['points'] = $2
-+ finfo['points'] = '13'
- end
-- else
-- finfo['points'] = '13'
- end
-- finfo[2..-1].each{|style|
-+ font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
diff --git a/ext/tk/sample/demos-en/pendulum.rb b/ext/tk/sample/demos-en/pendulum.rb
index 36bb44edec..a3498d67cf 100644
--- a/ext/tk/sample/demos-en/pendulum.rb
+++ b/ext/tk/sample/demos-en/pendulum.rb
@@ -49,9 +49,11 @@ TkFrame.new($pendulum_demo) {|frame|
class PendulumAnimationDemo
def initialize(frame)
# Create some structural widgets
- pane = TkPanedWindow.new(frame).pack(:fill=>:both, :expand=>true)
- pane.add(@lf1 = TkLabelFrame.new(pane, :text=>'Pendulum Simulation'))
- pane.add(@lf2 = TkLabelFrame.new(pane, :text=>'Phase Space'))
+ @pane = TkPanedWindow.new(frame).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.
@@ -99,23 +101,24 @@ class PendulumAnimationDemo
@dTheta = 0.0
@length = 150
- # init display
- showPendulum
-
# 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, y)}, '%x %y')
- btag.bind('B1-Motion', proc{|x, y| showPendulum(x, y)}, '%x %y')
+ 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, y); @timer.start }, '%x %y')
+ proc{|x, y| showPendulum(x.to_i, y.to_i); @timer.start },
+ '%x %y')
- btag.bind('Configure', proc{|w| @plate.coords(0, 25, w, 25)}, '%w')
+ 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)
@@ -124,6 +127,14 @@ class PendulumAnimationDemo
@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
@@ -154,6 +165,10 @@ class PendulumAnimationDemo
# 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]
diff --git a/ext/tk/sample/demos-en/rolodex-j b/ext/tk/sample/demos-en/rolodex-j
deleted file mode 100644
index 27e2bc9da0..0000000000
--- a/ext/tk/sample/demos-en/rolodex-j
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/usr/bin/env ruby
-#
-# rolodex --
-# このスクリプトは Tom LaStrange の rolodex の一部です。
-#
-# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
-# Time-stamp: "03/08/02 14:02:04 nagai"
-#
-
-require "tk"
-
-Tk.encoding = "euc-jp"
-$font = TkFont.new('k14')
-
-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}",
- "font"=>$font,
- "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",
- "font"=>$font,
- "default_button"=>0,
- "buttons"=>["OK"])
- STDERR.print "dummy file name\n"
-end
-
-def deleteAction
- result = TkDialog.new("title"=>"Confirm Action",
- "message"=>"よろしいですか?",
- "font"=>$font,
- "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",
- "font" => $font)
- @entry[i] = TkEntry.new(@i[i],
- "width"=>30,
- "relief"=>"sunken",
- "font" => $font)
- @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" => "クリアー",
- "font" => $font)
- @add = TkButton.new(self,
- "text" => "追加",
- "font" => $font)
- @search = TkButton.new(self,
- "text" => "検索",
- "font" => $font)
- @delete = TkButton.new(self,
- "text" => "消去",
- "font" => $font)
- 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"=> "ファイル",
- "font"=> $font,
- "underline"=>0)
- @file_menu = TkMenu.new(@file)
- @file_menu.add("command",
- "label" => "読み込み ...",
- "font" => $font,
- "command" => proc{fileAction},
- "underline" => 0)
- @file_menu.add("command",
- "label" => "終了",
- "font" => $font,
- "command" => proc{$root.destroy},
- "underline" => 0)
- @file.menu(@file_menu)
- @file.pack("side"=>"left")
-
- @help = TkMenubutton.new(self,
- "text"=> "ヘルプ",
- "font"=> $font,
- "underline"=>0)
- @help_menu = TkMenu.new(@help)
- @help_menu.add("command",
- "label"=> "コンテキストについて",
- "font" => $font,
- "command"=>proc{show_help("コンテキスト")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "ヘルプについて",
- "font" => $font,
- "command"=>proc{show_help("ヘルプ")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "ウィンドウについて",
- "font" => $font,
- "command"=>proc{show_help("ウィンドウ")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "キー操作について",
- "font" => $font,
- "command"=>proc{show_help("キー操作")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "バージョン情報",
- "font" => $font,
- "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", "font" => $font)
-$root.bind("Control-c",proc{clearAction})
-
-$root.buttons.add.configure("text"=> "追加 Ctrl+A", "font" => $font)
-$root.bind("Control-a",proc{addAction})
-
-$root.buttons.search.configure("text"=> "検索 Ctrl+S", "font" => $font)
-$root.bind("Control-s",proc{addAction; fillCard})
-
-$root.buttons.delete.configure("text"=> "消去 Ctrl+D", "font" => $font)
-$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.1e です。
-EOF
-
-Tk.mainloop
diff --git a/ext/tk/sample/demos-en/search.rb b/ext/tk/sample/demos-en/search.rb
index 3d3b4aecc8..3749423bbc 100644
--- a/ext/tk/sample/demos-en/search.rb
+++ b/ext/tk/sample/demos-en/search.rb
@@ -140,7 +140,7 @@ $search_text = TkText.new($search_demo, 'setgrid'=>true, 'wrap'=>'word') {|t|
pack('side'=>'right', 'fill'=>'y')
}
pack('expand'=>'yes', 'fill'=>'both')
-}
+}
# Set up display styles for text highlighting.
@@ -173,8 +173,13 @@ type a string in the lower entry and type <Return> or click on \
\"Load File\". This will cause all of the instances of the string to \
be tagged with the tag \"search\", and it will arrange for the tag\'s \
display attributes to change to make all of the strings blink.")
+$search_text.insert('end', "\
+The current directory to load a file is \"#{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/ext/tk/sample/demos-en/style.rb b/ext/tk/sample/demos-en/style.rb
index 5ed11aa459..8606893c9b 100644
--- a/ext/tk/sample/demos-en/style.rb
+++ b/ext/tk/sample/demos-en/style.rb
@@ -40,9 +40,10 @@ TkFrame.new($style_demo) {|frame|
TkText.new($style_demo){|t|
#
setgrid 'true'
- width 70
- height 32
+ #width 70
+ #height 32
wrap 'word'
+ font $font
TkScrollbar.new($style_demo) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
@@ -51,11 +52,20 @@ TkText.new($style_demo){|t|
pack('expand'=>'yes', 'fill'=>'both')
#
- 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)
+ 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-*', '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.*/
@@ -109,8 +119,13 @@ TkText.new($style_demo){|t|
style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
style_tag_right = TkTextTag.new(t, 'justify'=>'right')
style_tag_center = TkTextTag.new(t, 'justify'=>'center')
- 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-*-*-*-*-*-*')
+ 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',
@@ -132,7 +147,8 @@ available display styles are:
insert('end', " You can choose any X font, ")
insert('end', "large", style_tag_verybig)
insert('end', " or ")
- insert('end', "small.\n")
+ insert('end', "small", style_tag_small)
+ insert('end', ".\n")
insert('end', "\n2. Color.", style_tag_big)
insert('end', " You can change either the ")
insert('end', "background", style_tag_color1)
@@ -209,3 +225,5 @@ available display styles are:
}
+txt.width 70
+txt.height 32
diff --git a/ext/tk/sample/demos-en/textpeer.rb b/ext/tk/sample/demos-en/textpeer.rb
new file mode 100644
index 0000000000..d98ef170b4
--- /dev/null
+++ b/ext/tk/sample/demos-en/textpeer.rb
@@ -0,0 +1,72 @@
+#
+# 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)
+}
+
+count = [0]
+
+## Define a widget that we peer from; it won't ever actually be shown though
+first = TkText.new($textpeer_demo, :widgetname=>"text#{count[0] += 1}")
+first.insert :end,"This is a coupled pair of text widgets; they are peers to "
+first.insert :end,"each other. They have the same underlying data model, but "
+first.insert :end,"can show different locations, have different current edit "
+first.insert :end,"locations, and have different selections. You can also "
+first.insert :end,"create additional peers of any of these text widgets using "
+first.insert :end,"the Make Peer button beside the text widget to clone, and "
+first.insert :end,"delete a particular peer widget using the Delete Peer "
+first.insert :end,"button."
+
+## 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=>'Make Peer',
+ :command=>proc{makeClone(count, win, peer)})
+ b2 = TkButton.new(win, :widgetname=>"kill#{cnt}", :text=>'Delete 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, $textpeer_demo, first)
+makeClone(count, $textpeer_demo, first)
+first.destroy
+
+## See Code / Dismiss buttons
+TkFrame.new($textpeer_demo){|f|
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'textpeer'
+ }).pack(:side=>:left, :expand=>true)
+
+ TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
+}
+TkGrid.columnconfigure($textpeer_demo, 0, :weight=>1)
diff --git a/ext/tk/sample/demos-en/twind.rb b/ext/tk/sample/demos-en/twind.rb
index 24a4bcf706..f29e49f35a 100644
--- a/ext/tk/sample/demos-en/twind.rb
+++ b/ext/tk/sample/demos-en/twind.rb
@@ -206,7 +206,11 @@ def textWindPlot (t)
cursor 'top_left_arrow'
}
- font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ 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)
diff --git a/ext/tk/sample/demos-en/vscale.rb b/ext/tk/sample/demos-en/vscale.rb
index 636b85813b..c0170467d5 100644
--- a/ext/tk/sample/demos-en/vscale.rb
+++ b/ext/tk/sample/demos-en/vscale.rb
@@ -66,7 +66,6 @@ TkFrame.new($vscale_demo) {|frame|
scale.set 75
}.pack
-
def setHeight(w, height)
height = height + 21
y2 = height - 30
diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget
index adf8cb76ed..391d8532b6 100644
--- a/ext/tk/sample/demos-en/widget
+++ b/ext/tk/sample/demos-en/widget
@@ -21,7 +21,8 @@ require 'tk'
#----------------------------------------------------------------
# widget demo directory
-$demo_dir = File.dirname($0)
+# $demo_dir = File.dirname($0)
+$demo_dir = File.dirname(__FILE__)
# root
$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
@@ -164,12 +165,17 @@ else
textFrame.pack('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'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2)
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
end
@@ -178,7 +184,11 @@ end
# section titles and demo descriptions. Also define the bindings for
# tags.
-tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+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
# We put some "space" characters to the left and right of each demo description
# so that the descriptions are highlighted only when the mouse cursor
@@ -331,6 +341,8 @@ txt.insert('end', "5. A text widget with embedded windows. (if supported)\n", ta
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "6. A search tool built with a text widget.\n", tag_demo, "demo-search")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. Peering text widgets. (if supported)\n", tag_demo, "demo-textpeer")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Canvases\n", tag_title)
@@ -445,7 +457,11 @@ def showVars1(parent, *args)
text "Variable values:"
width 20
anchor 'center'
- font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ 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|
@@ -592,7 +608,9 @@ end
private :_null_binding
def eval_samplecode(code)
- Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }.run
+ #eval(code)
+ #_null_binding.pseudo_toplevel_eval{ eval(code) }
+ Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }
Tk.update
end
@@ -896,7 +914,7 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
- 'message'=>"Ruby/Tk widget demonstration Ver.1.6.2-en\n\n" +
+ 'message'=>"Ruby/Tk widget demonstration Ver.1.6.3-en\n\n" +
"based on demos of Tk8.1 -- 8.5 " +
"( Copyright:: " +
"(c) 1996-1997 Sun Microsystems, Inc. / " +