The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. class UIAGridProvider : public UIAProviderBase,
  17. public ComBaseClassHelper<ComTypes::IGridProvider>
  18. {
  19. public:
  20. using UIAProviderBase::UIAProviderBase;
  21. //==============================================================================
  22. JUCE_COMRESULT GetItem (int row, int column, IRawElementProviderSimple** pRetVal) override
  23. {
  24. return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface)
  25. {
  26. if (! isPositiveAndBelow (row, tableInterface.getNumRows())
  27. || ! isPositiveAndBelow (column, tableInterface.getNumColumns()))
  28. return E_INVALIDARG;
  29. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token")
  30. if (auto* handler = tableInterface.getCellHandler (row, column))
  31. handler->getNativeImplementation()->QueryInterface (IID_PPV_ARGS (pRetVal));
  32. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  33. return S_OK;
  34. });
  35. }
  36. JUCE_COMRESULT get_RowCount (int* pRetVal) override
  37. {
  38. return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface)
  39. {
  40. *pRetVal = tableInterface.getNumRows();
  41. return S_OK;
  42. });
  43. }
  44. JUCE_COMRESULT get_ColumnCount (int* pRetVal) override
  45. {
  46. return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface)
  47. {
  48. *pRetVal = tableInterface.getNumColumns();
  49. return S_OK;
  50. });
  51. }
  52. private:
  53. template <typename Value, typename Callback>
  54. JUCE_COMRESULT withTableInterface (Value* pRetVal, Callback&& callback) const
  55. {
  56. return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
  57. {
  58. if (auto* tableInterface = getHandler().getTableInterface())
  59. return callback (*tableInterface);
  60. return (HRESULT) UIA_E_NOTSUPPORTED;
  61. });
  62. }
  63. //==============================================================================
  64. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAGridProvider)
  65. };
  66. } // namespace juce