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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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
|