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.

433 lines
16KB

  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. #ifdef JUCE_GUI_BASICS_H_INCLUDED
  19. /* When you add this cpp file to your project, you mustn't include it in a file where you've
  20. already included any other headers - just put it inside a file on its own, possibly with your config
  21. flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
  22. header files that the compiler may be using.
  23. */
  24. #error "Incorrect use of JUCE cpp file"
  25. #endif
  26. #define NS_FORMAT_FUNCTION(F,A) // To avoid spurious warnings from GCC
  27. #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
  28. #define JUCE_CORE_INCLUDE_COM_SMART_PTR 1
  29. #define JUCE_CORE_INCLUDE_JNI_HELPERS 1
  30. #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
  31. #define JUCE_EVENTS_INCLUDE_WIN32_MESSAGE_WINDOW 1
  32. #define JUCE_GRAPHICS_INCLUDE_COREGRAPHICS_HELPERS 1
  33. #define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
  34. #define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1
  35. #include "juce_gui_basics.h"
  36. //==============================================================================
  37. #if JUCE_MAC
  38. #import <WebKit/WebKit.h>
  39. #import <IOKit/pwr_mgt/IOPMLib.h>
  40. #if JUCE_SUPPORT_CARBON
  41. #import <Carbon/Carbon.h> // still needed for SetSystemUIMode()
  42. #endif
  43. #elif JUCE_IOS
  44. #if JUCE_PUSH_NOTIFICATIONS && defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
  45. #import <UserNotifications/UserNotifications.h>
  46. #endif
  47. #import <UIKit/UIActivityViewController.h>
  48. //==============================================================================
  49. #elif JUCE_WINDOWS
  50. #include <windowsx.h>
  51. #include <vfw.h>
  52. #include <commdlg.h>
  53. #include <commctrl.h>
  54. #include <UIAutomation.h>
  55. #include <sapi.h>
  56. #if JUCE_WEB_BROWSER
  57. #include <exdisp.h>
  58. #include <exdispid.h>
  59. #endif
  60. #if JUCE_MINGW
  61. #include <imm.h>
  62. #elif ! JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
  63. #pragma comment(lib, "vfw32.lib")
  64. #pragma comment(lib, "imm32.lib")
  65. #pragma comment(lib, "comctl32.lib")
  66. #if JUCE_OPENGL
  67. #pragma comment(lib, "OpenGL32.Lib")
  68. #pragma comment(lib, "GlU32.Lib")
  69. #endif
  70. #if JUCE_DIRECT2D
  71. #pragma comment (lib, "Dwrite.lib")
  72. #pragma comment (lib, "D2d1.lib")
  73. #endif
  74. #endif
  75. #endif
  76. //==============================================================================
  77. #define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \
  78. jassert ((MessageManager::getInstanceWithoutCreating() != nullptr \
  79. && MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()) \
  80. || getPeer() == nullptr);
  81. namespace juce
  82. {
  83. bool juce_areThereAnyAlwaysOnTopWindows();
  84. bool isEmbeddedInForegroundProcess (Component* c);
  85. #if ! JUCE_WINDOWS
  86. bool isEmbeddedInForegroundProcess (Component*) { return false; }
  87. #endif
  88. /* Returns true if this process is in the foreground, or if the viewComponent
  89. is embedded into a window owned by the foreground process.
  90. */
  91. static bool isForegroundOrEmbeddedProcess (Component* viewComponent)
  92. {
  93. return Process::isForegroundProcess() || isEmbeddedInForegroundProcess (viewComponent);
  94. }
  95. bool isWindowOnCurrentVirtualDesktop (void*);
  96. struct CustomMouseCursorInfo
  97. {
  98. ScaledImage image;
  99. Point<int> hotspot;
  100. };
  101. } // namespace juce
  102. #include "mouse/juce_PointerState.h"
  103. #include "accessibility/juce_AccessibilityHandler.cpp"
  104. #include "components/juce_Component.cpp"
  105. #include "components/juce_ComponentListener.cpp"
  106. #include "components/juce_FocusTraverser.cpp"
  107. #include "mouse/juce_MouseInputSource.cpp"
  108. #include "desktop/juce_Displays.cpp"
  109. #include "desktop/juce_Desktop.cpp"
  110. #include "components/juce_ModalComponentManager.cpp"
  111. #include "mouse/juce_ComponentDragger.cpp"
  112. #include "mouse/juce_DragAndDropContainer.cpp"
  113. #include "mouse/juce_MouseEvent.cpp"
  114. #include "mouse/juce_MouseInactivityDetector.cpp"
  115. #include "mouse/juce_MouseListener.cpp"
  116. #include "keyboard/juce_CaretComponent.cpp"
  117. #include "keyboard/juce_KeyboardFocusTraverser.cpp"
  118. #include "keyboard/juce_KeyListener.cpp"
  119. #include "keyboard/juce_KeyPress.cpp"
  120. #include "keyboard/juce_ModifierKeys.cpp"
  121. #include "buttons/juce_ArrowButton.cpp"
  122. #include "buttons/juce_Button.cpp"
  123. #include "buttons/juce_DrawableButton.cpp"
  124. #include "buttons/juce_HyperlinkButton.cpp"
  125. #include "buttons/juce_ImageButton.cpp"
  126. #include "buttons/juce_ShapeButton.cpp"
  127. #include "buttons/juce_TextButton.cpp"
  128. #include "buttons/juce_ToggleButton.cpp"
  129. #include "buttons/juce_ToolbarButton.cpp"
  130. #include "drawables/juce_Drawable.cpp"
  131. #include "drawables/juce_DrawableComposite.cpp"
  132. #include "drawables/juce_DrawableImage.cpp"
  133. #include "drawables/juce_DrawablePath.cpp"
  134. #include "drawables/juce_DrawableRectangle.cpp"
  135. #include "drawables/juce_DrawableShape.cpp"
  136. #include "drawables/juce_DrawableText.cpp"
  137. #include "drawables/juce_SVGParser.cpp"
  138. #include "filebrowser/juce_DirectoryContentsDisplayComponent.cpp"
  139. #include "filebrowser/juce_DirectoryContentsList.cpp"
  140. #include "filebrowser/juce_FileBrowserComponent.cpp"
  141. #include "filebrowser/juce_FileChooser.cpp"
  142. #include "filebrowser/juce_FileChooserDialogBox.cpp"
  143. #include "filebrowser/juce_FileListComponent.cpp"
  144. #include "filebrowser/juce_FilenameComponent.cpp"
  145. #include "filebrowser/juce_FileSearchPathListComponent.cpp"
  146. #include "filebrowser/juce_FileTreeComponent.cpp"
  147. #include "filebrowser/juce_ImagePreviewComponent.cpp"
  148. #include "filebrowser/juce_ContentSharer.cpp"
  149. #include "layout/juce_ComponentAnimator.cpp"
  150. #include "layout/juce_ComponentBoundsConstrainer.cpp"
  151. #include "layout/juce_ComponentBuilder.cpp"
  152. #include "layout/juce_ComponentMovementWatcher.cpp"
  153. #include "layout/juce_ConcertinaPanel.cpp"
  154. #include "layout/juce_GroupComponent.cpp"
  155. #include "layout/juce_MultiDocumentPanel.cpp"
  156. #include "layout/juce_ResizableBorderComponent.cpp"
  157. #include "layout/juce_ResizableCornerComponent.cpp"
  158. #include "layout/juce_ResizableEdgeComponent.cpp"
  159. #include "layout/juce_ScrollBar.cpp"
  160. #include "layout/juce_SidePanel.cpp"
  161. #include "layout/juce_StretchableLayoutManager.cpp"
  162. #include "layout/juce_StretchableLayoutResizerBar.cpp"
  163. #include "layout/juce_StretchableObjectResizer.cpp"
  164. #include "layout/juce_TabbedButtonBar.cpp"
  165. #include "layout/juce_TabbedComponent.cpp"
  166. #include "layout/juce_Viewport.cpp"
  167. #include "lookandfeel/juce_LookAndFeel.cpp"
  168. #include "lookandfeel/juce_LookAndFeel_V2.cpp"
  169. #include "lookandfeel/juce_LookAndFeel_V1.cpp"
  170. #include "lookandfeel/juce_LookAndFeel_V3.cpp"
  171. #include "lookandfeel/juce_LookAndFeel_V4.cpp"
  172. #include "menus/juce_MenuBarComponent.cpp"
  173. #include "menus/juce_BurgerMenuComponent.cpp"
  174. #include "menus/juce_MenuBarModel.cpp"
  175. #include "menus/juce_PopupMenu.cpp"
  176. #include "positioning/juce_MarkerList.cpp"
  177. #include "positioning/juce_RelativeCoordinate.cpp"
  178. #include "positioning/juce_RelativeCoordinatePositioner.cpp"
  179. #include "positioning/juce_RelativeParallelogram.cpp"
  180. #include "positioning/juce_RelativePoint.cpp"
  181. #include "positioning/juce_RelativePointPath.cpp"
  182. #include "positioning/juce_RelativeRectangle.cpp"
  183. #include "properties/juce_BooleanPropertyComponent.cpp"
  184. #include "properties/juce_ButtonPropertyComponent.cpp"
  185. #include "properties/juce_ChoicePropertyComponent.cpp"
  186. #include "properties/juce_PropertyComponent.cpp"
  187. #include "properties/juce_PropertyPanel.cpp"
  188. #include "properties/juce_SliderPropertyComponent.cpp"
  189. #include "properties/juce_TextPropertyComponent.cpp"
  190. #include "properties/juce_MultiChoicePropertyComponent.cpp"
  191. #include "widgets/juce_ComboBox.cpp"
  192. #include "widgets/juce_ImageComponent.cpp"
  193. #include "widgets/juce_Label.cpp"
  194. #include "widgets/juce_ListBox.cpp"
  195. #include "widgets/juce_ProgressBar.cpp"
  196. #include "widgets/juce_Slider.cpp"
  197. #include "widgets/juce_TableHeaderComponent.cpp"
  198. #include "widgets/juce_TableListBox.cpp"
  199. #include "widgets/juce_TextEditor.cpp"
  200. #include "widgets/juce_ToolbarItemComponent.cpp"
  201. #include "widgets/juce_Toolbar.cpp"
  202. #include "widgets/juce_ToolbarItemPalette.cpp"
  203. #include "widgets/juce_TreeView.cpp"
  204. #include "windows/juce_AlertWindow.cpp"
  205. #include "windows/juce_CallOutBox.cpp"
  206. #include "windows/juce_ComponentPeer.cpp"
  207. #include "windows/juce_DialogWindow.cpp"
  208. #include "windows/juce_DocumentWindow.cpp"
  209. #include "windows/juce_ResizableWindow.cpp"
  210. #include "windows/juce_ThreadWithProgressWindow.cpp"
  211. #include "windows/juce_TooltipWindow.cpp"
  212. #include "windows/juce_TopLevelWindow.cpp"
  213. #include "commands/juce_ApplicationCommandInfo.cpp"
  214. #include "commands/juce_ApplicationCommandManager.cpp"
  215. #include "commands/juce_ApplicationCommandTarget.cpp"
  216. #include "commands/juce_KeyPressMappingSet.cpp"
  217. #include "application/juce_Application.cpp"
  218. #include "misc/juce_BubbleComponent.cpp"
  219. #include "misc/juce_DropShadower.cpp"
  220. #include "misc/juce_FocusOutline.cpp"
  221. #include "misc/juce_JUCESplashScreen.cpp"
  222. #include "layout/juce_FlexBox.cpp"
  223. #include "layout/juce_GridItem.cpp"
  224. #include "layout/juce_Grid.cpp"
  225. #if JUCE_IOS || JUCE_WINDOWS
  226. #include "native/juce_MultiTouchMapper.h"
  227. #endif
  228. #if JUCE_ANDROID || JUCE_WINDOWS
  229. #include "native/accessibility/juce_AccessibilityTextHelpers.h"
  230. #endif
  231. namespace juce
  232. {
  233. static const juce::Identifier disableAsyncLayerBackedViewIdentifier { "disableAsyncLayerBackedView" };
  234. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wmissing-prototypes")
  235. /** Used by the macOS and iOS peers. */
  236. void setComponentAsyncLayerBackedViewDisabled (juce::Component& comp, bool shouldDisableAsyncLayerBackedView)
  237. {
  238. comp.getProperties().set (disableAsyncLayerBackedViewIdentifier, shouldDisableAsyncLayerBackedView);
  239. }
  240. /** Used by the macOS and iOS peers. */
  241. bool getComponentAsyncLayerBackedViewDisabled (juce::Component& comp)
  242. {
  243. return comp.getProperties()[disableAsyncLayerBackedViewIdentifier];
  244. }
  245. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  246. } // namespace juce
  247. #if JUCE_MAC || JUCE_IOS
  248. #include "native/accessibility/juce_mac_AccessibilitySharedCode.mm"
  249. #if JUCE_IOS
  250. #include "native/accessibility/juce_ios_Accessibility.mm"
  251. #include "native/juce_ios_UIViewComponentPeer.mm"
  252. #include "native/juce_ios_Windowing.mm"
  253. #include "native/juce_ios_FileChooser.mm"
  254. #if JUCE_CONTENT_SHARING
  255. #include "native/juce_ios_ContentSharer.cpp"
  256. #endif
  257. #else
  258. #include "native/accessibility/juce_mac_Accessibility.mm"
  259. #include "native/juce_mac_NSViewComponentPeer.mm"
  260. #include "native/juce_mac_Windowing.mm"
  261. #include "native/juce_mac_MainMenu.mm"
  262. #include "native/juce_mac_FileChooser.mm"
  263. #endif
  264. #include "native/juce_mac_MouseCursor.mm"
  265. #elif JUCE_WINDOWS
  266. #include "native/accessibility/juce_win32_ComInterfaces.h"
  267. #include "native/accessibility/juce_win32_WindowsUIAWrapper.h"
  268. #include "native/accessibility/juce_win32_AccessibilityElement.h"
  269. #include "native/accessibility/juce_win32_UIAHelpers.h"
  270. #include "native/accessibility/juce_win32_UIAProviders.h"
  271. #include "native/accessibility/juce_win32_AccessibilityElement.cpp"
  272. #include "native/accessibility/juce_win32_Accessibility.cpp"
  273. #include "native/juce_win32_Windowing.cpp"
  274. #include "native/juce_win32_DragAndDrop.cpp"
  275. #include "native/juce_win32_FileChooser.cpp"
  276. #elif JUCE_LINUX || JUCE_BSD
  277. #include "native/x11/juce_linux_X11_Symbols.cpp"
  278. #include "native/x11/juce_linux_X11_DragAndDrop.cpp"
  279. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-as-null-pointer-constant")
  280. #include "native/juce_linux_Windowing.cpp"
  281. #include "native/x11/juce_linux_XWindowSystem.cpp"
  282. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  283. #include "native/juce_linux_FileChooser.cpp"
  284. #elif JUCE_ANDROID
  285. #include "juce_core/files/juce_common_MimeTypes.h"
  286. #include "native/accessibility/juce_android_Accessibility.cpp"
  287. #include "native/juce_android_Windowing.cpp"
  288. #include "native/juce_android_FileChooser.cpp"
  289. #if JUCE_CONTENT_SHARING
  290. #include "native/juce_android_ContentSharer.cpp"
  291. #endif
  292. #endif
  293. namespace juce
  294. {
  295. #if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED
  296. class AccessibilityHandler::AccessibilityNativeImpl { public: AccessibilityNativeImpl (AccessibilityHandler&) {} };
  297. void AccessibilityHandler::notifyAccessibilityEvent (AccessibilityEvent) const {}
  298. void AccessibilityHandler::postAnnouncement (const String&, AnnouncementPriority) {}
  299. AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const { return nullptr; }
  300. void notifyAccessibilityEventInternal (const AccessibilityHandler&, InternalAccessibilityEvent) {}
  301. std::unique_ptr<AccessibilityHandler::AccessibilityNativeImpl> AccessibilityHandler::createNativeImpl (AccessibilityHandler&)
  302. {
  303. return nullptr;
  304. }
  305. #else
  306. std::unique_ptr<AccessibilityHandler::AccessibilityNativeImpl> AccessibilityHandler::createNativeImpl (AccessibilityHandler& handler)
  307. {
  308. return std::make_unique<AccessibilityNativeImpl> (handler);
  309. }
  310. #endif
  311. }
  312. //==============================================================================
  313. #if JUCE_WINDOWS
  314. namespace juce
  315. {
  316. JUCE_COMCLASS (JuceIVirtualDesktopManager, "a5cd92ff-29be-454c-8d04-d82879fb3f1b") : public IUnknown
  317. {
  318. public:
  319. virtual HRESULT STDMETHODCALLTYPE IsWindowOnCurrentVirtualDesktop(
  320. __RPC__in HWND topLevelWindow,
  321. __RPC__out BOOL * onCurrentDesktop) = 0;
  322. virtual HRESULT STDMETHODCALLTYPE GetWindowDesktopId(
  323. __RPC__in HWND topLevelWindow,
  324. __RPC__out GUID * desktopId) = 0;
  325. virtual HRESULT STDMETHODCALLTYPE MoveWindowToDesktop(
  326. __RPC__in HWND topLevelWindow,
  327. __RPC__in REFGUID desktopId) = 0;
  328. };
  329. JUCE_COMCLASS (JuceVirtualDesktopManager, "aa509086-5ca9-4c25-8f95-589d3c07b48a");
  330. } // namespace juce
  331. #ifdef __CRT_UUID_DECL
  332. __CRT_UUID_DECL (juce::JuceIVirtualDesktopManager, 0xa5cd92ff, 0x29be, 0x454c, 0x8d, 0x04, 0xd8, 0x28, 0x79, 0xfb, 0x3f, 0x1b)
  333. __CRT_UUID_DECL (juce::JuceVirtualDesktopManager, 0xaa509086, 0x5ca9, 0x4c25, 0x8f, 0x95, 0x58, 0x9d, 0x3c, 0x07, 0xb4, 0x8a)
  334. #endif
  335. bool juce::isWindowOnCurrentVirtualDesktop (void* x)
  336. {
  337. if (x == nullptr)
  338. return false;
  339. static auto* desktopManager = []
  340. {
  341. JuceIVirtualDesktopManager* result = nullptr;
  342. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token")
  343. if (SUCCEEDED (CoCreateInstance (__uuidof (JuceVirtualDesktopManager), nullptr, CLSCTX_ALL, IID_PPV_ARGS (&result))))
  344. return result;
  345. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  346. return static_cast<JuceIVirtualDesktopManager*> (nullptr);
  347. }();
  348. BOOL current = false;
  349. if (auto* dm = desktopManager)
  350. if (SUCCEEDED (dm->IsWindowOnCurrentVirtualDesktop (static_cast<HWND> (x), &current)))
  351. return current != false;
  352. return true;
  353. }
  354. #else
  355. bool juce::isWindowOnCurrentVirtualDesktop (void*) { return true; }
  356. juce::ScopedDPIAwarenessDisabler::ScopedDPIAwarenessDisabler() { ignoreUnused (previousContext); }
  357. juce::ScopedDPIAwarenessDisabler::~ScopedDPIAwarenessDisabler() {}
  358. #endif
  359. // Depends on types defined in platform-specific windowing files
  360. #include "mouse/juce_MouseCursor.cpp"