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.

249 lines
8.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. /*
  19. This file wraps together all the mac-specific code, so that
  20. we can include all the native headers just once, and compile all our
  21. platform-specific stuff in one big lump, keeping it out of the way of
  22. the rest of the codebase.
  23. */
  24. #include "../../core/juce_TargetPlatform.h"
  25. #if JUCE_MAC || JUCE_IOS
  26. #undef JUCE_BUILD_NATIVE
  27. #define JUCE_BUILD_NATIVE 1
  28. #include "../../core/juce_StandardHeader.h"
  29. #include "juce_mac_NativeIncludes.h"
  30. BEGIN_JUCE_NAMESPACE
  31. //==============================================================================
  32. #include "../../core/juce_Singleton.h"
  33. #include "../../maths/juce_Random.h"
  34. #include "../../core/juce_SystemStats.h"
  35. #include "../../threads/juce_Process.h"
  36. #include "../../threads/juce_Thread.h"
  37. #include "../../threads/juce_InterProcessLock.h"
  38. #include "../../io/files/juce_FileInputStream.h"
  39. #include "../../io/files/juce_FileOutputStream.h"
  40. #include "../../io/files/juce_NamedPipe.h"
  41. #include "../../io/files/juce_DirectoryIterator.h"
  42. #include "../../io/files/juce_MemoryMappedFile.h"
  43. #include "../../io/network/juce_URL.h"
  44. #include "../../io/network/juce_MACAddress.h"
  45. #include "../../io/streams/juce_MemoryInputStream.h"
  46. #include "../../io/streams/juce_BufferedInputStream.h"
  47. #include "../../core/juce_PlatformUtilities.h"
  48. #include "../../core/juce_Initialisation.h"
  49. #include "../../text/juce_LocalisedStrings.h"
  50. #include "../../text/juce_XmlDocument.h"
  51. #include "../../utilities/juce_DeletedAtShutdown.h"
  52. #include "../../application/juce_Application.h"
  53. #include "../../utilities/juce_SystemClipboard.h"
  54. #include "../../events/juce_MessageManager.h"
  55. #include "../../containers/juce_ReferenceCountedArray.h"
  56. #include "../../gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h"
  57. #include "../../gui/graphics/contexts/juce_EdgeTable.h"
  58. #include "../../gui/graphics/imaging/juce_ImageFileFormat.h"
  59. #include "../../gui/graphics/imaging/juce_CameraDevice.h"
  60. #include "../../gui/components/windows/juce_AlertWindow.h"
  61. #include "../../gui/components/windows/juce_NativeMessageBox.h"
  62. #include "../../gui/components/windows/juce_ComponentPeer.h"
  63. #include "../../gui/components/juce_Desktop.h"
  64. #include "../../gui/components/menus/juce_MenuBarModel.h"
  65. #include "../../gui/components/special/juce_OpenGLComponent.h"
  66. #include "../../gui/components/special/juce_QuickTimeMovieComponent.h"
  67. #include "../../gui/components/mouse/juce_DragAndDropContainer.h"
  68. #include "../../gui/components/mouse/juce_MouseEvent.h"
  69. #include "../../gui/components/mouse/juce_MouseInputSource.h"
  70. #include "../../gui/components/keyboard/juce_KeyPressMappingSet.h"
  71. #include "../../gui/components/special/juce_NSViewComponent.h"
  72. #include "../../gui/components/layout/juce_ComponentMovementWatcher.h"
  73. #include "../../gui/components/special/juce_WebBrowserComponent.h"
  74. #include "../../gui/components/filebrowser/juce_FileChooser.h"
  75. #include "../../audio/audio_file_formats/juce_AudioCDBurner.h"
  76. #include "../../audio/audio_file_formats/juce_AudioCDReader.h"
  77. #include "../../audio/audio_file_formats/juce_AiffAudioFormat.h"
  78. #include "../../audio/audio_sources/juce_AudioSource.h"
  79. #include "../../audio/dsp/juce_AudioDataConverters.h"
  80. #include "../../audio/devices/juce_AudioIODeviceType.h"
  81. #include "../../audio/midi/juce_MidiOutput.h"
  82. #include "../../audio/midi/juce_MidiInput.h"
  83. #include "../../containers/juce_ScopedValueSetter.h"
  84. #include "../common/juce_MidiDataConcatenator.h"
  85. #undef Point
  86. #if ! JUCE_ONLY_BUILD_CORE_LIBRARY
  87. namespace
  88. {
  89. template <class RectType>
  90. const Rectangle<int> convertToRectInt (const RectType& r)
  91. {
  92. return Rectangle<int> ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height);
  93. }
  94. template <class RectType>
  95. const Rectangle<float> convertToRectFloat (const RectType& r)
  96. {
  97. return Rectangle<float> (r.origin.x, r.origin.y, r.size.width, r.size.height);
  98. }
  99. template <class RectType>
  100. CGRect convertToCGRect (const RectType& r)
  101. {
  102. return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight());
  103. }
  104. }
  105. //==============================================================================
  106. class MessageQueue
  107. {
  108. public:
  109. MessageQueue()
  110. {
  111. #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS
  112. runLoop = CFRunLoopGetMain();
  113. #else
  114. runLoop = CFRunLoopGetCurrent();
  115. #endif
  116. CFRunLoopSourceContext sourceContext = { 0 };
  117. sourceContext.info = this;
  118. sourceContext.perform = runLoopSourceCallback;
  119. runLoopSource = CFRunLoopSourceCreate (kCFAllocatorDefault, 1, &sourceContext);
  120. CFRunLoopAddSource (runLoop, runLoopSource, kCFRunLoopCommonModes);
  121. }
  122. ~MessageQueue()
  123. {
  124. CFRunLoopRemoveSource (runLoop, runLoopSource, kCFRunLoopCommonModes);
  125. CFRunLoopSourceInvalidate (runLoopSource);
  126. CFRelease (runLoopSource);
  127. }
  128. void post (Message* const message)
  129. {
  130. messages.add (message);
  131. CFRunLoopSourceSignal (runLoopSource);
  132. CFRunLoopWakeUp (runLoop);
  133. }
  134. private:
  135. ReferenceCountedArray <Message, CriticalSection> messages;
  136. CriticalSection lock;
  137. CFRunLoopRef runLoop;
  138. CFRunLoopSourceRef runLoopSource;
  139. bool deliverNextMessage()
  140. {
  141. const Message::Ptr nextMessage (messages.removeAndReturn (0));
  142. if (nextMessage == nullptr)
  143. return false;
  144. JUCE_AUTORELEASEPOOL
  145. MessageManager::getInstance()->deliverMessage (nextMessage);
  146. return true;
  147. }
  148. void runLoopCallback()
  149. {
  150. for (int i = 4; --i >= 0;)
  151. if (! deliverNextMessage())
  152. return;
  153. CFRunLoopSourceSignal (runLoopSource);
  154. CFRunLoopWakeUp (runLoop);
  155. }
  156. static void runLoopSourceCallback (void* info)
  157. {
  158. static_cast <MessageQueue*> (info)->runLoopCallback();
  159. }
  160. };
  161. #endif
  162. //==============================================================================
  163. #define JUCE_INCLUDED_FILE 1
  164. // Now include the actual code files..
  165. #include "juce_mac_ObjCSuffix.h"
  166. #include "juce_mac_Strings.mm"
  167. #include "juce_mac_SystemStats.mm"
  168. #include "juce_mac_Network.mm"
  169. #include "../common/juce_posix_NamedPipe.cpp"
  170. #include "juce_mac_Threads.mm"
  171. #include "../common/juce_posix_SharedCode.h"
  172. #include "juce_mac_Files.mm"
  173. #if JUCE_IOS
  174. #include "juce_ios_MiscUtilities.mm"
  175. #else
  176. #include "juce_mac_MiscUtilities.mm"
  177. #endif
  178. #include "juce_mac_Debugging.mm"
  179. #if ! JUCE_ONLY_BUILD_CORE_LIBRARY
  180. #if JUCE_IOS
  181. #include "juce_mac_Fonts.mm"
  182. #include "juce_mac_CoreGraphicsContext.mm"
  183. #include "juce_ios_UIViewComponentPeer.mm"
  184. #include "juce_ios_MessageManager.mm"
  185. #include "juce_mac_FileChooser.mm"
  186. #include "juce_mac_OpenGLComponent.mm"
  187. #include "juce_mac_MouseCursor.mm"
  188. #include "juce_mac_WebBrowserComponent.mm"
  189. #include "juce_ios_Audio.cpp"
  190. #include "juce_mac_CoreMidi.cpp"
  191. #else
  192. #include "juce_mac_Fonts.mm" // (must go before juce_mac_CoreGraphicsContext.mm)
  193. #include "juce_mac_CoreGraphicsContext.mm"
  194. #include "juce_mac_NSViewComponentPeer.mm"
  195. #include "juce_mac_MouseCursor.mm"
  196. #include "juce_mac_NSViewComponent.mm"
  197. #include "juce_mac_AppleRemote.mm"
  198. #include "juce_mac_OpenGLComponent.mm"
  199. #include "juce_mac_MainMenu.mm"
  200. #include "juce_mac_FileChooser.mm"
  201. #include "juce_mac_QuickTimeMovieComponent.mm"
  202. #include "juce_mac_AudioCDBurner.mm"
  203. #include "juce_mac_AudioCDReader.mm"
  204. #include "juce_mac_MessageManager.mm"
  205. #include "juce_mac_WebBrowserComponent.mm"
  206. #include "juce_mac_CoreAudio.cpp"
  207. #include "juce_mac_CoreMidi.cpp"
  208. #include "juce_mac_CameraDevice.mm"
  209. #endif
  210. #endif
  211. END_JUCE_NAMESPACE
  212. #endif