aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/sample/demos-jp
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-16 07:45:51 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-16 07:45:51 +0000
commit98a3a9db9718d8a54a66ae5f5e4da080c57cba5c (patch)
treeebca1fb8cbbd8d33e46c7c8267fc26c5d67a5c61 /ext/tk/sample/demos-jp
parente45c4cd1ac8523f83b1d72b068ba009e3d9fe6db (diff)
downloadruby-98a3a9db9718d8a54a66ae5f5e4da080c57cba5c.tar.gz
Add Tk::EncodedString and Tk::UTF8_String class to support characters
using the \uXXXX escape to the UNICODE string. sample/{demos-en,demos-jp}/unicodeout.rb are samples of Tk::UTF8_String. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample/demos-jp')
-rw-r--r--ext/tk/sample/demos-jp/entry3.rb14
-rw-r--r--ext/tk/sample/demos-jp/unicodeout.rb102
-rw-r--r--ext/tk/sample/demos-jp/widget22
3 files changed, 121 insertions, 17 deletions
diff --git a/ext/tk/sample/demos-jp/entry3.rb b/ext/tk/sample/demos-jp/entry3.rb
index 4c0b24e28c..9bf3f62097 100644
--- a/ext/tk/sample/demos-jp/entry3.rb
+++ b/ext/tk/sample/demos-jp/entry3.rb
@@ -29,7 +29,7 @@ TkLabel.new($entry3_demo,
二つめのエントリボックスは,入力された文字列の長さが\
10文字未満の場合だけを受け付け,制限を越えて書き込もうとしたときには\
ベルを鳴らして知らせます.\
-三つめはアメリカの電話番号を受け付けるエントリボックスです.\
+三つめは米国の電話番号を受け付けるエントリボックスです.\
アルファベットは,電話機のダイヤル上で対応づけられている数字に変換されます.\
不適切な文字が入力されたり数字以外の文字の位置に数字を入力しようとしたり\
した場合には警告のベルが鳴ります.\
@@ -41,12 +41,12 @@ EOL
TkFrame.new($entry3_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
- TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{
$entry3_demo.destroy
$entry3_demo = nil
}).pack(:side=>:left, :expand=>true)
- TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'entry3'
}).pack(:side=>:left, :expand=>true)
}
@@ -71,7 +71,7 @@ def focusAndFlash(widget, fg, bg, count=5)
widget.focus(true)
end
-l1 = TkLabelFrame.new($entry3_demo, :text=>"Integer Entry")
+l1 = TkLabelFrame.new($entry3_demo, :text=>"整数エントリ")
TkEntry.new(l1, :validate=>:focus,
:vcmd=>[
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
@@ -80,7 +80,7 @@ TkEntry.new(l1, :validate=>:focus,
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l2 = TkLabelFrame.new($entry3_demo, :text=>"Length-Constrained Entry")
+l2 = TkLabelFrame.new($entry3_demo, :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')
@@ -167,7 +167,7 @@ def validatePhoneChange(widget, vmode, idx, char)
end
-l3 = TkLabelFrame.new($entry3_demo, :text=>"US Phone-Number Entry")
+l3 = TkLabelFrame.new($entry3_demo, :text=>"米国電話番号エントリ")
TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
:textvariable=>entry3content,
:vcmd=>[
@@ -186,7 +186,7 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l4 = TkLabelFrame.new($entry3_demo, :text=>"Password Entry")
+l4 = TkLabelFrame.new($entry3_demo, :text=>"パスワードエントリ")
TkEntry.new(l4, :validate=>:key, :show=>'*',
:vcmd=>[
proc{|s| s.length <= 8},
diff --git a/ext/tk/sample/demos-jp/unicodeout.rb b/ext/tk/sample/demos-jp/unicodeout.rb
new file mode 100644
index 0000000000..fcc0a21875
--- /dev/null
+++ b/ext/tk/sample/demos-jp/unicodeout.rb
@@ -0,0 +1,102 @@
+# 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)
+}
+
+TkLabel.new($unicodeout_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+これは,Tkにおける非欧米文字集合を用いる言語に対するサポートについての\
+サンプルです.ただし,下の表示においてあなたが実際にどのような表示を\
+目にするかは,あなたの環境にどのような文字集合がインストールされているかに\
+大きく依存します.また,対象となる文字集合がインストールされていない場合に\
+どのような表示がなされるかもあなたの環境次第です.\
+スクリプトが可搬性を持つように,文字列は\\uXXXXという\
+Tclのエスケープ表現を用いたUNICODE文字列で書かれています.
+文字列はTk::UTF8_StringメソッドによってUTF8形式の文字列であるという\
+エンコード情報付きの文字列オブジェクト\
+(Tclのエスケープ表現の変換済み)に変換して\
+ラベルウィジェットに渡している点に注意してください.
+EOL
+#'
+
+TkFrame.new($unicodeout_demo){|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($unicodeout_demo,
+ :text=>"フォント読み込みの完了まで" +
+ "しばらくお待ち下さい...",
+ :font=>"Helvetica 12 italic").pack
+
+class Unicodeout_SampleFrame < TkFrame
+ @@font = $font
+
+ def initialize()
+ super($unicodeout_demo)
+ 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=>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
+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/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget
index 3dd285a489..696a9073cc 100644
--- a/ext/tk/sample/demos-jp/widget
+++ b/ext/tk/sample/demos-jp/widget
@@ -211,33 +211,35 @@ 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. ボタン \n", tag_demo, "demo-button")
+txt.insert('end', "2. ラベルとUNICODEテキスト (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-unicodeout")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "3. チェックボタン (複数を選択可能)\n",
+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', "4. ラジオボタン (任意の一つを選択可能)\n",
+txt.insert('end', "5. ラジオボタン (任意の一つを選択可能)\n",
tag_demo, "demo-radio")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "5. ラジオボタン (機能に対応したバージョンのTkが必要)\n",
+txt.insert('end', "6. ラジオボタン (機能に対応したバージョンのTkが必要)\n",
tag_demo, "demo-radio2")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "6. ボタンで作られた15-パズルゲーム\n",
+txt.insert('end', "7. ボタンで作られた15-パズルゲーム\n",
tag_demo, "demo-puzzle")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "7. ビットマップを使用したアイコンボタン\n",
+txt.insert('end', "8. ビットマップを使用したアイコンボタン\n",
tag_demo, "demo-icon")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "8. 画像を表示する二つのラベル\n",
+txt.insert('end', "9. 画像を表示する二つのラベル\n",
tag_demo, "demo-image1")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "9. 画像を見るための簡単なユーザインターフェース\n",
+txt.insert('end', "10. 画像を見るための簡単なユーザインターフェース\n",
tag_demo, "demo-image2")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "10. 画像を見るための簡単なユーザインターフェース (機能に対応したバージョンのTkが必要)\n",
+txt.insert('end', "11. 画像を見るための簡単なユーザインターフェース (機能に対応したバージョンのTkが必要)\n",
tag_demo, "demo-image3")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "11. ラベル付きフレーム (機能に対応したバージョンのTkが必要)\n",
+txt.insert('end', "12. ラベル付きフレーム (機能に対応したバージョンのTkが必要)\n",
tag_demo, "demo-labelframe")
txt.insert('end', " \n ", tag_demospace)