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.

77 lines
2.4KB

  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 UIAValueProvider : public UIAProviderBase,
  17. public ComBaseClassHelper<ComTypes::IValueProvider>
  18. {
  19. public:
  20. using UIAProviderBase::UIAProviderBase;
  21. //==============================================================================
  22. JUCE_COMRESULT SetValue (LPCWSTR val) override
  23. {
  24. if (! isElementValid())
  25. return (HRESULT) UIA_E_ELEMENTNOTAVAILABLE;
  26. const auto& handler = getHandler();
  27. auto& valueInterface = *handler.getValueInterface();
  28. if (valueInterface.isReadOnly())
  29. return (HRESULT) UIA_E_NOTSUPPORTED;
  30. valueInterface.setValueAsString (String (val));
  31. VARIANT newValue;
  32. VariantHelpers::setString (valueInterface.getCurrentValueAsString(), &newValue);
  33. sendAccessibilityPropertyChangedEvent (handler, UIA_ValueValuePropertyId, newValue);
  34. return S_OK;
  35. }
  36. JUCE_COMRESULT get_Value (BSTR* pRetVal) override
  37. {
  38. return withCheckedComArgs (pRetVal, *this, [&]
  39. {
  40. auto currentValueString = getHandler().getValueInterface()->getCurrentValueAsString();
  41. *pRetVal = SysAllocString ((const OLECHAR*) currentValueString.toWideCharPointer());
  42. return S_OK;
  43. });
  44. }
  45. JUCE_COMRESULT get_IsReadOnly (BOOL* pRetVal) override
  46. {
  47. return withCheckedComArgs (pRetVal, *this, [&]
  48. {
  49. *pRetVal = getHandler().getValueInterface()->isReadOnly();
  50. return S_OK;
  51. });
  52. }
  53. private:
  54. //==============================================================================
  55. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAValueProvider)
  56. };
  57. } // namespace juce