Class: Fzeet::Windows::PropertyStore

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/fzeet/windows/propsys.rb,
lib/fzeet/windows/uiribbon.rb

Instance Method Summary collapse

Instance Method Details

#commitObject



41
# File 'lib/fzeet/windows/propsys.rb', line 41

def commit; Commit(); self end

#countObject Also known as: size, length



23
# File 'lib/fzeet/windows/propsys.rb', line 23

def count; FFI::MemoryPointer.new(:ulong) { |pc| GetCount(pc); return pc.get_ulong(0) } end

#eachObject



43
# File 'lib/fzeet/windows/propsys.rb', line 43

def each; length.times { |i| v = get(k = key(i)); yield k, v }; self end

#get(k) ⇒ Object

superclass.superclass is FFI::Struct, so do NOT touch [] and []=



30
# File 'lib/fzeet/windows/propsys.rb', line 30

def get(k) PROPVARIANT.new.tap { |v| GetValue(k, v) } end

#key(i) ⇒ Object



27
# File 'lib/fzeet/windows/propsys.rb', line 27

def key(i) PROPERTYKEY.new.tap { |k| GetAt(i, k) } end

#prop(*args) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/fzeet/windows/propsys.rb', line 33

def prop(*args)
  case args.length
  when 1; get(*args)
  when 2; set(*args)
  else raise ArgumentError
  end
end

#set(k, v) ⇒ Object



31
# File 'lib/fzeet/windows/propsys.rb', line 31

def set(k, v) SetValue(k, v); self end

#uiprop(*args) ⇒ Object



411
412
413
414
415
# File 'lib/fzeet/windows/uiribbon.rb', line 411

def uiprop(*args)
  args[0] = Windows.const_get("UI_PKEY_#{args[0]}")

  prop(*args)
end

#update(from) ⇒ Object



417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/fzeet/windows/uiribbon.rb', line 417

def update(from)
  case from
  when Windows::LOGFONT
    uiprop(:FontProperties_Family, Windows::PROPVARIANT[:wstring, from.face])
    uiprop(:FontProperties_Size, Windows::PROPVARIANT[:decimal, from.size.round])
    uiprop(:FontProperties_Bold, Windows::PROPVARIANT[:uint, (from.bold?) ? 2 : 1])
    uiprop(:FontProperties_Italic, Windows::PROPVARIANT[:uint, (from.italic?) ? 2 : 1])
    uiprop(:FontProperties_Underline, Windows::PROPVARIANT[:uint, (from.underline?) ? 2 : 1])
    uiprop(:FontProperties_Strikethrough, Windows::PROPVARIANT[:uint, (from.strikeout?) ? 2 : 1])
  else raise ArgumentError
  end

  self
end