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
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
23 ==============================================================================
29 //==============================================================================
30 class UIAWindowProvider
: public UIAProviderBase
,
31 public ComBaseClassHelper
<ComTypes::IWindowProvider
>
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())
46 case ComTypes::WindowVisualState_Maximized
:
47 peer
->setFullScreen (true);
50 case ComTypes::WindowVisualState_Minimized
:
51 peer
->setMinimised (true);
54 case ComTypes::WindowVisualState_Normal
:
55 peer
->setFullScreen (false);
56 peer
->setMinimised (false);
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();
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
;
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;
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;
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();
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
;
144 *pRetVal
= ComTypes::WindowVisualState_Normal
;
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
;
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();
180 return (HRESULT
) UIA_E_NOTSUPPORTED
;
185 ComponentPeer
* getPeer() const
187 return getHandler().getComponent().getPeer();
190 //==============================================================================
191 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAWindowProvider
)