2
# tk/grid.rb : control grid geometry manager
10
TkCommandNames = ['grid'.freeze].freeze
12
def anchor(master, anchor=None)
13
# master = master.epath if master.kind_of?(TkObject)
14
master = _epath(master)
15
tk_call_without_enc('grid', 'anchor', master, anchor)
18
def bbox(master, *args)
19
# master = master.epath if master.kind_of?(TkObject)
20
master = _epath(master)
22
list(tk_call_without_enc('grid', 'bbox', *args))
25
def configure(win, *args)
26
if args[-1].kind_of?(Hash)
32
params.push(_epath(win))
35
when '-', 'x', '^' # RELATIVE PLACEMENT
38
params.push(_epath(win))
43
params.push((v.kind_of?(TkObject))? v.epath: v)
45
if Tk::TCL_MAJOR_VERSION < 8 ||
46
(Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3)
47
if params[0] == '-' || params[0] == 'x' || params[0] == '^'
48
tk_call_without_enc('grid', *params)
50
tk_call_without_enc('grid', 'configure', *params)
53
tk_call_without_enc('grid', 'configure', *params)
58
def columnconfigure(master, index, args)
59
# master = master.epath if master.kind_of?(TkObject)
60
master = _epath(master)
61
tk_call_without_enc("grid", 'columnconfigure',
62
master, index, *hash_kv(args))
65
def rowconfigure(master, index, args)
66
# master = master.epath if master.kind_of?(TkObject)
67
master = _epath(master)
68
tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args))
71
def columnconfiginfo(master, index, slot=nil)
72
# master = master.epath if master.kind_of?(TkObject)
73
master = _epath(master)
76
when 'uniform', :uniform
77
tk_call_without_enc('grid', 'columnconfigure',
78
master, index, "-#{slot}")
80
num_or_str(tk_call_without_enc('grid', 'columnconfigure',
81
master, index, "-#{slot}"))
84
#ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
85
ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
88
while key = ilist.shift
91
info[key[1..-1]] = ilist.shift
93
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
100
def rowconfiginfo(master, index, slot=nil)
101
# master = master.epath if master.kind_of?(TkObject)
102
master = _epath(master)
105
when 'uniform', :uniform
106
tk_call_without_enc('grid', 'rowconfigure',
107
master, index, "-#{slot}")
109
num_or_str(tk_call_without_enc('grid', 'rowconfigure',
110
master, index, "-#{slot}"))
113
#ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
114
ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
117
while key = ilist.shift
120
info[key[1..-1]] = ilist.shift
122
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
129
def add(widget, *args)
130
configure(widget, *args)
134
return '' if args.size == 0
135
wins = args.collect{|win|
136
# (win.kind_of?(TkObject))? win.epath: win
139
tk_call_without_enc('grid', 'forget', *wins)
143
# slave = slave.epath if slave.kind_of?(TkObject)
144
slave = _epath(slave)
145
#ilist = list(tk_call_without_enc('grid', 'info', slave))
146
ilist = simplelist(tk_call_without_enc('grid', 'info', slave))
148
while key = ilist.shift
149
#info[key[1..-1]] = ilist.shift
150
info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
155
def location(master, x, y)
156
# master = master.epath if master.kind_of?(TkObject)
157
master = _epath(master)
158
list(tk_call_without_enc('grid', 'location', master, x, y))
161
def propagate(master, mode=None)
162
# master = master.epath if master.kind_of?(TkObject)
163
master = _epath(master)
165
bool(tk_call_without_enc('grid', 'propagate', master))
167
tk_call_without_enc('grid', 'propagate', master, mode)
172
return '' if args.size == 0
173
wins = args.collect{|win|
174
# (win.kind_of?(TkObject))? win.epath: win
177
tk_call_without_enc('grid', 'remove', *wins)
181
# master = master.epath if master.kind_of?(TkObject)
182
master = _epath(master)
183
list(tk_call_without_enc('grid', 'size', master))
186
def slaves(master, args)
187
# master = master.epath if master.kind_of?(TkObject)
188
master = _epath(master)
189
list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
192
module_function :bbox, :forget, :propagate, :info
193
module_function :remove, :size, :slaves, :location
194
module_function :grid, :configure, :columnconfigure, :rowconfigure
195
module_function :columnconfiginfo, :rowconfiginfo
198
def TkGrid(win, *args)
199
if args[-1].kind_of?(Hash)
205
params.push((win.kind_of?(TkObject))? win.epath: win)
208
when '-', 'x', '^' # RELATIVE PLACEMENT
211
params.push((win.kind_of?(TkObject))? win.epath: win)
216
params.push((v.kind_of?(TkObject))? v.epath: v)
218
tk_call_without_enc("grid", *params)