Module: Tk::ItemValidateConfigure
- Included in:
- BLT::Treeview
- Defined in:
- lib/tk/validation.rb
Class Method Summary collapse
Instance Method Summary collapse
- #__conv_item_vcmd_on_hash_kv(keys) ⇒ Object
- #__get_item_validate_key2class(id) ⇒ Object
- #__item_validation_class_list(id) ⇒ Object
- #__item_validcmd_call(tagOrId, klass, key, *args, &b) ⇒ Object
- #itemconfigure(tagOrId, slot, value = TkComm::None) ⇒ Object
Class Method Details
.__def_validcmd(scope, klass, keys = nil) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/tk/validation.rb', line 112 def self.__def_validcmd(scope, klass, keys=nil) keys = klass._config_keys unless keys keys.each{|key| eval("def item_#{key}(id, *args, &b) __item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b) end", scope) } end |
Instance Method Details
#__conv_item_vcmd_on_hash_kv(keys) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/tk/validation.rb', line 149 def __conv_item_vcmd_on_hash_kv(keys) key2class = __get_item_validate_key2class(tagid(tagOrId)) keys = _symbolkey2str(keys) key2class.each{|key, klass| if keys[key].kind_of?(Array) cmd, *args = keys[key] #keys[key] = klass.new(cmd, args.join(' ')) keys[key] = klass.new(cmd, *args) # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) end } keys end |
#__get_item_validate_key2class(id) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/tk/validation.rb', line 140 def __get_item_validate_key2class(id) k2c = {} __item_validation_class_list(id).each{|klass| klass._config_keys.each{|key| k2c[key.to_s] = klass } } end |
#__item_validation_class_list(id) ⇒ Object
135 136 137 138 |
# File 'lib/tk/validation.rb', line 135 def __item_validation_class_list(id) # maybe need to override [] end |
#__item_validcmd_call(tagOrId, klass, key, *args, &b) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/tk/validation.rb', line 121 def __item_validcmd_call(tagOrId, klass, key, *args, &b) return itemcget(tagid(tagOrId), key) if args.empty? && !b cmd = (b)? proc(&b) : args.shift if cmd.kind_of?(klass) itemconfigure(tagid(tagOrId), key, cmd) elsif !args.empty? itemconfigure(tagid(tagOrId), key, [cmd, args]) else itemconfigure(tagid(tagOrId), key, cmd) end end |
#itemconfigure(tagOrId, slot, value = TkComm::None) ⇒ Object
166 167 168 169 170 171 172 173 |
# File 'lib/tk/validation.rb', line 166 def itemconfigure(tagOrId, slot, value=TkComm::None) if slot.kind_of?(Hash) super(__conv_item_vcmd_on_hash_kv(slot)) else super(__conv_item_vcmd_on_hash_kv(slot=>value)) end self end |