Module: TkItemConfigMethod
- Includes:
- TkItemConfigOptkeys, TkTreatItemFont, TkUtil
- Included in:
- Tk::BLT::Busy, Tk::BLT::DnD, Tk::BLT::DragDrop, Tk::BLT::Htext, Tk::BLT::PlotComponent, Tk::BLT::Table, Tk::BLT::Tabset, Tk::BLT::Ted, Tk::BLT::Treeview::ConfigMethod, Tk::BWidget::ButtonBox, Tk::BWidget::Dialog, Tk::BWidget::ListBox, Tk::BWidget::NoteBook, Tk::BWidget::Tree, Tk::Iwidgets::Buttonbox, Tk::Iwidgets::Checkbox, Tk::Iwidgets::Dialogshell, Tk::Iwidgets::Menubar, Tk::Iwidgets::Messagebox, Tk::Iwidgets::Notebook, Tk::Iwidgets::Panedwindow, Tk::Iwidgets::Radiobox, Tk::Iwidgets::Tabnotebook, Tk::Iwidgets::Tabset, Tk::Iwidgets::Toolbar, Tk::Tcllib::TablelistItemConfig, Tk::Tile::TNotebook, Tk::Tile::TreeviewConfig, Tk::TkTable::ConfigMethod, Tk::TreeCtrl::ConfigMethod, Tk::Vu::PieSliceConfigMethod, TkCanvasItemConfig, TkListItemConfig, TkMenuEntryConfig, TkTextTagConfig
- Defined in:
- lib/tk/itemconfig.rb
Constant Summary
Constants included
from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Instance Method Summary
collapse
#__conv_item_keyonly_opts, #itemconfig_hash_kv
Methods included from TkUtil
_conv_args, #_conv_args, #_fromUTF8, _get_eval_enc_str, #_get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, bool, #bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd
#kanjifont_copy, #kanjitagfont_configure, #latintagfont_configure, #latintagfont_copy, #tagfont_configinfo, #tagfont_configure, #tagfont_copy
Instance Method Details
#current_itemconfiginfo(tagOrId, slot = nil) ⇒ Object
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
|
# File 'lib/tk/itemconfig.rb', line 1029
def current_itemconfiginfo(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
org_slot = slot
begin
conf = __itemconfiginfo_core(tagOrId, slot)
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
return {conf[0] => conf[-1]}
end
slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
end while(org_slot != slot)
fail RuntimeError,
"there is a configure alias loop about '#{org_slot}'"
else
ret = {}
__itemconfiginfo_core(tagOrId).each{|conf|
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
ret[conf[0]] = conf[-1]
end
}
ret
end
else
ret = {}
__itemconfiginfo_core(tagOrId, slot).each{|key, conf|
ret[key] = conf[-1] if conf.kind_of?(Array)
}
ret
end
end
|
#itemcget(tagOrId, option) ⇒ Object
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
|
# File 'lib/tk/itemconfig.rb', line 152
def itemcget(tagOrId, option)
orig_opt = option
option = option.to_s
if option.length == 0
fail ArgumentError, "Invalid option `#{orig_opt.inspect}'"
end
if ( method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[option] )
optval = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
begin
return method.call(tagOrId, optval)
rescue => e
warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
return optval
end
end
if ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[option] )
return self.__send__(method, tagOrId)
end
case option
when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
begin
number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
rescue
nil
end
when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
num_or_str(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
begin
bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
rescue
nil
end
when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
simplelist(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
conf = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
if conf =~ /^[0-9]/
list(conf)
else
conf
end
when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
v = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
(v.empty?)? nil: TkVarAccess.new(v)
when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
_fromUTF8(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
when /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/
fontcode = $1
fontkey = $2
fnt = tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{fontkey}")), true)
unless fnt.kind_of?(TkFont)
fnt = tagfontobj(tagid(tagOrId), fontkey)
end
if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
fnt.kanji_font
else
fnt
end
else
tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
end
end
|
#itemconfiginfo(tagOrId, slot = nil) ⇒ Object
1025
1026
1027
|
# File 'lib/tk/itemconfig.rb', line 1025
def itemconfiginfo(tagOrId, slot = nil)
__itemconfiginfo_core(tagOrId, slot)
end
|
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
|
# File 'lib/tk/itemconfig.rb', line 228
def itemconfigure(tagOrId, slot, value=None)
if slot.kind_of? Hash
slot = _symbolkey2str(slot)
__item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
value = slot.delete(key.to_s)
self.__send__(method, tagOrId, value) if value
}
__item_ruby2val_optkeys(tagid(tagOrId)).each{|key, method|
key = key.to_s
slot[key] = method.call(tagOrId, slot[key]) if slot.has_key?(key)
}
__item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey|
conf = slot.find{|kk, vv| kk == defkey.to_s}
if conf
k, v = conf
if v
slot[k] = None
else
slot[undefkey.to_s] = None if undefkey
slot.delete(k)
end
end
}
if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/})
tagfont_configure(tagid(tagOrId), slot)
elsif slot.size > 0
tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot))))
end
else
orig_slot = slot
slot = slot.to_s
if slot.length == 0
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
end
if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
defkey, undefkey = conf
if value
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}"))
elsif undefkey
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}"))
end
elsif ( method = _symbolkey2str(__item_ruby2val_optkeys(tagid(tagOrId)))[slot] )
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << method.call(tagOrId, value)))
elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] )
self.__send__(method, tagOrId, value)
elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
if value == None
tagfontobj(tagid(tagOrId), $2)
else
tagfont_configure(tagid(tagOrId), {slot=>value})
end
else
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value))
end
end
self
end
|
#tagid(tagOrId) ⇒ Object
145
146
147
148
|
# File 'lib/tk/itemconfig.rb', line 145
def tagid(tagOrId)
tagOrId
end
|