class Fzeet::Windows::HTMLElement
Attributes
handlers[R]
Public Instance Methods
attr(*args)
click to toggle source
# File lib/fzeet/windows/mshtml/Common.rb, line 776 def attr(*args) case args.length when 1 getAttribute(bstr = Windows.SysAllocString("#{args[0]}\0".encode('utf-16le')), 0, v = VARIANT.new) case v[:vt] when VT_BSTR; (v[:bstrVal].null?) ? nil : Windows.WCSTOMBS(v[:bstrVal]) when VT_I4; v[:lVal] when VT_BOOL; v[:boolVal] == -1 else raise end when 2 v = VARIANT.new case args[1] when String; v[:vt] = VT_BSTR; v[:bstrVal] = bstrv = Windows.SysAllocString("#{args[0]}\0".encode('utf-16le')) when Integer; v[:vt] = VT_I4; v[:lVal] = args[1] when TrueClass; v[:vt] = VT_BOOL; v[:boolVal] = -1 when FalseClass, NilClass; v[:vt] = VT_BOOL; v[:boolVal] = 0 else raise ArgumentError end setAttribute(bstr = Windows.SysAllocString("#{args[0]}\0".encode('utf-16le')), v, 0) self else raise ArgumentError end ensure Windows.SysFreeString(bstr) if bstr Windows.SysFreeString(bstrv) if bstrv end
css(hash)
click to toggle source
# File lib/fzeet/windows/mshtml/Common.rb, line 818 def css(hash) s = style; hash.each { |k, v| s.send("#{k}=", v) }; self end
node()
click to toggle source
# File lib/fzeet/windows/mshtml/Common.rb, line 808 def node; QueryInstance(HTMLDOMNode) end
on(event, &block)
click to toggle source
# File lib/fzeet/windows/mshtml/Common.rb, line 710 def on(event, &block) ((@handlers ||= {})[event] ||= []) << block @dcallbacks ||= [] send("put_on#{event}", VARIANT.new.tap { |v| v[:vt] = VT_DISPATCH v[:pdispVal] = @dcallbacks.push(DCallback.new.tap { |dcb| dcb.instance_variable_set(:@element, self) dcb.instance_variable_set(:@event, event) def dcb.Invoke(*args) @element.handlers[@event].each { |handler| (handler.arity == 0) ? handler.call : handler.call(*args) } S_OK end }).last }) unless @handlers[event].length > 1 self end
style()
click to toggle source
# File lib/fzeet/windows/mshtml/Common.rb, line 810 def style FFI::MemoryPointer.new(:pointer) { |pstyle| get_style(pstyle) return HTMLStyle.new(pstyle.read_pointer) } end