1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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')
}
|