Module: Uia::Library::ElementLayout

Included in:
ElementStruct, ManagedElementStruct
Defined in:
lib/uia/library/element_structs.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/uia/library/element_structs.rb', line 8

def self.included(base)
  base.class_eval do
    extend StructAttributes

    layout :handle, :int,
           :runtime_id, :pointer,
           :number_of_ids, :int,
           :name, :string,
           :help_text, :string,
           :class_name, :string,
           :control_type_id, :int,
           :patterns, :pointer,
           :patterns_length, :int,
           :id, :string,
           :is_enabled, :bool,
           :is_visible, :bool,
           :has_focus, :bool,
           :bounding_rectangle, [:long, 4]

    struct_attr :id, :name, :handle, :control_type_id, :class_name, :help_text,
                [:enabled?, :is_enabled], [:visible?, :is_visible], [:focused?, :has_focus]

    def runtime_id
      self[:runtime_id].read_array_of_int(number_of_ids)
    end

    def bounding_rectangle
      self[:bounding_rectangle].to_a
    end

    def pattern_ids
      self[:patterns].read_array_of_int(self[:patterns_length])
    end

    def children
      Library.children(self)
    end

    def descendants
      Library.descendants(self)
    end

    def empty?
      to_ptr.address == 0
    end

    private
    def number_of_ids
      self[:number_of_ids]
    end
  end
end