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.

96 lines
3.1KB

  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 UIAGridItemProvider : public UIAProviderBase,
  17. public ComBaseClassHelper<ComTypes::IGridItemProvider>
  18. {
  19. public:
  20. using UIAProviderBase::UIAProviderBase;
  21. //==============================================================================
  22. JUCE_COMRESULT get_Row (int* pRetVal) override
  23. {
  24. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  25. {
  26. *pRetVal = cellInterface.getRowIndex();
  27. });
  28. }
  29. JUCE_COMRESULT get_Column (int* pRetVal) override
  30. {
  31. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  32. {
  33. *pRetVal = cellInterface.getColumnIndex();
  34. });
  35. }
  36. JUCE_COMRESULT get_RowSpan (int* pRetVal) override
  37. {
  38. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  39. {
  40. *pRetVal = cellInterface.getRowSpan();
  41. });
  42. }
  43. JUCE_COMRESULT get_ColumnSpan (int* pRetVal) override
  44. {
  45. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  46. {
  47. *pRetVal = cellInterface.getColumnSpan();
  48. });
  49. }
  50. JUCE_COMRESULT get_ContainingGrid (IRawElementProviderSimple** pRetVal) override
  51. {
  52. return withCellInterface (pRetVal, [&] (const AccessibilityCellInterface& cellInterface)
  53. {
  54. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token")
  55. if (auto* handler = cellInterface.getTableHandler())
  56. handler->getNativeImplementation()->QueryInterface (IID_PPV_ARGS (pRetVal));
  57. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  58. });
  59. }
  60. private:
  61. template <typename Value, typename Callback>
  62. JUCE_COMRESULT withCellInterface (Value* pRetVal, Callback&& callback) const
  63. {
  64. return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
  65. {
  66. if (auto* cellInterface = getHandler().getCellInterface())
  67. {
  68. callback (*cellInterface);
  69. return S_OK;
  70. }
  71. return (HRESULT) UIA_E_NOTSUPPORTED;
  72. });
  73. }
  74. //==============================================================================
  75. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAGridItemProvider)
  76. };
  77. } // namespace juce