// iuiautomationelement8.dart

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: unused_import
// ignore_for_file: constant_identifier_names, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers

import 'dart:ffi';

import 'package:ffi/ffi.dart';

import '../callbacks.dart';
import '../combase.dart';
import '../constants.dart';
import '../exceptions.dart';
import '../guid.dart';
import '../macros.dart';
import '../propertykey.dart';
import '../structs.g.dart';
import '../utils.dart';
import '../variant.dart';
import '../win32/ole32.g.dart';
import 'iuiautomationelement7.dart';
import 'iunknown.dart';

/// @nodoc
const IID_IUIAutomationElement8 = '{8c60217d-5411-4cde-bcc0-1ceda223830c}';

/// Extends the IUIAutomationElement7 interface.
///
/// {@category com}
class IUIAutomationElement8 extends IUIAutomationElement7 {
  // vtable begins at 115, is 2 entries long.
  IUIAutomationElement8(super.ptr);

  factory IUIAutomationElement8.from(IUnknown interface) =>
      IUIAutomationElement8(interface.toInterface(IID_IUIAutomationElement8));

  int get currentHeadingLevel {
    final retValuePtr = calloc<Uint32>();

    try {
      final hr = (ptr.ref.vtable + 115)
          .cast<
            Pointer<
              NativeFunction<Int32 Function(Pointer, Pointer<Uint32> retVal)>
            >
          >()
          .value
          .asFunction<
            int Function(Pointer, Pointer<Uint32> retVal)
          >()(ptr.ref.lpVtbl, retValuePtr);

      if (FAILED(hr)) throw WindowsException(hr);

      final retValue = retValuePtr.value;
      return retValue;
    } finally {
      free(retValuePtr);
    }
  }

  int get cachedHeadingLevel {
    final retValuePtr = calloc<Uint32>();

    try {
      final hr = (ptr.ref.vtable + 116)
          .cast<
            Pointer<
              NativeFunction<Int32 Function(Pointer, Pointer<Uint32> retVal)>
            >
          >()
          .value
          .asFunction<
            int Function(Pointer, Pointer<Uint32> retVal)
          >()(ptr.ref.lpVtbl, retValuePtr);

      if (FAILED(hr)) throw WindowsException(hr);

      final retValue = retValuePtr.value;
      return retValue;
    } finally {
      free(retValuePtr);
    }
  }
}
