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.

103 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. class UIAGridItemProvider : public UIAProviderBase,
  22. public ComBaseClassHelper<ComTypes::IGridItemProvider>
  23. {
  24. public:
  25. using UIAProviderBase::UIAProviderBase;
  26. //==============================================================================
  27. JUCE_COMRESULT get_Row (int* pRetVal) override
  28. {
  29. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  30. {
  31. *pRetVal = cellInterface.getRowIndex();
  32. });
  33. }
  34. JUCE_COMRESULT get_Column (int* pRetVal) override
  35. {
  36. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  37. {
  38. *pRetVal = cellInterface.getColumnIndex();
  39. });
  40. }
  41. JUCE_COMRESULT get_RowSpan (int* pRetVal) override
  42. {
  43. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  44. {
  45. *pRetVal = cellInterface.getRowSpan();
  46. });
  47. }
  48. JUCE_COMRESULT get_ColumnSpan (int* pRetVal) override
  49. {
  50. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  51. {
  52. *pRetVal = cellInterface.getColumnSpan();
  53. });
  54. }
  55. JUCE_COMRESULT get_ContainingGrid (IRawElementProviderSimple** pRetVal) override
  56. {
  57. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  58. {
  59. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token")
  60. if (auto* handler = cellInterface.getTableHandler())
  61. handler->getNativeImplementation()->QueryInterface (IID_PPV_ARGS (pRetVal));
  62. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  63. });
  64. }
  65. private:
  66. template <typename Value, typename Callback>
  67. JUCE_COMRESULT withCellInterface (Value* pRetVal, Callback&& callback) const
  68. {
  69. return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
  70. {
  71. if (auto* cellInterface = getHandler().getCellInterface())
  72. {
  73. callback (*cellInterface);
  74. return S_OK;
  75. }
  76. return (HRESULT) UIA_E_NOTSUPPORTED;
  77. });
  78. }
  79. //==============================================================================
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAGridItemProvider)
  81. };
  82. } // namespace juce