VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / native / accessibility / juce_win32_UIAWindowProvider.h
blobd3abd8cdf37b4d35191025843466e553940b5401
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 class UIAWindowProvider : public UIAProviderBase,
31 public ComBaseClassHelper<ComTypes::IWindowProvider>
33 public:
34 using UIAProviderBase::UIAProviderBase;
36 //==============================================================================
37 JUCE_COMRESULT SetVisualState (ComTypes::WindowVisualState state) override
39 if (! isElementValid())
40 return (HRESULT) UIA_E_ELEMENTNOTAVAILABLE;
42 if (auto* peer = getPeer())
44 switch (state)
46 case ComTypes::WindowVisualState_Maximized:
47 peer->setFullScreen (true);
48 break;
50 case ComTypes::WindowVisualState_Minimized:
51 peer->setMinimised (true);
52 break;
54 case ComTypes::WindowVisualState_Normal:
55 peer->setFullScreen (false);
56 peer->setMinimised (false);
57 break;
59 default:
60 break;
63 return S_OK;
66 return (HRESULT) UIA_E_NOTSUPPORTED;
69 JUCE_COMRESULT Close() override
71 if (! isElementValid())
72 return (HRESULT) UIA_E_ELEMENTNOTAVAILABLE;
74 if (auto* peer = getPeer())
76 peer->handleUserClosingWindow();
77 return S_OK;
80 return (HRESULT) UIA_E_NOTSUPPORTED;
83 JUCE_COMRESULT WaitForInputIdle (int, BOOL* pRetVal) override
85 return withCheckedComArgs (pRetVal, *this, []
87 return (HRESULT) UIA_E_NOTSUPPORTED;
88 });
91 JUCE_COMRESULT get_CanMaximize (BOOL* pRetVal) override
93 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
95 if (auto* peer = getPeer())
97 *pRetVal = (peer->getStyleFlags() & ComponentPeer::windowHasMaximiseButton) != 0;
98 return S_OK;
101 return (HRESULT) UIA_E_NOTSUPPORTED;
105 JUCE_COMRESULT get_CanMinimize (BOOL* pRetVal) override
107 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
109 if (auto* peer = getPeer())
111 *pRetVal = (peer->getStyleFlags() & ComponentPeer::windowHasMinimiseButton) != 0;
112 return S_OK;
115 return (HRESULT) UIA_E_NOTSUPPORTED;
119 JUCE_COMRESULT get_IsModal (BOOL* pRetVal) override
121 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
123 if (auto* peer = getPeer())
125 *pRetVal = peer->getComponent().isCurrentlyModal();
126 return S_OK;
129 return (HRESULT) UIA_E_NOTSUPPORTED;
133 JUCE_COMRESULT get_WindowVisualState (ComTypes::WindowVisualState* pRetVal) override
135 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
137 if (auto* peer = getPeer())
139 if (peer->isFullScreen())
140 *pRetVal = ComTypes::WindowVisualState_Maximized;
141 else if (peer->isMinimised())
142 *pRetVal = ComTypes::WindowVisualState_Minimized;
143 else
144 *pRetVal = ComTypes::WindowVisualState_Normal;
146 return S_OK;
149 return (HRESULT) UIA_E_NOTSUPPORTED;
153 JUCE_COMRESULT get_WindowInteractionState (ComTypes::WindowInteractionState* pRetVal) override
155 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
157 if (auto* peer = getPeer())
159 *pRetVal = peer->getComponent().isCurrentlyBlockedByAnotherModalComponent()
160 ? ComTypes::WindowInteractionState::WindowInteractionState_BlockedByModalWindow
161 : ComTypes::WindowInteractionState::WindowInteractionState_Running;
163 return S_OK;
166 return (HRESULT) UIA_E_NOTSUPPORTED;
170 JUCE_COMRESULT get_IsTopmost (BOOL* pRetVal) override
172 return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT
174 if (auto* peer = getPeer())
176 *pRetVal = peer->isFocused();
177 return S_OK;
180 return (HRESULT) UIA_E_NOTSUPPORTED;
184 private:
185 ComponentPeer* getPeer() const
187 return getHandler().getComponent().getPeer();
190 //==============================================================================
191 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAWindowProvider)
194 } // namespace juce