Class: WinFFI::Gdi32::PIXELFORMATDESCRIPTOR

Inherits:
FFIStruct
  • Object
show all
Defined in:
lib/win-ffi/structs/gdi32/pixel_format_descriptor.rb

Constant Summary collapse

FLAGS_INV =
PFDFlags.to_hash.reduce(Hash.new{|h,k| h[k] = []}){|h,(k,v)| h[v] << k; h}.freeze

Instance Method Summary collapse

Methods inherited from FFIStruct

layout

Constructor Details

#initializePIXELFORMATDESCRIPTOR

TODO undef_method :nSize=



38
39
40
41
# File 'lib/win-ffi/structs/gdi32/pixel_format_descriptor.rb', line 38

def initialize
  super
  self[:nSize] = self.size
end

Instance Method Details

#dwFlagsObject



43
44
45
46
# File 'lib/win-ffi/structs/gdi32/pixel_format_descriptor.rb', line 43

def dwFlags
  val = self[:dwFlags]
  Set.new(FLAGS_INV.select{|k,_| val & k != 0}.reduce([]) {|a,(_,v)| a << v}.flatten)
end

#dwFlags=(flags) ⇒ Object



48
49
50
# File 'lib/win-ffi/structs/gdi32/pixel_format_descriptor.rb', line 48

def dwFlags=(flags)
  self[:dwFlags] = [*flags].reduce(0) {|a,f| a | PFDFlags[f].to_i}
end

#to_sObject



52
53
54
# File 'lib/win-ffi/structs/gdi32/pixel_format_descriptor.rb', line 52

def to_s
  [:iPixelType, :cColorBits, :cAccumBits, :cDepthBits, :iLayerType, :dwFlags].map{|n| "#{n} = #{send(n).inspect}"}.join(', ')
end