blob: ed7796aafb4e811ba5f8bd68c7264f01db199b32 (
plain)
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
|
#
# tk/composite.rb :
#
require 'tk'
module TkComposite
include Tk
extend Tk
def initialize(parent=nil, *args)
@delegates = {}
if parent.kind_of? Hash
keys = _symbolkey2str(parent)
parent = keys.delete('parent')
@frame = TkFrame.new(parent)
@delegates['DEFAULT'] = @frame
@path = @epath = @frame.path
initialize_composite(keys)
else
@frame = TkFrame.new(parent)
@delegates['DEFAULT'] = @frame
@path = @epath = @frame.path
initialize_composite(*args)
end
end
def epath
@epath
end
def initialize_composite(*args) end
private :initialize_composite
def delegate(option, *wins)
if @delegates[option].kind_of?(Array)
for i in wins
@delegates[option].push(i)
end
else
@delegates[option] = wins
end
end
def configure(slot, value=None)
if slot.kind_of? Hash
slot.each{|slot,value| configure slot, value}
else
if @delegates and @delegates[slot]
for i in @delegates[slot]
if not i
i = @delegates['DEFALUT']
redo
else
last = i.configure(slot, value)
end
end
last
else
super
end
end
end
end
|