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.

295 lines
9.7KB

  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. #ifndef __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__
  20. #define __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__
  21. #include "../../core/juce_TargetPlatform.h"
  22. #include "../../../juce_Config.h"
  23. #ifndef STRICT
  24. #define STRICT 1
  25. #endif
  26. #undef WIN32_LEAN_AND_MEAN
  27. #define WIN32_LEAN_AND_MEAN 1
  28. #if JUCE_MSVC
  29. #ifndef _CPPRTTI
  30. #error "You're compiling without RTTI enabled! This is needed for a lot of JUCE classes, please update your compiler settings!"
  31. #endif
  32. #ifndef _CPPUNWIND
  33. #error "You're compiling without exceptions enabled! This is needed for a lot of JUCE classes, please update your compiler settings!"
  34. #endif
  35. #pragma warning (push)
  36. #pragma warning (disable : 4100 4201 4514 4312 4995)
  37. #endif
  38. #define _WIN32_WINNT 0x0500
  39. #define _UNICODE 1
  40. #define UNICODE 1
  41. #ifndef _WIN32_IE
  42. #define _WIN32_IE 0x0400
  43. #endif
  44. #include <windows.h>
  45. #include <windowsx.h>
  46. #include <commdlg.h>
  47. #include <shellapi.h>
  48. #include <mmsystem.h>
  49. #include <vfw.h>
  50. #include <tchar.h>
  51. #include <stddef.h>
  52. #include <ctime>
  53. #include <wininet.h>
  54. #include <nb30.h>
  55. #include <iphlpapi.h>
  56. #include <mapi.h>
  57. #include <float.h>
  58. #include <process.h>
  59. #include <Exdisp.h>
  60. #include <exdispid.h>
  61. #include <shlobj.h>
  62. #include <shlwapi.h>
  63. #if ! JUCE_MINGW
  64. #include <crtdbg.h>
  65. #include <comutil.h>
  66. #endif
  67. #if JUCE_OPENGL
  68. #include <gl/gl.h>
  69. #endif
  70. #undef PACKED
  71. //==============================================================================
  72. #if JUCE_ASIO && JUCE_BUILD_NATIVE
  73. /*
  74. This is very frustrating - we only need to use a handful of definitions from
  75. a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy
  76. about 30 lines of code into this cpp file to create a fully stand-alone ASIO
  77. implementation...
  78. ..unfortunately that would break Steinberg's license agreement for use of
  79. their SDK, so I'm not allowed to do this.
  80. This means that anyone who wants to use JUCE's ASIO abilities will have to:
  81. 1) Agree to Steinberg's licensing terms and download the ASIO SDK
  82. (see www.steinberg.net/Steinberg/Developers.asp).
  83. 2) Enable this code with a global definition #define JUCE_ASIO 1.
  84. 3) Make sure that your header search path contains the iasiodrv.h file that
  85. comes with the SDK. (Only about a handful of the SDK header files are actually
  86. needed - so to simplify things, you could just copy these into your JUCE directory).
  87. */
  88. #include <iasiodrv.h>
  89. #endif
  90. //==============================================================================
  91. #if JUCE_USE_CDBURNER && JUCE_BUILD_NATIVE
  92. /* You'll need the Platform SDK for these headers - if you don't have it and don't
  93. need to use CD-burning, then you might just want to disable the JUCE_USE_CDBURNER
  94. flag in juce_Config.h to avoid these includes.
  95. */
  96. #include <imapi.h>
  97. #include <imapierror.h>
  98. #endif
  99. //==============================================================================
  100. #if (JUCE_USE_CAMERA || JUCE_DIRECTSHOW) && JUCE_BUILD_NATIVE
  101. /* If you're using the camera classes, you'll need access to a few DirectShow headers.
  102. These files are provided in the normal Windows SDK, but some Microsoft plonker
  103. didn't realise that qedit.h doesn't actually compile without the rest of the DirectShow SDK..
  104. Microsoft's suggested fix for this is to hack their qedit.h file! See:
  105. http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/ed097d2c-3d68-4f48-8448-277eaaf68252
  106. .. which is a bit of a bodge, but a lot less hassle than installing the full DShow SDK.
  107. An alternative workaround is to create a dummy dxtrans.h file and put it in your include path.
  108. The dummy file just needs to contain the following content:
  109. #define __IDxtCompositor_INTERFACE_DEFINED__
  110. #define __IDxtAlphaSetter_INTERFACE_DEFINED__
  111. #define __IDxtJpeg_INTERFACE_DEFINED__
  112. #define __IDxtKey_INTERFACE_DEFINED__
  113. ..and that should be enough to convince qedit.h that you have the SDK!
  114. */
  115. #include <dshow.h>
  116. #include <qedit.h>
  117. #include <dshowasf.h>
  118. #endif
  119. #if JUCE_DIRECTSHOW && JUCE_MEDIAFOUNDATION && JUCE_BUILD_NATIVE
  120. #include <evr.h>
  121. #endif
  122. //==============================================================================
  123. #if JUCE_WASAPI && JUCE_BUILD_NATIVE
  124. #include <MMReg.h>
  125. #include <mmdeviceapi.h>
  126. #include <Audioclient.h>
  127. #include <Audiopolicy.h>
  128. #include <Avrt.h>
  129. #include <functiondiscoverykeys.h>
  130. #endif
  131. //==============================================================================
  132. #if JUCE_QUICKTIME
  133. /* If you've got an include error here, you probably need to install the QuickTime SDK and
  134. add its header directory to your include path.
  135. Alternatively, if you don't need any QuickTime services, just turn off the JUCE_QUICKTIME
  136. flag in juce_Config.h
  137. */
  138. #include <Movies.h>
  139. #include <QTML.h>
  140. #include <QuickTimeComponents.h>
  141. #include <MediaHandlers.h>
  142. #include <ImageCodec.h>
  143. /* If you've got QuickTime 7 installed, then these COM objects should be found in
  144. the "\Program Files\Quicktime" directory. You'll need to add this directory to
  145. your include search path to make these import statements work.
  146. */
  147. #import <QTOLibrary.dll>
  148. #import <QTOControl.dll>
  149. #endif
  150. //==============================================================================
  151. #if JUCE_MSVC
  152. #pragma warning (pop)
  153. #endif
  154. #if JUCE_DIRECT2D && JUCE_BUILD_NATIVE
  155. #include <d2d1.h>
  156. #include <dwrite.h>
  157. #endif
  158. #ifndef WM_APPCOMMAND
  159. #define WM_APPCOMMAND 0x0319
  160. #endif
  161. //==============================================================================
  162. /** A simple COM smart pointer.
  163. Avoids having to include ATL just to get one of these.
  164. */
  165. template <class ComClass>
  166. class ComSmartPtr
  167. {
  168. public:
  169. ComSmartPtr() throw() : p (0) {}
  170. ComSmartPtr (ComClass* const p_) : p (p_) { if (p_ != 0) p_->AddRef(); }
  171. ComSmartPtr (const ComSmartPtr<ComClass>& p_) : p (p_.p) { if (p != 0) p->AddRef(); }
  172. ~ComSmartPtr() { release(); }
  173. operator ComClass*() const throw() { return p; }
  174. ComClass& operator*() const throw() { return *p; }
  175. ComClass* operator->() const throw() { return p; }
  176. ComSmartPtr& operator= (ComClass* const newP)
  177. {
  178. if (newP != 0) newP->AddRef();
  179. release();
  180. p = newP;
  181. return *this;
  182. }
  183. ComSmartPtr& operator= (const ComSmartPtr<ComClass>& newP) { return operator= (newP.p); }
  184. // Releases and nullifies this pointer and returns its address
  185. ComClass** resetAndGetPointerAddress()
  186. {
  187. release();
  188. p = 0;
  189. return &p;
  190. }
  191. HRESULT CoCreateInstance (REFCLSID classUUID, DWORD dwClsContext = CLSCTX_INPROC_SERVER)
  192. {
  193. #ifndef __MINGW32__
  194. return ::CoCreateInstance (classUUID, 0, dwClsContext, __uuidof (ComClass), (void**) resetAndGetPointerAddress());
  195. #else
  196. return E_NOTIMPL;
  197. #endif
  198. }
  199. template <class OtherComClass>
  200. HRESULT QueryInterface (REFCLSID classUUID, ComSmartPtr<OtherComClass>& destObject) const
  201. {
  202. if (p == 0)
  203. return E_POINTER;
  204. return p->QueryInterface (classUUID, (void**) destObject.resetAndGetPointerAddress());
  205. }
  206. private:
  207. ComClass* p;
  208. void release() { if (p != 0) p->Release(); }
  209. ComClass** operator&() throw(); // private to avoid it being used accidentally
  210. };
  211. //==============================================================================
  212. /** Handy base class for writing COM objects, providing ref-counting and a basic QueryInterface method.
  213. */
  214. template <class ComClass>
  215. class ComBaseClassHelper : public ComClass
  216. {
  217. public:
  218. ComBaseClassHelper() : refCount (1) {}
  219. virtual ~ComBaseClassHelper() {}
  220. HRESULT __stdcall QueryInterface (REFIID refId, void** result)
  221. {
  222. #ifndef __MINGW32__
  223. if (refId == __uuidof (ComClass)) { AddRef(); *result = dynamic_cast <ComClass*> (this); return S_OK; }
  224. #endif
  225. if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast <IUnknown*> (this); return S_OK; }
  226. *result = 0;
  227. return E_NOINTERFACE;
  228. }
  229. ULONG __stdcall AddRef() { return ++refCount; }
  230. ULONG __stdcall Release() { const int r = --refCount; if (r == 0) delete this; return r; }
  231. protected:
  232. int refCount;
  233. };
  234. #endif // __JUCE_WIN32_NATIVEINCLUDES_JUCEHEADER__